From 0acfc51082b4d1c9e1f814785a9e5e7efe6a72ec Mon Sep 17 00:00:00 2001 From: Tadgh Date: Thu, 5 Mar 2020 16:38:42 -0800 Subject: [PATCH] Split test into two tests, one of which passes, one of which fails, showing the missing functionality --- .../FhirResourceDaoDstu3SearchNoFtTest.java | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java index 7a1224f98fd..34a54742bd1 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java @@ -366,11 +366,34 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { SearchParameterMap params; - // Not currently working -// params = new SearchParameterMap(); -// params.setLoadSynchronous(true); -// params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID")); -// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue())); + params = new SearchParameterMap(); + params.setLoadSynchronous(true); + params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID")); + //This is the tested query: + // Patient?_has:Observation:subject:device.identifier=urn:system|DEVICEID + assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue())); + } + + @Test + public void testHasParameterReverseChained() { + IIdType pid0; + { + Device device = new Device(); + device.addIdentifier().setSystem("urn:system").setValue("DEVICEID"); + IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless(); + + Patient patient = new Patient(); + patient.setGender(AdministrativeGender.MALE); + pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless(); + + Observation obs = new Observation(); + obs.addIdentifier().setSystem("urn:system").setValue("FOO"); + obs.setDevice(new Reference(devId)); + obs.setSubject(new Reference(pid0)); + myObservationDao.create(obs, mySrd).getId(); + } + + SearchParameterMap params; // No targets exist params = new SearchParameterMap(); @@ -384,7 +407,6 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { params.add("_has", new HasParam("Observation", "subject", "identifier", "urn:system|NOLINK")); assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), empty()); } - @Test public void testHasParameterInvalidResourceType() { SearchParameterMap params = new SearchParameterMap();