use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientGivenName.
@Test
public void searchForObsConditions_shouldReturnConditionByPatientGivenName() {
ReferenceParam patientReference = new ReferenceParam(Patient.SP_GIVEN, PATIENT_GIVEN_NAME);
ReferenceAndListParam patientList = new ReferenceAndListParam();
patientList.addValue(new ReferenceOrListParam().add(patientReference));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnEmptyListOfConditionsByMultiplePatientIdentifierAnd.
@Test
public void searchForObsConditions_shouldReturnEmptyListOfConditionsByMultiplePatientIdentifierAnd() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_IDENTIFIER);
patient.setChain(Patient.SP_IDENTIFIER);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_IDENTIFIER);
badPatient.setChain(Patient.SP_IDENTIFIER);
referenceParam.addValue(new ReferenceOrListParam().add(patient)).addAnd(new ReferenceOrListParam().add(badPatient));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientUuid.
@Test
public void searchForObsConditions_shouldReturnConditionByPatientUuid() {
ReferenceParam patientReference = new ReferenceParam(null, PATIENT_UUID);
ReferenceAndListParam patientList = new ReferenceAndListParam();
patientList.addAnd(new ReferenceOrListParam().addOr(patientReference));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMultiplePatientUuidOr.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMultiplePatientUuidOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_UUID);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_UUID);
referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnUniqueConditionsByPatientGivenName.
@Test
public void searchForObsConditions_shouldReturnUniqueConditionsByPatientGivenName() {
ReferenceParam patientReference = new ReferenceParam(Patient.SP_GIVEN, PATIENT_GIVEN_NAME);
ReferenceAndListParam patientList = new ReferenceAndListParam();
patientList.addValue(new ReferenceOrListParam().add(patientReference));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(2));
Set<String> resultSet = new HashSet<>(dao.getSearchResultUuids(theParams));
assertThat(resultSet.size(), equalTo(2));
}
Aggregations