use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method createDiagnosticReport_shouldCreateNewDiagnosticReport.
@Test
public void createDiagnosticReport_shouldCreateNewDiagnosticReport() {
when(service.create(any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenReturn(diagnosticReport);
MethodOutcome result = resourceProvider.createDiagnosticReport(DiagnosticReport30_40.convertDiagnosticReport(diagnosticReport));
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(diagnosticReport.getId()));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method findDiagnosticReports_shouldReturnMatchingBundleOfDiagnosticReports.
@Test
public void findDiagnosticReports_shouldReturnMatchingBundleOfDiagnosticReports() {
when(service.searchForDiagnosticReports(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(diagnosticReport), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForDiagnosticReports(null, null, null, null, null, null, null, null, null, null);
List<DiagnosticReport> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.DIAGNOSTIC_REPORT));
assertThat(resultList.get(0).getId(), equalTo(UUID));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method findDiagnosticReports_shouldReturnMatchingBundleOfDiagnosticReportsWhenSubjectIsSpecified.
@Test
public void findDiagnosticReports_shouldReturnMatchingBundleOfDiagnosticReportsWhenSubjectIsSpecified() {
ReferenceAndListParam subject = new ReferenceAndListParam();
subject.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME)));
when(service.searchForDiagnosticReports(any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(diagnosticReport), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForDiagnosticReports(null, null, subject, null, null, null, null, null, null, null);
List<DiagnosticReport> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.DIAGNOSTIC_REPORT));
assertThat(resultList.get(0).getId(), equalTo(UUID));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method findDiagnosticReports_shouldNotReturnRelatedResourcesIfIncludeIsEmpty.
@Test
public void findDiagnosticReports_shouldNotReturnRelatedResourcesIfIncludeIsEmpty() {
HashSet<Include> includes = new HashSet<>();
when(service.searchForDiagnosticReports(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(diagnosticReport), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchForDiagnosticReports(null, null, null, null, null, null, null, null, null, includes);
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(results, notNullValue());
assertThat(resultList.size(), equalTo(1));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.DIAGNOSTIC_REPORT));
assertThat(((DiagnosticReport) resultList.iterator().next()).getId(), equalTo(UUID));
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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(), equalTo(UUID));
}
Aggregations