use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldAddMedicationForMedicationInclude.
@Test
public void searchForMedicationRequests_shouldAddMedicationForMedicationInclude() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("MedicationRequest:medication"));
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(Medication.class)), hasProperty("id", equalTo((returnedMedicationRequest.getMedicationReference().getReferenceElement().getIdPart()))))));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequest_shouldSupportMappedAndUnmappedConcepts.
@Test
public void searchForMedicationRequest_shouldSupportMappedAndUnmappedConcepts() {
TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam().setSystem(FhirTestConstants.LOINC_SYSTEM_URL).setValue(LOINC_BENDAQUILINE), new TokenParam().setValue(RIFAMPICIN_CONCEPT_ID));
SearchParameterMap theParams = new SearchParameterMap();
theParams.addParameter(FhirConstants.CODED_SEARCH_HANDLER, code);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(2));
List<MedicationRequest> resultList = get(results);
assertThat(resultList, notNullValue());
assertThat(resultList, hasSize(equalTo(2)));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientNameOr.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientNameOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_GIVEN_NAME + " " + PATIENT_FAMILY_NAME);
patient.setChain(Patient.SP_NAME);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(WRONG_NAME);
badPatient.setChain(Patient.SP_NAME);
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_shouldReturnMedicationRequestByParticipantGivenName.
@Test
public void searchForMedicationRequest_shouldReturnMedicationRequestByParticipantGivenName() {
ReferenceAndListParam participantReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PARTICIPANT_GIVEN_NAME).setChain(Practitioner.SP_GIVEN)));
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_shouldAddPatientsForPatientInclude.
@Test
public void searchForMedicationRequests_shouldAddPatientsForPatientInclude() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("MedicationRequest:patient"));
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(Patient.class)), hasProperty("id", equalTo((returnedMedicationRequest.getSubject().getReferenceElement().getIdPart()))))));
}
Aggregations