Add a test
This commit is contained in:
parent
3cd3fdcb79
commit
ba46d330f1
|
@ -14,6 +14,7 @@ import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.*;
|
import ca.uhn.fhir.rest.server.exceptions.*;
|
||||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
@ -1513,6 +1514,58 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
|
||||||
assertTrue(p.getGeneralPractitionerFirstRep().getReferenceElement().isIdPartValidLong());
|
assertTrue(p.getGeneralPractitionerFirstRep().getReferenceElement().isIdPartValidLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransactionDoesntDoubleCreate() throws IOException {
|
||||||
|
String inputString = IOUtils.toString(FhirSystemDaoR4Test.class.getResourceAsStream("/r4/musc-obs-transaction.xml"), Charsets.UTF_8);
|
||||||
|
|
||||||
|
Bundle output;
|
||||||
|
BundleEntryResponseComponent respEntry;
|
||||||
|
IdType createdId;
|
||||||
|
|
||||||
|
Bundle input = myFhirCtx.newXmlParser().parseResource(Bundle.class, inputString);
|
||||||
|
output = mySystemDao.transaction(mySrd, input);
|
||||||
|
respEntry = output.getEntry().get(0).getResponse();
|
||||||
|
assertEquals("201 Created", respEntry.getStatus());
|
||||||
|
createdId = new IdType(respEntry.getLocation());
|
||||||
|
assertEquals("Patient", createdId.getResourceType());
|
||||||
|
assertEquals("1", createdId.getVersionIdPart());
|
||||||
|
|
||||||
|
respEntry = output.getEntry().get(1).getResponse();
|
||||||
|
assertEquals("201 Created", respEntry.getStatus());
|
||||||
|
createdId = new IdType(respEntry.getLocation());
|
||||||
|
assertEquals("Encounter", createdId.getResourceType());
|
||||||
|
assertEquals("1", createdId.getVersionIdPart());
|
||||||
|
|
||||||
|
respEntry = output.getEntry().get(0).getResponse();
|
||||||
|
assertEquals("201 Created", respEntry.getStatus());
|
||||||
|
createdId = new IdType(respEntry.getLocation());
|
||||||
|
assertEquals("Observation", createdId.getResourceType());
|
||||||
|
assertEquals("1", createdId.getVersionIdPart());
|
||||||
|
|
||||||
|
// Same bundle again
|
||||||
|
|
||||||
|
input = myFhirCtx.newXmlParser().parseResource(Bundle.class, inputString);
|
||||||
|
output = mySystemDao.transaction(mySrd, input);
|
||||||
|
respEntry = output.getEntry().get(0).getResponse();
|
||||||
|
assertEquals("200 OK", respEntry.getStatus());
|
||||||
|
createdId = new IdType(respEntry.getLocation());
|
||||||
|
assertEquals("Patient", createdId.getResourceType());
|
||||||
|
assertEquals("1", createdId.getVersionIdPart());
|
||||||
|
|
||||||
|
respEntry = output.getEntry().get(1).getResponse();
|
||||||
|
assertEquals("200 OK", respEntry.getStatus());
|
||||||
|
createdId = new IdType(respEntry.getLocation());
|
||||||
|
assertEquals("Encounter", createdId.getResourceType());
|
||||||
|
assertEquals("1", createdId.getVersionIdPart());
|
||||||
|
|
||||||
|
respEntry = output.getEntry().get(0).getResponse();
|
||||||
|
assertEquals("200 OK", respEntry.getStatus());
|
||||||
|
createdId = new IdType(respEntry.getLocation());
|
||||||
|
assertEquals("Observation", createdId.getResourceType());
|
||||||
|
assertEquals("1", createdId.getVersionIdPart());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransactionDoubleConditionalCreateOnlyCreatesOne() {
|
public void testTransactionDoubleConditionalCreateOnlyCreatesOne() {
|
||||||
Bundle inputBundle = new Bundle();
|
Bundle inputBundle = new Bundle();
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<Bundle xmlns="http://hl7.org/fhir">
|
||||||
|
<type value="transaction"/>
|
||||||
|
<!--
|
||||||
|
<entry>
|
||||||
|
<fullUrl value="urn:uuid:7b8b116b-8b7f-4d18-aece-392d9ebb4a47"/>
|
||||||
|
<resource>
|
||||||
|
<Patient xmlns="http://hl7.org/fhir">
|
||||||
|
<identifier>
|
||||||
|
<use value="official"/>
|
||||||
|
<system value="urn:hssc:musc:patientid"/>
|
||||||
|
<value value="001110000"/>
|
||||||
|
</identifier>
|
||||||
|
</Patient>
|
||||||
|
</resource>
|
||||||
|
<request>
|
||||||
|
<method value="POST"/>
|
||||||
|
<url value="/Patient"/>
|
||||||
|
<ifNoneExist value="Patient?identifier=urn%3Ahssc%3Amusc%3Apatientid|001110000"/>
|
||||||
|
</request>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<fullUrl value="urn:uuid:e82b0224-ec4a-48c6-b8f0-ee34a9d0f65a"/>
|
||||||
|
<resource>
|
||||||
|
<Encounter xmlns="http://hl7.org/fhir">
|
||||||
|
<identifier>
|
||||||
|
<system value="urn:hssc:musc:encounterid"/>
|
||||||
|
<value value="1076000000"/>
|
||||||
|
</identifier>
|
||||||
|
<subject>
|
||||||
|
<reference value="urn:uuid:7b8b116b-8b7f-4d18-aece-392d9ebb4a47"/>
|
||||||
|
</subject>
|
||||||
|
</Encounter>
|
||||||
|
</resource>
|
||||||
|
<request>
|
||||||
|
<method value="POST"/>
|
||||||
|
<url value="/Encounter"/>
|
||||||
|
<ifNoneExist value="Encounter?identifier=urn%3Ahssc%3Amusc%3Aencounterid|1076000000"/>
|
||||||
|
</request>
|
||||||
|
</entry>
|
||||||
|
-->
|
||||||
|
<entry>
|
||||||
|
<resource>
|
||||||
|
<Observation xmlns="http://hl7.org/fhir">
|
||||||
|
<identifier>
|
||||||
|
<system value="urn:hssc:musc:observationid"/>
|
||||||
|
<value value="109000000.2"/>
|
||||||
|
</identifier>
|
||||||
|
<status value="corrected"/>
|
||||||
|
<code>
|
||||||
|
<coding>
|
||||||
|
<system value="urn:hssc:musc:observation:code:epic"/>
|
||||||
|
<code value="1552110"/>
|
||||||
|
<display value="PH, POC"/>
|
||||||
|
</coding>
|
||||||
|
</code>
|
||||||
|
<!--
|
||||||
|
<subject>
|
||||||
|
<reference value="urn:uuid:7b8b116b-8b7f-4d18-aece-392d9ebb4a47"/>
|
||||||
|
</subject>
|
||||||
|
<context>
|
||||||
|
<reference value="urn:uuid:e82b0224-ec4a-48c6-b8f0-ee34a9d0f65a"/>
|
||||||
|
</context>
|
||||||
|
-->
|
||||||
|
<effectiveDateTime value="2017-04-10T10:52:00-04:00"/>
|
||||||
|
<valueQuantity>
|
||||||
|
<value value="5"/>
|
||||||
|
<unit value="NULL"/>
|
||||||
|
</valueQuantity>
|
||||||
|
<referenceRange>
|
||||||
|
<low>
|
||||||
|
<unit value="NULL"/>
|
||||||
|
</low>
|
||||||
|
<high>
|
||||||
|
<unit value="NULL"/>
|
||||||
|
</high>
|
||||||
|
</referenceRange>
|
||||||
|
</Observation>
|
||||||
|
</resource>
|
||||||
|
<request>
|
||||||
|
<method value="PUT"/>
|
||||||
|
<url value="/Observation?identifier=urn%3Ahssc%3Amusc%3Aobservationid|109000000.2"/>
|
||||||
|
</request>
|
||||||
|
</entry>
|
||||||
|
</Bundle>
|
Loading…
Reference in New Issue