Merge branch 'master' of github.com:jamesagnew/hapi-fhir
This commit is contained in:
commit
2143c6906b
|
@ -435,7 +435,7 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
String resourceId;
|
String resourceId;
|
||||||
if (!ref.getValue().matches("[a-zA-Z]+\\/.*")) {
|
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>>();
|
resourceTypes = new ArrayList<Class<? extends IBaseResource>>();
|
||||||
|
|
||||||
Set<String> targetTypes = param.getTargets();
|
Set<String> targetTypes = param.getTargets();
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,8 @@ public class StopWatch {
|
||||||
tgt.append(val);
|
tgt.append(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMillisPerOperation(int theNumOperations) {
|
public int getMillisPerOperation(int theNumOperations) {
|
||||||
return ((double) getMillis()) / Math.max(1.0, theNumOperations);
|
return (int)(((double) getMillis()) / Math.max(1.0, theNumOperations));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ca.uhn.fhir.jpa.dao.dstu3;
|
package ca.uhn.fhir.jpa.dao.dstu3;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
import static org.hamcrest.Matchers.empty;
|
import static org.hamcrest.Matchers.empty;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
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.Reference;
|
||||||
import org.hl7.fhir.dstu3.model.SearchParameter;
|
import org.hl7.fhir.dstu3.model.SearchParameter;
|
||||||
import org.hl7.fhir.dstu3.model.StringType;
|
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.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -269,7 +272,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;
|
||||||
|
@ -289,6 +296,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
|
||||||
|
@ -315,6 +330,10 @@ public class FhirResourceDaoDstu3SearchCustomSearchParamTest extends BaseJpaDstu
|
||||||
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;
|
||||||
List<String> foundResources;
|
List<String> foundResources;
|
||||||
|
@ -333,6 +352,13 @@ 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
|
||||||
|
|
Loading…
Reference in New Issue