Search in sources :

Example 6 with FhirTask

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

the class FhirTaskDaoImplTest method searchForTasks_shouldHandleNullBasedOnRefs.

@Test
public void searchForTasks_shouldHandleNullBasedOnRefs() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference nullTypeRef = new FhirReference();
    nullTypeRef.setType(null);
    nullTypeRef.setReference(BASED_ON_ORDER_UUID);
    toUpdate.setOwnerReference(nullTypeRef);
    toUpdate.setBasedOnReferences(Collections.singleton(nullTypeRef));
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getBasedOnReferences(), notNullValue());
    assertThat(result.getBasedOnReferences().size(), greaterThan(0));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirReference(org.openmrs.module.fhir2.model.FhirReference) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 7 with FhirTask

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

the class FhirTaskDaoImplTest method saveTask_shouldUpdateEncounterReference.

@Test
public void saveTask_shouldUpdateEncounterReference() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference forReference = new FhirReference();
    forReference.setType(FhirConstants.ENCOUNTER);
    forReference.setReference(ENCOUNTER_UUID);
    forReference.setName("TEMP");
    toUpdate.setEncounterReference(forReference);
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getEncounterReference(), notNullValue());
    assertThat(result.getEncounterReference().getId(), notNullValue());
    assertThat(result.getEncounterReference().getType(), equalTo(FhirConstants.ENCOUNTER));
    assertThat(result.getEncounterReference().getReference(), equalTo(ENCOUNTER_UUID));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirReference(org.openmrs.module.fhir2.model.FhirReference) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 8 with FhirTask

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

the class FhirTaskDaoImplTest method getTaskByUuid_shouldRetrieveTaskByUuid.

@Test
public void getTaskByUuid_shouldRetrieveTaskByUuid() {
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), equalTo(TASK_UUID));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 9 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldUpdateIntentOnExistingTask.

@Test
public void toOpenmrsType_shouldUpdateIntentOnExistingTask() {
    FhirTask task = new FhirTask();
    task.setIntent(null);
    task.setUuid(TASK_UUID);
    Task fhirTask = taskTranslator.toFhirResource(task);
    fhirTask.setIntent(FHIR_TASK_INTENT);
    FhirTask result = taskTranslator.toOpenmrsType(task, fhirTask);
    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 10 with FhirTask

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

the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldSetOpenmrsTaskUUIDWhenNull.

@Test
public void toOpenmrsType_shouldSetOpenmrsTaskUUIDWhenNull() {
    FhirTask task = new FhirTask();
    task.setUuid(null);
    Task fhirTask = taskTranslator.toFhirResource(task);
    fhirTask.setId(TASK_UUID);
    FhirTask result = taskTranslator.toOpenmrsType(task, fhirTask);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), 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)

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