Do not force enableWhen to have system

This commit is contained in:
Matti Uusitalo 2018-12-13 13:29:17 +02:00 committed by Eeva Turkka
parent 73e85ce668
commit 3c56640d57
3 changed files with 31 additions and 2 deletions

View File

@ -11,7 +11,7 @@
<artifactId>hapi-fhir-validation</artifactId> <artifactId>hapi-fhir-validation</artifactId>
<packaging>bundle</packaging> <packaging>bundle</packaging>
<version>3.6.3-PHRFIX</version> <version>3.6.4-PHRFIX</version>
<name>HAPI FHIR - Validation</name> <name>HAPI FHIR - Validation</name>

View File

@ -188,7 +188,7 @@ public class DefaultEnableWhenEvaluator implements IEnableWhenEvaluator {
} }
private boolean compareSystems(Coding expectedCoding, Coding value) { private boolean compareSystems(Coding expectedCoding, Coding value) {
if (expectedCoding.hasSystem() != value.hasSystem()) { if (expectedCoding.hasSystem() && !value.hasSystem()) {
return false; return false;
} }
if (expectedCoding.hasSystem()) { if (expectedCoding.hasSystem()) {

View File

@ -580,6 +580,35 @@ public class QuestionnaireResponseValidatorDstu3Test {
} }
@Test
public void testChoiceItemsEnableWhenHasNoSystemYetAnswerHasSystem() throws Exception {
Questionnaire q = new Questionnaire();
Coding qcoding = new Coding();
qcoding.setCode("male");
qcoding.setSystem("http://hl7.org/fhir/administrative-gender");
q.addItem().setLinkId("1B").setRequired(true).setType(CHOICE).addOption().setValue(qcoding);
Coding enablewhenCoding = new Coding();
enablewhenCoding.setCode("male");
q.addItem().setLinkId("2B").setType(BOOLEAN).addEnableWhen().setQuestion("1B").setAnswer(enablewhenCoding);
QuestionnaireResponse qr = new QuestionnaireResponse();
qr.setStatus(COMPLETED);
qr.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
QuestionnaireResponseItemComponent qrItem = qr.addItem().setLinkId("1B");
Coding coding = new Coding();
coding.setCode("male");
coding.setSystem("http://hl7.org/fhir/administrative-gender");
QuestionnaireResponseItemAnswerComponent answer = qrItem.addAnswer();
answer.setValue(coding);
qr.addItem().setLinkId("2B").addAnswer().setValue(new BooleanType(true));
String reference = qr.getQuestionnaire().getReference();
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
ValidationResult errors = myVal.validateWithResult(qr);
assertThat(errors.toString(), containsString("No issues"));
}
@Test @Test
public void testEmbeddedItemInChoice() { public void testEmbeddedItemInChoice() {
String questionnaireRef = QUESTIONNAIRE_URL; String questionnaireRef = QUESTIONNAIRE_URL;