Awell Health Developer Hub
Developer Hub

This query lets us fetch all of the pathway activities of any status for a specific orchestrated pathway, including system activities such as calculations or activations.

We suggest reading the page on our domain model first to get an understanding of the activity model.

Request

Query

  • graphql
01query GetPathwayActivities($pathway_id: String!) {
02 pathwayActivities(pathway_id: $pathway_id) {
03 success
04 activities {
05 id
06 stream_id
07 status
08 date
09 isUserActivity
10 subject {
11 type
12 name
13 }
14 action
15 object {
16 id
17 type
18 name
19 }
20 indirect_object {
21 id
22 type
23 name
24 }
25 # For form content
26 form {
27 ...Form
28 }
29 }
30 }
31}

Variables

  • json
01{
02 "pathway_id": "{{PATIENT_PATHWAY_ID}}"
03}

How to use

Get all pending user activities

An orchesrated care flow consists of system activities and user actionable activities (forms, messages, checklists, ...). System activities are activities related to the Orchestration of the care flow whereas user actionable activities are the actual activities a stakeholder (eg: patient) needs to interact with.

In most cases, you're only interested in the user actionable activities which you can get by filtering the activities array by the isUserActivity field.

Additionally, you can filter the results by status === 'ACTIVE' to only get the pending activities.

The query doesn't support server-side filtering yet so the filters have to be applied on the response of the query.

Filter activities by stakeholder

User actionable activities need to be completed by a certain stakeholder. The stakeholder who needs to complete an activity is determined by the stakeholder you assigned to an action in Awell Studio. To get all pending activities for a given stakeholder, you can filter on the activity.indirect_object.type and the activity.indirect_object.name field.

Example:
If you'd like to get all pending activities for the patient, you can filter the activities array by activity.indirect_object.type === PATIENT.

The table below can help you with filtering activities for the right stakeholder:

Stakeholder type
(activity.indirect_object.type)
Stakeholder name
(activity.indirect_object.name)
PATIENTName of the actual patient as stored in the Awell patient profile
STAKEHOLDERNurse
STAKEHOLDERPhysician
STAKEHOLDERDietician
STAKEHOLDER(any other stakeholder that is not the patient)

Including Form Content in Form Activities

To simplify obtaining the content of a form for a form activity, there are two options:

  • as with all actions, you can use the activity.object.id and the related getter query (e.g. GetForm, GetMessage) to fetch the content you need
  • expand this query by including the form field at the activity root (see ...Form in the query above), along with the form fields you are interested in. The schema of a form is identical to what you would use in the GetForm query:
  • graphql
01form {
02 id
03 definition_id # static id from Studio
04 title
05 key # form key set in Studio
06 metadata # JSON metadata string set in Studio
07 questions {
08 id
09 definition_id # static id from Studio
10 title # string or html string (for description questions)
11 key # question key set in Studio
12 dataPointValueType
13 questionType
14 metadata # JSON metadata string set in Studio
15 options {
16 id
17 value
18 label
19 }
20 rule {
21 # visibility conditions of a question
22 boolean_operator
23 conditions {
24 id
25 reference # definition id of the question this condition is based on
26 operator
27 operand {
28 type
29 value
30 }
31 }
32 }
33 }
34}

For non-Form activities, this field will return null. Currently, the form field is only available on this activity query.

Form and question metadata is returned in all form queries as a JSON string rather than a JSON object. This is because the metadata is defined in Studio as a JSON string and we want to avoid any potential parsing errors. You can parse the metadata string into a JSON object in your application (for example, using JSON.parse in JavaScript/TypeScript, json.loads in Python or json_decode in PHP or Ruby).

Example:
If you'd like to get all pending activities for the patient, you can filter the activities array by activity.indirect_object.type === PATIENT.

Examples