use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderTest method searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenParticipantParamIsSpecified.
@Test
public void searchMedicationRequest_shouldReturnMatchingMedicationRequestWhenParticipantParamIsSpecified() {
when(fhirMedicationRequestService.searchForMedicationRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(medicationRequest), 10, 1));
ReferenceAndListParam participantParam = new ReferenceAndListParam();
participantParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Practitioner.SP_NAME)));
IBundleProvider results = resourceProvider.searchForMedicationRequests(null, null, null, null, participantParam, null, 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 deleteTask_shouldDeleteMedicationRequest.
@Test
public void deleteTask_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 updateMedicationRequest_shouldUpdateMedicationRequest.
@Test
public void updateMedicationRequest_shouldUpdateMedicationRequest() {
when(fhirMedicationRequestService.update(eq(MEDICATION_REQUEST_UUID), any(MedicationRequest.class))).thenReturn(medicationRequest);
MethodOutcome result = resourceProvider.updateMedicationRequest(new IdType().setValue(MEDICATION_REQUEST_UUID), medicationRequest);
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
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_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<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 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<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));
}
Aggregations