Support parsing valueReference

This commit is contained in:
David Gileadi 2018-06-04 19:07:15 -07:00 committed by James Agnew
parent f5f9dff391
commit 23a09ef7d7
2 changed files with 14 additions and 1 deletions

View File

@ -831,7 +831,7 @@ public class QuestionnaireResponse extends DomainResource {
/**
* The answer (or one of the answers) provided by the respondent to the question.
*/
@Child(name = "value", type = {BooleanType.class, DecimalType.class, IntegerType.class, DateType.class, DateTimeType.class, InstantType.class, TimeType.class, StringType.class, UriType.class, Attachment.class, Coding.class, Quantity.class}, order=1, min=0, max=1, modifier=false, summary=false)
@Child(name = "value", type = {BooleanType.class, DecimalType.class, IntegerType.class, DateType.class, DateTimeType.class, InstantType.class, TimeType.class, StringType.class, UriType.class, Attachment.class, Coding.class, Quantity.class, Reference.class}, order=1, min=0, max=1, modifier=false, summary=false)
@Description(shortDefinition="Single-valued answer to the question", formalDefinition="The answer (or one of the answers) provided by the respondent to the question." )
protected Type value;

View File

@ -11,6 +11,7 @@ import org.apache.commons.io.IOUtils;
import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains;
import org.hamcrest.text.StringContainsInOrder;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.*;
import org.hl7.fhir.instance.model.Address.AddressUse;
import org.hl7.fhir.instance.model.Address.AddressUseEnumFactory;
@ -19,6 +20,7 @@ import org.hl7.fhir.instance.model.Conformance.UnknownContentCode;
import org.hl7.fhir.instance.model.Identifier.IdentifierUse;
import org.hl7.fhir.instance.model.Narrative.NarrativeStatus;
import org.hl7.fhir.instance.model.Patient.ContactComponent;
import org.hl7.fhir.instance.model.QuestionnaireResponse.QuestionAnswerComponent;
import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent;
import org.hl7.fhir.instance.model.ValueSet.ValueSetCodeSystemComponent;
import org.hl7.fhir.instance.model.api.IIdType;
@ -1257,6 +1259,17 @@ public class JsonParserHl7OrgDstu2Test {
Assert.assertEquals(refVal, ((Reference) extlst.get(0).getValue()).getReference());
}
@Test
public void testParseQuestionnaireResponseAnswerWithValueReference() throws FHIRException {
String response = "{\"resourceType\":\"QuestionnaireResponse\",\"group\":{\"question\":[{\"answer\": [{\"valueReference\": {\"reference\": \"Observation/testid\"}}]}]}}";
QuestionnaireResponse r = ourCtx.newJsonParser().parseResource(QuestionnaireResponse.class, response);
QuestionAnswerComponent answer = r.getGroup().getQuestion().get(0).getAnswer().get(0);
assertNotNull(answer);
assertNotNull(answer.getValueReference());
assertEquals("Observation/testid", answer.getValueReference().getReference());
}
@ResourceDef(name = "Patient")
public static class MyPatientWithOneDeclaredAddressExtension extends Patient {