cache xversion extension manager, and use it in any place accessing extension definitions
This commit is contained in:
parent
4b43e46d11
commit
532aba2485
|
@ -76,6 +76,7 @@ import org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode;
|
|||
import org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent;
|
||||
import org.hl7.fhir.r5.terminologies.TerminologyClient;
|
||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.TimeTracker;
|
||||
|
@ -138,7 +139,8 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
}
|
||||
|
||||
public interface IValidatorFactory {
|
||||
IResourceValidator makeValidator(IWorkerContext ctxts) throws FHIRException;
|
||||
// IResourceValidator makeValidator(IWorkerContext ctxt) throws FHIRException;
|
||||
IResourceValidator makeValidator(IWorkerContext ctxts, XVerExtensionManager xverManager) throws FHIRException;
|
||||
}
|
||||
|
||||
private Questionnaire questionnaire;
|
||||
|
@ -149,6 +151,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
private boolean progress;
|
||||
private List<String> loadedPackages = new ArrayList<String>();
|
||||
private boolean canNoTS;
|
||||
private XVerExtensionManager xverManager;
|
||||
|
||||
public SimpleWorkerContext() throws FileNotFoundException, IOException, FHIRException {
|
||||
super();
|
||||
|
@ -539,7 +542,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
public IResourceValidator newValidator() throws FHIRException {
|
||||
if (validatorFactory == null)
|
||||
throw new Error(formatMessage(I18nConstants.NO_VALIDATOR_CONFIGURED));
|
||||
return validatorFactory.makeValidator(this);
|
||||
return validatorFactory.makeValidator(this, xverManager);
|
||||
}
|
||||
|
||||
|
||||
|
@ -770,6 +773,10 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
ProfileUtilities pu = new ProfileUtilities(this, msgs, this);
|
||||
pu.setAutoFixSliceNames(true);
|
||||
pu.setThrowException(false);
|
||||
if (xverManager == null) {
|
||||
xverManager = new XVerExtensionManager(this);
|
||||
}
|
||||
pu.setXver(xverManager);
|
||||
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
|
||||
pu.sortDifferential(sd, p, p.getUrl(), errors, true);
|
||||
}
|
||||
|
@ -828,5 +835,12 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
this.canNoTS = canNoTS;
|
||||
}
|
||||
|
||||
public XVerExtensionManager getXVer() {
|
||||
if (xverManager == null) {
|
||||
xverManager = new XVerExtensionManager(this);
|
||||
}
|
||||
return xverManager;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -84,6 +84,7 @@ public class XVerExtensionManager {
|
|||
|
||||
StructureDefinition sd = new StructureDefinition();
|
||||
sd.setUserData(XVER_EXT_MARKER, "true");
|
||||
sd.setUserData("path", "http://hl7.org/fhir/versions.html#extensions");
|
||||
sd.setUrl(url);
|
||||
sd.setVersion(context.getVersion());
|
||||
sd.setFhirVersion(FHIRVersion.fromCode(context.getVersion()));
|
||||
|
|
|
@ -73,8 +73,11 @@ import org.hl7.fhir.r5.elementmodel.Element;
|
|||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetUtilities;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
@ -118,6 +121,17 @@ public class BaseValidator {
|
|||
protected Source source;
|
||||
protected IWorkerContext context;
|
||||
protected TimeTracker timeTracker = new TimeTracker();
|
||||
protected XVerExtensionManager xverManager;
|
||||
|
||||
public BaseValidator(IWorkerContext context, XVerExtensionManager xverManager) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.xverManager = xverManager;
|
||||
if (this.xverManager == null) {
|
||||
this.xverManager = new XVerExtensionManager(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to control what validation the validator performs.
|
||||
|
@ -129,10 +143,6 @@ public class BaseValidator {
|
|||
*/
|
||||
private Map<String, ValidationControl> validationControl = new HashMap<>();
|
||||
|
||||
public BaseValidator(IWorkerContext context){
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a rule and add a {@link IssueSeverity#FATAL} validation message if the validation fails
|
||||
*
|
||||
|
@ -873,5 +883,74 @@ public class BaseValidator {
|
|||
return validationControl;
|
||||
}
|
||||
|
||||
|
||||
public XVerExtensionStatus xverStatus(String url) {
|
||||
return xverManager.status(url);
|
||||
}
|
||||
|
||||
public boolean isXverUrl(String url) {
|
||||
return xverManager.matchingUrl(url);
|
||||
}
|
||||
|
||||
public StructureDefinition xverDefn(String url) {
|
||||
return xverManager.makeDefinition(url);
|
||||
}
|
||||
|
||||
public String xverVersion(String url) {
|
||||
return xverManager.getVersion(url);
|
||||
}
|
||||
|
||||
public String xverElementId(String url) {
|
||||
return xverManager.getElementId(url);
|
||||
}
|
||||
|
||||
public StructureDefinition getXverExt(StructureDefinition profile, List<ValidationMessage> errors, String url) {
|
||||
if (isXverUrl(url)) {
|
||||
switch (xverStatus(url)) {
|
||||
case BadVersion:
|
||||
rule(errors, IssueType.BUSINESSRULE, profile.getId(), false, I18nConstants.EXTENSION_EXT_VERSION_INVALID, url, xverVersion(url));
|
||||
return null;
|
||||
case Unknown:
|
||||
rule(errors, IssueType.BUSINESSRULE, profile.getId(), false, I18nConstants.EXTENSION_EXT_VERSION_INVALIDID, url, xverElementId(url));
|
||||
return null;
|
||||
case Invalid:
|
||||
rule(errors, IssueType.BUSINESSRULE, profile.getId(), false, I18nConstants.EXTENSION_EXT_VERSION_NOCHANGE, url, xverElementId(url));
|
||||
return null;
|
||||
case Valid:
|
||||
StructureDefinition defn = xverDefn(url);
|
||||
context.generateSnapshot(defn);
|
||||
context.cacheResource(defn);
|
||||
return defn;
|
||||
default:
|
||||
rule(errors, IssueType.INVALID, profile.getId(), false, I18nConstants.EXTENSION_EXT_VERSION_INTERNAL, url);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public StructureDefinition getXverExt(List<ValidationMessage> errors, String path, Element element, String url) {
|
||||
if (isXverUrl(url)) {
|
||||
switch (xverStatus(url)) {
|
||||
case BadVersion:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_INVALID, url, xverVersion(url));
|
||||
break;
|
||||
case Unknown:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_INVALIDID, url, xverElementId(url));
|
||||
break;
|
||||
case Invalid:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_NOCHANGE, url, xverElementId(url));
|
||||
break;
|
||||
case Valid:
|
||||
StructureDefinition ex = xverDefn(url);
|
||||
context.generateSnapshot(ex);
|
||||
context.cacheResource(ex);
|
||||
return ex;
|
||||
default:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_INTERNAL, url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1564,7 +1564,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
|
|||
}
|
||||
|
||||
public InstanceValidator getValidator() {
|
||||
InstanceValidator validator = new InstanceValidator(context, null);
|
||||
InstanceValidator validator = new InstanceValidator(context, null, null);
|
||||
validator.setHintAboutNonMustSupport(hintAboutNonMustSupport);
|
||||
validator.setAnyExtensionsAllowed(anyExtensionsAllowed);
|
||||
validator.setNoInvariantChecks(isNoInvariantChecks());
|
||||
|
|
|
@ -39,14 +39,15 @@ import java.util.Set;
|
|||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.CodeSystem;
|
||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
import org.hl7.fhir.validation.BaseValidator;
|
||||
|
||||
public class CodeSystemValidator extends BaseValidator {
|
||||
|
||||
public CodeSystemValidator(IWorkerContext context) {
|
||||
super(context);
|
||||
public CodeSystemValidator(IWorkerContext context, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
}
|
||||
|
||||
public List<ValidationMessage> validate(CodeSystem cs, boolean forBuild) {
|
||||
|
|
|
@ -368,7 +368,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
|
||||
private EnableWhenEvaluator myEnableWhenEvaluator = new EnableWhenEvaluator();
|
||||
private String executionId;
|
||||
private XVerExtensionManager xverManager;
|
||||
private IValidationProfileUsageTracker tracker;
|
||||
private ValidatorHostServices validatorServices;
|
||||
private boolean assumeValidRestReferences;
|
||||
|
@ -380,8 +379,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
private boolean validateValueSetCodesOnTxServer = true;
|
||||
private QuestionnaireMode questionnaireMode;
|
||||
|
||||
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices) {
|
||||
super(theContext);
|
||||
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices, XVerExtensionManager xverManager) {
|
||||
super(theContext, xverManager);
|
||||
this.externalHostServices = hostServices;
|
||||
this.profileUtilities = new ProfileUtilities(theContext, null, null);
|
||||
fpe = new FHIRPathEngine(context);
|
||||
|
@ -1504,30 +1503,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
StructureDefinition ex = Utilities.isAbsoluteUrl(url) ? context.fetchResource(StructureDefinition.class, url) : null;
|
||||
timeTracker.sd(t);
|
||||
if (ex == null) {
|
||||
if (xverManager == null) {
|
||||
xverManager = new XVerExtensionManager(context);
|
||||
ex = getXverExt(errors, path, element, url);
|
||||
}
|
||||
if (xverManager.matchingUrl(url)) {
|
||||
switch (xverManager.status(url)) {
|
||||
case BadVersion:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_INVALID, url, xverManager.getVersion(url));
|
||||
break;
|
||||
case Unknown:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_INVALIDID, url, xverManager.getElementId(url));
|
||||
break;
|
||||
case Invalid:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_NOCHANGE, url, xverManager.getElementId(url));
|
||||
break;
|
||||
case Valid:
|
||||
ex = xverManager.makeDefinition(url);
|
||||
context.generateSnapshot(ex);
|
||||
context.cacheResource(ex);
|
||||
break;
|
||||
default:
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", false, I18nConstants.EXTENSION_EXT_VERSION_INTERNAL, url);
|
||||
break;
|
||||
}
|
||||
} else if (extensionUrl != null && !isAbsolute(url)) {
|
||||
if (ex == null) {
|
||||
if (extensionUrl != null && !isAbsolute(url)) {
|
||||
if (extensionUrl.equals(profile.getUrl())) {
|
||||
rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", hasExtensionSlice(profile, url), I18nConstants.EXTENSION_EXT_SUBEXTENSION_INVALID, url, profile.getUrl());
|
||||
}
|
||||
|
@ -1569,6 +1548,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
|
||||
|
||||
|
||||
private boolean hasExtensionSlice(StructureDefinition profile, String sliceName) {
|
||||
for (ElementDefinition ed : profile.getSnapshot().getElement()) {
|
||||
if (ed.getPath().equals("Extension.extension.url") && ed.hasFixed() && sliceName.equals(ed.getFixed().primitiveValue())) {
|
||||
|
@ -1951,7 +1931,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
boolean found;
|
||||
try {
|
||||
found = isDefinitionURL(url) || (allowExamples && (url.contains("example.org") || url.contains("acme.com")) || url.contains("acme.org")) || (url.startsWith("http://hl7.org/fhir/tools")) || fetcher.resolveURL(appContext, path, url) ||
|
||||
SpecialExtensions.isKnownExtension(url);
|
||||
SpecialExtensions.isKnownExtension(url) || isXverUrl(url);
|
||||
} catch (IOException e1) {
|
||||
found = false;
|
||||
}
|
||||
|
@ -3889,27 +3869,27 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
public void checkSpecials(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element element, NodeStack stack, boolean checkSpecials) {
|
||||
// specific known special validations
|
||||
if (element.getType().equals(BUNDLE)) {
|
||||
new BundleValidator(context, serverBase, this).validateBundle(errors, element, stack, checkSpecials, hostContext);
|
||||
new BundleValidator(context, serverBase, this, xverManager).validateBundle(errors, element, stack, checkSpecials, hostContext);
|
||||
} else if (element.getType().equals("Observation")) {
|
||||
validateObservation(errors, element, stack);
|
||||
} else if (element.getType().equals("Questionnaire")) {
|
||||
new QuestionnaireValidator(context, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode).validateQuestionannaire(errors, element, element, stack);
|
||||
new QuestionnaireValidator(context, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode, xverManager).validateQuestionannaire(errors, element, element, stack);
|
||||
} else if (element.getType().equals("QuestionnaireResponse")) {
|
||||
new QuestionnaireValidator(context, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode).validateQuestionannaireResponse(hostContext, errors, element, stack);
|
||||
new QuestionnaireValidator(context, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode, xverManager).validateQuestionannaireResponse(hostContext, errors, element, stack);
|
||||
} else if (element.getType().equals("Measure")) {
|
||||
new MeasureValidator(context, timeTracker).validateMeasure(hostContext, errors, element, stack);
|
||||
new MeasureValidator(context, timeTracker, xverManager).validateMeasure(hostContext, errors, element, stack);
|
||||
} else if (element.getType().equals("MeasureReport")) {
|
||||
new MeasureValidator(context, timeTracker).validateMeasureReport(hostContext, errors, element, stack);
|
||||
new MeasureValidator(context, timeTracker, xverManager).validateMeasureReport(hostContext, errors, element, stack);
|
||||
} else if (element.getType().equals("CapabilityStatement")) {
|
||||
validateCapabilityStatement(errors, element, stack);
|
||||
} else if (element.getType().equals("CodeSystem")) {
|
||||
new CodeSystemValidator(context, timeTracker).validateCodeSystem(errors, element, stack);
|
||||
new CodeSystemValidator(context, timeTracker, xverManager).validateCodeSystem(errors, element, stack);
|
||||
} else if (element.getType().equals("SearchParameter")) {
|
||||
new SearchParameterValidator(context, timeTracker, fpe).validateSearchParameter(errors, element, stack);
|
||||
new SearchParameterValidator(context, timeTracker, fpe, xverManager).validateSearchParameter(errors, element, stack);
|
||||
} else if (element.getType().equals("StructureDefinition")) {
|
||||
new StructureDefinitionValidator(context, timeTracker, fpe, wantCheckSnapshotUnchanged).validateStructureDefinition(errors, element, stack);
|
||||
new StructureDefinitionValidator(context, timeTracker, fpe, wantCheckSnapshotUnchanged, xverManager).validateStructureDefinition(errors, element, stack);
|
||||
} else if (element.getType().equals("ValueSet")) {
|
||||
new ValueSetValidator(context, timeTracker, this).validateValueSet(errors, element, stack);
|
||||
new ValueSetValidator(context, timeTracker, this, xverManager).validateValueSet(errors, element, stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,12 +36,18 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext.IValidatorFactory;
|
||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
|
||||
public class InstanceValidatorFactory implements IValidatorFactory {
|
||||
|
||||
@Override
|
||||
public IResourceValidator makeValidator(IWorkerContext ctxt, XVerExtensionManager xverManager) throws FHIRException {
|
||||
return new InstanceValidator(ctxt, null, xverManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IResourceValidator makeValidator(IWorkerContext ctxt) throws FHIRException {
|
||||
return new InstanceValidator(ctxt, null);
|
||||
return new InstanceValidator(ctxt, null, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,7 @@ import org.hl7.fhir.r5.elementmodel.Element;
|
|||
import org.hl7.fhir.r5.model.Constants;
|
||||
import org.hl7.fhir.r5.model.Enumerations.FHIRVersion;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.r5.utils.IResourceValidator.BundleValidationRule;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
|
@ -31,8 +32,8 @@ public class BundleValidator extends BaseValidator{
|
|||
private String serverBase;
|
||||
private InstanceValidator validator;
|
||||
|
||||
public BundleValidator(IWorkerContext context, String serverBase, InstanceValidator validator) {
|
||||
super(context);
|
||||
public BundleValidator(IWorkerContext context, String serverBase, InstanceValidator validator, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
this.serverBase = serverBase;
|
||||
this.validator = validator;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
@ -17,8 +18,8 @@ import org.hl7.fhir.validation.instance.utils.NodeStack;
|
|||
|
||||
public class CodeSystemValidator extends BaseValidator {
|
||||
|
||||
public CodeSystemValidator(IWorkerContext context, TimeTracker timeTracker) {
|
||||
super(context);
|
||||
public CodeSystemValidator(IWorkerContext context, TimeTracker timeTracker, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.hl7.fhir.r5.model.Measure.MeasureGroupPopulationComponent;
|
|||
import org.hl7.fhir.r5.model.Measure.MeasureGroupStratifierComponent;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.renderers.DataRenderer;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
@ -40,8 +41,8 @@ import org.w3c.dom.Document;
|
|||
|
||||
public class MeasureValidator extends BaseValidator {
|
||||
|
||||
public MeasureValidator(IWorkerContext context, TimeTracker timeTracker) {
|
||||
super(context);
|
||||
public MeasureValidator(IWorkerContext context, TimeTracker timeTracker, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.hl7.fhir.r5.model.StringType;
|
|||
import org.hl7.fhir.r5.model.TimeType;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
|
@ -58,8 +59,8 @@ public class QuestionnaireValidator extends BaseValidator {
|
|||
private FHIRPathEngine fpe;
|
||||
private QuestionnaireMode questionnaireMode;
|
||||
|
||||
public QuestionnaireValidator(IWorkerContext context, EnableWhenEvaluator myEnableWhenEvaluator, FHIRPathEngine fpe, TimeTracker timeTracker, QuestionnaireMode questionnaireMode) {
|
||||
super(context);
|
||||
public QuestionnaireValidator(IWorkerContext context, EnableWhenEvaluator myEnableWhenEvaluator, FHIRPathEngine fpe, TimeTracker timeTracker, QuestionnaireMode questionnaireMode, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
source = Source.InstanceValidator;
|
||||
this.myEnableWhenEvaluator = myEnableWhenEvaluator;
|
||||
this.fpe = fpe;
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.hl7.fhir.r5.model.ExpressionNode.Kind;
|
|||
import org.hl7.fhir.r5.model.ExpressionNode.Operation;
|
||||
import org.hl7.fhir.r5.model.SearchParameter;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
@ -34,8 +35,8 @@ public class SearchParameterValidator extends BaseValidator {
|
|||
|
||||
private FHIRPathEngine fpe;
|
||||
|
||||
public SearchParameterValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe) {
|
||||
super(context);
|
||||
public SearchParameterValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
source = Source.InstanceValidator;
|
||||
this.fpe = fpe;
|
||||
this.timeTracker = timeTracker;
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.hl7.fhir.r5.model.StructureDefinition;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
@ -46,8 +47,8 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
private FHIRPathEngine fpe;
|
||||
private boolean wantCheckSnapshotUnchanged;
|
||||
|
||||
public StructureDefinitionValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, boolean wantCheckSnapshotUnchanged) {
|
||||
super(context);
|
||||
public StructureDefinitionValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, boolean wantCheckSnapshotUnchanged, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
source = Source.InstanceValidator;
|
||||
this.fpe = fpe;
|
||||
this.timeTracker = timeTracker;
|
||||
|
@ -66,6 +67,7 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
|
||||
List<ValidationMessage> msgs = new ArrayList<>();
|
||||
ProfileUtilities pu = new ProfileUtilities(context, msgs, null);
|
||||
pu.setXver(xverManager);
|
||||
pu.generateSnapshot(base, sd, sd.getUrl(), "http://hl7.org/fhir", sd.getName());
|
||||
if (msgs.size() > 0) {
|
||||
for (ValidationMessage msg : msgs) {
|
||||
|
@ -160,6 +162,9 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
private void validateTypeProfile(List<ValidationMessage> errors, Element profile, String code, NodeStack stack) {
|
||||
String p = profile.primitiveValue();
|
||||
StructureDefinition sd = context.fetchResource(StructureDefinition.class, p);
|
||||
if (sd == null ) {
|
||||
sd = getXverExt(errors, stack.getLiteralPath(), profile, p);
|
||||
}
|
||||
if (warning(errors, IssueType.EXCEPTION, stack.getLiteralPath(), sd != null, I18nConstants.SD_ED_TYPE_PROFILE_UNKNOWN, p)) {
|
||||
String t = determineBaseType(sd);
|
||||
if (t == null) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.hl7.fhir.r5.model.Coding;
|
|||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.VersionUtilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
|
@ -42,8 +43,8 @@ public class ValueSetValidator extends BaseValidator {
|
|||
|
||||
private InstanceValidator parent;
|
||||
|
||||
public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent) {
|
||||
super(context);
|
||||
public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
this.parent = parent;
|
||||
|
|
|
@ -40,7 +40,9 @@ import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintCompon
|
|||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
import org.hl7.fhir.validation.BaseValidator;
|
||||
|
@ -50,8 +52,8 @@ public class ProfileValidator extends BaseValidator {
|
|||
private boolean checkAggregation = false;
|
||||
private boolean checkMustSupport = false;
|
||||
|
||||
public ProfileValidator(IWorkerContext context) {
|
||||
super(context);
|
||||
public ProfileValidator(IWorkerContext context, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
}
|
||||
|
||||
public boolean isCheckAggregation() {
|
||||
|
@ -138,7 +140,12 @@ public class ProfileValidator extends BaseValidator {
|
|||
if (!ec.getType().isEmpty() && "Extension".equals(ec.getType().get(0).getWorkingCode()) && ec.getType().get(0).hasProfile()) {
|
||||
String url = ec.getType().get(0).getProfile().get(0).getValue();
|
||||
StructureDefinition defn = context.fetchResource(StructureDefinition.class, url);
|
||||
if (defn == null) {
|
||||
defn = getXverExt(profile, errors, url);
|
||||
}
|
||||
rule(errors, IssueType.BUSINESSRULE, profile.getId(), defn != null, "Unable to find Extension '"+url+"' referenced at "+profile.getUrl()+" "+kind+" "+ec.getPath()+" ("+ec.getSliceName()+")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue