Search in sources :

Example 41 with FhirTask

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

the class FhirTaskDaoImplTest method saveTask_shouldUpdateTaskStatus.

@Test
public void saveTask_shouldUpdateTaskStatus() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    toUpdate.setStatus(NEW_STATUS);
    dao.createOrUpdate(toUpdate);
    assertThat(dao.get(TASK_UUID).getStatus(), equalTo(NEW_STATUS));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 42 with FhirTask

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

the class FhirTaskDaoImplTest method saveTask_shouldUpdateBasedOnReferences.

@Test
public void saveTask_shouldUpdateBasedOnReferences() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference basedOnReference = new FhirReference();
    basedOnReference.setType(FhirConstants.SERVICE_REQUEST);
    basedOnReference.setReference(BASED_ON_ORDER_UUID);
    basedOnReference.setName("TEMP");
    toUpdate.setBasedOnReferences(Collections.singleton(basedOnReference));
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getBasedOnReferences(), notNullValue());
    assertThat(result.getBasedOnReferences().size(), greaterThan(0));
    assertThat(result.getBasedOnReferences(), hasItem(hasProperty("type", equalTo(FhirConstants.SERVICE_REQUEST))));
    assertThat(result.getBasedOnReferences(), hasItem(hasProperty("reference", equalTo(BASED_ON_ORDER_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 43 with FhirTask

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

the class FhirTaskDaoImplTest method saveTask_shouldUpdateOwnerReference.

@Test
public void saveTask_shouldUpdateOwnerReference() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference ownerReference = new FhirReference();
    ownerReference.setType(FhirConstants.PRACTITIONER);
    ownerReference.setReference(USER_UUID);
    ownerReference.setName("TEMP");
    toUpdate.setOwnerReference(ownerReference);
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getOwnerReference(), notNullValue());
    assertThat(result.getOwnerReference().getId(), notNullValue());
    assertThat(result.getOwnerReference().getType(), equalTo(FhirConstants.PRACTITIONER));
    assertThat(result.getOwnerReference().getReference(), equalTo(USER_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 44 with FhirTask

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

the class FhirTaskDaoImplTest method saveTask_shouldUpdateForReference.

@Test
public void saveTask_shouldUpdateForReference() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference forReference = new FhirReference();
    forReference.setType(FhirConstants.PATIENT);
    forReference.setReference(PATIENT_ID);
    forReference.setName("TEMP");
    toUpdate.setForReference(forReference);
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getForReference(), notNullValue());
    assertThat(result.getForReference().getId(), notNullValue());
    assertThat(result.getForReference().getType(), equalTo(FhirConstants.PATIENT));
    assertThat(result.getForReference().getReference(), equalTo(PATIENT_ID));
}
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 45 with FhirTask

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

the class ProvenanceTranslatorImplTest method shouldGetCreateProvenanceForOpenmrsMetaWithoutChange.

@Test
public void shouldGetCreateProvenanceForOpenmrsMetaWithoutChange() {
    FhirTask task = new FhirTask();
    task.setUuid(TASK_UUID);
    task.setCreator(user);
    task.setDateCreated(new Date());
    Provenance provenance = taskProvenanceTranslator.getCreateProvenance(task);
    assertThat(provenance, notNullValue());
    assertThat(provenance.getId(), notNullValue());
}
Also used : Provenance(org.hl7.fhir.r4.model.Provenance) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Date(java.util.Date) 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