More fixes for chaining on custom search params
This commit is contained in:
parent
d58a9e7ed4
commit
9ea8e7822a
|
@ -447,8 +447,12 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
if (resourceTypes.isEmpty()) {
|
||||
RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(myResourceType);
|
||||
String paramPath = myCallingDao.getSearchParamByName(resourceDef, theParamName).getPath();
|
||||
RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(theResourceName);
|
||||
RuntimeSearchParam searchParamByName = myCallingDao.getSearchParamByName(resourceDef, theParamName);
|
||||
if (searchParamByName == null) {
|
||||
throw new InternalErrorException("Could not find parameter " + theParamName );
|
||||
}
|
||||
String paramPath = searchParamByName.getPath();
|
||||
if (paramPath.endsWith(".as(Reference)")) {
|
||||
paramPath = paramPath.substring(0, paramPath.length() - ".as(Reference)".length()) + "Reference";
|
||||
}
|
||||
|
|
|
@ -264,7 +264,11 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
|
|||
Patient p2 = new Patient();
|
||||
p2.addName().setFamily("P2");
|
||||
p2.addExtension().setUrl("http://acme.org/sibling").setValue(new Reference(p1id));
|
||||
|
||||
IIdType p2id = myPatientDao.create(p2).getId().toUnqualifiedVersionless();
|
||||
Appointment app = new Appointment();
|
||||
app.addParticipant().getActor().setReference(p2id.getValue());
|
||||
IIdType appid = myAppointmentDao.create(app).getId().toUnqualifiedVersionless();
|
||||
|
||||
SearchParameterMap map;
|
||||
IBundleProvider results;
|
||||
|
@ -284,6 +288,14 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
|
|||
foundResources = toUnqualifiedVersionlessIdValues(results);
|
||||
assertThat(foundResources, contains(p2id.getValue()));
|
||||
|
||||
// Search by two level chain
|
||||
map = new SearchParameterMap();
|
||||
map.add("patient", new ReferenceParam("sibling.name", "P1"));
|
||||
results = myAppointmentDao.search(map);
|
||||
foundResources = toUnqualifiedVersionlessIdValues(results);
|
||||
assertThat(foundResources, containsInAnyOrder(appid.getValue()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue