use of org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor.TaskUpdateInfoHolder 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();
}
}
Aggregations