Search in sources :

Example 6 with ProcedureRequest

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));
}
Also used : MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 7 with ProcedureRequest

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));
}
Also used : MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Test(org.junit.Test)

Example 8 with ProcedureRequest

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));
}
Also used : ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 9 with ProcedureRequest

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));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 10 with ProcedureRequest

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());
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

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