use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderWebTest method deleteDiagnosticReport_shouldDeleteDiagnosticReport.
@Test
public void deleteDiagnosticReport_shouldDeleteDiagnosticReport() throws Exception {
org.hl7.fhir.r4.model.DiagnosticReport diagnosticReport = new org.hl7.fhir.r4.model.DiagnosticReport();
diagnosticReport.setId(DIAGNOSTIC_REPORT_UUID);
diagnosticReport.setStatus(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.CANCELLED);
when(service.delete(any(String.class))).thenReturn(diagnosticReport);
MockHttpServletResponse response = delete("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderWebTest method updateDiagnosticReport_shouldErrorForNonexistentDiagnosticReport.
@Test
public void updateDiagnosticReport_shouldErrorForNonexistentDiagnosticReport() throws Exception {
String jsonDiagnosticReport;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_DIAGNOSTIC_REPORT_WRONG_UUID_PATH)) {
Objects.requireNonNull(is);
jsonDiagnosticReport = IOUtils.toString(is, StandardCharsets.UTF_8);
}
when(service.update(eq(WRONG_UUID), any(DiagnosticReport.class))).thenThrow(new MethodNotAllowedException("DiagnosticReport " + WRONG_UUID + " does not exist"));
MockHttpServletResponse response = put("/DiagnosticReport/" + WRONG_UUID).jsonContent(jsonDiagnosticReport).accept(FhirMediaTypes.JSON).go();
assertThat(response, isMethodNotAllowed());
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderWebTest method updateDiagnosticReport_shouldUpdateExistingDiagnosticReport.
@Test
public void updateDiagnosticReport_shouldUpdateExistingDiagnosticReport() throws Exception {
String jsonDiagnosticReport;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_DIAGNOSTIC_REPORT_PATH)) {
Objects.requireNonNull(is);
jsonDiagnosticReport = IOUtils.toString(is, StandardCharsets.UTF_8);
}
DiagnosticReport diagnosticReport = new DiagnosticReport();
diagnosticReport.setId(DIAGNOSTIC_REPORT_UUID);
when(service.update(anyString(), any(DiagnosticReport.class))).thenReturn(diagnosticReport);
MockHttpServletResponse response = put("/DiagnosticReport/" + DIAGNOSTIC_REPORT_UUID).jsonContent(jsonDiagnosticReport).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderWebTest method createDiagnosticReport_shouldCreateNewDiagnosticReport.
@Test
public void createDiagnosticReport_shouldCreateNewDiagnosticReport() throws Exception {
String jsonDiagnosticReport;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_DIAGNOSTIC_REPORT_PATH)) {
Objects.requireNonNull(is);
jsonDiagnosticReport = IOUtils.toString(is, StandardCharsets.UTF_8);
}
DiagnosticReport diagnosticReport = new DiagnosticReport();
diagnosticReport.setId(DIAGNOSTIC_REPORT_UUID);
when(service.create(any(DiagnosticReport.class))).thenReturn(diagnosticReport);
MockHttpServletResponse response = post("/DiagnosticReport").jsonContent(jsonDiagnosticReport).accept(FhirMediaTypes.JSON).go();
assertThat(response, isCreated());
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnCountForDiagonosticReportAsJson.
@Test
public void shouldReturnCountForDiagonosticReportAsJson() throws Exception {
MockHttpServletResponse response = get("/DiagnosticReport?patient.given=Collet&_summary=count").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(2)));
}
Aggregations