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));
}
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));
}
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));
}
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);
}
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))));
}
Aggregations