diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java index e2acc3f090d..f9cb97f9fa1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseFhirResourceDao.java @@ -2006,7 +2006,7 @@ public abstract class BaseFhirResourceDao extends BaseFhirD entity = myEntityManager.find(ResourceTable.class, pid); resourceId = entity.getIdDt(); } else { - return create(theResource); + return create(theResource, null, thePerformIndexing); } } else { resourceId = theResource.getId(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java index 663986c3601..6ba4ce8d609 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2.java @@ -200,9 +200,9 @@ public class FhirSystemDaoDstu2 extends BaseFhirSystemDao { String url = extractTransactionUrlOrThrowException(nextEntry, verb); UrlParts parts = parseUrl(verb.getCode(), url); - if (res.getId().hasIdPart() && isBlank(parts.getResourceId())) { - parts.setResourceId(res.getId().getIdPart()); - } +// if (res.getId().hasIdPart() && isBlank(parts.getResourceId())) { +// parts.setResourceId(res.getId().getIdPart()); +// } if (isNotBlank(parts.getResourceId())) { res.setId(new IdDt(parts.getResourceType(), parts.getResourceId())); outcome = resourceDao.update(res, null, false); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java index d0dc21ba83e..b2f2ad9f750 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java @@ -517,12 +517,12 @@ public class FhirSystemDaoDstu2Test { p = new Patient(); p.addIdentifier().setSystem("urn:system").setValue(methodName); p.addName().addFamily("Hello"); - p.setId("urn:"+methodName); + p.setId(methodName); request.addEntry().setResource(p).getTransaction().setMethod(HTTPVerbEnum.PUT).setUrl("Patient?identifier=urn%3Asystem%7C" + methodName); Observation o = new Observation(); o.getCode().setText("Some Observation"); - o.getSubject().setReference("Patient/urn:"+methodName); + o.getSubject().setReference("Patient/"+methodName); request.addEntry().setResource(o).getTransaction().setMethod(HTTPVerbEnum.POST); Bundle resp = ourSystemDao.transaction(request); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java index dfabe1bc542..8554751f5f1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java @@ -302,7 +302,7 @@ public class ResourceProviderDstu2Test { byte[] buf = new byte[10000]; int count; StringBuilder b = new StringBuilder(); - while ((count = inputStream.read(buf)) > 0) { + while ((count = inputStream.read(buf)) != -1) { b.append(new String(buf, 0, count, Charset.forName("UTF-8"))); } String resp = b.toString(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTest.java index d8d657db000..ee449458d3e 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderTest.java @@ -1,5 +1,7 @@ package ca.uhn.fhir.jpa.provider; +import static org.junit.Assert.*; + import java.io.InputStream; import org.apache.commons.io.IOUtils; @@ -21,6 +23,8 @@ import ca.uhn.fhir.model.dstu.resource.Observation; import ca.uhn.fhir.model.dstu.resource.Organization; import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.resource.Questionnaire; +import ca.uhn.fhir.model.dstu2.resource.Bundle; +import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.client.IGenericClient; import ca.uhn.fhir.rest.server.RestfulServer; @@ -48,6 +52,34 @@ public class SystemProviderTest { String bundle = IOUtils.toString(bundleRes); String response = ourClient.transaction().withBundle(bundle).prettyPrint().execute(); ourLog.info(response); + + Bundle resp = ourCtx.newXmlParser().parseResource(Bundle.class, response); + IdDt id1_1 = new IdDt(resp.getEntry().get(1).getTransactionResponse().getLocation()); + assertEquals("Provenance", id1_1.getResourceType()); + IdDt id1_2 = new IdDt(resp.getEntry().get(2).getTransactionResponse().getLocation()); + IdDt id1_3 = new IdDt(resp.getEntry().get(3).getTransactionResponse().getLocation()); + IdDt id1_4 = new IdDt(resp.getEntry().get(4).getTransactionResponse().getLocation()); + + /* + * Same bundle! + */ + + bundleRes = SystemProviderTest.class.getResourceAsStream("/transaction_link_patient_eve_temp.xml"); + bundle = IOUtils.toString(bundleRes); + response = ourClient.transaction().withBundle(bundle).prettyPrint().execute(); + ourLog.info(response); + + resp = ourCtx.newXmlParser().parseResource(Bundle.class, response); + IdDt id2_1 = new IdDt(resp.getEntry().get(1).getTransactionResponse().getLocation()); + IdDt id2_2 = new IdDt(resp.getEntry().get(2).getTransactionResponse().getLocation()); + IdDt id2_3 = new IdDt(resp.getEntry().get(3).getTransactionResponse().getLocation()); + IdDt id2_4 = new IdDt(resp.getEntry().get(4).getTransactionResponse().getLocation()); + + assertNotEquals(id1_1.toVersionless(), id2_1.toVersionless()); + assertEquals("Provenance", id2_1.getResourceType()); + assertEquals(id1_2.toVersionless(), id2_2.toVersionless()); + assertEquals(id1_3.toVersionless(), id2_3.toVersionless()); + assertEquals(id1_4.toVersionless(), id2_4.toVersionless()); } @AfterClass diff --git a/hapi-fhir-jpaserver-base/src/test/resources/transaction_link_patient_eve_temp.xml b/hapi-fhir-jpaserver-base/src/test/resources/transaction_link_patient_eve_temp.xml index 4f6ccb24c92..499221893e5 100644 --- a/hapi-fhir-jpaserver-base/src/test/resources/transaction_link_patient_eve_temp.xml +++ b/hapi-fhir-jpaserver-base/src/test/resources/transaction_link_patient_eve_temp.xml @@ -11,7 +11,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -123,7 +123,7 @@ - +