More auto qualify resource references
This commit is contained in:
parent
83a57f8e7c
commit
11c5ab7892
|
@ -282,6 +282,9 @@ public abstract class BaseParser implements IParser {
|
||||||
}
|
}
|
||||||
return reference;
|
return reference;
|
||||||
} else {
|
} else {
|
||||||
|
if (!ref.hasResourceType()) {
|
||||||
|
ref = ref.withResourceType(myContext.getResourceDefinition(theRef.getResource()).getName());
|
||||||
|
}
|
||||||
if (isNotBlank(myServerBaseUrl) && StringUtils.equals(myServerBaseUrl, ref.getBaseUrl())) {
|
if (isNotBlank(myServerBaseUrl) && StringUtils.equals(myServerBaseUrl, ref.getBaseUrl())) {
|
||||||
if (isStripVersionsFromReferences()) {
|
if (isStripVersionsFromReferences()) {
|
||||||
return ref.toUnqualifiedVersionless().getValue();
|
return ref.toUnqualifiedVersionless().getValue();
|
||||||
|
|
|
@ -44,6 +44,7 @@ import ca.uhn.fhir.model.dstu2.composite.ElementDefinitionDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.ElementDefinitionDt.Binding;
|
import ca.uhn.fhir.model.dstu2.composite.ElementDefinitionDt.Binding;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
|
||||||
|
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
|
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.AllergyIntolerance;
|
import ca.uhn.fhir.model.dstu2.resource.AllergyIntolerance;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Binary;
|
import ca.uhn.fhir.model.dstu2.resource.Binary;
|
||||||
|
@ -61,9 +62,13 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.AddressUseEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.AddressUseEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.AdministrativeGenderEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
|
||||||
|
import ca.uhn.fhir.model.dstu2.valueset.ContactPointSystemEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.DocumentReferenceStatusEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.DocumentReferenceStatusEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
||||||
|
import ca.uhn.fhir.model.dstu2.valueset.NameUseEnum;
|
||||||
|
import ca.uhn.fhir.model.dstu2.valueset.ObservationRelationshipTypeEnum;
|
||||||
|
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
||||||
import ca.uhn.fhir.model.primitive.DateDt;
|
import ca.uhn.fhir.model.primitive.DateDt;
|
||||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||||
import ca.uhn.fhir.model.primitive.IdDt;
|
import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
|
@ -80,19 +85,44 @@ public class XmlParserDstu2Test {
|
||||||
@Test
|
@Test
|
||||||
public void testEncodeReferenceUsingUnqualifiedResourceWorksCorrectly() {
|
public void testEncodeReferenceUsingUnqualifiedResourceWorksCorrectly() {
|
||||||
|
|
||||||
Organization org = new Organization();
|
Patient patient = new Patient();
|
||||||
org.setId("orgId");
|
patient.setId("phitcc_pat_normal");
|
||||||
|
patient.addName().addGiven("Patty").setUse(NameUseEnum.NICKNAME);
|
||||||
|
patient.addTelecom().setSystem(ContactPointSystemEnum.EMAIL).setValue("patpain@ehealthinnovation.org");
|
||||||
|
patient.setGender(AdministrativeGenderEnum.FEMALE);
|
||||||
|
patient.setBirthDate(new DateDt("2001-10-13"));
|
||||||
|
|
||||||
Patient pat = new Patient();
|
DateTimeDt obsEffectiveTime = new DateTimeDt("2015-04-11T12:22:01-04:00");
|
||||||
pat.getManagingOrganization().setResource(org);
|
|
||||||
|
|
||||||
String str = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(pat);
|
Observation obsParent = new Observation();
|
||||||
|
obsParent.setId("phitcc_obs_bp_parent");
|
||||||
|
obsParent.getSubject().setResource(patient);
|
||||||
|
obsParent.setStatus(ObservationStatusEnum.FINAL);
|
||||||
|
obsParent.setEffective(obsEffectiveTime);
|
||||||
|
|
||||||
|
Observation obsSystolic = new Observation();
|
||||||
|
obsSystolic.setId("phitcc_obs_bp_dia");
|
||||||
|
obsSystolic.getSubject().setResource(patient);
|
||||||
|
obsSystolic.setEffective(obsEffectiveTime);
|
||||||
|
obsParent.addRelated().setType(ObservationRelationshipTypeEnum.HAS_MEMBER).setTarget(new ResourceReferenceDt(obsSystolic));
|
||||||
|
|
||||||
|
Observation obsDiastolic = new Observation();
|
||||||
|
obsDiastolic.setId("phitcc_obs_bp_dia");
|
||||||
|
obsDiastolic.getSubject().setResource(patient);
|
||||||
|
obsDiastolic.setEffective(obsEffectiveTime);
|
||||||
|
obsParent.addRelated().setType(ObservationRelationshipTypeEnum.HAS_MEMBER).setTarget(new ResourceReferenceDt(obsDiastolic));
|
||||||
|
|
||||||
|
String str = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(obsParent);
|
||||||
ourLog.info(str);
|
ourLog.info(str);
|
||||||
|
|
||||||
assertThat(str, containsString("<reference value=\"Organization/orgId\"/>"));
|
assertThat(str, containsString("<reference value=\"Patient/phitcc_pat_normal\"/>"));
|
||||||
|
assertThat(str, containsString("<reference value=\"Observation/phitcc_obs_bp_dia\"/>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBundleWithBinary() {
|
public void testBundleWithBinary() {
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
|
|
Loading…
Reference in New Issue