use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateDiagnosticReport_shouldThrowInvalidRequestForMissingId() {
DiagnosticReport noIdDiagnosticReport = new DiagnosticReport();
when(service.update(UUID, noIdDiagnosticReport)).thenThrow(InvalidRequestException.class);
resourceProvider.updateDiagnosticReport(new IdType().setValue(UUID), noIdDiagnosticReport);
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method getDiagnosticReportById_shouldReturnMatchingDiagnosticReport.
@Test
public void getDiagnosticReportById_shouldReturnMatchingDiagnosticReport() {
IdType id = new IdType();
id.setValue(UUID);
when(service.get(UUID)).thenReturn(diagnosticReport);
DiagnosticReport result = resourceProvider.getDiagnosticReportById(id);
assertThat(result, notNullValue());
assertThat(result.isResource(), is(true));
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(UUID));
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method deleteDiagnosticReport_shouldDeleteRequestedDiagnosticReport.
@Test
public void deleteDiagnosticReport_shouldDeleteRequestedDiagnosticReport() {
when(service.delete(UUID)).thenReturn(diagnosticReport);
OperationOutcome result = resourceProvider.deleteDiagnosticReport(new IdType().setValue(UUID));
assertThat(result, notNullValue());
assertThat(result.getIssue(), notNullValue());
assertThat(result.getIssueFirstRep().getSeverity(), equalTo(OperationOutcome.IssueSeverity.INFORMATION));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getCode(), equalTo("MSG_DELETED"));
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist.
@Test(expected = MethodNotAllowedException.class)
public void updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist() {
DiagnosticReport wrongDiagnosticReport = new DiagnosticReport();
wrongDiagnosticReport.setId(WRONG_UUID);
when(service.update(WRONG_UUID, wrongDiagnosticReport)).thenThrow(MethodNotAllowedException.class);
resourceProvider.updateDiagnosticReport(new IdType().setValue(WRONG_UUID), wrongDiagnosticReport);
}
use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method findDiagnosticReports_shouldReturnRelatedResourcesIfIncludeIsSpecified.
@Test
public void findDiagnosticReports_shouldReturnRelatedResourcesIfIncludeIsSpecified() {
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("DiagnosticReport:patient"));
when(service.searchForDiagnosticReports(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includes)))).thenReturn(new MockIBundleProvider<>(Arrays.asList(diagnosticReport, new Patient()), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForDiagnosticReports(null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.size(), greaterThanOrEqualTo(2));
assertThat(resultList.get(1).fhirType(), is(FhirConstants.PATIENT));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.DIAGNOSTIC_REPORT));
assertThat(((DiagnosticReport) resultList.iterator().next()).getId(), equalTo(UUID));
}
Aggregations