Search in sources :

Example 21 with FhirReference

use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateOutputReference.

// Task.output
@Test
public void toFhirResource_shouldTranslateOutputReference() {
    FhirTask task = new FhirTask();
    FhirTaskOutput output = new FhirTaskOutput();
    FhirReference outputReference = new FhirReference();
    Concept outputType = new Concept();
    outputReference.setType(FhirConstants.DIAGNOSTIC_REPORT);
    outputReference.setReference(DIAGNOSTIC_REPORT_UUID);
    outputType.setUuid(CONCEPT_UUID);
    output.setType(outputType);
    output.setValueReference(outputReference);
    task.setOutput(Collections.singleton(output));
    when(conceptTranslator.toFhirResource(outputType)).thenReturn(new CodeableConcept().setCoding(Collections.singletonList(new Coding().setCode(CONCEPT_UUID))));
    Task result = shouldTranslateReferenceToFhir(task, FhirConstants.DIAGNOSTIC_REPORT, DIAGNOSTIC_REPORT_UUID, output::setValueReference, t -> (Reference) t.getOutput().iterator().next().getValue());
    assertThat(result.getOutput(), hasSize(1));
    assertThat(result.getOutput().iterator().next().getType().getCoding().iterator().next().getCode(), equalTo(CONCEPT_UUID));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) FhirTaskOutput(org.openmrs.module.fhir2.model.FhirTaskOutput) Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Coding(org.hl7.fhir.r4.model.Coding) FhirReference(org.openmrs.module.fhir2.model.FhirReference) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 22 with FhirReference

use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.

the class FhirTaskTranslatorImplTest method shouldUpdateReferenceInOpenmrs.

private FhirTask shouldUpdateReferenceInOpenmrs(Task task, String refType, String refUuid, Consumer<Reference> setFhirReference, Function<FhirTask, FhirReference> getOpenmrsReference) {
    Reference fhirReference = new Reference().setReference(refUuid).setType(refType);
    setFhirReference.accept(fhirReference);
    FhirReference openmrsReference = new FhirReference();
    openmrsReference.setReference(refUuid);
    openmrsReference.setType(refType);
    FhirTask openmrsTask = new FhirTask();
    openmrsTask.setUuid(TASK_UUID);
    openmrsTask.setEncounterReference(new FhirReference());
    when(referenceTranslator.toOpenmrsType(any(Reference.class))).thenReturn(openmrsReference);
    FhirTask result = taskTranslator.toOpenmrsType(openmrsTask, task);
    FhirReference resultReference = getOpenmrsReference.apply(result);
    assertThat(resultReference, notNullValue());
    assertThat(resultReference.getReference(), equalTo(refUuid));
    assertThat(resultReference.getType(), equalTo(refType));
    return result;
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) Reference(org.hl7.fhir.r4.model.Reference) FhirReference(org.openmrs.module.fhir2.model.FhirReference) FhirReference(org.openmrs.module.fhir2.model.FhirReference)

Aggregations

FhirReference (org.openmrs.module.fhir2.model.FhirReference)22 FhirTask (org.openmrs.module.fhir2.model.FhirTask)13 Test (org.junit.Test)12 Reference (org.hl7.fhir.r4.model.Reference)11 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)6 Task (org.hl7.fhir.r4.model.Task)3 Concept (org.openmrs.Concept)3 FhirTaskOutput (org.openmrs.module.fhir2.model.FhirTaskOutput)3 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 Coding (org.hl7.fhir.r4.model.Coding)1 HibernateConceptDAO (org.openmrs.api.db.hibernate.HibernateConceptDAO)1