Search in sources :

Example 21 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateOwner.

// Task.owner
@Test
public void toFhirResource_shouldTranslateOwner() {
    FhirTask task = new FhirTask();
    shouldTranslateReferenceToFhir(task, FhirConstants.ORGANIZATION, OPENELIS_ID, task::setOwnerReference, Task::getOwner);
}
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 22 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldIgnoreUUIDForNewOpenmrsTask.

@Test
public void toOpenmrsType_shouldIgnoreUUIDForNewOpenmrsTask() {
    Task fhirTask = new Task();
    fhirTask.setId(TASK_UUID);
    FhirTask result = taskTranslator.toOpenmrsType(fhirTask);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), not(equalTo(TASK_UUID)));
}
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 23 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateNewOpenmrsTask.

@Test
public void toOpenmrsType_shouldTranslateNewOpenmrsTask() {
    Task fhirTask = new Task();
    FhirTask result = taskTranslator.toOpenmrsType(fhirTask);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), notNullValue());
}
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 24 with FhirTask

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

the class FhirTaskTranslatorImplTest method shouldTranslateReferenceToFhir.

/**
 * Helpers for reference associations
 */
private Task shouldTranslateReferenceToFhir(FhirTask task, String refType, String refUuid, Consumer<FhirReference> setOpenmrsReference, Function<Task, Reference> getFhirReference) {
    FhirReference openmrsReference = new FhirReference();
    openmrsReference.setType(refType);
    openmrsReference.setReference(refUuid);
    setOpenmrsReference.accept(openmrsReference);
    Reference fhirReference = new Reference().setReference(refUuid).setType(refType);
    when(referenceTranslator.toFhirResource(any(FhirReference.class))).thenReturn(fhirReference);
    Task result = taskTranslator.toFhirResource(task);
    Reference resultReference = getFhirReference.apply(result);
    assertThat(resultReference, notNullValue());
    assertThat(resultReference.getType(), equalTo(refType));
    assertThat(resultReference.getReference(), equalTo(refUuid));
    return result;
}
Also used : Task(org.hl7.fhir.r4.model.Task) 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 25 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateUnsupportedStatusToUnknown.

@Test
public void toOpenmrsType_shouldTranslateUnsupportedStatusToUnknown() {
    Task task = new Task();
    task.setStatus(Task.TaskStatus.ENTEREDINERROR);
    FhirTask result = taskTranslator.toOpenmrsType(task);
    assertThat(result, notNullValue());
    assertThat(result.getStatus(), equalTo(FhirTask.TaskStatus.UNKNOWN));
}
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