Search in sources :

Example 1 with TaskUpdateBundleExtractor

use of org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskService method update.

public void update(String id, UpdateTaskRequestDto update, UserDto user) {
    Bundle taskBundle = getTask(id, Task.INCLUDE_FOCUS, Task.INCLUDE_OWNER, Organization.INCLUDE_ENDPOINT.setRecurse(true));
    TaskUpdateInfoHolder updateInfo = new TaskUpdateBundleExtractor(id).extract(taskBundle);
    Task task = updateInfo.getTask();
    ServiceRequest serviceRequest = updateInfo.getServiceRequest();
    TaskUpdateBundleFactory updateBundleFactory = new TaskUpdateBundleFactory();
    updateBundleFactory.setTask(task);
    updateBundleFactory.setServiceRequest(serviceRequest);
    updateBundleFactory.setStatus(update.getFhirStatus());
    updateBundleFactory.setStatusReason(update.getStatusReason());
    updateBundleFactory.setComment(update.getComment());
    updateBundleFactory.setUser(user);
    ehrClient.transaction().withBundle(updateBundleFactory.createUpdateBundle()).execute();
    try {
        cpService.sync(task, serviceRequest, updateInfo.getEndpoint());
    } catch (CpClientException exc) {
        ehrClient.transaction().withBundle(new TaskFailBundleFactory(task, serviceRequest, exc.getMessage()).createFailBundle()).execute();
    }
}
Also used : TaskFailBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskFailBundleFactory) Task(org.hl7.fhir.r4.model.Task) CpClientException(org.hl7.gravity.refimpl.sdohexchange.service.CpService.CpClientException) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) TaskUpdateBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor) TaskUpdateInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor.TaskUpdateInfoHolder) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) TaskUpdateBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskUpdateBundleFactory)

Aggregations

IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)1 Task (org.hl7.fhir.r4.model.Task)1 TaskUpdateBundleExtractor (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor)1 TaskUpdateInfoHolder (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor.TaskUpdateInfoHolder)1 TaskFailBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskFailBundleFactory)1 TaskUpdateBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskUpdateBundleFactory)1 CpClientException (org.hl7.gravity.refimpl.sdohexchange.service.CpService.CpClientException)1