Dynamic Tasking Sample Plan Definitions
This page includes sample plan definitions for achieving the dynamic tasking across the platform. These are all considered a work in progress until they are deployed in actual products. Then, we can codify them in other documentation.
- 1 PNC Module Tasks
- 1.1 Variability
- 1.2 Logic Narrative - Daisy Chain approach
- 1.3 Sample Plan
- 1.4 Test Cases - Daisy Chain Approach
- 1.4.1 Case 1 Plan Activation: Child Exists in the system DOB 27 Sept 2020
- 1.4.2 Case 2 Plan Activation: Child Exists in the system DOB 18 Sept 2020
- 1.4.3 Case 3 Plan Activation: Child Exists in the system DOB 5 Sept 2020
- 1.4.4 Case 4 Birth Outcome Form: DOB 30 Sept 2020
- 1.4.5 Case 5 Birth Outcome Form: DOB 3 Aug 2020
- 1.4.6 Case 6 Birth Outcome Form: DOB 12 Sept 2020
- 1.4.7 Case 7 Day 2 Form: DOB 29 Sept 2020
- 1.4.8 Case 8 Day 3 Form: DOB 27 Sept 2020
- 1.4.9 Case 9 Day 14 Form: DOB 14 Sept 2020
- 2 Questions
PNC Module Tasks
The PNC module will generate tasks when there is a pregnancy outcome form submitted for a particular child. Then, there are numerous visits which are made by a healthcare worker. Below is a table which shows a sample visit schedule with the logic that we want to define for each visit.
Name | Trigger Event | Trigger Date | Due | Overdue | Expiry | Form to open | Priority |
Day 2 visit | Pregnancy Outcome form is submitted | {delivery_date} | {delivery_date} + 2 days | NA | {delivery_date} + 3 days | PNC form... | ASAP |
Day 3 visit | Pregnancy Outcome form is submitted OR PNC visit "Day 2" form is submitted | {delivery_date} | {delivery_date} + 3 days | {delivery_date} + 4 days | {delivery_date} + 14 days | PNC form... | ASAP |
Day 14 visit |
| {delivery_date} | {delivery_date} + 14 days | {delivery_date} + 15 days | {delivery_date} + 21 days | PNC form... | Urgent |
Day 21 visit |
| {delivery_date} | {delivery_date} + 21 days | {delivery_date} + 22 days | {delivery_date} + 28 days | PNC form... | Urgent |
Day 28 visit |
| {delivery_date} | {delivery_date} + 28 days | {delivery_date} + 29 days | {delivery_date} + 49 days | PNC form... | Urgent |
Day 49 visit |
| {delivery_date} | {delivery_date} + 49 days | {delivery_date} + 50 days | NA | PNC form... | Routine |
Variability
We anticipate the need for variability within this schedule and the plan actions must be able to accommodate. This section defines some of the use cases to consider.
Pregnancy Outcome form is submitted 'n' days after birth.
We need to be able to calculate the date of birth from the form and determine which visit to trigger. Note that we need to determine, medically, if it’s appropriate to skip visits or to create tasks for visits that couldn’t be accommodated. For example, if we get the pregnancy outcome form on day 15, we have missed the care that was scheduled to be provided on Day 2, Day 3, and Day 14.
Is it appropriate to start with the day 21 visit, or should we modify the day 2 and day 3 visit forms to be collected later?
A person can miss any visit in the sequence. Furthermore, they can miss all but 1 visit.
We should strictly adhere to the expiration dates and generate tasks on a cron schedule. So, if they miss a particular event, we mark that as missed and then generate another task for the next scheduled task.
We should also show these ‘missed’ visits in the UI.
The Day 3 visit may be triggered by a pregnancy outcome form or the Day 2 form.
We need to accommodate both situations. When we check the form submission of the birth outcome and day 2 submissions, we need to check to see if there is already a task associated with day 3.
Logic Narrative - Daisy Chain approach
This section includes a narrative of how we want to structure the plan. This helps us ensure that we all align on the logic before we encode it in the plan actions.
Action 1: Day 2 Visit
Trigger on plan activation to identify any children who may already be registered in the system.
Create an event for any person in the system that is between the age of 0 and 2 days old.
Trigger on event submission when a birth outcome event is created
Check to see if the DOB is between today minus 2 days and today. So, if today is 1 Oct 2020, the DOB must be between 29 Sept 2020 and 1 Oct 2020.
Check to see if there is a task already created for the Day 2 visit for this patient. Do not create a duplicate task.
The Day 2 visit form can be created in the app without a birth outcome form submission by the user add
Action 2: Day 3 Visit
Trigger on plan activation to identify any children who may already be registered in the system.
Create an event for any person in the system that is between the age of 3 and 13 days old.
Do not create a duplicate task if there is already a Day 3 visit task in the system for that person.
Trigger on event submission when a birth outcome event is created
Check to see if the DOB is between today minus 13 days and today minus 3 days. So, if today is 1 Oct 2020, the DOB must be between 18 Sept 2020 and 28 Sept 2020.
Check to see if there is a task already created for the Day 3 visit for this patient. Do not create a duplicate task.
Trigger on event submission when a Day 2 visit is created.
Check to see if the DOB is between today minus 13 days and today. So, if today is 1 Oct 2020, the DOB must be between 18 Sept 2020 and 1 Oct 2020.
Check to see if there is a task already created for the Day 3 visit for this patient. Do not create a duplicate task.
Action 3: Day 14 Visit
Trigger on plan activation to identify any children who may already be registered in the system.
Create an event for any person in the system that is between the age of 14 and 20 days old.
Do not create a duplicate task if there is already a Day 14 visit task in the system for that person.
Trigger on event submission when a birth outcome event is created
Check to see if the DOB is between today minus 20 days and today minus 14 days. So, if today is 1 Oct 2020, the DOB must be between 11 Sept 2020 and 17 Sept 2020.
Check to see if there is a task already created for the Day 14 visit for this patient. Do not create a duplicate task.
Trigger on event submission when a Day 3 visit is created.
Check to see if the DOB is between today minus 20 days and today. So, if today is 1 Oct 2020, the DOB must be between 11 Sept 2020 and 1 Oct 2020.
Check to see if there is a task already created for the Day 14 visit for this patient. Do not create a duplicate task.
Action 4: Day 21 Visit
Trigger on plan activation to identify any children who may already be registered in the system.
Create an event for any person in the system that is between the age of 27 and 21 days old.
Do not create a duplicate task if there is already a Day 21 visit task in the system for that person.
Trigger on event submission when a birth outcome event is created
Check to see if the DOB is between today minus 27 days and today minus 21 days. So, if today is 1 Oct 2020, the DOB must be between 4 Sept 2020 and 10 Sept 2020.
Check to see if there is a task already created for the Day 21 visit for this patient. Do not create a duplicate task.
Trigger on event submission when a Day 14 visit is created.
Check to see if the DOB is between today minus 27 days and today. So, if today is 1 Oct 2020, the DOB must be between 4 Sept 2020 and 1 Oct 2020.
Check to see if there is a task already created for the Day 21 visit for this patient. Do not create a duplicate task.
Action 5: Day 28 Visit
Trigger on plan activation to identify any children who may already be registered in the system.
Create an event for any person in the system that is between the age of 48 and 28 days old.
Do not create a duplicate task if there is already a Day 28 visit task in the system for that person.
Trigger on event submission when a birth outcome event is created
Check to see if the DOB is between today minus 48 days and today minus 28 days. So, if today is 1 Oct 2020, the DOB must be between 14 Aug 2020 and 3 Sept 2020.
Check to see if there is a task already created for the Day 28 visit for this patient. Do not create a duplicate task.
Trigger on event submission when a Day 21 visit is created.
Check to see if the DOB is between today minus 48 days and today. So, if today is 1 Oct 2020, the DOB must be between 14 Aug 2020 and 1 Oct 2020.
Check to see if there is a task already created for the Day 28 visit for this patient. Do not create a duplicate task.
Action 6: Day 49 Visit
Trigger on plan activation to identify any children who may already be registered in the system.
Create an event for any person in the system that is greater than 48 days old but less than 1 year.
Do not create a duplicate task if there is already a Day 49 visit task in the system for that person.
Trigger on event submission when a birth outcome event is created
Check to see if the DOB is before today minus 49 days. So, if today is 1 Oct 2020, the DOB must be earlier than 13 Aug 2020.
Check to see if there is a task already created for the Day 49 visit for this patient. Do not create a duplicate task.
Trigger on event submission when a Day 28 visit is created.
Check to see if there is a task already created for the Day 49 visit for this patient. Do not create a duplicate task.
Sample Plan
This section includes a sample plan
{
"identifier": "86d6afc1-a20a-49ca-9b4c-467b7ee2aeeb",
"version": "1",
"name": "Sample_PNC_Plan_Template",
"title": "Sample PNC Plan Template",
"status": "active",
"date": "2020-10-20",
"effectivePeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"useContext": [
{
"code": "interventionType",
"valueCodableConcept": "Linked-PNC"
},
{
"code": "taskGenerationStatus",
"valueCodableConcept": "internal"
}
],
"jurisdiction": [
{
"code": "ce13e7f4-6926-4be0-9117-519bd1cc4bb2"
}
],
"goal": [
{
"id": "Day_2_Visit",
"description": "Complete the Day 2 Visit form for each child.",
"priority": "medium-priority",
"target": [
{
"measure": "Percent of children with completed Day 2 Visit form completed.",
"detail": {
"detailQuantity": {
"value": 80,
"comparator": ">=",
"unit": "Percent"
}
},
"due": "2021-10-19"
}
]
},
{
"id": "Day_3_Visit",
"description": "Complete the Day 3 Visit form for each child.",
"priority": "medium-priority",
"target": [
{
"measure": "Percent of children with completed Day 3 Visit form completed.",
"detail": {
"detailQuantity": {
"value": 80,
"comparator": ">=",
"unit": "Percent"
}
},
"due": "2021-10-19"
}
]
},
{
"id": "Day_14_Visit",
"description": "Complete the Day 14 Visit form for each child.",
"priority": "medium-priority",
"target": [
{
"measure": "Percent of children with completed Day 14 Visit form completed.",
"detail": {
"detailQuantity": {
"value": 80,
"comparator": ">=",
"unit": "Percent"
}
},
"due": "2021-10-19"
}
]
},
{
"id": "Day_21_Visit",
"description": "Complete the Day 21 Visit form for each child.",
"priority": "medium-priority",
"target": [
{
"measure": "Percent of children with completed Day 21 Visit form completed.",
"detail": {
"detailQuantity": {
"value": 80,
"comparator": ">=",
"unit": "Percent"
}
},
"due": "2021-10-19"
}
]
},
{
"id": "Day_28_Visit",
"description": "Complete the Day 28 Visit form for each child.",
"priority": "medium-priority",
"target": [
{
"measure": "Percent of children with completed Day 28 Visit form completed.",
"detail": {
"detailQuantity": {
"value": 80,
"comparator": ">=",
"unit": "Percent"
}
},
"due": "2021-10-19"
}
]
},
{
"id": "Day_49_Visit",
"description": "Complete the Day 49 Visit form for each child.",
"priority": "medium-priority",
"target": [
{
"measure": "Percent of children with completed Day 49 Visit forms completed.",
"detail": {
"detailQuantity": {
"value": 80,
"comparator": ">=",
"unit": "Percent"
}
},
"due": "2021-10-19"
}
]
}
],
"action": [
{
"identifier": "7c88b1f2-9c87-4a91-8a5b-0b5a7ed19c96",
"prefix": 1,
"title": "Day 2 Visit",
"description": "Complete the Day 2 Visit form for each child.",
"code": "Day 2 Visit",
"timingPeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"reason": "Routine",
"goalId": "Day_2_Visit",
"subjectCodableConcept": {
"text": "Person"
},
"trigger": [
{
"type": "named-event",
"name": "plan-activation"
},
{
"type": "named-event",
"name": "event-submission",
"expression": {
"description": "Trigger when a Pregnancy_Outcome or Family_Member_Registration event is submitted",
"expression": "questionnaire = 'Pregnancy_Outcome' or questionnaire = 'Family_Member_Registration'"
}
}
],
"condition": [
{
"kind": "applicability",
"expression": {
"description": "Person is 0 to 2 days old",
"expression": "($this.is(FHIR.Patient) and $this.birthDate >= today() - 2 'days') or ($this.contained.where(Patient.birthDate >= today() - 2 'days').exists())"
}
}
],
"definitionUri": "pnc_visit_form.json",
"type": "create"
},
{
"identifier": "f30acf5c-a894-4aa8-b032-8bf7b9dd2ab7",
"prefix": 2,
"title": "Day 3 Visit",
"description": "Complete the Day 3 Visit form for each child.",
"code": "Day 3 Visit",
"timingPeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"reason": "Routine",
"goalId": "Day_3_Visit",
"subjectCodableConcept": {
"text": "Person"
},
"trigger": [
{
"type": "named-event",
"name": "plan-activation"
},
{
"type": "named-event",
"name": "event-submission",
"expression": {
"description": "Trigger when a Pregnancy_Outcome, Family_Member_Registration, or PNC_Visit_Form event is submitted",
"expression": "questionnaire = 'Pregnancy_Outcome' or questionnaire = 'Family_Member_Registration' or questionnaire = 'PNC_VISIT_FORM'"
}
}
],
"condition": [
{
"kind": "applicability",
"expression": {
"description": "Person is 3 to 13 days old",
"expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 3 'days' and $this.birthDate >= today() - 13 'days') or ($this.contained.where(Patient.birthDate <= today() - 3 'days' and Patient.birthDate >= today() - 13 'days').exists())"
}
}
],
"definitionUri": "pnc_visit_form.json",
"type": "create"
},
{
"identifier": "610b6e14-2098-47f9-84e9-1b97c23e9bd1",
"prefix": 3,
"title": "Day 14 Visit",
"description": "Complete the Day 14 Visit form for each child.",
"code": "Day 14 Visit",
"timingPeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"reason": "Routine",
"goalId": "Day_14_Visit",
"subjectCodableConcept": {
"text": "Person"
},
"trigger": [
{
"type": "named-event",
"name": "plan-activation"
},
{
"type": "named-event",
"name": "event-submission",
"expression": {
"description": "Trigger when a Pregnancy_Outcome, Family_Member_Registration, or PNC_Visit_Form event is submitted",
"expression": "questionnaire = 'Pregnancy_Outcome' or questionnaire = 'Family_Member_Registration' or questionnaire = 'PNC_VISIT_FORM'"
}
}
],
"condition": [
{
"kind": "applicability",
"expression": {
"description": "Person is 14 to 20 days old",
"expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 14 'days' and $this.birthDate >= today() - 20 'days') or ($this.contained.where(Patient.birthDate <= today() - 14 'days' and Patient.birthDate >= today() - 20 'days').exists())"
}
}
],
"definitionUri": "pnc_visit_form.json",
"type": "create"
},
{
"identifier": "073e5eb1-5212-4526-9fad-40116bb7e84f",
"prefix": 4,
"title": "Day 21 Visit",
"description": "Complete the Day 21 Visit form for each child.",
"code": "Day 21 Visit",
"timingPeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"reason": "Routine",
"goalId": "Day_21_Visit",
"subjectCodableConcept": {
"text": "Person"
},
"trigger": [
{
"type": "named-event",
"name": "plan-activation"
},
{
"type": "named-event",
"name": "event-submission",
"expression": {
"description": "Trigger when a Pregnancy_Outcome, Family_Member_Registration, or PNC_Visit_Form event is submitted",
"expression": "questionnaire = 'Pregnancy_Outcome' or questionnaire = 'Family_Member_Registration' or questionnaire = 'PNC_VISIT_FORM'"
}
}
],
"condition": [
{
"kind": "applicability",
"expression": {
"description": "Person is 21 to 27 days old",
"expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 21 'days' and $this.birthDate >= today() - 27 'days') or ($this.contained.where(Patient.birthDate <= today() - 21 'days' and Patient.birthDate >= today() - 27 'days').exists())"
}
}
],
"definitionUri": "pnc_visit_form.json",
"type": "create"
},
{
"identifier": "605ce7e7-f5bc-4849-95c6-6998bc44e6e1",
"prefix": 5,
"title": "Day 28 Visit",
"description": "Complete the Day 28 Visit form for each child.",
"code": "Day 28 Visit",
"timingPeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"reason": "Routine",
"goalId": "Day_28_Visit",
"subjectCodableConcept": {
"text": "Person"
},
"trigger": [
{
"type": "named-event",
"name": "plan-activation"
},
{
"type": "named-event",
"name": "event-submission",
"expression": {
"description": "Trigger when a Pregnancy_Outcome, Family_Member_Registration, or PNC_Visit_Form event is submitted",
"expression": "questionnaire = 'Pregnancy_Outcome' or questionnaire = 'Family_Member_Registration' or questionnaire = 'PNC_VISIT_FORM'"
}
}
],
"condition": [
{
"kind": "applicability",
"expression": {
"description": "Person is 28 to 48 days old",
"expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 28 'days' and $this.birthDate >= today() - 48 'days') or ($this.contained.where(Patient.birthDate <= today() - 28 'days' and Patient.birthDate >= today() - 48 'days').exists())"
}
}
],
"definitionUri": "pnc_visit_form.json",
"type": "create"
},
{
"identifier": "7c2746f5-9aed-43f6-926a-c30af62b2001",
"prefix": 6,
"title": "Day 49 Visit",
"description": "Complete the Day 49 Visit form for each child.",
"code": "Day 49 Visit",
"timingPeriod": {
"start": "2020-10-20",
"end": "2021-10-19"
},
"reason": "Routine",
"goalId": "Day_49_Visit",
"subjectCodableConcept": {
"text": "Person"
},
"trigger": [
{
"type": "named-event",
"name": "plan-activation"
},
{
"type": "named-event",
"name": "event-submission",
"expression": {
"description": "Trigger when a Pregnancy_Outcome, Family_Member_Registration, or PNC_Visit_Form event is submitted",
"expression": "questionnaire = 'Pregnancy_Outcome' or questionnaire = 'Family_Member_Registration' or questionnaire = 'PNC_VISIT_FORM'"
}
}
],
"condition": [
{
"kind": "applicability",
"expression": {
"description": "Person is to days old",
"expression": "($this.is(FHIR.Patient) and $this.birthDate <= today() - 49 'days' and $this.birthDate >= today() - 90 'days') or ($this.contained.where(Patient.birthDate <= today() - 49 'days' and Patient.birthDate >= today() - 90 'days').exists())"
}
}
],
"definitionUri": "pnc_visit_form.json",
"type": "create"
}
],
"experimental": false
}
Notes:
Action 1 is for the day 2 visit and can be triggered by a family member registration or a birth outcome form is completed
Action 6 is for someone who is older than 49 days
Test Cases - Daisy Chain Approach
Today’s date is 1 Oct 2020
Case 1 Plan Activation: Child Exists in the system DOB 27 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | True | False | False |
Action 2: Day 3 Visit | True | False | True Age = 5 Days |
Action 3: Day 14 Visit | True | False | False |
Action 4: Day 21 Visit | True | False | False |
Action 5: Day 28 Visit | True | False | False |
Action 49: Day 49 Visit | True | False | False |
Case 2 Plan Activation: Child Exists in the system DOB 18 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | True | False | False |
Action 2: Day 3 Visit | True | False | False |
Action 3: Day 14 Visit | True | False | True Age = 14 Days |
Action 4: Day 21 Visit | True | False | False |
Action 5: Day 28 Visit | True | False | False |
Action 49: Day 49 Visit | True | False | False |
Case 3 Plan Activation: Child Exists in the system DOB 5 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | True | False | False |
Action 2: Day 3 Visit | True | False | False |
Action 3: Day 14 Visit | True | False | False |
Action 4: Day 21 Visit | True | False | True Age = 27 Days |
Action 5: Day 28 Visit | True | False | False |
Action 49: Day 49 Visit | True | False | False |
Case 4 Birth Outcome Form: DOB 30 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | False | True | True Age = 1 Day |
Action 2: Day 3 Visit | False | True | False |
Action 3: Day 14 Visit | False | True | False |
Action 4: Day 21 Visit | False | True | False |
Action 5: Day 28 Visit | False | True | False |
Action 49: Day 49 Visit | False | True | False |
Case 5 Birth Outcome Form: DOB 3 Aug 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | False | True | False |
Action 2: Day 3 Visit | False | True | False |
Action 3: Day 14 Visit | False | True | False |
Action 4: Day 21 Visit | False | True | False |
Action 5: Day 28 Visit | False | True | False |
Action 49: Day 49 Visit | False | True | True Age = 60 Days |
Case 6 Birth Outcome Form: DOB 12 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | False | True | False |
Action 2: Day 3 Visit | False | True | False |
Action 3: Day 14 Visit | False | True | True Age = 20 Days |
Action 4: Day 21 Visit | False | True | False |
Action 5: Day 28 Visit | False | True | False |
Action 49: Day 49 Visit | False | True | False |
Case 7 Day 2 Form: DOB 29 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | False | False | False |
Action 2: Day 3 Visit | False | True | True Age = 2 Days |
Action 3: Day 14 Visit | False | False | False |
Action 4: Day 21 Visit | False | False | False |
Action 5: Day 28 Visit | False | False | False |
Action 49: Day 49 Visit | False | False | False |
Case 8 Day 3 Form: DOB 27 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | False | False | False |
Action 2: Day 3 Visit | False | False | False |
Action 3: Day 14 Visit | False | True | True Age = 4 Days |
Action 4: Day 21 Visit | False | False | False |
Action 5: Day 28 Visit | False | False | False |
Action 49: Day 49 Visit | False | False | False |
Case 9 Day 14 Form: DOB 14 Sept 2020
Actions | Plan Activation Trigger | Event Submission trigger | Condition |
---|---|---|---|
Action 1: Day 2 Visit | False | False | False |
Action 2: Day 3 Visit | False | False | False |
Action 3: Day 14 Visit | False | False | False |
Action 4: Day 21 Visit | False | True | True Age = 18 Days |
Action 5: Day 28 Visit | False | False | False |
Action 49: Day 49 Visit | False | False | False |
Questions
Please confirm that there isn’t a way to create a visit other than the Day 2 form. What if the child is 10 days old? What do we expect the health worker to do? Submit a birth outcome form? (I think so)
This site is no longer maintained. Please visit docs.opensrp.io for current documentation.