use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequest_shouldReturnMedicationRequestByMedication.
@Test
public void searchForMedicationRequest_shouldReturnMedicationRequestByMedication() {
ReferenceAndListParam medicationReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(MEDICATION_UUID)));
SearchParameterMap theParams = new SearchParameterMap();
theParams.addParameter(FhirConstants.MEDICATION_REFERENCE_SEARCH_HANDLER, medicationReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
List<MedicationRequest> resultList = get(results);
assertThat(resultList, notNullValue());
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_shouldReturnEmptyListOfMedicationRequestsByMultipleParticipantGivenNameAnd.
@Test
public void searchForMedicationRequests_shouldReturnEmptyListOfMedicationRequestsByMultipleParticipantGivenNameAnd() {
ReferenceAndListParam participantReference = new ReferenceAndListParam();
ReferenceParam participant = new ReferenceParam();
participant.setValue(PARTICIPANT_GIVEN_NAME);
participant.setChain(Practitioner.SP_GIVEN);
ReferenceParam badParticipant = new ReferenceParam();
badParticipant.setValue(WRONG_GIVEN_NAME);
badParticipant.setChain(Practitioner.SP_GIVEN);
participantReference.addValue(new ReferenceOrListParam().add(participant)).addAnd(new ReferenceOrListParam().add(badParticipant));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference);
IBundleProvider results = search(theParams);
List<MedicationRequest> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldAddPractitionersForRequesterInclude.
@Test
public void searchForMedicationRequests_shouldAddPractitionersForRequesterInclude() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("MedicationRequest:requester"));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
IBundleProvider results = search(theParams);
assertThat(results.size(), equalTo(1));
assertThat(results, notNullValue());
List<IBaseResource> resultList = results.getResources(0, 10);
assertThat(resultList, not(empty()));
// included resource added as part of the result list
assertThat(resultList.size(), equalTo(2));
assertThat(((MedicationRequest) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(MEDICATION_REQUEST_UUID));
MedicationRequest returnedMedicationRequest = (MedicationRequest) resultList.iterator().next();
assertThat(resultList, hasItem(allOf(is(instanceOf(Practitioner.class)), hasProperty("id", equalTo(returnedMedicationRequest.getRequester().getReferenceElement().getIdPart())))));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldReturnEmptyListOfMedicationRequestsByMultipleParticipantNameAnd.
@Test
public void searchForMedicationRequests_shouldReturnEmptyListOfMedicationRequestsByMultipleParticipantNameAnd() {
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)).addAnd(new ReferenceOrListParam().add(badParticipant));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference);
IBundleProvider results = search(theParams);
List<MedicationRequest> resultList = get(results);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(0));
assertThat(resultList, empty());
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequest_shouldSearchForMedicationRequestByConceptUuid.
@Test
public void searchForMedicationRequest_shouldSearchForMedicationRequestByConceptUuid() {
TokenAndListParam code = new TokenAndListParam();
TokenParam codingToken = new TokenParam();
codingToken.setValue(MEDICATION_REQUEST_CONCEPT_UUID);
code.addAnd(codingToken);
SearchParameterMap theParams = new SearchParameterMap();
theParams.addParameter(FhirConstants.CODED_SEARCH_HANDLER, code);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<MedicationRequest> resultList = get(results);
assertThat(resultList, not(empty()));
assertThat(resultList, hasItem(hasProperty("id", equalTo(MEDICATION_REQUEST_UUID))));
}
Aggregations