This commit is contained in:
markiantorno 2020-02-21 17:05:49 -05:00
parent a91b9886ce
commit dc40256af4
1 changed files with 12 additions and 24 deletions

View File

@ -3475,21 +3475,18 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private void validateQuestionnaireElement(List<ValidationMessage> errors, NodeStack ns, Element questionnaire, Element item, List<Element> parents) { private void validateQuestionnaireElement(List<ValidationMessage> errors, NodeStack ns, Element questionnaire, Element item, List<Element> parents) {
// R4+ // R4+
if (FHIRVersion.isR4Plus(context.getVersion())) { if ((FHIRVersion.isR4Plus(context.getVersion())) && (item.hasChildren("enableWhen"))) {
if (item.hasChildren("enableWhen")) { List<Element> ewl = item.getChildren("enableWhen");
List<Element> ewl = item.getChildren("enableWhen"); for (Element ew : ewl) {
for (Element ew : ewl) { String ql = ew.getNamedChildValue("question");
// Element ew = item.getNamedChild("enableWhen"); if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, ql != null, "Questions with an enableWhen must have a value for the question link")) {
String ql = ew.getNamedChildValue("question"); Element tgt = getQuestionById(item, ql);
if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, ql != null, "Questions with an enableWhen must have a value for the question link")) { if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, tgt == null, "Questions with an enableWhen cannot refer to an inner question for it's enableWhen condition")) {
Element tgt = getQuestionById(item, ql); tgt = getQuestionById(questionnaire, ql);
if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, tgt == null, "Questions with an enableWhen cannot refer to an inner question for it's enableWhen condition")) { if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, tgt != null, "Unable to find target '" + ql + "' for this question enableWhen")) {
tgt = getQuestionById(questionnaire, ql); if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, tgt != item, "Target for this question enableWhen can't reference itself")) {
if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, tgt != null, "Unable to find target '" + ql + "' for this question enableWhen")) { if (!isBefore(item, tgt, parents)) {
if (rule(errors, IssueType.BUSINESSRULE, ns.literalPath, tgt != item, "Target for this question enableWhen can't reference itself")) { warning(errors, IssueType.BUSINESSRULE, ns.literalPath, false, "The target of this enableWhen rule (" + ql + ") comes after the question itself");
if (!isBefore(item, tgt, parents)) {
warning(errors, IssueType.BUSINESSRULE, ns.literalPath, false, "The target of this enableWhen rule (" + ql + ") comes after the question itself");
}
} }
} }
} }
@ -4568,15 +4565,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private void validateElement(ValidatorHostContext hostContext, List<ValidationMessage> errors, StructureDefinition profile, ElementDefinition definition, StructureDefinition cprofile, ElementDefinition context, private void validateElement(ValidatorHostContext hostContext, List<ValidationMessage> errors, StructureDefinition profile, ElementDefinition definition, StructureDefinition cprofile, ElementDefinition context,
Element resource, Element element, String actualType, NodeStack stack, boolean inCodeableConcept, boolean checkDisplayInContext, String extensionUrl) throws FHIRException { Element resource, Element element, String actualType, NodeStack stack, boolean inCodeableConcept, boolean checkDisplayInContext, String extensionUrl) throws FHIRException {
// element.markValidation(profile, definition);
// time = System.nanoTime();
// check type invariants // check type invariants
checkInvariants(hostContext, errors, profile, definition, resource, element, stack, false); checkInvariants(hostContext, errors, profile, definition, resource, element, stack, false);
if (definition.getFixed() != null) if (definition.getFixed() != null)
checkFixedValue(errors, stack.getLiteralPath(), element, definition.getFixed(), profile.getUrl(), definition.getSliceName(), null); checkFixedValue(errors, stack.getLiteralPath(), element, definition.getFixed(), profile.getUrl(), definition.getSliceName(), null);
// get the list of direct defined children, including slices // get the list of direct defined children, including slices
List<ElementDefinition> childDefinitions = ProfileUtilities.getChildMap(profile, definition); List<ElementDefinition> childDefinitions = ProfileUtilities.getChildMap(profile, definition);
if (childDefinitions.isEmpty()) { if (childDefinitions.isEmpty()) {
@ -4997,14 +4991,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} else if (slicer != null && !slicer.getPath().equals(ed.getPath())) } else if (slicer != null && !slicer.getPath().equals(ed.getPath()))
slicer = null; slicer = null;
// if (process) {
for (ElementInfo ei : children) { for (ElementInfo ei : children) {
if (ei.sliceInfo == null) { if (ei.sliceInfo == null) {
ei.sliceInfo = new ArrayList<>(); ei.sliceInfo = new ArrayList<>();
} }
unsupportedSlicing = matchSlice(hostContext, errors, ei.sliceInfo, profile, stack, slicer, unsupportedSlicing, problematicPaths, sliceOffset, i, ed, childUnsupportedSlicing, ei); unsupportedSlicing = matchSlice(hostContext, errors, ei.sliceInfo, profile, stack, slicer, unsupportedSlicing, problematicPaths, sliceOffset, i, ed, childUnsupportedSlicing, ei);
} }
// }
} }
int last = -1; int last = -1;
int lastSlice = -1; int lastSlice = -1;
@ -5466,10 +5458,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
res.logicalPaths.add(definition.typeSummary()); res.logicalPaths.add(definition.typeSummary());
} else } else
res.logicalPaths.addAll(getLogicalPaths()); res.logicalPaths.addAll(getLogicalPaths());
// CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
// for (String lp : res.logicalPaths)
// b.append(lp);
// System.out.println(res.literalPath+" : "+b.toString());
return res; return res;
} }