Search in sources :

Example 36 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.

the class FhirDiagnosticReportServiceImplTest method updateTask_shouldThrowResourceNotFoundIfTaskDoesNotExist.

@Test(expected = ResourceNotFoundException.class)
public void updateTask_shouldThrowResourceNotFoundIfTaskDoesNotExist() {
    DiagnosticReport diagnosticReport = new DiagnosticReport();
    diagnosticReport.setId(WRONG_UUID);
    when(dao.get(WRONG_UUID)).thenReturn(null);
    service.update(WRONG_UUID, diagnosticReport);
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Test(org.junit.Test)

Example 37 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.

the class FhirDiagnosticReportServiceImplTest method searchForDiagnosticReports_shouldReturnCollectionOfDiagnosticReportsByParameters.

@Test
public void searchForDiagnosticReports_shouldReturnCollectionOfDiagnosticReportsByParameters() {
    FhirDiagnosticReport fhirDiagnosticReport = new FhirDiagnosticReport();
    fhirDiagnosticReport.setUuid(UUID);
    DiagnosticReport diagnosticReport = new DiagnosticReport();
    diagnosticReport.setId(UUID);
    List<FhirDiagnosticReport> fhirDiagnosticReports = new ArrayList<>();
    fhirDiagnosticReports.add(fhirDiagnosticReport);
    SearchParameterMap theParams = new SearchParameterMap();
    when(dao.getSearchResults(any(), any())).thenReturn(fhirDiagnosticReports);
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
    when(translator.toFhirResource(fhirDiagnosticReport)).thenReturn(diagnosticReport);
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    IBundleProvider results = service.searchForDiagnosticReports(null, null, null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasItem(hasProperty("id", equalTo(UUID))));
}
Also used : FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) ArrayList(java.util.ArrayList) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 38 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldTranslateOpenMrsDateChangedToLastUpdatedDate.

@Test
public void toFhirResource_shouldTranslateOpenMrsDateChangedToLastUpdatedDate() {
    fhirDiagnosticReport.setDateChanged(new Date());
    DiagnosticReport result = translator.toFhirResource(fhirDiagnosticReport);
    assertThat(result, notNullValue());
    assertThat(result.getMeta().getLastUpdated(), DateMatchers.sameDay(new Date()));
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Date(java.util.Date) Test(org.junit.Test)

Example 39 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldSetUnknownStatus.

@Test
public void toFhirResource_shouldSetUnknownStatus() {
    DiagnosticReport result = translator.toFhirResource(fhirDiagnosticReport);
    assertThat(result.getStatus(), equalTo(DiagnosticReport.DiagnosticReportStatus.UNKNOWN));
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Test(org.junit.Test)

Example 40 with DiagnosticReport

use of org.hl7.fhir.dstu3.model.DiagnosticReport in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldConvertEncounter.

@Test
public void toFhirResource_shouldConvertEncounter() {
    Encounter encounter = new Encounter();
    Reference encounterReference = new Reference();
    fhirDiagnosticReport.setEncounter(encounter);
    when(encounterReferenceTranslator.toFhirResource(encounter)).thenReturn(encounterReference);
    DiagnosticReport result = translator.toFhirResource(fhirDiagnosticReport);
    assertThat(result.getEncounter(), equalTo(encounterReference));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Encounter(org.openmrs.Encounter) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) 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