use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.
the class ProcedureRequestFhirResourceProviderTest method updateProcedureRequest_shouldUpdateProcedureRequest.
@Test
public void updateProcedureRequest_shouldUpdateProcedureRequest() {
when(serviceRequestService.update(eq(SERVICE_REQUEST_UUID), any(ServiceRequest.class))).thenReturn(serviceRequest);
MethodOutcome result = resourceProvider.updateProcedureRequest(new IdType().setValue(SERVICE_REQUEST_UUID), (ProcedureRequest) VersionConvertor_30_40.convertResource(serviceRequest, false));
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(SERVICE_REQUEST_UUID));
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.
the class ProcedureRequestFhirResourceProviderTest method createProcedureRequest_shouldCreateNewProcedureRequest.
@Test
public void createProcedureRequest_shouldCreateNewProcedureRequest() {
when(serviceRequestService.create(any(ServiceRequest.class))).thenReturn(serviceRequest);
MethodOutcome result = resourceProvider.createProcedureRequest((ProcedureRequest) VersionConvertor_30_40.convertResource(serviceRequest, false));
assertThat(result, notNullValue());
assertThat(result.getCreated(), is(true));
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(SERVICE_REQUEST_UUID));
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.
the class ProcedureRequestFhirResourceProviderTest method updateProcedureRequest_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateProcedureRequest_shouldThrowInvalidRequestForMissingId() {
ServiceRequest noIdServiceRequest = new ServiceRequest();
when(serviceRequestService.update(eq(SERVICE_REQUEST_UUID), any(ServiceRequest.class))).thenThrow(InvalidRequestException.class);
resourceProvider.updateProcedureRequest(new IdType().setValue(SERVICE_REQUEST_UUID), (ProcedureRequest) VersionConvertor_30_40.convertResource(noIdServiceRequest, false));
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.
the class ProcedureRequestFhirResourceProviderWebTest method verifyUri.
private void verifyUri(String uri) throws Exception {
ProcedureRequest procedureRequest = new ProcedureRequest();
procedureRequest.setId(SERVICE_REQUEST_UUID);
when(service.searchForServiceRequests(any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(procedureRequest), 10, 1));
MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
Bundle results = readBundleResponse(response);
assertThat(results.getEntry(), notNullValue());
assertThat(results.getEntry(), not(empty()));
assertThat(results.getEntry().get(0).getResource(), notNullValue());
assertThat(results.getEntry().get(0).getResource().getIdElement().getIdPart(), equalTo(SERVICE_REQUEST_UUID));
}
use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.
the class ProcedureRequestFhirResourceProviderIntegrationTest method shouldReturnExistingProcedureRequestAsXML.
@Test
public void shouldReturnExistingProcedureRequestAsXML() throws Exception {
MockHttpServletResponse response = get("/ProcedureRequest/" + PROCEDURE_REQUEST_UUID).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
ProcedureRequest serviceRequest = readResponse(response);
assertThat(serviceRequest, notNullValue());
assertThat(serviceRequest.getIdElement().getIdPart(), equalTo(PROCEDURE_REQUEST_UUID));
assertThat(serviceRequest, validResource());
}
Aggregations