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 738d1702f9b..26c37eb07f8 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 @@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.model.entity.*; import ca.uhn.fhir.jpa.searchparam.SearchParamConstants; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap.EverythingModeEnum; +import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl; import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; @@ -229,6 +230,36 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { } + @Test + public void testHasChain() { + + Patient p = new Patient(); + p.setId("P"); + p.setActive(true); + myPatientDao.update(p); + + Group group = new Group(); + group.setId("G"); + group.addMember().getEntity().setReference("Patient/P"); + myGroupDao.update(group); + + DiagnosticReport dr = new DiagnosticReport(); + dr.setId("DR"); + dr.getSubject().setReference("Patient/P"); + myDiagnosticReportDao.update(dr); + + SearchParameterMap map = new SearchParameterMap(); + map.setLoadSynchronous(true); + + ReferenceParam referenceParam = new ReferenceParam(); + referenceParam.setValueAsQueryToken(myFhirCtx, "subject", "._has:Group:member:_id", "Group/G"); + map.add("subject", referenceParam); + List actual = toUnqualifiedVersionlessIdValues(myDiagnosticReportDao.search(map)); + assertThat(actual, containsInAnyOrder("DiagnosticReport/DR")); + + // http://hapi.fhir.org/baseR4/DiagnosticReport?subject._has:Group:member:_id=52152 + } + @SuppressWarnings("unused") @Test public void testHasAndHas() { diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/ResourceMetaParams.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/ResourceMetaParams.java index 698201476d0..09a14facce1 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/ResourceMetaParams.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/ResourceMetaParams.java @@ -23,6 +23,8 @@ package ca.uhn.fhir.jpa.searchparam; import ca.uhn.fhir.model.api.IQueryParameterAnd; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.rest.api.Constants; +import ca.uhn.fhir.rest.param.HasAndListParam; +import ca.uhn.fhir.rest.param.HasParam; import ca.uhn.fhir.rest.param.StringAndListParam; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.TokenAndListParam; @@ -61,6 +63,8 @@ public class ResourceMetaParams { resourceMetaAndParams.put(Constants.PARAM_PROFILE, UriAndListParam.class); resourceMetaParams.put(Constants.PARAM_SECURITY, TokenParam.class); resourceMetaAndParams.put(Constants.PARAM_SECURITY, TokenAndListParam.class); + resourceMetaParams.put(Constants.PARAM_HAS, HasParam.class); + resourceMetaAndParams.put(Constants.PARAM_HAS, HasAndListParam.class); RESOURCE_META_PARAMS = Collections.unmodifiableMap(resourceMetaParams); RESOURCE_META_AND_PARAMS = Collections.unmodifiableMap(resourceMetaAndParams); diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 30df7b31289..e8dd43c674f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -37,6 +37,10 @@ HAPI FHIR 4.1.0 the value in Bundle.entry.fullUrl will only be used to set the parsed resource ID if the resource has no ID present. + + Chained searches using the _has search parameter as the chain value are now supported by + the JPA server. +