Search in sources :

Example 26 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderTest method updateProcedureRequest_shouldThrowMethodNotAllowedIfDoesNotExist.

@Test(expected = MethodNotAllowedException.class)
public void updateProcedureRequest_shouldThrowMethodNotAllowedIfDoesNotExist() {
    ServiceRequest wrongServiceRequest = new ServiceRequest();
    wrongServiceRequest.setId(WRONG_SERVICE_REQUEST_UUID);
    when(serviceRequestService.update(eq(WRONG_SERVICE_REQUEST_UUID), any(ServiceRequest.class))).thenThrow(MethodNotAllowedException.class);
    resourceProvider.updateProcedureRequest(new IdType().setValue(WRONG_SERVICE_REQUEST_UUID), (ProcedureRequest) VersionConvertor_30_40.convertResource(wrongServiceRequest, false));
}
Also used : ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 27 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderTest method getServiceRequestById_shouldReturnServiceRequest.

@Test
public void getServiceRequestById_shouldReturnServiceRequest() {
    IdType id = new IdType();
    id.setValue(SERVICE_REQUEST_UUID);
    when(serviceRequestService.get(SERVICE_REQUEST_UUID)).thenReturn(serviceRequest);
    ProcedureRequest result = resourceProvider.getProcedureRequestById(id);
    assertThat(result.isResource(), is(true));
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(SERVICE_REQUEST_UUID));
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 28 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderIntegrationTest method shouldReturnExistingProcedureRequestAsJson.

@Test
public void shouldReturnExistingProcedureRequestAsJson() throws Exception {
    MockHttpServletResponse response = get("/ProcedureRequest/" + PROCEDURE_REQUEST_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    ProcedureRequest serviceRequest = readResponse(response);
    assertThat(serviceRequest, notNullValue());
    assertThat(serviceRequest.getIdElement().getIdPart(), equalTo(PROCEDURE_REQUEST_UUID));
    assertThat(serviceRequest, validResource());
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 29 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderWebTest method getProcedureRequestById_shouldReturnServiceRequest.

@Test
public void getProcedureRequestById_shouldReturnServiceRequest() throws Exception {
    ServiceRequest serviceRequest = new ServiceRequest();
    serviceRequest.setId(SERVICE_REQUEST_UUID);
    when(service.get(SERVICE_REQUEST_UUID)).thenReturn(serviceRequest);
    MockHttpServletResponse response = get("/ProcedureRequest/" + SERVICE_REQUEST_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
    assertThat(readResponse(response).getIdElement().getIdPart(), equalTo(SERVICE_REQUEST_UUID));
}
Also used : ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 30 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project openmrs-module-fhir2 by openmrs.

the class ProcedureRequestFhirResourceProviderWebTest method setup.

@Before
@Override
public void setup() throws ServletException {
    resourceProvider = new ProcedureRequestFhirResourceProvider();
    resourceProvider.setServiceRequestService(service);
    ServiceRequest procedureRequest = new ServiceRequest();
    procedureRequest.setId(SERVICE_REQUEST_UUID);
    super.setup();
}
Also used : ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Before(org.junit.Before)

Aggregations

ProcedureRequest (org.hl7.fhir.dstu3.model.ProcedureRequest)23 Test (org.junit.jupiter.api.Test)12 Test (org.junit.Test)10 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 Reference (org.hl7.fhir.dstu3.model.Reference)5 Bundle (org.hl7.fhir.dstu3.model.Bundle)4 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)3 Identifier (org.hl7.fhir.dstu3.model.Identifier)2 Resource (org.hl7.fhir.dstu3.model.Resource)2 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Test (org.testng.annotations.Test)2 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)1 IParser (ca.uhn.fhir.parser.IParser)1 Create (ca.uhn.fhir.rest.annotation.Create)1 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 URI (java.net.URI)1