More fixes for chaining on custom search params

This commit is contained in:
James Agnew 2017-05-18 17:16:30 -04:00
parent d58a9e7ed4
commit 9ea8e7822a
2 changed files with 18 additions and 2 deletions

View File

@ -447,8 +447,12 @@ public class SearchBuilder implements ISearchBuilder {
} }
if (resourceTypes.isEmpty()) { if (resourceTypes.isEmpty()) {
RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(myResourceType); RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(theResourceName);
String paramPath = myCallingDao.getSearchParamByName(resourceDef, theParamName).getPath(); 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)")) { if (paramPath.endsWith(".as(Reference)")) {
paramPath = paramPath.substring(0, paramPath.length() - ".as(Reference)".length()) + "Reference"; paramPath = paramPath.substring(0, paramPath.length() - ".as(Reference)".length()) + "Reference";
} }

View File

@ -264,7 +264,11 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
Patient p2 = new Patient(); Patient p2 = new Patient();
p2.addName().setFamily("P2"); p2.addName().setFamily("P2");
p2.addExtension().setUrl("http://acme.org/sibling").setValue(new Reference(p1id)); p2.addExtension().setUrl("http://acme.org/sibling").setValue(new Reference(p1id));
IIdType p2id = myPatientDao.create(p2).getId().toUnqualifiedVersionless(); 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; SearchParameterMap map;
IBundleProvider results; IBundleProvider results;
@ -284,6 +288,14 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
foundResources = toUnqualifiedVersionlessIdValues(results); foundResources = toUnqualifiedVersionlessIdValues(results);
assertThat(foundResources, contains(p2id.getValue())); 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 @Test