Tidy, fix up tests
This commit is contained in:
parent
d91cb7524c
commit
b80e71773d
|
@ -180,8 +180,8 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A search is a candidate for Composite Unique SP if unique indexes are enabled, we are not in
|
* A search is a candidate for Composite Unique SP if unique indexes are enabled, there is no EverythingMode, and the
|
||||||
* @return
|
* parameters all have no modifiers.
|
||||||
*/
|
*/
|
||||||
private boolean isCompositeUniqueSpCandidate() {
|
private boolean isCompositeUniqueSpCandidate() {
|
||||||
return myDaoConfig.isUniqueIndexesEnabled() &&
|
return myDaoConfig.isUniqueIndexesEnabled() &&
|
||||||
|
@ -272,7 +272,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
myAlsoIncludePids = new ArrayList<>(1);
|
myAlsoIncludePids = new ArrayList<>(1);
|
||||||
}
|
}
|
||||||
myAlsoIncludePids.add(pid);
|
myAlsoIncludePids.add(pid);
|
||||||
//Won't this fail on non-long IDs? Or does IdHelperService massage this?
|
|
||||||
myQueryRoot.addPredicate(myCriteriaBuilder.equal(join.get("myTargetResourcePid").as(Long.class), pid.getIdAsLong()));
|
myQueryRoot.addPredicate(myCriteriaBuilder.equal(join.get("myTargetResourcePid").as(Long.class), pid.getIdAsLong()));
|
||||||
} else {
|
} else {
|
||||||
Predicate targetTypePredicate = myCriteriaBuilder.equal(join.get("myTargetResourceType").as(String.class), myResourceName);
|
Predicate targetTypePredicate = myCriteriaBuilder.equal(join.get("myTargetResourceType").as(String.class), myResourceName);
|
||||||
|
|
|
@ -869,7 +869,6 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
Predicate sourceTypePredicate = myCriteriaBuilder.equal(join.get("myTargetResourceType"), theResourceType);
|
Predicate sourceTypePredicate = myCriteriaBuilder.equal(join.get("myTargetResourceType"), theResourceType);
|
||||||
Predicate sourcePidPredicate = join.get("mySourceResourcePid").in(subQ);
|
Predicate sourcePidPredicate = join.get("mySourceResourcePid").in(subQ);
|
||||||
Predicate andPredicate = myCriteriaBuilder.and(pathPredicate, sourcePidPredicate, sourceTypePredicate);
|
Predicate andPredicate = myCriteriaBuilder.and(pathPredicate, sourcePidPredicate, sourceTypePredicate);
|
||||||
//Predicate andPredicate = myCriteriaBuilder.and(pathPredicate, predicate, sourceTypePredicate);
|
|
||||||
myQueryRoot.addPredicate(andPredicate);
|
myQueryRoot.addPredicate(andPredicate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,6 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||||
@Test
|
@Test
|
||||||
public void testHasParameterChained() {
|
public void testHasParameterChained() {
|
||||||
IIdType pid0;
|
IIdType pid0;
|
||||||
IIdType oid0;
|
|
||||||
{
|
{
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
device.addIdentifier().setSystem("urn:system").setValue("DEVICEID");
|
device.addIdentifier().setSystem("urn:system").setValue("DEVICEID");
|
||||||
|
@ -366,39 +365,15 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||||
obs.setDevice(new Reference(devId));
|
obs.setDevice(new Reference(devId));
|
||||||
obs.setSubject(new Reference(pid0));
|
obs.setSubject(new Reference(pid0));
|
||||||
obs.setCode(new CodeableConcept(new Coding("sys", "val", "disp")));
|
obs.setCode(new CodeableConcept(new Coding("sys", "val", "disp")));
|
||||||
oid0 = myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchParameterMap hasWithChainParamQuery = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
|
||||||
hasWithChainParamQuery.setLoadSynchronous(true);
|
// Target exists and is linked
|
||||||
hasWithChainParamQuery.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
|
params.setLoadSynchronous(true);
|
||||||
// Patient?_has:Observation:subject:device.identifier=urn:system|DEVICEID
|
params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
|
||||||
myCaptureQueriesListener.clear();
|
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(hasWithChainParamQuery)), contains(pid0.getValue()));
|
|
||||||
ourLog.warn(myCaptureQueriesListener.getSelectQueriesForCurrentThread().stream().map(q -> q.getSql(true, true)).collect(Collectors.joining("******")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHasParameterReverseChained() {
|
|
||||||
IIdType pid0;
|
|
||||||
{
|
|
||||||
Device device = new Device();
|
|
||||||
device.addIdentifier().setSystem("urn:system").setValue("DEVICEID");
|
|
||||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
|
||||||
|
|
||||||
Patient patient = new Patient();
|
|
||||||
patient.setGender(AdministrativeGender.MALE);
|
|
||||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
|
||||||
|
|
||||||
Observation obs = new Observation();
|
|
||||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
|
||||||
obs.setDevice(new Reference(devId));
|
|
||||||
obs.setSubject(new Reference(pid0));
|
|
||||||
myObservationDao.create(obs, mySrd).getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchParameterMap params;
|
|
||||||
|
|
||||||
// No targets exist
|
// No targets exist
|
||||||
params = new SearchParameterMap();
|
params = new SearchParameterMap();
|
||||||
|
@ -412,6 +387,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||||
params.add("_has", new HasParam("Observation", "subject", "identifier", "urn:system|NOLINK"));
|
params.add("_has", new HasParam("Observation", "subject", "identifier", "urn:system|NOLINK"));
|
||||||
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), empty());
|
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHasParameterInvalidResourceType() {
|
public void testHasParameterInvalidResourceType() {
|
||||||
SearchParameterMap params = new SearchParameterMap();
|
SearchParameterMap params = new SearchParameterMap();
|
||||||
|
|
|
@ -497,12 +497,10 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
SearchParameterMap params;
|
SearchParameterMap params;
|
||||||
|
|
||||||
// KHS JA When we switched _has from two queries to a nested subquery, we broke support for chains within _has
|
params = new SearchParameterMap();
|
||||||
// We have decided for now to prefer the performance optimization of the subquery over the slower full capability
|
params.setLoadSynchronous(true);
|
||||||
// params = new SearchParameterMap();
|
params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
|
||||||
// params.setLoadSynchronous(true);
|
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
|
||||||
// params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
|
|
||||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
|
|
||||||
|
|
||||||
// No targets exist
|
// No targets exist
|
||||||
params = new SearchParameterMap();
|
params = new SearchParameterMap();
|
||||||
|
|
Loading…
Reference in New Issue