Support chained HAS (#1605)

This commit is contained in:
James Agnew 2019-11-24 06:29:56 +01:00 committed by GitHub
parent dc9650e32c
commit 27749f4e23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 0 deletions

View File

@ -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<String> 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() {

View File

@ -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);

View File

@ -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.
</action>
<action type="add">
Chained searches using the _has search parameter as the chain value are now supported by
the JPA server.
</action>
</release>
<release version="4.1.0" date="2019-11-13" description="Jitterbug">
<action type="add">