Search in sources :

Example 31 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateInputTextValue.

// Task.input
@Test
public void toFhirResource_shouldTranslateInputTextValue() {
    FhirTask task = new FhirTask();
    FhirTaskInput input = new FhirTaskInput();
    String inputVal = "some input value";
    Concept inputType = new Concept();
    inputType.setUuid(CONCEPT_UUID);
    input.setType(inputType);
    input.setValueText(inputVal);
    task.setInput(Collections.singleton(input));
    when(conceptTranslator.toFhirResource(inputType)).thenReturn(new CodeableConcept().setCoding(Collections.singletonList(new Coding().setCode(CONCEPT_UUID))));
    Task result = taskTranslator.toFhirResource(task);
    assertThat(result, notNullValue());
    assertThat(result.getInput(), hasSize(1));
    assertThat(result.getInput().iterator().next().getType().getCoding().iterator().next().getCode(), equalTo(CONCEPT_UUID));
    assertThat(result.getInput().iterator().next().getValue().toString(), equalTo(inputVal));
}
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) Coding(org.hl7.fhir.r4.model.Coding) FhirTaskInput(org.openmrs.module.fhir2.model.FhirTaskInput) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 32 with FhirTask

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

the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateIntent.

// Task.intent
@Test
public void toFhirResource_shouldTranslateIntent() {
    FhirTask task = new FhirTask();
    task.setIntent(OPENMRS_TASK_INTENT);
    Task result = taskTranslator.toFhirResource(task);
    assertThat(result, notNullValue());
    assertThat(result.getIntent(), equalTo(FHIR_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 33 with FhirTask

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

the class ProvenanceTranslatorImplTest method initDummyObjects.

@Before
public void initDummyObjects() {
    user = new User();
    user.setUuid(USER_UUID);
    person = new Person();
    person.setUuid(PERSON_UUID);
    person.setGender(GENDER);
    person.setCreator(user);
    person.setDateCreated(new Date());
    person.setChangedBy(user);
    person.setDateChanged(new Date());
    task = new FhirTask();
    task.setUuid(TASK_UUID);
    task.setCreator(user);
    task.setDateCreated(new Date());
    task.setChangedBy(user);
    task.setDateChanged(new Date());
}
Also used : User(org.openmrs.User) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Person(org.openmrs.Person) Date(java.util.Date) Before(org.junit.Before)

Example 34 with FhirTask

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

the class TaskTranslatorImpl method toFhirResource.

@Override
public Task toFhirResource(@Nonnull FhirTask openmrsTask) {
    notNull(openmrsTask, "The openmrsTask object should not be null");
    Task fhirTask = new Task();
    setFhirTaskFields(openmrsTask, fhirTask);
    fhirTask.addContained(provenanceTranslator.getCreateProvenance(openmrsTask));
    fhirTask.addContained(provenanceTranslator.getUpdateProvenance(openmrsTask));
    return fhirTask;
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask)

Example 35 with FhirTask

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

the class TaskTranslatorImpl method toOpenmrsType.

@Override
public FhirTask toOpenmrsType(@Nonnull Task fhirTask) {
    notNull(fhirTask, "The Task object should not be null");
    FhirTask openmrsTask = new FhirTask();
    setOpenmrsTaskFields(openmrsTask, fhirTask);
    return openmrsTask;
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask)

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