Added default enablewhen behaviour to STU3 resources converted to R4

This commit is contained in:
Matti Uusitalo 2018-11-06 13:11:12 +02:00
parent 139ec6503f
commit b140351650
3 changed files with 6 additions and 3 deletions

View File

@ -32,6 +32,7 @@ import org.hl7.fhir.dstu3.model.ExpansionProfile.DesignationIncludeDesignationCo
import org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode; import org.hl7.fhir.dstu3.model.ExpansionProfile.SystemVersionProcessingMode;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Expression.ExpressionLanguage; 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.BooleanType;
import org.hl7.fhir.r4.model.Contributor; import org.hl7.fhir.r4.model.Contributor;
import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Identifier;
@ -16184,6 +16185,7 @@ public class VersionConvertor_30_40 {
tgt.setType(convertQuestionnaireItemType(src.getType())); tgt.setType(convertQuestionnaireItemType(src.getType()));
for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen()) for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent t : src.getEnableWhen())
tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t)); tgt.addEnableWhen(convertQuestionnaireItemEnableWhenComponent(t));
tgt.setEnableBehavior(EnableWhenBehavior.ANY);
if (src.hasRequired()) if (src.hasRequired())
tgt.setRequired(src.getRequired()); tgt.setRequired(src.getRequired());
if (src.hasRepeats()) if (src.hasRepeats())

View File

@ -2782,7 +2782,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
validateQuestionannaireResponseItem(qsrc, qItem, errors, mapItem, stack, inProgress); validateQuestionannaireResponseItem(qsrc, qItem, errors, mapItem, stack, inProgress);
} else { } else {
//item is missing, is the question enabled? //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()); rule(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), !qItem.getRequired(), "No response found for required item "+qItem.getLinkId());
} }
} }

View File

@ -24,6 +24,7 @@ import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemC
import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus; import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseStatus;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,10 +53,10 @@ public class QuestionnaireResponseValidatorDstu3Test {
private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport(); private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport();
private static FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private FhirInstanceValidator myInstanceVal; private FhirInstanceValidator myInstanceVal;
private FhirValidator myVal; private static FhirValidator myVal;
private IValidationSupport myValSupport; private IValidationSupport myValSupport;
private IWorkerContext myWorkerCtx; private IWorkerContext myWorkerCtx;
@Before @Before
public void before() { public void before() {
myValSupport = mock(IValidationSupport.class); myValSupport = mock(IValidationSupport.class);