mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-09 14:33:32 +00:00
4671 Searching with _source parameter will return matches for all resource types (#4673)
* adding solution with new test. * adding changelog --------- Co-authored-by: peartree <etienne.poirier@smilecdr.com>
This commit is contained in:
parent
b33b789880
commit
fb057d4fb1
@ -0,0 +1,5 @@
|
||||
---
|
||||
type: fix
|
||||
issue: 4671
|
||||
jira: SMILE-6213
|
||||
title: "Previously, searching with the '_source' parameter would return matching source for all resource types. This has been corrected."
|
@ -1311,6 +1311,8 @@ public class QueryStack {
|
||||
}
|
||||
|
||||
private Condition createPredicateSourceForAndList(@Nullable DbColumn theSourceJoinColumn, List<List<IQueryParameterType>> theAndOrParams) {
|
||||
mySqlBuilder.getOrCreateFirstPredicateBuilder();
|
||||
|
||||
List<Condition> andPredicates = new ArrayList<>(theAndOrParams.size());
|
||||
for (List<? extends IQueryParameterType> nextAnd : theAndOrParams) {
|
||||
andPredicates.add(createPredicateSource(theSourceJoinColumn, nextAnd));
|
||||
|
@ -15,6 +15,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import org.apache.commons.text.RandomStringGenerator;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -80,6 +81,30 @@ public class FhirResourceDaoR4SourceTest extends BaseJpaR4Test {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchSource_whenSameSourceForMultipleResourceTypes_willMatchSearchResourceTypeOnly(){
|
||||
String sourceUrn = "urn:source:0";
|
||||
String requestId = "a_request_id";
|
||||
|
||||
when(mySrd.getRequestId()).thenReturn(requestId);
|
||||
Patient patient = new Patient();
|
||||
patient.getMeta().setSource(sourceUrn);
|
||||
patient.setActive(true);
|
||||
IIdType ptId = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation observation = new Observation();
|
||||
observation.setStatus(Observation.ObservationStatus.FINAL);
|
||||
observation.getMeta().setSource(sourceUrn);
|
||||
myObservationDao.create(observation, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
SearchParameterMap params = new SearchParameterMap();
|
||||
params.setLoadSynchronous(true);
|
||||
params.add(Constants.PARAM_SOURCE, new TokenParam("urn:source:0"));
|
||||
IBundleProvider result = myPatientDao.search(params);
|
||||
|
||||
assertThat(toUnqualifiedVersionlessIdValues(result), containsInAnyOrder(ptId.getValue()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithOr() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user