Retrieve Tasks for a User
Retrieving User Tasks
Overview
The getTasks method in the b.well SDK is designed for retrieving personalized tasks for users, which can include general health activities, user specific care needs, or next best actions. These tasks are FHIR-compliant and can be linked to other FHIR resources or external content.
Method Signature
suspend fun getTasks(request: TasksRequest): BWellResult<Task>request: ATasksRequestobject containing search criteria.BWellResult<Task>: Returns a collection of FHIR Task resources, FHIR OperationOutcome, and paging information.
TasksRequest Object
TasksRequest ObjectThe TasksRequest object facilitates precise task searches with various parameters:
- Id: Filters to a specific Task with the given ID, if provided.
- ActivityId: Narrows results to Tasks based on listed ActivityDefinition IDs, if provided.
- ActivityType: Filters Tasks that match provided activity type codes, if provided.
- ActivityTopic: Focuses on Tasks with matching topic codes, if provided.
- Status: Searches for Tasks with a specified status. Tasks that should be displayed to a user as prompts for action typically have the status
READY. Please reference Update Task Status for a full list of supported status values. - EnrichContent: If true, retrieves related CMS content, adding it to the Task's extension field.
- SmartSort: Enables prioritization of Tasks for improved user consumption.
- ContentLanguage: Specifies the language of the content to be searched.
Please note that in some cases, search options must be used in combination in order to return results. For example:
- When using
.enrichContent(true)you must also search by.id("taskId")or.activityId("activityId")to return specificextensionelements (see below Content Extension Elements for more detail) - When requesting translated content by using a parameter such as
.contentLanguage("es")you must also include.enrichContent(true)in order for the retrieved content to be translated.
Example Usage
The following is an example of a common implementation of the getTasks method.
First, getTasks is called to retrieve a list of tasks (aka activities) for the given user.
Once the list is retrieved, getTasks can then be used to retrieve details about a specific task.
// Retrieve all tasks for a user
private fun getTasks() {
val taskRequest = TasksRequest.Builder() // Build the task request
.smartSort(true) // sort list based on prioritization
.status(listOf(TaskStatus.READY)) // retrieve tasks of status READY
.page(0)
.pageSize(100)
.build()
healthJourneyViewModel.getTasks(taskRequest)
viewLifecycleOwner.lifecycleScope.launch {
healthJourneyViewModel.taskResults.collect { result ->
if (result != null) {
Log.e("result","health journey result>>>>>>>>>>>>>>> "+result)
setAdapter(result)
}
}
}
}
// Retrieve details of a specific task
private fun showDetails() {
val request = TasksRequest.Builder()
.id(taskId) // Retrieve a specific task based on the taskId returned above. activityId can also be used.
.enrichContent(true) // Include task details
.build()
healthJourneyViewModel.getTasks(request)
viewLifecycleOwner.lifecycleScope.launch {
healthJourneyViewModel.taskResults.collect { result ->
if (result != null) {
when (result) {
is BWellResult.ResourceCollection -> {
val dataList = result.data
for (i in 0 until (dataList?.size ?: 0)) {
val task = dataList?.get(i)
Understanding the Task Object in b.well SDK
Task Object in b.well SDKOverview
The Task object in the b.well SDK represents a task to be performed, encapsulating various details and attributes related to healthcare tasks.
Properties and Types
resourceType(String): Type of the FHIR resource.id(String): Unique identifier of the Task.identifier(List<Identifier>): Task Instance Identifiers.- Includes
activityId,activityName,activityTitle,sourceId,uuid.
- Includes
code(CodeableConcept): TaskactivityType.meta(Meta): Metadata about the Task.- Includes
activityClassinmeta.tag.
- Includes
extension(List<Extension>): Optional Extensions Element.instantiatesCanonical(String): Formal definition of the task.status(TaskStatus): Current status of the task.description(String): Human-readable explanation of the task.executionPeriod(Period): Start and end time of task execution.lastModified(Date): Task Last Modified Date.basedOn(List<Reference>): Request fulfilled by this task.focus(Reference): Focus of the task.for(Reference): Beneficiary of the Task.
Task activityType and activityClass
activityType and activityClassThe Task activityType declares the type of activity of the task.
The Task activityClass further identifies the specific topic of the task. Found in meta.tag.
The following table outlines the specific activityType and activityClass that can be expected.
| Activity (Insight) | activityType (Type) | activityClass (Topic) |
|---|---|---|
| Care Needs | care-need | Prevention |
| Next Best Actions | Next Best Action | Next Best Action |
| Condition/Disease Management | health-activity | Condition/DiseaseManagement |
| Emotional Health | health-activity | EmotionalHealth |
| Fitness | health-activity | Fitness |
| Healthcare Education | health-activity | HealthcareEducation |
| Nutrition | health-activity | Nutrition |
| Sleep | health-activity | Sleep |
| General | Other | Other |
Tasks extension Element
extension ElementOverview
The getTasks method in the b.well SDK includes task extensions that enrich task data with visual elements and interactive features.
Image/Icon URLs
- Content Image and Icon: URLs for images and icons are provided via the API with a time-limited security key for S3 bucket access.
- Timely Retrieval: It's essential to retrieve and use these URLs shortly after fetching the Task (preferably within minutes) as the access expires. Avoid holding onto these URLs for long-term use.
Insights and Layout
- Current Format: All Insights, such as Care Needs, Health Activities, and Next Best Actions, follow the same format.
- Layout Components:
- Image (
contentImage): Visual representation. - Title (
identifier/activityTitle): Descriptive title of the task. - Description (
contentDescription): Detailed explanation. - Call to Action Button (
contentButtonText): For MVP Insights, this button indicates an intent to perform the activity, changing to a success message upon completion. Future Insights may redirect users within the app for task completion. - References (
contentReferences): Additional resources, shown only when available.
- Image (
Future Considerations
- Video Links: Guidance on handling video links will be provided if they are included in future tasks and Insights. Currently, no MVP Insights involve video links.
Content Extension Definitions
| System | Use | Example Value |
|---|---|---|
| contentIcon | Returned in list view when enrichedContent = true | valueString = "https://bwell-prod-mstarvac-content-management-default-ue1.s3.amazonaws.com/media/original_images/Property_1Fill_311.png?AWSAccessKeyId=ASIAV2SWM3JT75B7KRI2&Signature=rQqF%2FmmQq7TnLynd%2BhZAOrWs8oE%3D&x-amz-security-token=IQoJb3JpZ2luX2VjELj%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCpCrXJuXv%2Bu0YHf%2FYfQd4PNempKWD%2FuhsqesVC1lYh2gIgbenAD1yh434EUpcm%2FBP6nrv7GbR4IwZO6VwRKi7E9dQqmAUIkf%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAFGgw0MDA2ODY4OTc3NjciDHrrqerAtL%2FVsGAXmyrsBGQyYyUL%2B9vMAt54Haj8GY5r80Xikr697hNt63ChPWkg9cIBKNTb0xqqYuohHQjl0a48oOvaAolv5nvvxgD9yBCuMQnjgNiKqhuul%2F3k5aD0wsc%2FEQZ4V%2FCOKr7bNaQBoS5aU3Vg087Njdo7B6K1UDHES4X2DZn2zCPKZ5lG12bY2peP3fqFGTK9JJmi4Dpn98Tqt0qC3tswvx6NsdyTMj%2FLcom49lvSy4vTo%2Fs8iRRLlM%2Bb9MlXxZLK%2B%2Bf9V9i7iGwNRQIhKc6RkBocgiZNIUOyxhjm8MN3KI%2By1jlcLE1bGy8x4dYJbaUrzEL05JQ73%2BsXDp3H5%2Fdpq4kuLiFTnavHre7EdOpGJRFT0OFnjDXqB4%2FpH1R73hW9owsNnGbo2ETrQEpiCorH4rlu0QHg1mwzEpzcotUCGyWBGmFd6YH3EWYmJs8CaoNFD6UjgmDPH3XQ13DgzCsn%2BjVcElbpcenhUqTGZJ0QuUBjSIA%2BuP86F0dc5IA1syPp1iPguc1sn6ZJQhizlQmaEV1aZcpWmVIXlGj0fN%2BJ9HgDJqwYqLK8%2FFQ%2FtKSI7ZYdXWNy59uIXs4Cexadzh8TfDrWYY2sCgQv0aDllmJQt5q3DTjuW6kV2p0ztCnsXBhAUjnXbjsEOuw5GA80%2FC%2BDCzQV9WgmoqdF1rCaTEuLwbKR5aEY%2BleWL5g1sZRTWi0c%2BOVkpNO8LCII8SJZPFhRkn52LpcSH0vjl%2FUDjEpou9zQCY1t6MiKLOD2GuME7aE7HzkT8Pe%2BBunkB1DaK90Rx%2BRWC9N%2BJ6alqyB3Oz5CmWSwjFYo3br5vfgjqdAQ9Vx%2BGIpeMJjDs64GOpsBzLqzkes2Aivv3OW71hqdLpB6k5Uj8w5tDvH5VfpZjMrHn9YxGJ%2FH8EaSZVfUrgFNEeI2rF%2FKxrLaYKcNVC2w0hVlkIhsRF3B5uoFZ%2F%2B5Zt3nIgyTLT7n2r%2FNu9dtlnv%2BFDSHHcC81ObEr25X3MDXS5CTk32m292nSe8iEtS0xDVqU1EN6xByt1vr579TAP55Ufa%2BCefXihYeO1o%3D&Expires=1707931155" |
| contentReferences | Returned for specific Task when searching by id and enrichContent = true | valueString = "<p data-block-key=\"ob6k0\">Centers for Disease Control and Prevention. <a href=\"https://www.cdc.gov/nccdphp/dnpao/features/healthy-eating-tips/index.html\">Healthy Eating Tips.</a></p>" |
| contentButtonText | Returned in list view when enrichedContent = true | valueString = "Will do" |
| contentImage | Returned for specific Task when searching by id and enrichContent = true | valueString = "https://bwell-prod-mstarvac-content-management-default-ue1.s3.amazonaws.com/media/original_images/pexels-mikhail-nilov-6707378.jpg?AWSAccessKeyId=ASIAV2SWM3JT75B7KRI2&Signature=Iv1bryryrl%2BO4C5Bzvx1%2Bn0i%2BAs%3D&x-amz-security-token=IQoJb3JpZ2luX2VjELj%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCpCrXJuXv%2Bu0YHf%2FYfQd4PNempKWD%2FuhsqesVC1lYh2gIgbenAD1yh434EUpcm%2FBP6nrv7GbR4IwZO6VwRKi7E9dQqmAUIkf%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAFGgw0MDA2ODY4OTc3NjciDHrrqerAtL%2FVsGAXmyrsBGQyYyUL%2B9vMAt54Haj8GY5r80Xikr697hNt63ChPWkg9cIBKNTb0xqqYuohHQjl0a48oOvaAolv5nvvxgD9yBCuMQnjgNiKqhuul%2F3k5aD0wsc%2FEQZ4V%2FCOKr7bNaQBoS5aU3Vg087Njdo7B6K1UDHES4X2DZn2zCPKZ5lG12bY2peP3fqFGTK9JJmi4Dpn98Tqt0qC3tswvx6NsdyTMj%2FLcom49lvSy4vTo%2Fs8iRRLlM%2Bb9MlXxZLK%2B%2Bf9V9i7iGwNRQIhKc6RkBocgiZNIUOyxhjm8MN3KI%2By1jlcLE1bGy8x4dYJbaUrzEL05JQ73%2BsXDp3H5%2Fdpq4kuLiFTnavHre7EdOpGJRFT0OFnjDXqB4%2FpH1R73hW9owsNnGbo2ETrQEpiCorH4rlu0QHg1mwzEpzcotUCGyWBGmFd6YH3EWYmJs8CaoNFD6UjgmDPH3XQ13DgzCsn%2BjVcElbpcenhUqTGZJ0QuUBjSIA%2BuP86F0dc5IA1syPp1iPguc1sn6ZJQhizlQmaEV1aZcpWmVIXlGj0fN%2BJ9HgDJqwYqLK8%2FFQ%2FtKSI7ZYdXWNy59uIXs4Cexadzh8TfDrWYY2sCgQv0aDllmJQt5q3DTjuW6kV2p0ztCnsXBhAUjnXbjsEOuw5GA80%2FC%2BDCzQV9WgmoqdF1rCaTEuLwbKR5aEY%2BleWL5g1sZRTWi0c%2BOVkpNO8LCII8SJZPFhRkn52LpcSH0vjl%2FUDjEpou9zQCY1t6MiKLOD2GuME7aE7HzkT8Pe%2BBunkB1DaK90Rx%2BRWC9N%2BJ6alqyB3Oz5CmWSwjFYo3br5vfgjqdAQ9Vx%2BGIpeMJjDs64GOpsBzLqzkes2Aivv3OW71hqdLpB6k5Uj8w5tDvH5VfpZjMrHn9YxGJ%2FH8EaSZVfUrgFNEeI2rF%2FKxrLaYKcNVC2w0hVlkIhsRF3B5uoFZ%2F%2B5Zt3nIgyTLT7n2r%2FNu9dtlnv%2BFDSHHcC81ObEr25X3MDXS5CTk32m292nSe8iEtS0xDVqU1EN6xByt1vr579TAP55Ufa%2BCefXihYeO1o%3D&Expires=1707931155" |
| contentDescription | Returned for specific Task when searching by id and enrichContent = true | valueString = "<p data-block-key=\"nmj9d\">Get inspired to create an easy, healthy smoothie.</p><ul><li data-block-key=\"prm4\"><b>Start with veggies.</b> Try blending nutrient-dense greens like spinach, kale, or arugula. If you're in the mood for something more hydrating, opt for cucumbers or celery.</li><li data-block-key=\"6tp4l\"><b>Mix in your favorite fruits</b>. Add berries such as blueberries, blackberries, and raspberries. Or go for tropical fruits like mango, pineapple, or papaya.</li><li data-block-key=\"bit8v\"><b>Fill up on protein</b>. Greek and plain yogurt can add an extra nutrition boost. Or add a scoop of whey or plant-based protein powder.</li><li data-block-key=\"1qqeh\"><b>Add some healthy fats.</b> Nuts, seeds, nut butters, or avocado are great options for added flavor and nutrients.</li><li data-block-key=\"6dpv3\"><b>Add a liquid.</b> Try ice, milk, or an alternative milk such as almond, soy, or cashew milk. Coconut water or 100% juice works too.</li></ul>" |
| contentTeaser | Returned in list view when enrichedContent = true | valueString = "Feel confident in getting more information about your health" |
| contentAuthor | Returned for given Task when searching by id and enrichContent = true | valueString = "Katiecleary" |
| sourceType | Returned in list view when enrichedContent = true | valueString = "cql-engine" |
| activityCompletionMethod | Returned in list view when enrichedContent = true | valueString = "Manual" |
| activityContentId | Returned in list view when enrichedContent = true | valueString = 36f5b850-40ae-11e9-a297-04d3b0f4d058 |
| activityPriority | Returned in list view when enrichedContent = true | valueInteger = 1000 |
| activityPoints | Returned in list view when enrichedContent = true | valueInteger = "300" |
Updated about 2 months ago
