use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMultiplePatientGivenNameOr.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMultiplePatientGivenNameOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_GIVEN_NAME);
patient.setChain(Patient.SP_GIVEN);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_GIVEN_NAME);
badPatient.setChain(Patient.SP_GIVEN);
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);
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientIdentifier.
@Test
public void searchForObsConditions_shouldReturnConditionByPatientIdentifier() {
ReferenceParam patientReference = new ReferenceParam(Patient.SP_IDENTIFIER, PATIENT_IDENTIFIER);
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().getReference(), endsWith(PATIENT_UUID));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForConditions_shouldReturnEmptyListOfConditionsByMultiplePatientFamilyNameAnd.
@Test
public void searchForConditions_shouldReturnEmptyListOfConditionsByMultiplePatientFamilyNameAnd() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_FAMILY_NAME);
patient.setChain(Patient.SP_FAMILY);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_FAMILY_NAME);
badPatient.setChain(Patient.SP_FAMILY);
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_shouldSearchForConditionsByLastUpdatedDateCreated.
@Test
public void searchForObsConditions_shouldSearchForConditionsByLastUpdatedDateCreated() {
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CREATED).setLowerBound(DATE_CREATED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(2)));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForConditions_shouldReturnEmptyListOfConditionsByMultiplePatientNameAnd.
@Test
public void searchForConditions_shouldReturnEmptyListOfConditionsByMultiplePatientNameAnd() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_PARTIAL_NAME);
patient.setChain(Patient.SP_NAME);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_NOT_FOUND_NAME);
badPatient.setChain(Patient.SP_NAME);
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());
}
Aggregations