Add a failing test
This commit is contained in:
parent
35afa8bbfa
commit
8f200c1819
|
@ -89,6 +89,7 @@ import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
|
import org.hl7.fhir.r4.model.Task;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -864,6 +865,7 @@ public abstract class BaseTransactionProcessor {
|
||||||
matchUrl = parts.getResourceType();
|
matchUrl = parts.getResourceType();
|
||||||
}
|
}
|
||||||
matchUrl = performIdSubstitutionsInMatchUrl(theIdSubstitutions, matchUrl);
|
matchUrl = performIdSubstitutionsInMatchUrl(theIdSubstitutions, matchUrl);
|
||||||
|
//TODO FIXME GGG This update call comes back with a contained resource.
|
||||||
outcome = resourceDao.update(res, matchUrl, false, false, theRequest, theTransactionDetails);
|
outcome = resourceDao.update(res, matchUrl, false, false, theRequest, theTransactionDetails);
|
||||||
if (Boolean.TRUE.equals(outcome.getCreated())) {
|
if (Boolean.TRUE.equals(outcome.getCreated())) {
|
||||||
conditionalRequestUrls.put(matchUrl, res.getClass());
|
conditionalRequestUrls.put(matchUrl, res.getClass());
|
||||||
|
@ -1095,7 +1097,6 @@ public abstract class BaseTransactionProcessor {
|
||||||
}
|
}
|
||||||
deferredIndexesForAutoVersioning.put(nextOutcome, referencesToAutoVersion);
|
deferredIndexesForAutoVersioning.put(nextOutcome, referencesToAutoVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have any resources we'll be auto-versioning, index these next
|
// If we have any resources we'll be auto-versioning, index these next
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.jpa.dao.r4;
|
package ca.uhn.fhir.jpa.dao.r4;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||||
|
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
|
||||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||||
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
|
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
|
||||||
import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum;
|
import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum;
|
||||||
|
@ -63,6 +64,7 @@ import org.hl7.fhir.r4.model.Practitioner;
|
||||||
import org.hl7.fhir.r4.model.Quantity;
|
import org.hl7.fhir.r4.model.Quantity;
|
||||||
import org.hl7.fhir.r4.model.Reference;
|
import org.hl7.fhir.r4.model.Reference;
|
||||||
import org.hl7.fhir.r4.model.Resource;
|
import org.hl7.fhir.r4.model.Resource;
|
||||||
|
import org.hl7.fhir.r4.model.Task;
|
||||||
import org.hl7.fhir.r4.model.ValueSet;
|
import org.hl7.fhir.r4.model.ValueSet;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -1002,23 +1004,41 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTransactionNoContainedRedux() throws IOException {
|
||||||
|
//Pre-create the patient, which will cause the ifNoneExist to prevent a new creation during bundle transaction
|
||||||
|
Patient patient = loadResourceFromClasspath(Patient.class, "/r4/preexisting-patient.json");
|
||||||
|
myPatientDao.create(patient);
|
||||||
|
|
||||||
|
//Post the Bundle containing a conditional POST with an identical patient from the above resource.
|
||||||
|
Bundle request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained-2.json");
|
||||||
|
Bundle outcome = mySystemDao.transaction(mySrd, request);
|
||||||
|
IdType taskId = new IdType(outcome.getEntry().get(0).getResponse().getLocation());
|
||||||
|
Task task = myTaskDao.read(taskId, mySrd);
|
||||||
|
|
||||||
|
assertThat(task.getBasedOn().get(0).getReference(), matchesPattern("Patient/[0-9]+"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransactionNoContained() throws IOException {
|
public void testTransactionNoContained() throws IOException {
|
||||||
|
|
||||||
// Run once (should create the patient)
|
// Run once (should create the patient)
|
||||||
Bundle request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained.json");
|
Bundle request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained.json");
|
||||||
mySystemDao.transaction(mySrd, request);
|
|
||||||
|
|
||||||
// Run a second time (no conditional update)
|
|
||||||
request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained.json");
|
|
||||||
Bundle outcome = mySystemDao.transaction(mySrd, request);
|
Bundle outcome = mySystemDao.transaction(mySrd, request);
|
||||||
|
|
||||||
ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome));
|
|
||||||
|
|
||||||
IdType communicationId = new IdType(outcome.getEntry().get(1).getResponse().getLocation());
|
IdType communicationId = new IdType(outcome.getEntry().get(1).getResponse().getLocation());
|
||||||
Communication communication = myCommunicationDao.read(communicationId, mySrd);
|
Communication communication = myCommunicationDao.read(communicationId, mySrd);
|
||||||
assertThat(communication.getSubject().getReference(), matchesPattern("Patient/[0-9]+"));
|
assertThat(communication.getSubject().getReference(), matchesPattern("Patient/[0-9]+"));
|
||||||
|
|
||||||
|
// Run a second time (no conditional update)
|
||||||
|
request = loadResourceFromClasspath(Bundle.class, "/r4/transaction-no-contained.json");
|
||||||
|
outcome = mySystemDao.transaction(mySrd, request);
|
||||||
|
|
||||||
|
ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outcome));
|
||||||
|
|
||||||
|
// IdType communicationId = new IdType(outcome.getEntry().get(1).getResponse().getLocation());
|
||||||
|
// Communication communication = myCommunicationDao.read(communicationId, mySrd);
|
||||||
|
// assertThat(communication.getSubject().getReference(), matchesPattern("Patient/[0-9]+"));
|
||||||
|
|
||||||
ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(communication));
|
ourLog.info("Outcome: {}", myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(communication));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
"resourceType": "Bundle",
|
||||||
|
"type": "transaction",
|
||||||
|
"entry": [
|
||||||
|
{
|
||||||
|
"fullUrl": "urn:uuid:1f3b9e25-fd45-4342-a82b-7ca5755923bb",
|
||||||
|
"resource": {
|
||||||
|
"resourceType": "Task",
|
||||||
|
"language": "en-US",
|
||||||
|
"identifier": [
|
||||||
|
{
|
||||||
|
"system": "https://example.org/fhir/taskidentifier",
|
||||||
|
"value": "101019"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"basedOn": [
|
||||||
|
{
|
||||||
|
"reference": "urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"request": {
|
||||||
|
"method": "PUT",
|
||||||
|
"url": "/Task?identifier\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Ftaskidentifier|101019"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fullUrl": "urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced",
|
||||||
|
"resource": {
|
||||||
|
"resourceType": "Patient",
|
||||||
|
"identifier": [
|
||||||
|
{
|
||||||
|
"system": "https://example.org/fhir/memberidentifier",
|
||||||
|
"value": "12345670"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"system": "https://example.org/fhir/memberuniqueidentifier",
|
||||||
|
"value": "12345670TT"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"url": "/Patient",
|
||||||
|
"ifNoneExist": "Patient?identifier\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Fmemberuniqueidentifier|12345670TT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -250,8 +250,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"request": {
|
"request": {
|
||||||
"method": "POST",
|
"method": "PUT",
|
||||||
"url": "Communication"
|
"url": "Communication?identifier=https://example.com|zoop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue