Search in sources :

Example 41 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toOpenmrsType_shouldConvertSubject.

@Test
public void toOpenmrsType_shouldConvertSubject() {
    Patient subject = new Patient();
    Reference subjectReference = new Reference();
    subjectReference.setType(FhirConstants.PATIENT);
    diagnosticReport.setSubject(subjectReference);
    when(patientReferenceTranslator.toOpenmrsType(subjectReference)).thenReturn(subject);
    FhirDiagnosticReport result = translator.toOpenmrsType(diagnosticReport);
    assertThat(result.getSubject(), equalTo(subject));
}
Also used : FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Reference(org.hl7.fhir.r4.model.Reference) Patient(org.openmrs.Patient) Test(org.junit.Test)

Example 42 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldConvertIssued.

@Test
public void toFhirResource_shouldConvertIssued() {
    Date createdDate = new Date();
    fhirDiagnosticReport.setIssued(createdDate);
    DiagnosticReport result = translator.toFhirResource(fhirDiagnosticReport);
    assertThat(result.getIssued(), notNullValue());
    assertThat(result.getIssued(), equalTo(createdDate));
}
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 43 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldConvertUUID.

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

Example 44 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method setup.

@Before
public void setup() {
    translator = new DiagnosticReportTranslatorImpl();
    translator.setObservationReferenceTranslator(observationReferenceTranslator);
    translator.setConceptTranslator(conceptTranslator);
    translator.setEncounterReferenceTranslator(encounterReferenceTranslator);
    translator.setPatientReferenceTranslator(patientReferenceTranslator);
    // OpenMRS setup
    fhirDiagnosticReport = new FhirDiagnosticReport();
    Obs childObs = new Obs();
    childObs.setUuid(CHILD_UUID);
    fhirDiagnosticReport.setUuid(PARENT_UUID);
    fhirDiagnosticReport.getResults().add(childObs);
    // FHIR setup
    Reference obsReference = new Reference().setType("Observation").setReference("Observation/" + CHILD_UUID);
    diagnosticReport = new DiagnosticReport();
    diagnosticReport.setId(PARENT_UUID);
    diagnosticReport.addResult(obsReference);
    // Mocks for DiagnosticReport.result
    when(observationReferenceTranslator.toFhirResource(childObs)).thenReturn(obsReference);
    when(observationReferenceTranslator.toOpenmrsType(obsReference)).thenReturn(childObs);
}
Also used : Obs(org.openmrs.Obs) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Reference(org.hl7.fhir.r4.model.Reference) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) Before(org.junit.Before)

Example 45 with DIAGNOSTICREPORT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT in project openmrs-module-fhir2 by openmrs.

the class DiagnosticReportTranslatorImplTest method toFhirResource_shouldConvertResult.

@Test
public void toFhirResource_shouldConvertResult() {
    DiagnosticReport result = translator.toFhirResource(fhirDiagnosticReport);
    assertThat(result, notNullValue());
    assertThat(result.getId(), equalTo(PARENT_UUID));
    assertThat(result.getResult(), notNullValue());
    assertThat(result.getResult().size(), equalTo(1));
    assertThat(result.getResult(), contains(hasProperty("reference", equalTo("Observation/" + CHILD_UUID))));
}
Also used : 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