Fix #3261 - Incorrect revinclude selector (#3358)

This commit is contained in:
James Agnew 2022-02-04 07:50:13 -05:00 committed by GitHub
parent 6b15754b4a
commit 1d5714aec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
type: fix
issue: 3261
title: "When performing a search with a `_revinclude`. the results sometimes incorrectly included
resources that were reverse included by other search parameters with the same name. Thanks to
GitHub user @vivektk84 for reporting and to Jean-Francois Briere for proposing a fix."

View File

@ -997,7 +997,7 @@ public class SearchBuilder implements ISearchBuilder {
continue;
}
paths = param.getPathsSplit();
paths = param.getPathsSplitForResourceType(resType);
String targetResourceType = defaultString(nextInclude.getParamTargetType(), null);
for (String nextPath : paths) {

View File

@ -1964,6 +1964,29 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
assertThat(ids, containsInAnyOrder(obsId, ptId, encId));
}
@Test
public void testSearchWithRevIncludeDoesntSelectWrongResourcesWithSameSpName() {
Patient pt = new Patient();
pt.setActive(true);
IIdType ptId = myPatientDao.create(pt, mySrd).getId().toUnqualifiedVersionless();
Encounter enc = new Encounter();
enc.setStatus(Encounter.EncounterStatus.ARRIVED);
enc.getSubject().setReference(ptId.getValue());
IIdType encId = myEncounterDao.create(enc, mySrd).getId().toUnqualifiedVersionless();
Observation obs = new Observation();
obs.getSubject().setReference(ptId.getValue());
myObservationDao.create(obs, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap map = new SearchParameterMap()
.addRevInclude(Encounter.INCLUDE_PATIENT);
IBundleProvider outcome = myPatientDao.search(map);
List<IIdType> ids = toUnqualifiedVersionlessIds(outcome);
assertThat(ids, contains(ptId, encId));
}
@Test
public void testSearchWithRevIncludeStarQualified() {