Cherry picked changes from master to 3.5.0 branch
This commit is contained in:
parent
31bd2186ce
commit
4dbef9a799
|
@ -11,6 +11,7 @@
|
|||
|
||||
<artifactId>hapi-fhir-converter</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<version>3.5.1-PHRFIX-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -84,7 +85,7 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
<artifactId>hapi-fhir-validation</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<version>3.5.1-PHRFIX-SNAPSHOT</version>
|
||||
|
||||
<name>HAPI FHIR - Validation</name>
|
||||
|
||||
|
@ -18,17 +19,17 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-utilities</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-converter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.1-PHRFIX-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -63,49 +64,49 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-structures-r4</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
@ -118,13 +119,13 @@
|
|||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-client</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>3.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -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;
|
||||
|
@ -304,6 +305,135 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
|||
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() {
|
||||
String questionnaireRef = "http://example.com/Questionnaire/q1";
|
||||
|
|
Loading…
Reference in New Issue