diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml
index 75475bbddf6..e0c5d0d491d 100644
--- a/hapi-fhir-converter/pom.xml
+++ b/hapi-fhir-converter/pom.xml
@@ -11,6 +11,7 @@
hapi-fhir-converter
bundle
+ 3.5.1-PHRFIX-SNAPSHOT
@@ -84,7 +85,7 @@
ca.uhn.hapi.fhir
hapi-fhir-client
- ${project.version}
+ 3.5.0
test
diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml
index 3706695e243..7cafb6169e0 100644
--- a/hapi-fhir-validation/pom.xml
+++ b/hapi-fhir-validation/pom.xml
@@ -11,6 +11,7 @@
hapi-fhir-validation
bundle
+ 3.5.1-PHRFIX-SNAPSHOT
HAPI FHIR - Validation
@@ -18,17 +19,17 @@
ca.uhn.hapi.fhir
hapi-fhir-base
- ${project.version}
+ 3.5.0
ca.uhn.hapi.fhir
hapi-fhir-utilities
- ${project.version}
+ 3.5.0
ca.uhn.hapi.fhir
hapi-fhir-converter
- ${project.version}
+ 3.5.1-PHRFIX-SNAPSHOT
@@ -63,49 +64,49 @@
ca.uhn.hapi.fhir
hapi-fhir-structures-dstu2
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-structures-hl7org-dstu2
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-structures-dstu2.1
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-validation-resources-dstu2
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-structures-dstu3
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-validation-resources-dstu3
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-structures-r4
- ${project.version}
+ 3.5.0
true
ca.uhn.hapi.fhir
hapi-fhir-validation-resources-r4
- ${project.version}
+ 3.5.0
true
@@ -118,13 +119,13 @@
ca.uhn.hapi.fhir
hapi-fhir-server
- ${project.version}
+ 3.5.0
test
ca.uhn.hapi.fhir
hapi-fhir-client
- ${project.version}
+ 3.5.0
test
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 32e77320c39..32e9e31a973 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
@@ -17,6 +17,7 @@ import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.CodeSystem.CodeSystemContentMode;
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent;
+import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemOptionComponent;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType;
import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent;
@@ -303,6 +304,135 @@ public class QuestionnaireResponseValidatorDstu3Test {
ourLog.info(errors.toString());
assertThat(errors.toString(), containsString("No response found for required item link0"));
}
+
+ @Test
+ public void testRequiredQuestionWithEnableWhenHdesQuestionHasAnswerTrue() {
+
+ Questionnaire q = new Questionnaire();
+ q.addItem().setLinkId("link0").setRequired(true).setType(QuestionnaireItemType.STRING);
+
+ // create the questionnaire
+ QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
+ item1.setLinkId("link1").setRequired(true);
+ q.addItem(item1);
+ QuestionnaireItemEnableWhenComponent enable = new QuestionnaireItemEnableWhenComponent();
+ item1.addEnableWhen(enable);
+ enable.setQuestion("link0");
+ enable.setHasAnswer(true);
+
+
+ //q.getItemFirstRep().addEnableWhen().
+ //q.addItem().setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
+
+ QuestionnaireResponse qa = new QuestionnaireResponse();
+ qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
+ qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
+ qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
+
+ String reference = qa.getQuestionnaire().getReference();
+ when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
+ ValidationResult errors = myVal.validateWithResult(qa);
+
+ ourLog.info(errors.toString());
+ assertThat(errors.toString(), containsString("No issues"));
+ }
+
+ @Test
+ public void testRequiredQuestionWithEnableWhenHidesQuestion() {
+
+ Questionnaire q = new Questionnaire();
+ q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.STRING);
+
+ // create the questionnaire
+ QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
+ item1.setLinkId("link1").setRequired(true);
+ q.addItem(item1);
+ QuestionnaireItemEnableWhenComponent enable = new QuestionnaireItemEnableWhenComponent();
+ item1.addEnableWhen(enable);
+ enable.setQuestion("link0");
+ enable.setHasAnswer(true);
+
+
+ QuestionnaireResponse qa = new QuestionnaireResponse();
+ qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
+ qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
+ //qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
+
+ String reference = qa.getQuestionnaire().getReference();
+ when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
+ ValidationResult errors = myVal.validateWithResult(qa);
+
+ ourLog.info(errors.toString());
+ assertThat(errors.toString(), containsString("No issues"));
+ }
+
+ @Test
+ public void testRequiredQuestionWithEnableWhenHasAnswerTrueWithAnswer() {
+
+ Questionnaire q = new Questionnaire();
+ q.addItem().setLinkId("link0").setRequired(true).setType(QuestionnaireItemType.STRING);
+
+ // create the questionnaire
+ QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
+ item1.setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
+ q.addItem(item1);
+ QuestionnaireItemEnableWhenComponent enable = new QuestionnaireItemEnableWhenComponent();
+ item1.addEnableWhen(enable);
+ enable.setQuestion("link0");
+ enable.setHasAnswer(true);
+
+
+ //q.getItemFirstRep().addEnableWhen().
+ //q.addItem().setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
+
+ QuestionnaireResponse qa = new QuestionnaireResponse();
+ qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
+ qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
+ qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
+ qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("BAR"));
+
+ String reference = qa.getQuestionnaire().getReference();
+ when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
+ ValidationResult errors = myVal.validateWithResult(qa);
+
+ ourLog.info(errors.toString());
+ assertThat(errors.toString(), containsString("No issues"));
+ }
+
+
+ @Test
+ public void testRequiredQuestionWithEnableWheHidesRequiredQuestionnHasAnswerFalse() {
+
+ Questionnaire q = new Questionnaire();
+ q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.STRING);
+
+ // create the questionnaire
+ QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
+ item1.setLinkId("link1").setRequired(true);
+ q.addItem(item1);
+ QuestionnaireItemEnableWhenComponent enable = new QuestionnaireItemEnableWhenComponent();
+ item1.addEnableWhen(enable);
+ enable.setQuestion("link0");
+ enable.setHasAnswer(false);
+
+
+ //q.getItemFirstRep().addEnableWhen().
+ //q.addItem().setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
+
+ QuestionnaireResponse qa = new QuestionnaireResponse();
+ qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
+ qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
+
+ // link1 should be disabled, because the enableWhen enables it when link0 doesn't haven an answer
+ qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
+
+ String reference = qa.getQuestionnaire().getReference();
+ when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
+ ValidationResult errors = myVal.validateWithResult(qa);
+
+ ourLog.info(errors.toString());
+ assertThat(errors.toString(), containsString("No issues"));
+ }
@Test
public void testEmbeddedItemInChoice() {