Fix NPE handling R3 structure definitions
This commit is contained in:
parent
ec8e999162
commit
704d498300
|
@ -2238,7 +2238,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
public List<StructureDefinition> fetchTypeDefinitions(String typeName) {
|
||||
List<StructureDefinition> res = new ArrayList<>();
|
||||
structures.listAll(res);
|
||||
res.removeIf(sd -> !sd.getType().equals(typeName));
|
||||
res.removeIf(sd -> !sd.hasType() || !sd.getType().equals(typeName));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,15 +158,16 @@ public class BaseValidator implements IValidationContextResourceLoader {
|
|||
protected Coding jurisdiction;
|
||||
protected boolean allowExamples;
|
||||
protected boolean forPublication;
|
||||
protected boolean debug;
|
||||
|
||||
public BaseValidator(IWorkerContext context, XVerExtensionManager xverManager) {
|
||||
public BaseValidator(IWorkerContext context, XVerExtensionManager xverManager, boolean debug) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.xverManager = xverManager;
|
||||
if (this.xverManager == null) {
|
||||
this.xverManager = new XVerExtensionManager(context);
|
||||
}
|
||||
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
private boolean doingLevel(IssueSeverity error) {
|
||||
|
@ -1272,4 +1273,12 @@ public class BaseValidator implements IValidationContextResourceLoader {
|
|||
return this;
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
}
|
|
@ -47,7 +47,7 @@ import org.hl7.fhir.validation.BaseValidator;
|
|||
public class CodeSystemValidator extends BaseValidator {
|
||||
|
||||
public CodeSystemValidator(IWorkerContext context, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
super(context, xverManager, false);
|
||||
}
|
||||
|
||||
public List<ValidationMessage> validate(CodeSystem cs, boolean forBuild) {
|
||||
|
|
|
@ -479,7 +479,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
|
||||
// time tracking
|
||||
private boolean noBindingMsgSuppressed;
|
||||
private boolean debug;
|
||||
private Map<String, Element> fetchCache = new HashMap<>();
|
||||
private HashMap<Element, ResourceValidationTracker> resourceTracker = new HashMap<>();
|
||||
private IValidatorResourceFetcher fetcher;
|
||||
|
@ -507,7 +506,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
private boolean logProgress;
|
||||
|
||||
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices, XVerExtensionManager xverManager) {
|
||||
super(theContext, xverManager);
|
||||
super(theContext, xverManager, false);
|
||||
start = System.currentTimeMillis();
|
||||
this.externalHostServices = hostServices;
|
||||
this.profileUtilities = new ProfileUtilities(theContext, null, null);
|
||||
|
@ -5048,31 +5047,31 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
public boolean checkSpecials(ValidatorHostContext hostContext, List<ValidationMessage> errors, Element element, NodeStack stack, boolean checkSpecials, PercentageTracker pct, ValidationMode mode) {
|
||||
// specific known special validations
|
||||
if (element.getType().equals(BUNDLE)) {
|
||||
return new BundleValidator(context, serverBase, this, xverManager, jurisdiction).validateBundle(errors, element, stack, checkSpecials, hostContext, pct, mode);
|
||||
return new BundleValidator(context, debug, serverBase, this, xverManager, jurisdiction).validateBundle(errors, element, stack, checkSpecials, hostContext, pct, mode);
|
||||
} else if (element.getType().equals("Observation")) {
|
||||
return validateObservation(errors, element, stack);
|
||||
} else if (element.getType().equals("Questionnaire")) {
|
||||
return new QuestionnaireValidator(context, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode, xverManager, jurisdiction).validateQuestionannaire(errors, element, element, stack);
|
||||
return new QuestionnaireValidator(context, debug, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode, xverManager, jurisdiction).validateQuestionannaire(errors, element, element, stack);
|
||||
} else if (element.getType().equals("QuestionnaireResponse")) {
|
||||
return new QuestionnaireValidator(context, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode, xverManager, jurisdiction).validateQuestionannaireResponse(hostContext, errors, element, stack);
|
||||
return new QuestionnaireValidator(context, debug, myEnableWhenEvaluator, fpe, timeTracker, questionnaireMode, xverManager, jurisdiction).validateQuestionannaireResponse(hostContext, errors, element, stack);
|
||||
} else if (element.getType().equals("Measure")) {
|
||||
return new MeasureValidator(context, timeTracker, xverManager, jurisdiction, this).validateMeasure(hostContext, errors, element, stack);
|
||||
return new MeasureValidator(context, debug, timeTracker, xverManager, jurisdiction, this).validateMeasure(hostContext, errors, element, stack);
|
||||
} else if (element.getType().equals("MeasureReport")) {
|
||||
return new MeasureValidator(context, timeTracker, xverManager, jurisdiction, this).validateMeasureReport(hostContext, errors, element, stack);
|
||||
return new MeasureValidator(context, debug, timeTracker, xverManager, jurisdiction, this).validateMeasureReport(hostContext, errors, element, stack);
|
||||
} else if (element.getType().equals("CapabilityStatement")) {
|
||||
return validateCapabilityStatement(errors, element, stack);
|
||||
} else if (element.getType().equals("CodeSystem")) {
|
||||
return new CodeSystemValidator(context, timeTracker, this, xverManager, jurisdiction).validateCodeSystem(errors, element, stack, baseOptions.withLanguage(stack.getWorkingLang()));
|
||||
return new CodeSystemValidator(context, debug, timeTracker, this, xverManager, jurisdiction).validateCodeSystem(errors, element, stack, baseOptions.withLanguage(stack.getWorkingLang()));
|
||||
} else if (element.getType().equals("ConceptMap")) {
|
||||
return new ConceptMapValidator(context, timeTracker, this, xverManager, jurisdiction).validateConceptMap(errors, element, stack, baseOptions.withLanguage(stack.getWorkingLang()));
|
||||
return new ConceptMapValidator(context, debug, timeTracker, this, xverManager, jurisdiction).validateConceptMap(errors, element, stack, baseOptions.withLanguage(stack.getWorkingLang()));
|
||||
} else if (element.getType().equals("SearchParameter")) {
|
||||
return new SearchParameterValidator(context, timeTracker, fpe, xverManager, jurisdiction).validateSearchParameter(errors, element, stack);
|
||||
return new SearchParameterValidator(context, debug, timeTracker, fpe, xverManager, jurisdiction).validateSearchParameter(errors, element, stack);
|
||||
} else if (element.getType().equals("StructureDefinition")) {
|
||||
return new StructureDefinitionValidator(context, timeTracker, fpe, wantCheckSnapshotUnchanged, xverManager, jurisdiction, forPublication).validateStructureDefinition(errors, element, stack);
|
||||
return new StructureDefinitionValidator(context, debug, timeTracker, fpe, wantCheckSnapshotUnchanged, xverManager, jurisdiction, forPublication).validateStructureDefinition(errors, element, stack);
|
||||
} else if (element.getType().equals("StructureMap")) {
|
||||
return new StructureMapValidator(context, timeTracker, fpe, xverManager,profileUtilities, jurisdiction).validateStructureMap(errors, element, stack);
|
||||
return new StructureMapValidator(context, debug, timeTracker, fpe, xverManager,profileUtilities, jurisdiction).validateStructureMap(errors, element, stack);
|
||||
} else if (element.getType().equals("ValueSet")) {
|
||||
return new ValueSetValidator(context, timeTracker, this, xverManager, jurisdiction, allowExamples).validateValueSet(errors, element, stack);
|
||||
return new ValueSetValidator(context, debug, timeTracker, this, xverManager, jurisdiction, allowExamples).validateValueSet(errors, element, stack);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -6399,13 +6398,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
private String tail(String path) {
|
||||
return path.substring(path.lastIndexOf(".") + 1);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public class BundleValidator extends BaseValidator {
|
|||
private String serverBase;
|
||||
private InstanceValidator validator;
|
||||
|
||||
public BundleValidator(IWorkerContext context, String serverBase, InstanceValidator validator, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager);
|
||||
public BundleValidator(IWorkerContext context, boolean debug, String serverBase, InstanceValidator validator, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager, debug);
|
||||
this.serverBase = serverBase;
|
||||
this.validator = validator;
|
||||
this.jurisdiction = jurisdiction;
|
||||
|
|
|
@ -23,8 +23,8 @@ public class CodeSystemValidator extends BaseValidator {
|
|||
|
||||
private InstanceValidator parent;
|
||||
|
||||
public CodeSystemValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager);
|
||||
public CodeSystemValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
this.jurisdiction = jurisdiction;
|
||||
|
|
|
@ -54,8 +54,8 @@ public class ConceptMapValidator extends BaseValidator {
|
|||
|
||||
private InstanceValidator parent;
|
||||
|
||||
public ConceptMapValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager);
|
||||
public ConceptMapValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
this.jurisdiction = jurisdiction;
|
||||
|
|
|
@ -44,8 +44,8 @@ import org.w3c.dom.Document;
|
|||
public class MeasureValidator extends BaseValidator {
|
||||
|
||||
private InstanceValidator parent;
|
||||
public MeasureValidator(IWorkerContext context, TimeTracker timeTracker, XVerExtensionManager xverManager, Coding jurisdiction, InstanceValidator parent) {
|
||||
super(context, xverManager);
|
||||
public MeasureValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, XVerExtensionManager xverManager, Coding jurisdiction, InstanceValidator parent) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
this.jurisdiction = jurisdiction;
|
||||
|
|
|
@ -133,8 +133,8 @@ public class QuestionnaireValidator extends BaseValidator {
|
|||
private FHIRPathEngine fpe;
|
||||
private QuestionnaireMode questionnaireMode;
|
||||
|
||||
public QuestionnaireValidator(IWorkerContext context, EnableWhenEvaluator myEnableWhenEvaluator, FHIRPathEngine fpe, TimeTracker timeTracker, QuestionnaireMode questionnaireMode, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager);
|
||||
public QuestionnaireValidator(IWorkerContext context, boolean debug, EnableWhenEvaluator myEnableWhenEvaluator, FHIRPathEngine fpe, TimeTracker timeTracker, QuestionnaireMode questionnaireMode, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.myEnableWhenEvaluator = myEnableWhenEvaluator;
|
||||
this.fpe = fpe;
|
||||
|
|
|
@ -36,8 +36,8 @@ public class SearchParameterValidator extends BaseValidator {
|
|||
|
||||
private FHIRPathEngine fpe;
|
||||
|
||||
public SearchParameterValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager);
|
||||
public SearchParameterValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, FHIRPathEngine fpe, XVerExtensionManager xverManager, Coding jurisdiction) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.fpe = fpe;
|
||||
this.timeTracker = timeTracker;
|
||||
|
|
|
@ -62,8 +62,8 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
private FHIRPathEngine fpe;
|
||||
private boolean wantCheckSnapshotUnchanged;
|
||||
|
||||
public StructureDefinitionValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, boolean wantCheckSnapshotUnchanged, XVerExtensionManager xverManager, Coding jurisdiction, boolean forPublication) {
|
||||
super(context, xverManager);
|
||||
public StructureDefinitionValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, FHIRPathEngine fpe, boolean wantCheckSnapshotUnchanged, XVerExtensionManager xverManager, Coding jurisdiction, boolean forPublication) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.fpe = fpe;
|
||||
this.timeTracker = timeTracker;
|
||||
|
@ -496,6 +496,9 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
// String upath = profileUrl+"#"+path;
|
||||
fpe.check(invariant, rootPath, path, fpe.parse(expression));
|
||||
} catch (Exception e) {
|
||||
if (debug) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ok = rule(errors, "2023-06-19", IssueType.INVALID, stack, false, I18nConstants.ED_INVARIANT_EXPRESSION_ERROR, key, expression, e.getMessage()) && ok;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -303,8 +303,8 @@ public class StructureMapValidator extends BaseValidator {
|
|||
private ContextUtilities cu;
|
||||
private List<StructureMap> imports = new ArrayList<>();
|
||||
|
||||
public StructureMapValidator(IWorkerContext context, TimeTracker timeTracker, FHIRPathEngine fpe, XVerExtensionManager xverManager, ProfileUtilities profileUtilities, Coding jurisdiction) {
|
||||
super(context, xverManager);
|
||||
public StructureMapValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, FHIRPathEngine fpe, XVerExtensionManager xverManager, ProfileUtilities profileUtilities, Coding jurisdiction) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.fpe = fpe;
|
||||
this.timeTracker = timeTracker;
|
||||
|
|
|
@ -43,8 +43,8 @@ public class ValueSetValidator extends BaseValidator {
|
|||
|
||||
private InstanceValidator parent;
|
||||
|
||||
public ValueSetValidator(IWorkerContext context, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager, Coding jurisdiction, boolean allowExamples) {
|
||||
super(context, xverManager);
|
||||
public ValueSetValidator(IWorkerContext context, boolean debug, TimeTracker timeTracker, InstanceValidator parent, XVerExtensionManager xverManager, Coding jurisdiction, boolean allowExamples) {
|
||||
super(context, xverManager, debug);
|
||||
source = Source.InstanceValidator;
|
||||
this.timeTracker = timeTracker;
|
||||
this.parent = parent;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ProfileValidator extends BaseValidator {
|
|||
private FHIRPathEngine fpe;
|
||||
|
||||
public ProfileValidator(IWorkerContext context, XVerExtensionManager xverManager) {
|
||||
super(context, xverManager);
|
||||
super(context, xverManager, false);
|
||||
fpe = new FHIRPathEngine(context);
|
||||
fpe.setAllowDoubleQuotes(allowDoubleQuotesInFHIRPath);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue