use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method deleteMedicationRequest_shouldDeleteMedicationRequest.
@Test
public void deleteMedicationRequest_shouldDeleteMedicationRequest() {
when(fhirMedicationRequestService.delete(MEDICATION_REQUEST_UUID)).thenReturn(medicationRequest);
OperationOutcome result = resourceProvider.deleteMedicationRequest(new IdType().setValue(MEDICATION_REQUEST_UUID));
assertThat(result, notNullValue());
assertThat(result.getIssue(), notNullValue());
assertThat(result.getIssueFirstRep().getSeverity(), equalTo(OperationOutcome.IssueSeverity.INFORMATION));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getCode(), equalTo("MSG_DELETED"));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenUUIDIsSpecified.
@Test
public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenUUIDIsSpecified() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(MEDICATION_REQUEST_UUID));
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, uuid, 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 searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenLastUpdatedIsSpecified.
@Test
public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenLastUpdatedIsSpecified() {
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, null, lastUpdated, null);
List<IBaseResource> resources = results.getResources(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 searchMedicationRequest_shouldNotAddRelatedMedicationsForEmptyInclude.
@Test
public void searchMedicationRequest_shouldNotAddRelatedMedicationsForEmptyInclude() {
HashSet<Include> includes = new HashSet<>();
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, null, null, null, null, includes);
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_shouldThrowResourceNotFoundException.
@Test(expected = ResourceNotFoundException.class)
public void getMedicationRequestByUuid_shouldThrowResourceNotFoundException() {
IdType id = new IdType();
id.setValue(WRONG_MEDICATION_REQUEST_UUID);
MedicationRequest medicationRequest = resourceProvider.getMedicationRequestById(id);
assertThat(medicationRequest, nullValue());
}
Aggregations