Update Task Status

Updating Task Status

Overview

The updateTaskStatus method in the b.well SDK is used to update the status of a specific Task. It allows for changing a Task's status to a new state, based on the TaskStatus enum values.

Method Signature

suspend fun updateTaskStatus(request: UpdateTaskRequest): BWellResult<Task>
  • request: An object containing the ID of the Task and the desired new status.
  • BWellResult<Task>: Returns the updated Task resource along with FHIR OperationOutcome.
Task Status

The following Task Status enum values are supported:

  1. DRAFT: The task is not ready for action.
  2. REQUESTED: The task is ready and awaiting action.
  3. RECEIVED: A potential performer is considering the task.
  4. ACCEPTED: The task is agreed to but not started.
  5. REJECTED: The task is declined before any action.
  6. READY: The task is prepared for performance. Please note: Tasks in READY status can only be updated to COMPLETED or CANCELLED.
  7. CANCELLED: The task was not completed.
  8. IN_PROGRESS: The task has been started but not finished.
  9. ON_HOLD: The task has started but is paused.
  10. FAILED: The task was attempted but failed.
  11. COMPLETED: The task has been finished.
  12. ENTERED_IN_ERROR: The task should not have existed.

Example Usage

The following example shows a common implementation of the updateTaskStatus method.

In this example, the task status is updated from READY to COMPLETED.

suspend fun updateTask() {
    val updateTaskRequest = UpdateTaskRequest.Builder()
        .taskId("taskId") // Replace with the actual Task ID
        .newStatus(TaskStatus.COMPLETED) // Set the desired new status
        .build()

    val updateResult = bwellSdk.updateTaskStatus(updateTaskRequest)
    updateResult.let {
        when (it.status) {
            Status.SUCCESS -> {
                // Task status updated successfully
            }
            else -> {
                // Handle unsuccessful update
            }
        }
    }
}