Search in sources :

Example 51 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateOutputReference.

@Test
public void toOpenmrsType_shouldTranslateOutputReference() {
    Task task = new Task();
    Task.TaskOutputComponent output = new Task.TaskOutputComponent();
    Reference outputReference = new Reference().setReference(DIAGNOSTIC_REPORT_UUID).setType(FhirConstants.DIAGNOSTIC_REPORT);
    CodeableConcept outputType = new CodeableConcept().setText("some text");
    Concept openmrsOutputType = new Concept();
    openmrsOutputType.setUuid(CONCEPT_UUID);
    output.setType(outputType).setValue(outputReference);
    task.setOutput(Collections.singletonList(output));
    when(conceptTranslator.toOpenmrsType(outputType)).thenReturn(openmrsOutputType);
    FhirTask result = shouldTranslateReferenceToOpenmrs(task, FhirConstants.DIAGNOSTIC_REPORT, DIAGNOSTIC_REPORT_UUID, output::setValue, t -> t.getOutput().iterator().next().getValueReference());
    assertThat(result.getOutput(), hasSize(1));
    assertThat(result.getOutput().iterator().next().getType().getUuid(), equalTo(CONCEPT_UUID));
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Reference(org.hl7.fhir.r4.model.Reference) FhirReference(org.openmrs.module.fhir2.model.FhirReference) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 52 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateIntent.

@Test
public void toOpenmrsType_shouldTranslateIntent() {
    Task task = new Task();
    task.setIntent(FHIR_TASK_INTENT);
    FhirTask result = taskTranslator.toOpenmrsType(task);
    assertThat(result, notNullValue());
    assertThat(result.getIntent(), equalTo(OPENMRS_TASK_INTENT));
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Test(org.junit.Test)

Example 53 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateFor.

// Task.for
@Test
public void toFhirResource_shouldTranslateFor() {
    FhirTask task = new FhirTask();
    shouldTranslateReferenceToFhir(task, FhirConstants.PATIENT, PATIENT_UUID, task::setForReference, Task::getFor);
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Test(org.junit.Test)

Example 54 with FhirTask

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

the class FhirTaskTranslatorImplTest method shouldTranslateReferenceToOpenmrs.

private FhirTask shouldTranslateReferenceToOpenmrs(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);
    when(referenceTranslator.toOpenmrsType(any(Reference.class))).thenReturn(openmrsReference);
    FhirTask result = taskTranslator.toOpenmrsType(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)

Example 55 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateUnsupportedIntent.

@Test
public void toOpenmrsType_shouldTranslateUnsupportedIntent() {
    Task task = new Task();
    task.setIntent(Task.TaskIntent.PLAN);
    FhirTask result = taskTranslator.toOpenmrsType(task);
    assertThat(result, notNullValue());
    assertThat(result.getIntent(), equalTo(FhirTask.TaskIntent.ORDER));
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Test(org.junit.Test)

Aggregations

FhirTask (org.openmrs.module.fhir2.model.FhirTask)66 Test (org.junit.Test)57 Task (org.hl7.fhir.r4.model.Task)47 FhirReference (org.openmrs.module.fhir2.model.FhirReference)16 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)10 Reference (org.hl7.fhir.r4.model.Reference)9 Concept (org.openmrs.Concept)9 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)7 Date (java.util.Date)5 FhirTaskInput (org.openmrs.module.fhir2.model.FhirTaskInput)4 FhirTaskOutput (org.openmrs.module.fhir2.model.FhirTaskOutput)4 Coding (org.hl7.fhir.r4.model.Coding)3 StringType (org.hl7.fhir.r4.model.StringType)3 ArrayList (java.util.ArrayList)2 Identifier (org.hl7.fhir.r4.model.Identifier)2 Provenance (org.hl7.fhir.r4.model.Provenance)2 Before (org.junit.Before)2 HibernateConceptDAO (org.openmrs.api.db.hibernate.HibernateConceptDAO)2 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)1 Collection (java.util.Collection)1