Add test for #438
This commit is contained in:
parent
173d40496d
commit
27208127e0
|
@ -100,14 +100,13 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
TestUtil.clearAllStaticFieldsForUnitTest();
|
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
super.before();
|
super.before();
|
||||||
|
|
||||||
myDaoConfig.setAllowMultipleDelete(true);
|
myDaoConfig.setAllowMultipleDelete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkParamMissing(String paramName) throws IOException, ClientProtocolException {
|
private void checkParamMissing(String paramName) throws IOException, ClientProtocolException {
|
||||||
HttpGet get = new HttpGet(ourServerBase + "/Observation?" + paramName + ":missing=false");
|
HttpGet get = new HttpGet(ourServerBase + "/Observation?" + paramName + ":missing=false");
|
||||||
CloseableHttpResponse resp = ourHttpClient.execute(get);
|
CloseableHttpResponse resp = ourHttpClient.execute(get);
|
||||||
|
@ -115,6 +114,25 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
assertEquals(200, resp.getStatusLine().getStatusCode());
|
assertEquals(200, resp.getStatusLine().getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #438
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testCreateAndUpdateBinary() {
|
||||||
|
byte[] arr = { 23, 21, 74, 123, -44 };
|
||||||
|
Binary binary = new Binary();
|
||||||
|
binary.setContent(arr);
|
||||||
|
binary.setContentType("dansk");
|
||||||
|
binary.addUndeclaredExtension(true, "bobobo", new StringDt("hey there"));
|
||||||
|
|
||||||
|
|
||||||
|
IIdType resource = ourClient.create().resource(binary).execute().getId();
|
||||||
|
Binary fromDB = ourClient.read().resource(Binary.class).withId(resource.toVersionless()).execute();
|
||||||
|
fromDB.setContentType("test");
|
||||||
|
|
||||||
|
ourClient.update().resource(fromDB).execute();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See #441
|
* See #441
|
||||||
*/
|
*/
|
||||||
|
@ -123,7 +141,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
Medication medication = new Medication();
|
Medication medication = new Medication();
|
||||||
medication.getCode().addCoding().setSystem("SYSTEM").setCode("04823543");
|
medication.getCode().addCoding().setSystem("SYSTEM").setCode("04823543");
|
||||||
IIdType medId = myMedicationDao.create(medication).getId().toUnqualifiedVersionless();
|
IIdType medId = myMedicationDao.create(medication).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
MedicationAdministration ma = new MedicationAdministration();
|
MedicationAdministration ma = new MedicationAdministration();
|
||||||
ma.setMedication(new ResourceReferenceDt(medId));
|
ma.setMedication(new ResourceReferenceDt(medId));
|
||||||
IIdType moId = myMedicationAdministrationDao.create(ma).getId().toUnqualifiedVersionless();
|
IIdType moId = myMedicationAdministrationDao.create(ma).getId().toUnqualifiedVersionless();
|
||||||
|
@ -140,8 +158,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEverythingInstanceWithContentFilter() {
|
public void testEverythingInstanceWithContentFilter() {
|
||||||
Patient pt1 = new Patient();
|
Patient pt1 = new Patient();
|
||||||
|
@ -155,7 +171,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
Device dev1 = new Device();
|
Device dev1 = new Device();
|
||||||
dev1.setManufacturer("Some Manufacturer");
|
dev1.setManufacturer("Some Manufacturer");
|
||||||
IIdType devId1 = myDeviceDao.create(dev1, mySrd).getId().toUnqualifiedVersionless();
|
IIdType devId1 = myDeviceDao.create(dev1, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Device dev2 = new Device();
|
Device dev2 = new Device();
|
||||||
dev2.setManufacturer("Some Manufacturer 2");
|
dev2.setManufacturer("Some Manufacturer 2");
|
||||||
myDeviceDao.create(dev2, mySrd).getId().toUnqualifiedVersionless();
|
myDeviceDao.create(dev2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
@ -179,12 +195,12 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
obs3.getCode().addCoding().setCode("CODE3");
|
obs3.getCode().addCoding().setCode("CODE3");
|
||||||
obs3.setValue(new StringDt("obsvalue3"));
|
obs3.setValue(new StringDt("obsvalue3"));
|
||||||
IIdType obsId3 = myObservationDao.create(obs3, mySrd).getId().toUnqualifiedVersionless();
|
IIdType obsId3 = myObservationDao.create(obs3, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
List<IIdType> actual;
|
List<IIdType> actual;
|
||||||
StringAndListParam param;
|
StringAndListParam param;
|
||||||
|
|
||||||
ourLog.info("Pt1:{} Pt2:{} Obs1:{} Obs2:{} Obs3:{}", new Object[] {ptId1.getIdPart(), ptId2.getIdPart(), obsId1.getIdPart(), obsId2.getIdPart(), obsId3.getIdPart()});
|
ourLog.info("Pt1:{} Pt2:{} Obs1:{} Obs2:{} Obs3:{}", new Object[] { ptId1.getIdPart(), ptId2.getIdPart(), obsId1.getIdPart(), obsId2.getIdPart(), obsId3.getIdPart() });
|
||||||
|
|
||||||
param = new StringAndListParam();
|
param = new StringAndListParam();
|
||||||
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
|
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
|
||||||
|
|
||||||
|
@ -196,13 +212,12 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
.withParameter(Parameters.class, Constants.PARAM_CONTENT, new StringDt("obsvalue1"))
|
.withParameter(Parameters.class, Constants.PARAM_CONTENT, new StringDt("obsvalue1"))
|
||||||
.execute();
|
.execute();
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
actual = toUnqualifiedVersionlessIds((ca.uhn.fhir.model.dstu2.resource.Bundle)response.getParameter().get(0).getResource());
|
actual = toUnqualifiedVersionlessIds((ca.uhn.fhir.model.dstu2.resource.Bundle) response.getParameter().get(0).getResource());
|
||||||
assertThat(actual, containsInAnyOrder(ptId1, obsId1, devId1));
|
assertThat(actual, containsInAnyOrder(ptId1, obsId1, devId1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBundleCreate() throws Exception {
|
public void testBundleCreate() throws Exception {
|
||||||
IGenericClient client = ourClient;
|
IGenericClient client = ourClient;
|
||||||
|
@ -231,7 +246,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private void delete(String theResourceType, String theParamName, String theParamValue) {
|
// private void delete(String theResourceType, String theParamName, String theParamValue) {
|
||||||
// Bundle resources;
|
// Bundle resources;
|
||||||
// do {
|
// do {
|
||||||
|
@ -264,7 +278,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
subs.getChannel().setType(SubscriptionChannelTypeEnum.WEBSOCKET);
|
subs.getChannel().setType(SubscriptionChannelTypeEnum.WEBSOCKET);
|
||||||
subs.setCriteria("Observation?");
|
subs.setCriteria("Observation?");
|
||||||
IIdType id = ourClient.create().resource(subs).execute().getId().toUnqualifiedVersionless();
|
IIdType id = ourClient.create().resource(subs).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient
|
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient
|
||||||
.search()
|
.search()
|
||||||
|
@ -439,10 +453,10 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
// .conditionalByUrl("Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876")
|
// .conditionalByUrl("Patient?identifier=http://general-hospital.co.uk/Identifiers|09832345234543876876")
|
||||||
// .execute().getId();
|
// .execute().getId();
|
||||||
// //@formatter:on
|
// //@formatter:on
|
||||||
|
|
||||||
assertEquals(id.getValue(), id2.getValue());
|
assertEquals(id.getValue(), id2.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateResourceConditional() throws IOException {
|
public void testCreateResourceConditional() throws IOException {
|
||||||
String methodName = "testCreateResourceConditional";
|
String methodName = "testCreateResourceConditional";
|
||||||
|
@ -512,7 +526,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
ourLog.info(responseString);
|
ourLog.info(responseString);
|
||||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||||
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
|
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
|
||||||
assertEquals("Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)", oo.getIssue().get(0).getDiagnostics());
|
assertEquals("Can not create resource with ID \"2\", ID must not be supplied on a create (POST) operation (use an HTTP PUT / update operation if you wish to supply an ID)",
|
||||||
|
oo.getIssue().get(0).getDiagnostics());
|
||||||
} finally {
|
} finally {
|
||||||
response.getEntity().getContent().close();
|
response.getEntity().getContent().close();
|
||||||
response.close();
|
response.close();
|
||||||
|
@ -572,12 +587,12 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
String methodName = "testDeleteConditionalMultiple";
|
String methodName = "testDeleteConditionalMultiple";
|
||||||
|
|
||||||
myDaoConfig.setAllowMultipleDelete(false);
|
myDaoConfig.setAllowMultipleDelete(false);
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.addIdentifier().setSystem("urn:system").setValue(methodName);
|
p.addIdentifier().setSystem("urn:system").setValue(methodName);
|
||||||
p.addName().addFamily("FAM1");
|
p.addName().addFamily("FAM1");
|
||||||
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
|
IIdType id1 = myPatientDao.create(p, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
p = new Patient();
|
p = new Patient();
|
||||||
p.addIdentifier().setSystem("urn:system").setValue(methodName);
|
p.addIdentifier().setSystem("urn:system").setValue(methodName);
|
||||||
p.addName().addFamily("FAM2");
|
p.addName().addFamily("FAM2");
|
||||||
|
@ -593,15 +608,16 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
fail();
|
fail();
|
||||||
} catch (PreconditionFailedException e) {
|
} catch (PreconditionFailedException e) {
|
||||||
assertEquals("HTTP 412 Precondition Failed: Failed to DELETE resource with match URL \"Patient?identifier=testDeleteConditionalMultiple\" because this search matched 2 resources", e.getMessage());
|
assertEquals("HTTP 412 Precondition Failed: Failed to DELETE resource with match URL \"Patient?identifier=testDeleteConditionalMultiple\" because this search matched 2 resources",
|
||||||
|
e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not deleted yet..
|
// Not deleted yet..
|
||||||
ourClient.read().resource("Patient").withId(id1).execute();
|
ourClient.read().resource("Patient").withId(id1).execute();
|
||||||
ourClient.read().resource("Patient").withId(id2).execute();
|
ourClient.read().resource("Patient").withId(id2).execute();
|
||||||
|
|
||||||
myDaoConfig.setAllowMultipleDelete(true);
|
myDaoConfig.setAllowMultipleDelete(true);
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
ourClient
|
ourClient
|
||||||
.delete()
|
.delete()
|
||||||
|
@ -677,7 +693,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on email from Rene Spronk
|
* Based on email from Rene Spronk
|
||||||
*/
|
*/
|
||||||
|
@ -833,7 +849,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
IIdType devId = ourClient.create().resource(dev).execute().getId().toUnqualifiedVersionless();
|
IIdType devId = ourClient.create().resource(dev).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Location locParent = new Location();
|
Location locParent = new Location();
|
||||||
locParent.setName(methodName+"Parent");
|
locParent.setName(methodName + "Parent");
|
||||||
IIdType locPId = ourClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless();
|
IIdType locPId = ourClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Location locChild = new Location();
|
Location locChild = new Location();
|
||||||
|
@ -845,7 +861,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
encU.getPatient().setReference(patientId);
|
encU.getPatient().setReference(patientId);
|
||||||
encU.addLocation().getLocation().setReference(locCId);
|
encU.addLocation().getLocation().setReference(locCId);
|
||||||
IIdType encUId = ourClient.create().resource(encU).execute().getId().toUnqualifiedVersionless();
|
IIdType encUId = ourClient.create().resource(encU).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Encounter enc = new Encounter();
|
Encounter enc = new Encounter();
|
||||||
enc.getPatient().setReference(patientId);
|
enc.getPatient().setReference(patientId);
|
||||||
enc.addLocation().getLocation().setReference(locCId);
|
enc.addLocation().getLocation().setReference(locCId);
|
||||||
|
@ -858,7 +874,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
IIdType obsId = ourClient.create().resource(obs).execute().getId().toUnqualifiedVersionless();
|
IIdType obsId = ourClient.create().resource(obs).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
ourLog.info("IDs: EncU:" + encUId.getIdPart() + " Enc:" + encId.getIdPart() + " " + patientId.toUnqualifiedVersionless());
|
ourLog.info("IDs: EncU:" + encUId.getIdPart() + " Enc:" + encId.getIdPart() + " " + patientId.toUnqualifiedVersionless());
|
||||||
|
|
||||||
Parameters output = ourClient.operation().onInstance(encId).named("everything").withNoParameters(Parameters.class).execute();
|
Parameters output = ourClient.operation().onInstance(encId).named("everything").withNoParameters(Parameters.class).execute();
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle b = (ca.uhn.fhir.model.dstu2.resource.Bundle) output.getParameterFirstRep().getResource();
|
ca.uhn.fhir.model.dstu2.resource.Bundle b = (ca.uhn.fhir.model.dstu2.resource.Bundle) output.getParameterFirstRep().getResource();
|
||||||
List<IIdType> ids = toUnqualifiedVersionlessIds(b);
|
List<IIdType> ids = toUnqualifiedVersionlessIds(b);
|
||||||
|
@ -897,7 +913,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
IIdType devId = ourClient.create().resource(dev).execute().getId().toUnqualifiedVersionless();
|
IIdType devId = ourClient.create().resource(dev).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Location locParent = new Location();
|
Location locParent = new Location();
|
||||||
locParent.setName(methodName+"Parent");
|
locParent.setName(methodName + "Parent");
|
||||||
IIdType locPId = ourClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless();
|
IIdType locPId = ourClient.create().resource(locParent).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Location locChild = new Location();
|
Location locChild = new Location();
|
||||||
|
@ -908,7 +924,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
Encounter encU = new Encounter();
|
Encounter encU = new Encounter();
|
||||||
encU.addIdentifier().setValue(methodName);
|
encU.addIdentifier().setValue(methodName);
|
||||||
IIdType encUId = ourClient.create().resource(encU).execute().getId().toUnqualifiedVersionless();
|
IIdType encUId = ourClient.create().resource(encU).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Encounter enc = new Encounter();
|
Encounter enc = new Encounter();
|
||||||
enc.getPatient().setReference(patientId);
|
enc.getPatient().setReference(patientId);
|
||||||
enc.addLocation().getLocation().setReference(locCId);
|
enc.addLocation().getLocation().setReference(locCId);
|
||||||
|
@ -986,18 +1002,18 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
assertThat(ids.size(), greaterThan(10));
|
assertThat(ids.size(), greaterThan(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for #226
|
* Test for #226
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEverythingPatientIncludesBackReferences() throws Exception {
|
public void testEverythingPatientIncludesBackReferences() throws Exception {
|
||||||
String methodName = "testEverythingIncludesBackReferences";
|
String methodName = "testEverythingIncludesBackReferences";
|
||||||
|
|
||||||
Medication med = new Medication();
|
Medication med = new Medication();
|
||||||
med.getCode().setText(methodName);
|
med.getCode().setText(methodName);
|
||||||
IIdType medId = myMedicationDao.create(med, mySrd).getId().toUnqualifiedVersionless();
|
IIdType medId = myMedicationDao.create(med, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Patient pat = new Patient();
|
Patient pat = new Patient();
|
||||||
pat.addAddress().addLine(methodName);
|
pat.addAddress().addLine(methodName);
|
||||||
IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless();
|
IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
@ -1006,7 +1022,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
mo.getPatient().setReference(patId);
|
mo.getPatient().setReference(patId);
|
||||||
mo.setMedication(new ResourceReferenceDt(medId));
|
mo.setMedication(new ResourceReferenceDt(medId));
|
||||||
IIdType moId = myMedicationOrderDao.create(mo, mySrd).getId().toUnqualifiedVersionless();
|
IIdType moId = myMedicationOrderDao.create(mo, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Parameters output = ourClient.operation().onInstance(patId).named("everything").withNoParameters(Parameters.class).execute();
|
Parameters output = ourClient.operation().onInstance(patId).named("everything").withNoParameters(Parameters.class).execute();
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle b = (ca.uhn.fhir.model.dstu2.resource.Bundle) output.getParameterFirstRep().getResource();
|
ca.uhn.fhir.model.dstu2.resource.Bundle b = (ca.uhn.fhir.model.dstu2.resource.Bundle) output.getParameterFirstRep().getResource();
|
||||||
List<IIdType> ids = toUnqualifiedVersionlessIds(b);
|
List<IIdType> ids = toUnqualifiedVersionlessIds(b);
|
||||||
|
@ -1049,8 +1065,6 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEverythingPatientOperation() throws Exception {
|
public void testEverythingPatientOperation() throws Exception {
|
||||||
String methodName = "testEverythingOperation";
|
String methodName = "testEverythingOperation";
|
||||||
|
@ -1095,27 +1109,27 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
|
|
||||||
ourLog.info(ids.toString());
|
ourLog.info(ids.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEverythingPatientType() throws Exception {
|
public void testEverythingPatientType() throws Exception {
|
||||||
String methodName = "testEverythingPatientType";
|
String methodName = "testEverythingPatientType";
|
||||||
|
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
o1.setName(methodName+"1");
|
o1.setName(methodName + "1");
|
||||||
IIdType o1Id = ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
IIdType o1Id = ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||||
Organization o2 = new Organization();
|
Organization o2 = new Organization();
|
||||||
o2.setName(methodName+"2");
|
o2.setName(methodName + "2");
|
||||||
IIdType o2Id = ourClient.create().resource(o2).execute().getId().toUnqualifiedVersionless();
|
IIdType o2Id = ourClient.create().resource(o2).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Patient p1 = new Patient();
|
Patient p1 = new Patient();
|
||||||
p1.addName().addFamily(methodName+"1");
|
p1.addName().addFamily(methodName + "1");
|
||||||
p1.getManagingOrganization().setReference(o1Id);
|
p1.getManagingOrganization().setReference(o1Id);
|
||||||
IIdType p1Id = ourClient.create().resource(p1).execute().getId().toUnqualifiedVersionless();
|
IIdType p1Id = ourClient.create().resource(p1).execute().getId().toUnqualifiedVersionless();
|
||||||
Patient p2 = new Patient();
|
Patient p2 = new Patient();
|
||||||
p2.addName().addFamily(methodName+"2");
|
p2.addName().addFamily(methodName + "2");
|
||||||
p2.getManagingOrganization().setReference(o2Id);
|
p2.getManagingOrganization().setReference(o2Id);
|
||||||
IIdType p2Id = ourClient.create().resource(p2).execute().getId().toUnqualifiedVersionless();
|
IIdType p2Id = ourClient.create().resource(p2).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Condition c1 = new Condition();
|
Condition c1 = new Condition();
|
||||||
c1.getPatient().setReference(p1Id);
|
c1.getPatient().setReference(p1Id);
|
||||||
IIdType c1Id = ourClient.create().resource(c1).execute().getId().toUnqualifiedVersionless();
|
IIdType c1Id = ourClient.create().resource(c1).execute().getId().toUnqualifiedVersionless();
|
||||||
|
@ -1124,7 +1138,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
IIdType c2Id = ourClient.create().resource(c2).execute().getId().toUnqualifiedVersionless();
|
IIdType c2Id = ourClient.create().resource(c2).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Condition c3 = new Condition();
|
Condition c3 = new Condition();
|
||||||
c3.addIdentifier().setValue(methodName+"3");
|
c3.addIdentifier().setValue(methodName + "3");
|
||||||
IIdType c3Id = ourClient.create().resource(c3).execute().getId().toUnqualifiedVersionless();
|
IIdType c3Id = ourClient.create().resource(c3).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Parameters output = ourClient.operation().onType(Patient.class).named("everything").withNoParameters(Parameters.class).execute();
|
Parameters output = ourClient.operation().onType(Patient.class).named("everything").withNoParameters(Parameters.class).execute();
|
||||||
|
@ -1143,18 +1157,18 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
Organization org = new Organization();
|
Organization org = new Organization();
|
||||||
org.setName(methodName);
|
org.setName(methodName);
|
||||||
IIdType oId = ourClient.create().resource(org).execute().getId().toUnqualifiedVersionless();
|
IIdType oId = ourClient.create().resource(org).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
long time1 = System.currentTimeMillis();
|
long time1 = System.currentTimeMillis();
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.addName().addFamily(methodName);
|
p.addName().addFamily(methodName);
|
||||||
p.getManagingOrganization().setReference(oId);
|
p.getManagingOrganization().setReference(oId);
|
||||||
IIdType pId = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
|
IIdType pId = ourClient.create().resource(p).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
long time2 = System.currentTimeMillis();
|
long time2 = System.currentTimeMillis();
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
|
|
||||||
Condition c = new Condition();
|
Condition c = new Condition();
|
||||||
c.getCode().setText(methodName);
|
c.getCode().setText(methodName);
|
||||||
c.getPatient().setReference(pId);
|
c.getPatient().setReference(pId);
|
||||||
|
@ -1162,8 +1176,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
|
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
long time3 = System.currentTimeMillis();
|
long time3 = System.currentTimeMillis();
|
||||||
|
|
||||||
// %3E=> %3C=<
|
// %3E=> %3C=<
|
||||||
|
|
||||||
HttpGet get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantDt(new Date(time1)).getValueAsString());
|
HttpGet get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantDt(new Date(time1)).getValueAsString());
|
||||||
CloseableHttpResponse response = ourHttpClient.execute(get);
|
CloseableHttpResponse response = ourHttpClient.execute(get);
|
||||||
|
@ -1179,7 +1193,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantDt(new Date(time2)).getValueAsString() + "&_lastUpdated=%3C" + new InstantDt(new Date(time3)).getValueAsString());
|
get = new HttpGet(ourServerBase + "/Patient/" + pId.getIdPart() + "/$everything?_lastUpdated=%3E" + new InstantDt(new Date(time2)).getValueAsString() + "&_lastUpdated=%3C"
|
||||||
|
+ new InstantDt(new Date(time3)).getValueAsString());
|
||||||
response = ourHttpClient.execute(get);
|
response = ourHttpClient.execute(get);
|
||||||
try {
|
try {
|
||||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||||
|
@ -1220,7 +1235,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
} finally {
|
} finally {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1255,7 +1270,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
patient.setId(id);
|
patient.setId(id);
|
||||||
ourClient.update().resource(patient).execute();
|
ourClient.update().resource(patient).execute();
|
||||||
|
|
||||||
ca.uhn.fhir.model.dstu2.resource.Bundle history = ourClient.history().onInstance(id).andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).prettyPrint().summaryMode(SummaryEnum.DATA).execute();
|
ca.uhn.fhir.model.dstu2.resource.Bundle history = ourClient.history().onInstance(id).andReturnBundle(ca.uhn.fhir.model.dstu2.resource.Bundle.class).prettyPrint().summaryMode(SummaryEnum.DATA)
|
||||||
|
.execute();
|
||||||
assertEquals(3, history.getEntry().size());
|
assertEquals(3, history.getEntry().size());
|
||||||
assertEquals(id.withVersion("3"), history.getEntry().get(0).getResource().getId());
|
assertEquals(id.withVersion("3"), history.getEntry().get(0).getResource().getId());
|
||||||
assertEquals(1, ((Patient) history.getEntry().get(0).getResource()).getName().size());
|
assertEquals(1, ((Patient) history.getEntry().get(0).getResource()).getName().size());
|
||||||
|
@ -1502,7 +1518,8 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
p1.addIdentifier().setValue("testSearchByIdentifierWithoutSystem01");
|
p1.addIdentifier().setValue("testSearchByIdentifierWithoutSystem01");
|
||||||
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
||||||
|
|
||||||
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint().execute();
|
Bundle actual = ourClient.search().forResource(Patient.class).where(Patient.IDENTIFIER.exactly().systemAndCode(null, "testSearchByIdentifierWithoutSystem01")).encodedJson().prettyPrint()
|
||||||
|
.execute();
|
||||||
assertEquals(1, actual.size());
|
assertEquals(1, actual.size());
|
||||||
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
||||||
|
|
||||||
|
@ -1540,7 +1557,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
|
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
o1.setName("testSearchByResourceChainName01");
|
o1.setName("testSearchByResourceChainName01");
|
||||||
IdDt o1id = (IdDt) ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
IdDt o1id = (IdDt) ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Patient p1 = new Patient();
|
Patient p1 = new Patient();
|
||||||
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByResourceChain01");
|
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByResourceChain01");
|
||||||
|
@ -1567,28 +1584,28 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
assertEquals(p1Id.getIdPart(), actual.getEntries().get(0).getResource().getId().getIdPart());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchByReferenceIds() {
|
public void testSearchByReferenceIds() {
|
||||||
Organization o1 = new Organization();
|
Organization o1 = new Organization();
|
||||||
o1.setName("testSearchByResourceChainName01");
|
o1.setName("testSearchByResourceChainName01");
|
||||||
IdDt o1id = (IdDt) ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
IdDt o1id = (IdDt) ourClient.create().resource(o1).execute().getId().toUnqualifiedVersionless();
|
||||||
Organization o2 = new Organization();
|
Organization o2 = new Organization();
|
||||||
o2.setName("testSearchByResourceChainName02");
|
o2.setName("testSearchByResourceChainName02");
|
||||||
IdDt o2id = (IdDt) ourClient.create().resource(o2).execute().getId().toUnqualifiedVersionless();
|
IdDt o2id = (IdDt) ourClient.create().resource(o2).execute().getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Patient p1 = new Patient();
|
Patient p1 = new Patient();
|
||||||
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByReferenceIds01");
|
p1.addIdentifier().setSystem("urn:system").setValue("testSearchByReferenceIds01");
|
||||||
p1.addName().addFamily("testSearchByReferenceIdsFamily01").addGiven("testSearchByReferenceIdsGiven01");
|
p1.addName().addFamily("testSearchByReferenceIdsFamily01").addGiven("testSearchByReferenceIdsGiven01");
|
||||||
p1.setManagingOrganization(new ResourceReferenceDt(o1id.toUnqualifiedVersionless()));
|
p1.setManagingOrganization(new ResourceReferenceDt(o1id.toUnqualifiedVersionless()));
|
||||||
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
IdDt p1Id = (IdDt) ourClient.create().resource(p1).execute().getId();
|
||||||
|
|
||||||
Patient p2 = new Patient();
|
Patient p2 = new Patient();
|
||||||
p2.addIdentifier().setSystem("urn:system").setValue("testSearchByReferenceIds02");
|
p2.addIdentifier().setSystem("urn:system").setValue("testSearchByReferenceIds02");
|
||||||
p2.addName().addFamily("testSearchByReferenceIdsFamily02").addGiven("testSearchByReferenceIdsGiven02");
|
p2.addName().addFamily("testSearchByReferenceIdsFamily02").addGiven("testSearchByReferenceIdsGiven02");
|
||||||
p2.setManagingOrganization(new ResourceReferenceDt(o2id.toUnqualifiedVersionless()));
|
p2.setManagingOrganization(new ResourceReferenceDt(o2id.toUnqualifiedVersionless()));
|
||||||
IdDt p2Id = (IdDt) ourClient.create().resource(p2).execute().getId();
|
IdDt p2Id = (IdDt) ourClient.create().resource(p2).execute().getId();
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
Bundle actual = ourClient.search()
|
Bundle actual = ourClient.search()
|
||||||
.forResource(Patient.class)
|
.forResource(Patient.class)
|
||||||
|
@ -1640,7 +1657,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
patient.addName().addFamily(methodName).addGiven("John");
|
patient.addName().addFamily(methodName).addGiven("John");
|
||||||
id2 = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
id2 = (IdDt) ourClient.create().resource(patient).execute().getId().toUnqualifiedVersionless();
|
||||||
}
|
}
|
||||||
|
|
||||||
ourLog.info("Before: {}", beforeAny.getValue());
|
ourLog.info("Before: {}", beforeAny.getValue());
|
||||||
{
|
{
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
|
@ -1664,7 +1681,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
List<IdDt> patients = toIdListUnqualifiedVersionless(found);
|
||||||
assertThat(patients, hasItems(id1a, id1b, id2));
|
assertThat(patients, hasItems(id1a, id1b, id2));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
Bundle found = ourClient.search()
|
Bundle found = ourClient.search()
|
||||||
|
@ -1719,7 +1736,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
@Test
|
@Test
|
||||||
public void testSearchReturnsSearchDate() throws Exception {
|
public void testSearchReturnsSearchDate() throws Exception {
|
||||||
ourLog.info("Starting testSearchReturnsSearchDate");
|
ourLog.info("Starting testSearchReturnsSearchDate");
|
||||||
|
|
||||||
Date before = new Date();
|
Date before = new Date();
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
|
@ -2422,5 +2439,4 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue