Search in sources :

Example 51 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.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()));
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 52 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.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));
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) Test(org.junit.Test)

Example 53 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Test(org.junit.Test)

Example 54 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.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));
}
Also used : Include(ca.uhn.fhir.model.api.Include) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 55 with DiagnosticReport

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(), equalTo(UUID));
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) IdType(org.hl7.fhir.dstu3.model.IdType) 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