Support required questionnaireitem groups
This commit is contained in:
parent
b2e20b5c31
commit
64f378ae78
|
@ -2639,9 +2639,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
List<Element> answers = new ArrayList<Element>();
|
List<Element> answers = new ArrayList<Element>();
|
||||||
element.getNamedChildren("answer", answers);
|
element.getNamedChildren("answer", answers);
|
||||||
if (inProgress)
|
if (inProgress)
|
||||||
warning(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), (answers.size() > 0) || !qItem.getRequired(), "No response answer found for required item "+qItem.getLinkId());
|
warning(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), isAnswerRequirementFulfilled(qItem, answers), "No response answer found for required item "+qItem.getLinkId());
|
||||||
else
|
else
|
||||||
rule(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), (answers.size() > 0) || !qItem.getRequired(), "No response answer found for required item "+qItem.getLinkId());
|
rule(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), isAnswerRequirementFulfilled(qItem, answers), "No response answer found for required item "+qItem.getLinkId());
|
||||||
if (answers.size() > 1)
|
if (answers.size() > 1)
|
||||||
rule(errors, IssueType.INVALID, answers.get(1).line(), answers.get(1).col(), stack.getLiteralPath(), qItem.getRepeats(), "Only one response answer item with this linkId allowed");
|
rule(errors, IssueType.INVALID, answers.get(1).line(), answers.get(1).col(), stack.getLiteralPath(), qItem.getRepeats(), "Only one response answer item with this linkId allowed");
|
||||||
|
|
||||||
|
@ -2729,6 +2729,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isAnswerRequirementFulfilled(QuestionnaireItemComponent qItem, List<Element> answers) {
|
||||||
|
return !answers.isEmpty() || !qItem.getRequired() || qItem.getType() == QuestionnaireItemType.GROUP;
|
||||||
|
}
|
||||||
|
|
||||||
private void validateQuestionannaireResponseItem(Questionnaire qsrc, QuestionnaireItemComponent qItem, List<ValidationMessage> errors, List<Element> elements, NodeStack stack, boolean inProgress, Element questionnaireResponseRoot) {
|
private void validateQuestionannaireResponseItem(Questionnaire qsrc, QuestionnaireItemComponent qItem, List<ValidationMessage> errors, List<Element> elements, NodeStack stack, boolean inProgress, Element questionnaireResponseRoot) {
|
||||||
if (elements.size() > 1)
|
if (elements.size() > 1)
|
||||||
rule(errors, IssueType.INVALID, elements.get(1).line(), elements.get(1).col(), stack.getLiteralPath(), qItem.getRepeats(), "Only one response item with this linkId allowed - " + qItem.getLinkId());
|
rule(errors, IssueType.INVALID, elements.get(1).line(), elements.get(1).col(), stack.getLiteralPath(), qItem.getRepeats(), "Only one response item with this linkId allowed - " + qItem.getLinkId());
|
||||||
|
|
|
@ -22,6 +22,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;
|
||||||
|
@ -40,17 +41,23 @@ import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
public class QuestionnaireResponseValidatorDstu3Test {
|
public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
private static final String QUESTIONNAIRE_URL = "http://example.com/Questionnaire/q1";
|
||||||
public static final IdType ID_ICC_QUESTIONNAIRE_SETUP = new IdType("Questionnaire/profile");
|
public static final IdType ID_ICC_QUESTIONNAIRE_SETUP = new IdType("Questionnaire/profile");
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorDstu3Test.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorDstu3Test.class);
|
||||||
private static final String CODE_ICC_SCHOOLTYPE_PT = "PT";
|
private static final String CODE_ICC_SCHOOLTYPE_PT = "PT";
|
||||||
private static final IdType ID_VS_SCHOOLTYPE = new IdType("ValueSet/schooltype");
|
private static final IdType ID_VS_SCHOOLTYPE = new IdType("ValueSet/schooltype");
|
||||||
private static final String SYSTEMURI_ICC_SCHOOLTYPE = "http://ehealthinnovation/icc/ns/schooltype";
|
private static final String SYSTEMURI_ICC_SCHOOLTYPE = "http://ehealthinnovation/icc/ns/schooltype";
|
||||||
private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport();
|
private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport();
|
||||||
private static FhirContext ourCtx = FhirContext.forDstu3();
|
private static FhirContext ourCtx;
|
||||||
private FhirInstanceValidator myInstanceVal;
|
private FhirInstanceValidator myInstanceVal;
|
||||||
private FhirValidator myVal;
|
private FhirValidator myVal;
|
||||||
private IValidationSupport myValSupport;
|
private IValidationSupport myValSupport;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeClass() {
|
||||||
|
ourCtx = FhirContext.forDstu3();
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
myValSupport = mock(IValidationSupport.class);
|
myValSupport = mock(IValidationSupport.class);
|
||||||
|
@ -122,7 +129,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
answerValues[11] = new Coding().setSystem("http://codesystems.com/system").setCode("code0");
|
answerValues[11] = new Coding().setSystem("http://codesystems.com/system").setCode("code0");
|
||||||
answerValues[12] = new StringType("some value");
|
answerValues[12] = new StringType("some value");
|
||||||
answerValues[13] = new Attachment().setData("some data".getBytes()).setContentType("txt");
|
answerValues[13] = new Attachment().setData("some data".getBytes()).setContentType("txt");
|
||||||
answerValues[14] = new Reference("http://example.com/Questionnaire/q1");
|
answerValues[14] = new Reference(QUESTIONNAIRE_URL);
|
||||||
answerValues[15] = new Quantity(42);
|
answerValues[15] = new Quantity(42);
|
||||||
|
|
||||||
for (int i = 0; i < itemCnt; i++) {
|
for (int i = 0; i < itemCnt; i++) {
|
||||||
|
@ -132,7 +139,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
reset(myValSupport);
|
reset(myValSupport);
|
||||||
Questionnaire q = new Questionnaire();
|
Questionnaire q = new Questionnaire();
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class),
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class),
|
||||||
eq("http://example.com/Questionnaire/q1"))).thenReturn(q);
|
eq(QUESTIONNAIRE_URL))).thenReturn(q);
|
||||||
when(myValSupport.fetchCodeSystem(any(FhirContext.class), eq("http://codesystems.com/system"))).thenReturn(codeSystem);
|
when(myValSupport.fetchCodeSystem(any(FhirContext.class), eq("http://codesystems.com/system"))).thenReturn(codeSystem);
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(ValueSet.class), eq("http://somevalueset"))).thenReturn(options);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(ValueSet.class), eq("http://somevalueset"))).thenReturn(options);
|
||||||
myInstanceVal.flushCaches();
|
myInstanceVal.flushCaches();
|
||||||
|
@ -149,7 +156,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.INPROGRESS);
|
qa.setStatus(QuestionnaireResponseStatus.INPROGRESS);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId(linkId).addAnswer().setValue(answerValues[i]);
|
qa.addItem().setLinkId(linkId).addAnswer().setValue(answerValues[i]);
|
||||||
|
|
||||||
ValidationResult errors = myVal.validateWithResult(qa);
|
ValidationResult errors = myVal.validateWithResult(qa);
|
||||||
|
@ -165,7 +172,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
||||||
|
@ -178,11 +185,11 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCodedAnswer() {
|
public void testCodedAnswer() {
|
||||||
String questionnaireRef = "http://example.com/Questionnaire/q1";
|
String questionnaireRef = QUESTIONNAIRE_URL;
|
||||||
|
|
||||||
Questionnaire q = new Questionnaire();
|
Questionnaire q = new Questionnaire();
|
||||||
q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.CHOICE).setOptions(new Reference("http://somevalueset"));
|
q.addItem().setLinkId("link0").setRequired(false).setType(QuestionnaireItemType.CHOICE).setOptions(new Reference("http://somevalueset"));
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq("http://example.com/Questionnaire/q1"))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(QUESTIONNAIRE_URL))).thenReturn(q);
|
||||||
|
|
||||||
CodeSystem codeSystem = new CodeSystem();
|
CodeSystem codeSystem = new CodeSystem();
|
||||||
codeSystem.setContent(CodeSystemContentMode.COMPLETE);
|
codeSystem.setContent(CodeSystemContentMode.COMPLETE);
|
||||||
|
@ -246,7 +253,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
QuestionnaireResponseItemComponent qaGroup = qa.addItem();
|
QuestionnaireResponseItemComponent qaGroup = qa.addItem();
|
||||||
qaGroup.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
qaGroup.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
|
||||||
|
@ -256,6 +263,43 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
ourLog.info(errors.toString());
|
ourLog.info(errors.toString());
|
||||||
assertThat(errors.toString(), containsString("No LinkId, so can't be validated"));
|
assertThat(errors.toString(), containsString("No LinkId, so can't be validated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMissingAnswerInNestedStructureIsReported() throws Exception {
|
||||||
|
Questionnaire q = new Questionnaire();
|
||||||
|
q.addItem().setType(QuestionnaireItemType.GROUP).setRequired(true)
|
||||||
|
.addItem().setType(QuestionnaireItemType.GROUP).setRequired(true)
|
||||||
|
.addItem().setType(QuestionnaireItemType.BOOLEAN).setLinkId("link0").setRequired(true);
|
||||||
|
|
||||||
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
|
|
||||||
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
||||||
|
|
||||||
|
ValidationResult errors = myVal.validateWithResult(qa);
|
||||||
|
|
||||||
|
assertThat(errors.toString(), Matchers.not(containsString("No issues")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGroupMarkedAsRequiredIsOk() throws Exception {
|
||||||
|
Questionnaire q = new Questionnaire();
|
||||||
|
q.addItem().setType(QuestionnaireItemType.GROUP).setRequired(true).setLinkId("link1")
|
||||||
|
.addItem().setType(QuestionnaireItemType.BOOLEAN).setLinkId("link0").setRequired(true);
|
||||||
|
|
||||||
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
|
qa.addItem().setLinkId("link1")
|
||||||
|
.addItem().setLinkId("link0").addAnswer().setValue(new BooleanType(true));
|
||||||
|
|
||||||
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
||||||
|
|
||||||
|
ValidationResult errors = myVal.validateWithResult(qa);
|
||||||
|
|
||||||
|
assertThat(errors.toString(), containsString("No issues"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testItemWithNoType() {
|
public void testItemWithNoType() {
|
||||||
|
@ -266,7 +310,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
QuestionnaireResponseItemComponent qaGroup = qa.addItem().setLinkId("link0");
|
QuestionnaireResponseItemComponent qaGroup = qa.addItem().setLinkId("link0");
|
||||||
qaGroup.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));
|
qaGroup.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
|
||||||
|
@ -287,7 +331,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));
|
qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
String reference = qa.getQuestionnaire().getReference();
|
||||||
|
@ -315,7 +359,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
String reference = qa.getQuestionnaire().getReference();
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
||||||
|
@ -343,7 +387,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
String reference = qa.getQuestionnaire().getReference();
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
||||||
|
@ -370,7 +414,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link0").addAnswer().setValue(new Quantity().setValue(1L));
|
qa.addItem().setLinkId("link0").addAnswer().setValue(new Quantity().setValue(1L));
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
String reference = qa.getQuestionnaire().getReference();
|
||||||
|
@ -398,7 +442,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link0").addAnswer().setValue(new Quantity().setValue(1L));
|
qa.addItem().setLinkId("link0").addAnswer().setValue(new Quantity().setValue(1L));
|
||||||
|
|
||||||
String reference = qa.getQuestionnaire().getReference();
|
String reference = qa.getQuestionnaire().getReference();
|
||||||
|
@ -426,7 +470,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
||||||
qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("BAR"));
|
qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("BAR"));
|
||||||
|
|
||||||
|
@ -454,7 +498,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
|
|
||||||
// link1 should be disabled, because the enableWhen enables it when link0 doesn't haven an answer
|
// 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"));
|
qa.addItem().setLinkId("link0").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
@ -475,7 +519,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qr = new QuestionnaireResponse();
|
QuestionnaireResponse qr = new QuestionnaireResponse();
|
||||||
qr.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qr.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qr.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qr.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
|
|
||||||
qr.addItem().setLinkId("link2").addAnswer().setValue(new StringType("FOO"));
|
qr.addItem().setLinkId("link2").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
|
||||||
|
@ -495,7 +539,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qr = new QuestionnaireResponse();
|
QuestionnaireResponse qr = new QuestionnaireResponse();
|
||||||
qr.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qr.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qr.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qr.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qr.addItem().setLinkId("link0").setText("Text");
|
qr.addItem().setLinkId("link0").setText("Text");
|
||||||
qr.addItem().setLinkId("link1").addAnswer().setValue(new StringType("Answer"));
|
qr.addItem().setLinkId("link1").addAnswer().setValue(new StringType("Answer"));
|
||||||
String reference = qr.getQuestionnaire().getReference();
|
String reference = qr.getQuestionnaire().getReference();
|
||||||
|
@ -510,7 +554,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmbeddedItemInChoice() {
|
public void testEmbeddedItemInChoice() {
|
||||||
String questionnaireRef = "http://example.com/Questionnaire/q1";
|
String questionnaireRef = QUESTIONNAIRE_URL;
|
||||||
String valueSetRef = "http://somevalueset";
|
String valueSetRef = "http://somevalueset";
|
||||||
String codeSystemUrl = "http://codesystems.com/system";
|
String codeSystemUrl = "http://codesystems.com/system";
|
||||||
String codeValue = "code0";
|
String codeValue = "code0";
|
||||||
|
@ -566,7 +610,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmbeddedItemInOpenChoice() {
|
public void testEmbeddedItemInOpenChoice() {
|
||||||
String questionnaireRef = "http://example.com/Questionnaire/q1";
|
String questionnaireRef = QUESTIONNAIRE_URL;
|
||||||
String valueSetRef = "http://somevalueset";
|
String valueSetRef = "http://somevalueset";
|
||||||
String codeSystemUrl = "http://codesystems.com/system";
|
String codeSystemUrl = "http://codesystems.com/system";
|
||||||
String codeValue = "code0";
|
String codeValue = "code0";
|
||||||
|
@ -622,7 +666,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmbeddedItemInString() {
|
public void testEmbeddedItemInString() {
|
||||||
String questionnaireRef = "http://example.com/Questionnaire/q1";
|
String questionnaireRef = QUESTIONNAIRE_URL;
|
||||||
|
|
||||||
// create the questionnaire
|
// create the questionnaire
|
||||||
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
QuestionnaireItemComponent item1 = new QuestionnaireItemComponent();
|
||||||
|
@ -723,7 +767,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
.setType(QuestionnaireItemType.STRING)
|
.setType(QuestionnaireItemType.STRING)
|
||||||
.setRequired(true);
|
.setRequired(true);
|
||||||
|
|
||||||
String reference = "http://example.com/Questionnaire/q1";
|
String reference = QUESTIONNAIRE_URL;
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference)))
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference)))
|
||||||
.thenReturn(q);
|
.thenReturn(q);
|
||||||
|
|
||||||
|
@ -747,7 +791,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOpenchoiceAnswer() {
|
public void testOpenchoiceAnswer() {
|
||||||
String questionnaireRef = "http://example.com/Questionnaire/q1";
|
String questionnaireRef = QUESTIONNAIRE_URL;
|
||||||
|
|
||||||
Questionnaire q = new Questionnaire();
|
Questionnaire q = new Questionnaire();
|
||||||
QuestionnaireItemComponent item = q.addItem();
|
QuestionnaireItemComponent item = q.addItem();
|
||||||
|
@ -870,7 +914,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));
|
qa.addItem().setLinkId("link1").addAnswer().setValue(new StringType("FOO"));
|
||||||
|
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
||||||
|
@ -888,7 +932,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
QuestionnaireResponse qa = new QuestionnaireResponse();
|
QuestionnaireResponse qa = new QuestionnaireResponse();
|
||||||
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
qa.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
qa.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
qa.getQuestionnaire().setReference(QUESTIONNAIRE_URL);
|
||||||
qa.addItem().setLinkId("link1").addItem().setLinkId("link2");
|
qa.addItem().setLinkId("link1").addItem().setLinkId("link2");
|
||||||
|
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(qa.getQuestionnaire().getReference()))).thenReturn(q);
|
||||||
|
|
Loading…
Reference in New Issue