Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
James 2017-05-19 10:13:45 -04:00
commit 2143c6906b
3 changed files with 35 additions and 5 deletions

View File

@ -435,7 +435,7 @@ public class SearchBuilder implements ISearchBuilder {
String resourceId;
if (!ref.getValue().matches("[a-zA-Z]+\\/.*")) {
RuntimeSearchParam param = mySearchParamRegistry.getActiveSearchParam(myResourceName, theParamName);
RuntimeSearchParam param = mySearchParamRegistry.getActiveSearchParam(theResourceName, theParamName);
resourceTypes = new ArrayList<Class<? extends IBaseResource>>();
Set<String> targetTypes = param.getTargets();
@ -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";
}

View File

@ -93,8 +93,8 @@ public class StopWatch {
tgt.append(val);
}
public double getMillisPerOperation(int theNumOperations) {
return ((double) getMillis()) / Math.max(1.0, theNumOperations);
public int getMillisPerOperation(int theNumOperations) {
return (int)(((double) getMillis()) / Math.max(1.0, theNumOperations));
}
}

View File

@ -1,6 +1,7 @@
package ca.uhn.fhir.jpa.dao.dstu3;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@ -17,6 +18,8 @@ import org.hl7.fhir.dstu3.model.Practitioner;
import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.dstu3.model.SearchParameter;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.AfterClass;
import org.junit.Before;
@ -269,7 +272,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;
@ -289,6 +296,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
@ -315,6 +330,10 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
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;
List<String> foundResources;
@ -333,6 +352,13 @@ 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