Search in sources :

Example 71 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnNotFoundWhenDeletingNonExistentDiagnosticReport.

@Test
public void shouldReturnNotFoundWhenDeletingNonExistentDiagnosticReport() throws Exception {
    MockHttpServletResponse response = delete("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isNotFound());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    OperationOutcome operationOutcome = readOperationOutcome(response);
    assertThat(operationOutcome, notNullValue());
    assertThat(operationOutcome.hasIssue(), is(true));
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 72 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldUpdateExistingDiagnosticReportAsXML.

@Test
public void shouldUpdateExistingDiagnosticReportAsXML() throws Exception {
    // get the existing record
    MockHttpServletResponse response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.XML).go();
    DiagnosticReport diagnosticReport = readResponse(response);
    // verify condition we will change
    assertThat(diagnosticReport.getStatus(), not(is(DiagnosticReport.DiagnosticReportStatus.FINAL)));
    // update the existing record
    diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.FINAL);
    // send the update to the server
    response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).xmlContent(toXML(diagnosticReport)).accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    // read the updated record
    DiagnosticReport updatedDiagnosticReport = readResponse(response);
    assertThat(updatedDiagnosticReport, notNullValue());
    assertThat(updatedDiagnosticReport.getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
    assertThat(updatedDiagnosticReport.getStatus(), is(DiagnosticReport.DiagnosticReportStatus.FINAL));
    assertThat(diagnosticReport, validResource());
    // double-check the record returned via get
    response = get("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
    DiagnosticReport reReadDiagnosticReport = readResponse(response);
    assertThat(reReadDiagnosticReport.getStatus(), is(DiagnosticReport.DiagnosticReportStatus.FINAL));
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 73 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnNotFoundWhenDiagnosticReportDoesNotExistAsXML.

@Test
public void shouldReturnNotFoundWhenDiagnosticReportDoesNotExistAsXML() throws Exception {
    MockHttpServletResponse response = get("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.XML).go();
    assertThat(response, isNotFound());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    OperationOutcome operationOutcome = readOperationOutcome(response);
    assertThat(operationOutcome, notNullValue());
    assertThat(operationOutcome.getIssue(), hasSize(greaterThanOrEqualTo(1)));
    assertThat(operationOutcome.getIssue(), hasItem(hasProperty("severity", equalTo(OperationOutcome.IssueSeverity.ERROR))));
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 74 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldSearchForAllDiagnosticReportsAsJson.

@Test
public void shouldSearchForAllDiagnosticReportsAsJson() throws Exception {
    MockHttpServletResponse response = get("/DiagnosticReport").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/DiagnosticReport/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(DiagnosticReport.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 75 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnNotFoundWhenDiagnosticReportDoesNotExistAsJson.

@Test
public void shouldReturnNotFoundWhenDiagnosticReportDoesNotExistAsJson() throws Exception {
    MockHttpServletResponse response = get("/DiagnosticReport/" + WRONG_DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
    assertThat(response, isNotFound());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    OperationOutcome operationOutcome = readOperationOutcome(response);
    assertThat(operationOutcome, notNullValue());
    assertThat(operationOutcome.getIssue(), hasSize(greaterThanOrEqualTo(1)));
    assertThat(operationOutcome.getIssue(), hasItem(hasProperty("severity", equalTo(OperationOutcome.IssueSeverity.ERROR))));
}
Also used : OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)133 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)115 FhirDiagnosticReport (org.openmrs.module.fhir2.model.FhirDiagnosticReport)65 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)52 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)50 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)42 Test (org.junit.jupiter.api.Test)39 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)39 DiagnosticReport (org.hl7.fhir.dstu3.model.DiagnosticReport)32 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)29 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)28 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)28 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)28 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)19 Reference (org.hl7.fhir.r4.model.Reference)19 Bundle (org.hl7.fhir.r4.model.Bundle)18 Resource (org.hl7.fhir.r4.model.Resource)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)16 Include (ca.uhn.fhir.model.api.Include)12 HashSet (java.util.HashSet)12