diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java index 5a245ccc9b6..80ea3d508e9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoBundleDstu3.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.jpa.dao.dstu3; import org.hl7.fhir.dstu3.model.Bundle; -import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent; import org.hl7.fhir.dstu3.model.Bundle.BundleType; /* @@ -37,9 +36,6 @@ public class FhirResourceDaoBundleDstu3 extends FhirResourceDaoDstu3 { throw new UnprocessableEntityException(message); } - for (BundleEntryComponent next : theResource.getEntry()) { - next.setFullUrl((String)null); - } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3BundleTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3BundleTest.java new file mode 100644 index 00000000000..a7280d1094f --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3BundleTest.java @@ -0,0 +1,46 @@ +package ca.uhn.fhir.jpa.provider.dstu3; + +import static org.junit.Assert.*; + +import org.hl7.fhir.dstu3.model.Bundle; +import org.hl7.fhir.dstu3.model.Bundle.BundleType; +import org.hl7.fhir.dstu3.model.Composition; +import org.hl7.fhir.instance.model.api.IIdType; +import org.junit.AfterClass; +import org.junit.Test; + +import ca.uhn.fhir.util.TestUtil; + +public class ResourceProviderDstu3BundleTest extends BaseResourceProviderDstu3Test { + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu3BundleTest.class); + + @AfterClass + public static void afterClassClearContext() { + TestUtil.clearAllStaticFieldsForUnitTest(); + } + + + /** + * See #401 + */ + @Test + public void testBundlePreservesFullUrl() throws Exception { + + Bundle bundle = new Bundle(); + bundle.setType(BundleType.DOCUMENT); + + Composition composition = new Composition(); + composition.setTitle("Visit Summary"); + bundle.addEntry().setFullUrl("http://foo").setResource(composition); + + IIdType id = ourClient.create().resource(bundle).execute().getId(); + + Bundle retBundle = ourClient.read().resource(Bundle.class).withId(id).execute(); + ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(retBundle)); + + assertEquals("http://foo", bundle.getEntry().get(0).getFullUrl()); + } + + +} diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 8b69b0fb29b..c8374687ae7 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -94,6 +94,12 @@ Tag#setCode(String)]]> did not actually set the code it was supposed to set. Thanks to Tim Tschampel for reporting! + + JPA server's /Bundle]]> endpoint cleared + the Bundle.entry.fullUrl]]> field on stored + bundles, resulting in invalid content being saved. Thanks to Mirjam + Baltus for reporting! +