Tidy, fix up tests

This commit is contained in:
Tadgh 2020-03-13 18:36:43 -07:00
parent d91cb7524c
commit b80e71773d
4 changed files with 13 additions and 41 deletions

View File

@ -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
* @return
* A search is a candidate for Composite Unique SP if unique indexes are enabled, there is no EverythingMode, and the
* parameters all have no modifiers.
*/
private boolean isCompositeUniqueSpCandidate() {
return myDaoConfig.isUniqueIndexesEnabled() &&
@ -272,7 +272,6 @@ public class SearchBuilder implements ISearchBuilder {
myAlsoIncludePids = new ArrayList<>(1);
}
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()));
} else {
Predicate targetTypePredicate = myCriteriaBuilder.equal(join.get("myTargetResourceType").as(String.class), myResourceName);

View File

@ -869,7 +869,6 @@ class PredicateBuilderReference extends BasePredicateBuilder {
Predicate sourceTypePredicate = myCriteriaBuilder.equal(join.get("myTargetResourceType"), theResourceType);
Predicate sourcePidPredicate = join.get("mySourceResourcePid").in(subQ);
Predicate andPredicate = myCriteriaBuilder.and(pathPredicate, sourcePidPredicate, sourceTypePredicate);
//Predicate andPredicate = myCriteriaBuilder.and(pathPredicate, predicate, sourceTypePredicate);
myQueryRoot.addPredicate(andPredicate);
}
}

View File

@ -351,7 +351,6 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
@Test
public void testHasParameterChained() {
IIdType pid0;
IIdType oid0;
{
Device device = new Device();
device.addIdentifier().setSystem("urn:system").setValue("DEVICEID");
@ -366,39 +365,15 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
obs.setDevice(new Reference(devId));
obs.setSubject(new Reference(pid0));
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);
hasWithChainParamQuery.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
// Patient?_has:Observation:subject:device.identifier=urn:system|DEVICEID
myCaptureQueriesListener.clear();
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;
// Target exists and is linked
params.setLoadSynchronous(true);
params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
// No targets exist
params = new SearchParameterMap();
@ -412,6 +387,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
params.add("_has", new HasParam("Observation", "subject", "identifier", "urn:system|NOLINK"));
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), empty());
}
@Test
public void testHasParameterInvalidResourceType() {
SearchParameterMap params = new SearchParameterMap();

View File

@ -497,12 +497,10 @@ public class FhirResourceDaoR4SearchNoHashesTest extends BaseJpaR4Test {
SearchParameterMap params;
// KHS JA When we switched _has from two queries to a nested subquery, we broke support for chains within _has
// We have decided for now to prefer the performance optimization of the subquery over the slower full capability
// params = new SearchParameterMap();
// params.setLoadSynchronous(true);
// params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
params = new SearchParameterMap();
params.setLoadSynchronous(true);
params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
// No targets exist
params = new SearchParameterMap();