Search in sources :

Example 36 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderWebTest method deletePerson_shouldDeletePerson.

@Test
public void deletePerson_shouldDeletePerson() throws Exception {
    OperationOutcome retVal = new OperationOutcome();
    retVal.setId(PERSON_UUID);
    retVal.getText().setDivAsString("Deleted successfully");
    org.hl7.fhir.r4.model.Person person = new org.hl7.fhir.r4.model.Person();
    person.setId(PERSON_UUID);
    when(personService.delete(PERSON_UUID)).thenReturn(person);
    MockHttpServletResponse response = delete("/Person/" + PERSON_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) Person(org.hl7.fhir.dstu3.model.Person) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 37 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.

the class PractitionerFhirResourceProviderWebTest method deletePractitioner_shouldDeletePractitioner.

@Test
public void deletePractitioner_shouldDeletePractitioner() throws Exception {
    OperationOutcome retVal = new OperationOutcome();
    retVal.setId(PRACTITIONER_UUID);
    retVal.getText().setDivAsString("Deleted successfully");
    org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
    practitioner.setId(PRACTITIONER_UUID);
    when(practitionerService.delete(PRACTITIONER_UUID)).thenReturn(practitioner);
    MockHttpServletResponse response = delete("/Practitioner/" + PRACTITIONER_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 38 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.

the class GroupFhirResourceProviderWebTest method deleteGroup_shouldDeleteGroup.

@Test
public void deleteGroup_shouldDeleteGroup() throws Exception {
    OperationOutcome retVal = new OperationOutcome();
    retVal.setId(COHORT_UUID);
    retVal.getText().setDivAsString("Deleted Successfully");
    org.hl7.fhir.r4.model.Group group = new org.hl7.fhir.r4.model.Group();
    group.setId(COHORT_UUID);
    when(groupService.delete(COHORT_UUID)).thenReturn(group);
    MockHttpServletResponse response = delete("/Group/" + COHORT_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 39 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.

the class BaseFhirR3ResourceProviderWebTest method describeOperationOutcome.

@Override
public void describeOperationOutcome(Description mismatchDescription, IBaseOperationOutcome baseOperationOutcome) {
    if (baseOperationOutcome instanceof OperationOutcome) {
        OperationOutcome operationOutcome = (OperationOutcome) baseOperationOutcome;
        if (operationOutcome.hasIssue() && operationOutcome.getIssue().stream().anyMatch(o -> o.getSeverity().ordinal() <= OperationOutcome.IssueSeverity.WARNING.ordinal())) {
            mismatchDescription.appendText(" with message ");
            mismatchDescription.appendValue(operationOutcome.getIssue().stream().filter(o -> o.getSeverity().ordinal() <= OperationOutcome.IssueSeverity.WARNING.ordinal()).map(OperationOutcome.OperationOutcomeIssueComponent::getDiagnostics).collect(Collectors.joining(". ")));
        }
    }
}
Also used : Description(org.hamcrest.Description) FhirRestServlet(org.openmrs.module.fhir2.web.servlet.FhirRestServlet) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBaseOperationOutcome(org.hl7.fhir.instance.model.api.IBaseOperationOutcome) FhirR3RestServlet(org.openmrs.module.fhir2.web.servlet.FhirR3RestServlet) Collectors(java.util.stream.Collectors) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) BaseFhirResourceProviderWebTest(org.openmrs.module.fhir2.providers.BaseFhirResourceProviderWebTest) FhirContext(ca.uhn.fhir.context.FhirContext) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IBaseOperationOutcome(org.hl7.fhir.instance.model.api.IBaseOperationOutcome) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome)

Example 40 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome in project openmrs-module-fhir2 by openmrs.

the class PatientFhirResourceProviderWebTest method deletePatient_shouldDeletePatient.

@Test
public void deletePatient_shouldDeletePatient() throws Exception {
    OperationOutcome retVal = new OperationOutcome();
    retVal.setId(PATIENT_UUID);
    retVal.getText().setDivAsString("Deleted successfully");
    Patient patient = new Patient();
    patient.setId(PATIENT_UUID);
    when(patientService.delete(PATIENT_UUID)).thenReturn(patient);
    MockHttpServletResponse response = delete("/Patient/" + PATIENT_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
Also used : OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) Patient(org.hl7.fhir.r4.model.Patient) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)214 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)181 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)161 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)144 Test (org.junit.jupiter.api.Test)42 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)31 IOException (java.io.IOException)26 IBaseOperationOutcome (org.hl7.fhir.instance.model.api.IBaseOperationOutcome)24 OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)23 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)22 OperationOutcome (org.hl7.fhir.r5.model.OperationOutcome)20 IdType (org.hl7.fhir.dstu3.model.IdType)17 IdType (org.hl7.fhir.r4.model.IdType)17 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 URISyntaxException (java.net.URISyntaxException)13 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 Header (org.apache.http.Header)11