Search in sources :

Example 56 with FhirTask

use of org.openmrs.module.fhir2.model.FhirTask 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 57 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateLastModified.

// Task.lastModified
@Test
public void toFhirResource_shouldTranslateLastModified() {
    FhirTask task = new FhirTask();
    Date dateModified = new Date();
    task.setDateChanged(dateModified);
    Task result = taskTranslator.toFhirResource(task);
    assertThat(result, notNullValue());
    assertThat(result.getLastModified(), equalTo(dateModified));
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Date(java.util.Date) Test(org.junit.Test)

Example 58 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateStatus.

// Task.status
@Test
public void toFhirResource_shouldTranslateStatus() {
    FhirTask task = new FhirTask();
    task.setStatus(OPENMRS_TASK_STATUS);
    Task result = taskTranslator.toFhirResource(task);
    assertThat(result, notNullValue());
    assertThat(result.getStatus(), equalTo(FHIR_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 59 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateEncounter.

// Task.encounter
@Test
public void toFhirResource_shouldTranslateEncounter() {
    FhirTask task = new FhirTask();
    shouldTranslateReferenceToFhir(task, FhirConstants.ENCOUNTER, ENCOUNTER_UUID, task::setEncounterReference, Task::getEncounter);
}
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 60 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldTranslateOwner.

@Test
public void toOpenmrsType_shouldTranslateOwner() {
    Task task = new Task();
    shouldTranslateReferenceToOpenmrs(task, FhirConstants.ORGANIZATION, OPENELIS_ID, task::setOwner, FhirTask::getOwnerReference);
}
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