use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenMedicationParamIsSpecified.
@Test
public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenMedicationParamIsSpecified() {
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
ReferenceAndListParam medicationParam = new ReferenceAndListParam();
medicationParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Medication.SP_IDENTIFIER)));
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, medicationParam, null, null, null);
List<IBaseResource> resources = getResources(results, 1, 5);
assertThat(results, notNullValue());
assertThat(resources, hasSize(equalTo(1)));
assertThat(resources.get(0), notNullValue());
assertThat(resources.get(0).fhirType(), equalTo(FhirConstants.MEDICATION_REQUEST));
assertThat(resources.get(0).getIdElement().getIdPart(), equalTo(MEDICATION_REQUEST_UUID));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method createMedicationRequest_shouldCreateMedicationRequest.
@Test
public void createMedicationRequest_shouldCreateMedicationRequest() {
when(fhirMedicationRequestService.create(any(org.hl7.fhir.r4.model.MedicationRequest.class))).thenReturn(medicationRequest);
MethodOutcome result = resourceProvider.createMedicationRequest(MedicationRequest30_40.convertMedicationRequest(medicationRequest));
assertThat(result, notNullValue());
assertThat(result.getCreated(), is(true));
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(medicationRequest.getId()));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method searchMedicationRequest_shouldReturnMatchingMedicationRequestUsingCode.
@Test
public void searchMedicationRequest_shouldReturnMatchingMedicationRequestUsingCode() {
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
TokenAndListParam code = new TokenAndListParam();
TokenParam codingToken = new TokenParam();
codingToken.setValue("1000");
code.addAnd(codingToken);
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, code, null, null, null, null, null);
List<MedicationRequest> resources = get(results, 1, 5);
assertThat(results, notNullValue());
assertThat(resources, hasSize(equalTo(1)));
assertThat(resources.get(0), notNullValue());
assertThat(resources.get(0).fhirType(), equalTo(FhirConstants.MEDICATION_REQUEST));
assertThat(resources.get(0).getIdElement().getIdPart(), equalTo(MEDICATION_REQUEST_UUID));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method getMedicationRequestByUuid_shouldReturnMatchingMedicationRequest.
@Test
public void getMedicationRequestByUuid_shouldReturnMatchingMedicationRequest() {
when(fhirMedicationRequestService.get(MEDICATION_REQUEST_UUID)).thenReturn(medicationRequest);
IdType id = new IdType();
id.setValue(MEDICATION_REQUEST_UUID);
MedicationRequest medicationRequest = resourceProvider.getMedicationRequestById(id);
assertThat(medicationRequest, notNullValue());
assertThat(medicationRequest.getId(), notNullValue());
assertThat(medicationRequest.getId(), equalTo(MEDICATION_REQUEST_UUID));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenEncounterParamIsSpecified.
@Test
public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenEncounterParamIsSpecified() {
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
ReferenceAndListParam encounterParam = new ReferenceAndListParam();
encounterParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Encounter.SP_IDENTIFIER)));
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, encounterParam, null, null, null, null, null, null);
List<MedicationRequest> resources = get(results, 1, 5);
assertThat(results, notNullValue());
assertThat(resources, hasSize(equalTo(1)));
assertThat(resources.get(0), notNullValue());
assertThat(resources.get(0).fhirType(), equalTo(FhirConstants.MEDICATION_REQUEST));
assertThat(resources.get(0).getIdElement().getIdPart(), equalTo(MEDICATION_REQUEST_UUID));
}
Aggregations