From b14035165069554c67ddd31dc730e998fb80dc00 Mon Sep 17 00:00:00 2001 From: Matti Uusitalo Date: Tue, 6 Nov 2018 13:11:12 +0200 Subject: [PATCH] Added default enablewhen behaviour to STU3 resources converted to R4 --- .../java/org/hl7/fhir/convertors/VersionConvertor_30_40.java | 2 ++ .../java/org/hl7/fhir/r4/validation/InstanceValidator.java | 2 +- .../validation/QuestionnaireResponseValidatorDstu3Test.java | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java b/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java index f5016c93e8b..fb040d87e1e 100644 --- a/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java +++ b/hapi-fhir-converter/src/main/java/org/hl7/fhir/convertors/VersionConvertor_30_40.java @@ -32,6 +32,7 @@ import org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationCo import org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r4.model.Expression.ExpressionLanguage; +import org.hl7.fhir.r4.model.Questionnaire.EnableWhenBehavior; import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.Contributor; import org.hl7.fhir.r4.model.Identifier; @@ -16184,6 +16185,7 @@ public class VersionConvertor_30_40 { tgt.setType(convertQuestionnaireItemType(src.getType())); for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen()) tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t)); + tgt.setEnableBehavior(EnableWhenBehavior.ANY); if (src.hasRequired()) tgt.setRequired(src.getRequired()); if (src.hasRepeats()) diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java index 25c093e1f55..2f23a7cecae 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/r4/validation/InstanceValidator.java @@ -2782,7 +2782,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat validateQuestionannaireResponseItem(qsrc, qItem, errors, mapItem, stack, inProgress); } else { //item is missing, is the question enabled? - if (!myEnableWhenEvaluator.isQuestionEnabled(qItem, element)) { + if (myEnableWhenEvaluator.isQuestionEnabled(qItem, element)) { rule(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), !qItem.getRequired(), "No response found for required item "+qItem.getLinkId()); } } diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java index e5b67b9ce76..4053eeedd56 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/QuestionnaireResponseValidatorDstu3Test.java @@ -24,6 +24,7 @@ import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemC import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus; import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; @@ -52,10 +53,10 @@ public class QuestionnaireResponseValidatorDstu3Test { private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport(); private static FhirContext ourCtx = FhirContext.forDstu3(); private FhirInstanceValidator myInstanceVal; - private FhirValidator myVal; + private static FhirValidator myVal; private IValidationSupport myValSupport; private IWorkerContext myWorkerCtx; - + @Before public void before() { myValSupport = mock(IValidationSupport.class);