Search in sources :

Example 46 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldUpdateExistingOpenmrsTask.

@Test
public void toOpenmrsType_shouldUpdateExistingOpenmrsTask() {
    FhirTask task = new FhirTask();
    task.setUuid(TASK_UUID);
    Task fhirTask = taskTranslator.toFhirResource(task);
    fhirTask.setStatus(FHIR_NEW_TASK_STATUS);
    FhirTask result = taskTranslator.toOpenmrsType(task, fhirTask);
    assertThat(result, notNullValue());
    assertThat(result.getStatus(), equalTo(OPENMRS_NEW_TASK_STATUS));
}
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 47 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateEncounter.

@Test
public void toOpenmrsType_shouldTranslateEncounter() {
    Task task = new Task();
    shouldTranslateReferenceToOpenmrs(task, FhirConstants.ENCOUNTER, ENCOUNTER_UUID, task::setEncounter, FhirTask::getEncounterReference);
}
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 48 with FhirTask

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

the class FhirTaskTranslatorImplTest method shouldTranslateReferenceListToOpenmrs.

private void shouldTranslateReferenceListToOpenmrs(Task task, String refType, String refUuid, Consumer<List<Reference>> setFhirReference, Function<FhirTask, Set<FhirReference>> getOpenmrsReference) {
    Reference fhirReference = new Reference().setReference(refUuid).setType(refType);
    setFhirReference.accept(Collections.singletonList(fhirReference));
    FhirReference openmrsReference = new FhirReference();
    openmrsReference.setReference(refUuid);
    openmrsReference.setType(refType);
    when(referenceTranslator.toOpenmrsType(any(Reference.class))).thenReturn(openmrsReference);
    FhirTask result = taskTranslator.toOpenmrsType(task);
    Collection<FhirReference> resultReference = getOpenmrsReference.apply(result);
    assertThat(resultReference, notNullValue());
    assertThat(resultReference, hasSize(1));
    assertThat(resultReference.iterator().next().getReference(), equalTo(refUuid));
    assertThat(resultReference.iterator().next().getType(), equalTo(refType));
}
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 49 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldThrowExceptionWhenNullProvided.

@Test(expected = NullPointerException.class)
public void toOpenmrsType_shouldThrowExceptionWhenNullProvided() {
    Task fhirTask = new Task();
    fhirTask.setId(TASK_UUID);
    fhirTask.setStatus(FHIR_NEW_TASK_STATUS);
    taskTranslator.toOpenmrsType(null, fhirTask);
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Test(org.junit.Test)

Example 50 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateNullElements.

@Test
public void toOpenmrsType_shouldTranslateNullElements() {
    Task task = new Task().setBasedOn(null).setEncounter(null).setFor(null).setOwner(null).setInput(null).setOutput(null);
    FhirTask result = taskTranslator.toOpenmrsType(task);
    assertThat(result, 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)

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