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:
- DRAFT: The task is not ready for action.
- REQUESTED: The task is ready and awaiting action.
- RECEIVED: A potential performer is considering the task.
- ACCEPTED: The task is agreed to but not started.
- REJECTED: The task is declined before any action.
- READY: The task is prepared for performance. Please note: Tasks in
READYstatus can only be updated toCOMPLETEDorCANCELLED. - CANCELLED: The task was not completed.
- IN_PROGRESS: The task has been started but not finished.
- ON_HOLD: The task has started but is paused.
- FAILED: The task was attempted but failed.
- COMPLETED: The task has been finished.
- 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
}
}
}
}Updated about 2 months ago
