cache xversion extension manager, and use it in any place accessing extension definitions

This commit is contained in:
Grahame Grieve 2020-12-03 12:52:43 +11:00
parent 4b43e46d11
commit 532aba2485
15 changed files with 165 additions and 66 deletions

View File

@ -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.model.StructureMap.StructureMapStructureComponent;
import org.hl7.fhir.r5.terminologies.TerminologyClient; import org.hl7.fhir.r5.terminologies.TerminologyClient;
import org.hl7.fhir.r5.utils.IResourceValidator; 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.CSFileInputStream;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.TimeTracker; import org.hl7.fhir.utilities.TimeTracker;
@ -138,7 +139,8 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
} }
public interface IValidatorFactory { 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; private Questionnaire questionnaire;
@ -149,6 +151,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
private boolean progress; private boolean progress;
private List<String> loadedPackages = new ArrayList<String>(); private List<String> loadedPackages = new ArrayList<String>();
private boolean canNoTS; private boolean canNoTS;
private XVerExtensionManager xverManager;
public SimpleWorkerContext() throws FileNotFoundException, IOException, FHIRException { public SimpleWorkerContext() throws FileNotFoundException, IOException, FHIRException {
super(); super();
@ -539,7 +542,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
public IResourceValidator newValidator() throws FHIRException { public IResourceValidator newValidator() throws FHIRException {
if (validatorFactory == null) if (validatorFactory == null)
throw new Error(formatMessage(I18nConstants.NO_VALIDATOR_CONFIGURED)); 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); ProfileUtilities pu = new ProfileUtilities(this, msgs, this);
pu.setAutoFixSliceNames(true); pu.setAutoFixSliceNames(true);
pu.setThrowException(false); pu.setThrowException(false);
if (xverManager == null) {
xverManager = new XVerExtensionManager(this);
}
pu.setXver(xverManager);
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) { if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
pu.sortDifferential(sd, p, p.getUrl(), errors, true); pu.sortDifferential(sd, p, p.getUrl(), errors, true);
} }
@ -827,6 +834,13 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
public void setCanNoTS(boolean canNoTS) { public void setCanNoTS(boolean canNoTS) {
this.canNoTS = canNoTS; this.canNoTS = canNoTS;
} }
public XVerExtensionManager getXVer() {
if (xverManager == null) {
xverManager = new XVerExtensionManager(this);
}
return xverManager;
}
} }

View File

@ -84,6 +84,7 @@ public class XVerExtensionManager {
StructureDefinition sd = new StructureDefinition(); StructureDefinition sd = new StructureDefinition();
sd.setUserData(XVER_EXT_MARKER, "true"); sd.setUserData(XVER_EXT_MARKER, "true");
sd.setUserData("path", "http://hl7.org/fhir/versions.html#extensions");
sd.setUrl(url); sd.setUrl(url);
sd.setVersion(context.getVersion()); sd.setVersion(context.getVersion());
sd.setFhirVersion(FHIRVersion.fromCode(context.getVersion())); sd.setFhirVersion(FHIRVersion.fromCode(context.getVersion()));

View File

@ -73,8 +73,11 @@ import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Resource; 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.model.ValueSet;
import org.hl7.fhir.r5.terminologies.ValueSetUtilities; 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.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
@ -118,7 +121,18 @@ public class BaseValidator {
protected Source source; protected Source source;
protected IWorkerContext context; protected IWorkerContext context;
protected TimeTracker timeTracker = new TimeTracker(); 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. * Use to control what validation the validator performs.
* Using this, you can turn particular kinds of validation on and off * Using this, you can turn particular kinds of validation on and off
@ -129,11 +143,7 @@ public class BaseValidator {
*/ */
private Map<String, ValidationControl> validationControl = new HashMap<>(); 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 * Test a rule and add a {@link IssueSeverity#FATAL} validation message if the validation fails
* *
* @param thePass * @param thePass
@ -873,5 +883,74 @@ public class BaseValidator {
return validationControl; 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;
}
} }

View File

@ -1564,7 +1564,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IPackageInst
} }
public InstanceValidator getValidator() { public InstanceValidator getValidator() {
InstanceValidator validator = new InstanceValidator(context, null); InstanceValidator validator = new InstanceValidator(context, null, null);
validator.setHintAboutNonMustSupport(hintAboutNonMustSupport); validator.setHintAboutNonMustSupport(hintAboutNonMustSupport);
validator.setAnyExtensionsAllowed(anyExtensionsAllowed); validator.setAnyExtensionsAllowed(anyExtensionsAllowed);
validator.setNoInvariantChecks(isNoInvariantChecks()); validator.setNoInvariantChecks(isNoInvariantChecks());

View File

@ -39,14 +39,15 @@ import java.util.Set;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; 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;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.validation.BaseValidator; import org.hl7.fhir.validation.BaseValidator;
public class CodeSystemValidator extends BaseValidator { public class CodeSystemValidator extends BaseValidator {
public CodeSystemValidator(IWorkerContext context) { public CodeSystemValidator(IWorkerContext context, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
} }
public List<ValidationMessage> validate(CodeSystem cs, boolean forBuild) { public List<ValidationMessage> validate(CodeSystem cs, boolean forBuild) {

View File

@ -368,7 +368,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private EnableWhenEvaluator myEnableWhenEvaluator = new EnableWhenEvaluator(); private EnableWhenEvaluator myEnableWhenEvaluator = new EnableWhenEvaluator();
private String executionId; private String executionId;
private XVerExtensionManager xverManager;
private IValidationProfileUsageTracker tracker; private IValidationProfileUsageTracker tracker;
private ValidatorHostServices validatorServices; private ValidatorHostServices validatorServices;
private boolean assumeValidRestReferences; private boolean assumeValidRestReferences;
@ -380,8 +379,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private boolean validateValueSetCodesOnTxServer = true; private boolean validateValueSetCodesOnTxServer = true;
private QuestionnaireMode questionnaireMode; private QuestionnaireMode questionnaireMode;
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices) { public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices, XVerExtensionManager xverManager) {
super(theContext); super(theContext, xverManager);
this.externalHostServices = hostServices; this.externalHostServices = hostServices;
this.profileUtilities = new ProfileUtilities(theContext, null, null); this.profileUtilities = new ProfileUtilities(theContext, null, null);
fpe = new FHIRPathEngine(context); 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; StructureDefinition ex = Utilities.isAbsoluteUrl(url) ? context.fetchResource(StructureDefinition.class, url) : null;
timeTracker.sd(t); timeTracker.sd(t);
if (ex == null) { if (ex == null) {
if (xverManager == null) { ex = getXverExt(errors, path, element, url);
xverManager = new XVerExtensionManager(context); }
} if (ex == null) {
if (xverManager.matchingUrl(url)) { if (extensionUrl != null && !isAbsolute(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 (extensionUrl.equals(profile.getUrl())) { 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()); rule(errors, IssueType.INVALID, element.line(), element.col(), path + "[url='" + url + "']", hasExtensionSlice(profile, url), I18nConstants.EXTENSION_EXT_SUBEXTENSION_INVALID, url, profile.getUrl());
} }
@ -1568,6 +1547,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
return ex; return ex;
} }
private boolean hasExtensionSlice(StructureDefinition profile, String sliceName) { private boolean hasExtensionSlice(StructureDefinition profile, String sliceName) {
for (ElementDefinition ed : profile.getSnapshot().getElement()) { for (ElementDefinition ed : profile.getSnapshot().getElement()) {
@ -1951,7 +1931,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
boolean found; boolean found;
try { 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) || 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) { } catch (IOException e1) {
found = false; 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) { public void checkSpecials(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element element, NodeStack stack, boolean checkSpecials) {
// specific known special validations // specific known special validations
if (element.getType().equals(BUNDLE)) { 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")) { } else if (element.getType().equals("Observation")) {
validateObservation(errors, element, stack); validateObservation(errors, element, stack);
} else if (element.getType().equals("Questionnaire")) { } 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")) { } 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")) { } 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")) { } 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")) { } else if (element.getType().equals("CapabilityStatement")) {
validateCapabilityStatement(errors, element, stack); validateCapabilityStatement(errors, element, stack);
} else if (element.getType().equals("CodeSystem")) { } 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")) { } 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")) { } 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")) { } 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);
} }
} }

View File

@ -36,12 +36,18 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.SimpleWorkerContext.IValidatorFactory; import org.hl7.fhir.r5.context.SimpleWorkerContext.IValidatorFactory;
import org.hl7.fhir.r5.utils.IResourceValidator; import org.hl7.fhir.r5.utils.IResourceValidator;
import org.hl7.fhir.r5.utils.XVerExtensionManager;
public class InstanceValidatorFactory implements IValidatorFactory { public class InstanceValidatorFactory implements IValidatorFactory {
@Override
public IResourceValidator makeValidator(IWorkerContext ctxt, XVerExtensionManager xverManager) throws FHIRException {
return new InstanceValidator(ctxt, null, xverManager);
}
@Override @Override
public IResourceValidator makeValidator(IWorkerContext ctxt) throws FHIRException { public IResourceValidator makeValidator(IWorkerContext ctxt) throws FHIRException {
return new InstanceValidator(ctxt, null); return new InstanceValidator(ctxt, null, null);
} }
} }

View File

@ -13,6 +13,7 @@ import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.Constants; import org.hl7.fhir.r5.model.Constants;
import org.hl7.fhir.r5.model.Enumerations.FHIRVersion; import org.hl7.fhir.r5.model.Enumerations.FHIRVersion;
import org.hl7.fhir.r5.model.StructureDefinition; 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.r5.utils.IResourceValidator.BundleValidationRule;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
@ -31,8 +32,8 @@ public class BundleValidator extends BaseValidator{
private String serverBase; private String serverBase;
private InstanceValidator validator; private InstanceValidator validator;
public BundleValidator(IWorkerContext context, String serverBase, InstanceValidator validator) { public BundleValidator(IWorkerContext context, String serverBase, InstanceValidator validator, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
this.serverBase = serverBase; this.serverBase = serverBase;
this.validator = validator; this.validator = validator;
} }

View File

@ -6,6 +6,7 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.model.ValueSet; 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.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage; 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 class CodeSystemValidator extends BaseValidator {
public CodeSystemValidator(IWorkerContext context, TimeTracker timeTracker) { public CodeSystemValidator(IWorkerContext context, TimeTracker timeTracker, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.timeTracker = timeTracker; this.timeTracker = timeTracker;
} }

View File

@ -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.Measure.MeasureGroupStratifierComponent;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.DataRenderer; 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.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
@ -40,8 +41,8 @@ import org.w3c.dom.Document;
public class MeasureValidator extends BaseValidator { public class MeasureValidator extends BaseValidator {
public MeasureValidator(IWorkerContext context, TimeTracker timeTracker) { public MeasureValidator(IWorkerContext context, TimeTracker timeTracker, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.timeTracker = timeTracker; this.timeTracker = timeTracker;
} }

View File

@ -35,6 +35,7 @@ import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.TimeType; import org.hl7.fhir.r5.model.TimeType;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.utils.FHIRPathEngine; 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.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
@ -58,8 +59,8 @@ public class QuestionnaireValidator extends BaseValidator {
private FHIRPathEngine fpe; private FHIRPathEngine fpe;
private QuestionnaireMode questionnaireMode; private QuestionnaireMode questionnaireMode;
public QuestionnaireValidator(IWorkerContext context, EnableWhenEvaluator myEnableWhenEvaluator, FHIRPathEngine fpe, TimeTracker timeTracker, QuestionnaireMode questionnaireMode) { public QuestionnaireValidator(IWorkerContext context, EnableWhenEvaluator myEnableWhenEvaluator, FHIRPathEngine fpe, TimeTracker timeTracker, QuestionnaireMode questionnaireMode, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.myEnableWhenEvaluator = myEnableWhenEvaluator; this.myEnableWhenEvaluator = myEnableWhenEvaluator;
this.fpe = fpe; this.fpe = fpe;

View File

@ -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.ExpressionNode.Operation;
import org.hl7.fhir.r5.model.SearchParameter; import org.hl7.fhir.r5.model.SearchParameter;
import org.hl7.fhir.r5.utils.FHIRPathEngine; 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.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
@ -34,8 +35,8 @@ public class SearchParameterValidator extends BaseValidator {
private FHIRPathEngine fpe; private FHIRPathEngine fpe;
public SearchParameterValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe) { public SearchParameterValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.fpe = fpe; this.fpe = fpe;
this.timeTracker = timeTracker; this.timeTracker = timeTracker;

View File

@ -23,6 +23,7 @@ import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.r5.utils.ToolingExtensions; 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.VersionUtilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
@ -46,8 +47,8 @@ public class StructureDefinitionValidator extends BaseValidator {
private FHIRPathEngine fpe; private FHIRPathEngine fpe;
private boolean wantCheckSnapshotUnchanged; private boolean wantCheckSnapshotUnchanged;
public StructureDefinitionValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, boolean wantCheckSnapshotUnchanged) { public StructureDefinitionValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, boolean wantCheckSnapshotUnchanged, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.fpe = fpe; this.fpe = fpe;
this.timeTracker = timeTracker; this.timeTracker = timeTracker;
@ -66,6 +67,7 @@ public class StructureDefinitionValidator extends BaseValidator {
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) { if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
List<ValidationMessage> msgs = new ArrayList<>(); List<ValidationMessage> msgs = new ArrayList<>();
ProfileUtilities pu = new ProfileUtilities(context, msgs, null); ProfileUtilities pu = new ProfileUtilities(context, msgs, null);
pu.setXver(xverManager);
pu.generateSnapshot(base, sd, sd.getUrl(), "http://hl7.org/fhir", sd.getName()); pu.generateSnapshot(base, sd, sd.getUrl(), "http://hl7.org/fhir", sd.getName());
if (msgs.size() > 0) { if (msgs.size() > 0) {
for (ValidationMessage msg : msgs) { 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) { private void validateTypeProfile(List<ValidationMessage> errors, Element profile, String code, NodeStack stack) {
String p = profile.primitiveValue(); String p = profile.primitiveValue();
StructureDefinition sd = context.fetchResource(StructureDefinition.class, p); 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)) { if (warning(errors, IssueType.EXCEPTION, stack.getLiteralPath(), sd != null, I18nConstants.SD_ED_TYPE_PROFILE_UNKNOWN, p)) {
String t = determineBaseType(sd); String t = determineBaseType(sd);
if (t == null) { if (t == null) {

View File

@ -11,6 +11,7 @@ import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; 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.Utilities;
import org.hl7.fhir.utilities.VersionUtilities; import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
@ -42,8 +43,8 @@ public class ValueSetValidator extends BaseValidator {
private InstanceValidator parent; private InstanceValidator parent;
public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent) { public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
source = Source.InstanceValidator; source = Source.InstanceValidator;
this.timeTracker = timeTracker; this.timeTracker = timeTracker;
this.parent = parent; this.parent = parent;

View File

@ -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.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.utils.FHIRPathEngine; 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.Utilities;
import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.validation.BaseValidator; import org.hl7.fhir.validation.BaseValidator;
@ -50,8 +52,8 @@ public class ProfileValidator extends BaseValidator {
private boolean checkAggregation = false; private boolean checkAggregation = false;
private boolean checkMustSupport = false; private boolean checkMustSupport = false;
public ProfileValidator(IWorkerContext context) { public ProfileValidator(IWorkerContext context, XVerExtensionManager xverManager) {
super(context); super(context, xverManager);
} }
public boolean isCheckAggregation() { 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()) { 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(); String url = ec.getType().get(0).getProfile().get(0).getValue();
StructureDefinition defn = context.fetchResource(StructureDefinition.class, url); 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()+")"); rule(errors, IssueType.BUSINESSRULE, profile.getId(), defn != null, "Unable to find Extension '"+url+"' referenced at "+profile.getUrl()+" "+kind+" "+ec.getPath()+" ("+ec.getSliceName()+")");
} }
} }
} }