use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantFamilyNameOr.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantFamilyNameOr() {
ReferenceAndListParam participantReference = new ReferenceAndListParam();
ReferenceParam participant = new ReferenceParam();
participant.setValue(PARTICIPANT_FAMILY_NAME);
participant.setChain(Practitioner.SP_FAMILY);
ReferenceParam badParticipant = new ReferenceParam();
badParticipant.setValue(WRONG_FAMILY_NAME);
badParticipant.setChain(Practitioner.SP_FAMILY);
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 searchForMedicationRequest_shouldSearchForMedicationRequestByConceptId.
@Test
public void searchForMedicationRequest_shouldSearchForMedicationRequestByConceptId() {
TokenAndListParam code = new TokenAndListParam();
TokenParam codingToken = new TokenParam();
codingToken.setValue(MEDICATION_REQUEST_CONCEPT_ID);
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))));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByLastUpdatedDateCreated.
@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByLastUpdatedDateCreated() {
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);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(3));
List<MedicationRequest> resultList = get(results);
assertThat(resultList.size(), equalTo(3));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestSearchQueryTest method searchForMedicationRequest_shouldReturnMultipleMedicationRequestByConceptMapping.
@Test
public void searchForMedicationRequest_shouldReturnMultipleMedicationRequestByConceptMapping() {
TokenAndListParam code = new TokenAndListParam();
TokenOrListParam orListParam = new TokenOrListParam();
code.addAnd(orListParam);
for (String coding : LOINC_TB_DRUG_CODES) {
TokenParam codingToken = new TokenParam();
codingToken.setSystem(FhirTestConstants.LOINC_SYSTEM_URL);
codingToken.setValue(coding);
orListParam.addOr(codingToken);
}
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_shouldHandleMultipleIncludes.
@Test
public void searchForMedicationRequests_shouldHandleMultipleIncludes() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("MedicationRequest:medication"));
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 resources (medication + requester) added as part of the result list
assertThat(resultList.size(), equalTo(3));
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()))))));
assertThat(resultList, hasItem(allOf(is(instanceOf(Practitioner.class)), hasProperty("id", equalTo(returnedMedicationRequest.getRequester().getReferenceElement().getIdPart())))));
}
Aggregations