use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldAddEncountersForEncounterInclude.
@Test
public void searchForMedicationRequests_shouldAddEncountersForEncounterInclude() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("MedicationRequest:encounter"));
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(Encounter.class)), hasProperty("id", equalTo((returnedMedicationRequest.getEncounter().getReferenceElement().getIdPart()))))));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequest_shouldReturnMedicationRequestByPatientFamilyName.
@Test
public void searchForMedicationRequest_shouldReturnMedicationRequestByPatientFamilyName() {
ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_FAMILY_NAME).setChain(Patient.SP_FAMILY)));
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 searchForMedicationRequest_shouldReturnMedicationRequestByParticipantUuid.
@Test
public void searchForMedicationRequest_shouldReturnMedicationRequestByParticipantUuid() {
ReferenceAndListParam participantReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PARTICIPANT_UUID)));
SearchParameterMap theParams = new SearchParameterMap();
theParams.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, notNullValue());
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_shouldSearchForMedicationRequestsByMultipleParticipantIdentifierOr.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantIdentifierOr() {
ReferenceAndListParam participantReference = new ReferenceAndListParam();
ReferenceParam participant = new ReferenceParam();
participant.setValue(PARTICIPANT_IDENTIFIER);
participant.setChain(Practitioner.SP_IDENTIFIER);
ReferenceParam badParticipant = new ReferenceParam();
badParticipant.setValue(WRONG_IDENTIFIER);
badParticipant.setChain(Practitioner.SP_IDENTIFIER);
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)));
assertThat(resultList.get(0).getRequester().getIdentifier().getValue(), equalTo(PARTICIPANT_IDENTIFIER));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientIdentifierOr.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientIdentifierOr() {
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).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)));
}
Aggregations