diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java index 52bdfae8d..2112d307f 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/NpmPackage.java @@ -292,5 +292,18 @@ import com.google.gson.JsonObject; return npm.get("canonical").getAsString(); } + public InputStream loadResource(String type, String id) throws IOException { + String file = type+"-"+id+".json"; + if (content.containsKey("package/"+file)) + return new ByteArrayInputStream(content.get("package/"+file)); + else { + File f = new File(Utilities.path(path, "package", file)); + if (f.exists()) + return new FileInputStream(f); + else + return null; + } + } + } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java index d42ff4b5b..b6fdc95d1 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java @@ -2959,12 +2959,14 @@ private boolean isAnswerRequirementFulfilled(QuestionnaireItemComponent qItem, L } public void validateQuestionannaireResponseItem(Questionnaire qsrc, List errors, Element element, NodeStack stack, boolean inProgress, Element questionnaireResponseRoot, QuestionnaireItemComponent qItem, List mapItem) { + boolean enabled = myEnableWhenEvaluator.isQuestionEnabled(qItem, questionnaireResponseRoot); if (mapItem != null){ - rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), myEnableWhenEvaluator.isQuestionEnabled(qItem, questionnaireResponseRoot), "Item has answer, even though it is not enabled (item id = '"+qItem.getLinkId()+"')"); + if (!enabled) + rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), enabled, "Item has answer, even though it is not enabled (item id = '"+qItem.getLinkId()+"')"); validateQuestionannaireResponseItem(qsrc, qItem, errors, mapItem, stack, inProgress, questionnaireResponseRoot); } else { //item is missing, is the question enabled? - if (myEnableWhenEvaluator.isQuestionEnabled(qItem, questionnaireResponseRoot) && qItem.getRequired()) { + if (enabled && qItem.getRequired()) { rule(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), false, "No response found for required item (item id = '"+qItem.getLinkId()+"')"); } }