Merge pull request #903 from dgileadi/902-fix-bounds-exception
Fix #902, IndexOutOfBoundsException for DSTU2 QuestionnaireResponses with groups
This commit is contained in:
commit
f092caf386
|
@ -245,7 +245,7 @@ public class QuestionnaireResponseValidator extends BaseValidator {
|
|||
}
|
||||
}
|
||||
for (org.hl7.fhir.instance.model.QuestionnaireResponse.GroupComponent nextAnswerGroup : answerGroups) {
|
||||
int index = theAnswerGroups.indexOf(answerGroups.get(1));
|
||||
int index = theAnswerGroups.indexOf(nextAnswerGroup);
|
||||
thePathStack.add("group(" + index + ")");
|
||||
validateGroup(theErrors, nextQuestionGroup, nextAnswerGroup, thePathStack, theAnswers, theValidateRequired);
|
||||
thePathStack.removeLast();
|
||||
|
|
|
@ -17,8 +17,11 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.hl7.fhir.instance.model.DateType;
|
||||
import org.hl7.fhir.instance.model.Observation;
|
||||
import org.hl7.fhir.instance.model.Observation.ObservationStatus;
|
||||
import org.hl7.fhir.instance.model.Questionnaire;
|
||||
import org.hl7.fhir.instance.model.Questionnaire.AnswerFormat;
|
||||
import org.hl7.fhir.instance.model.QuestionnaireResponse;
|
||||
import org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionnaireResponseStatus;
|
||||
import org.hl7.fhir.instance.model.Reference;
|
||||
import org.hl7.fhir.instance.model.StringType;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Ignore;
|
||||
|
@ -223,6 +226,32 @@ public class FhirInstanceValidatorTest {
|
|||
|
||||
assertTrue(result.isSuccessful());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuestionnaireResponseValidator() {
|
||||
final Questionnaire q = new Questionnaire();
|
||||
q.getGroup().addGroup().setLinkId("group1").addQuestion().setLinkId("foo").setType(AnswerFormat.BOOLEAN);
|
||||
q.getGroup().addQuestion().setLinkId("bar").setType(AnswerFormat.TEXT);
|
||||
|
||||
QuestionnaireResponse qr = new QuestionnaireResponse();
|
||||
qr.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||
qr.getGroup().addGroup().setLinkId("group1").addQuestion().setLinkId("foo");
|
||||
qr.getGroup().addQuestion().setLinkId("bar");
|
||||
qr.setQuestionnaire(new Reference("#q"));
|
||||
qr.getQuestionnaire().setResource(q);
|
||||
|
||||
FhirValidator val = ourCtxHl7OrgDstu2.newValidator();
|
||||
|
||||
FhirQuestionnaireResponseValidator module = new FhirQuestionnaireResponseValidator();
|
||||
val.registerValidatorModule(module);
|
||||
|
||||
ValidationResult result = val.validateWithResult(qr);
|
||||
|
||||
String encoded = ourCtxHl7OrgDstu2.newJsonParser().setPrettyPrint(true).encodeResourceToString(result.toOperationOutcome());
|
||||
ourLog.info(encoded);
|
||||
|
||||
assertTrue(result.isSuccessful());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void afterClassClearContext() {
|
||||
|
|
Loading…
Reference in New Issue