Description
The current implementation of handlePatientReference in BaseDao appears to always result in AND queries instead of both AND and OR queries as appropriate so that a request for:
/Observation?subject.family=Foo,Bar
Effectively results in a query with a WHERE clause like this:
where pn.familyName = Foo and pn.familyName = Bar
Obviously this is not what is intended and should be fixed.
An example test (for the Encounter resource) that should pass:
@Test public void searchForEncounters_shouldSearchForEncountersByMultipleFamilyNames() { ReferenceAndListParam subjectReference = new ReferenceAndListParam(); subjectReference.addAnd(new ReferenceOrListParam() .addOr(new ReferenceParam().setValue("Hornblower").setChain(Patient.SP_FAMILY)) .addOr(new ReferenceParam().setValue("Chebaskwony").setChain(Patient.SP_FAMILY))); IBundleProvider results = search(new SearchParameterMap() .addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, subjectReference)); assertThat(results, notNullValue()); List<IBaseResource> resultList = get(results); assertThat(resultList, not(empty())); assertThat(resultList, hasItem(hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo("da7f524f-27ce-4bb2-86d6-6d1d05312bd5")))))); assertThat(resultList, hasItem(hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo("5946f880-b197-400b-9caa-a3c661d23041")))))); }
Other similar tests should be added to other resources as appropriate.