use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientGivenNameOr.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientGivenNameOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_GIVEN_NAME);
patient.setChain(Patient.SP_GIVEN);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(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<MedicationRequest> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequest_shouldReturnMedicationRequestByPatientIdentifier.
@Test
public void searchForMedicationRequest_shouldReturnMedicationRequestByPatientIdentifier() {
ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_IDENTIFIER).setChain(Patient.SP_IDENTIFIER)));
SearchParameterMap theParams = new SearchParameterMap();
theParams.addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
List<MedicationRequest> resultList = get(results);
assertThat(resultList, not(empty()));
assertThat(resultList, hasItem(hasProperty("id", equalTo(MEDICATION_REQUEST_UUID))));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantNameOr.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantNameOr() {
ReferenceAndListParam participantReference = new ReferenceAndListParam();
ReferenceParam participant = new ReferenceParam();
participant.setValue(PATIENT_GIVEN_NAME + " " + PARTICIPANT_FAMILY_NAME);
participant.setChain(Practitioner.SP_NAME);
ReferenceParam badParticipant = new ReferenceParam();
badParticipant.setValue(WRONG_NAME);
badParticipant.setChain(Practitioner.SP_NAME);
participantReference.addValue(new ReferenceOrListParam().add(participant).add(badParticipant));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(13));
List<MedicationRequest> resultList = get(results);
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(10)));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldReturnEmptyListByMismatchingUuidAndLastUpdated.
@Test
public void searchForMedicationRequests_shouldReturnEmptyListByMismatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_VOIDED).setLowerBound(DATE_VOIDED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(0));
List<MedicationRequest> resultList = get(results);
assertThat(resultList, empty());
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldReturnEmptyListOfMedicationRequestsByMultiplePatientIdentifierAnd.
@Test
public void searchForMedicationRequests_shouldReturnEmptyListOfMedicationRequestsByMultiplePatientIdentifierAnd() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_IDENTIFIER);
patient.setChain(Patient.SP_IDENTIFIER);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(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<MedicationRequest> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
Aggregations