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.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())

View File

@ -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());
}
}

View File

@ -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);