Basic Case Management Tutorial Part 1 - Creating Follow-up Forms
For an application to have case management, we need more than one form. We've already created a "registration" form which can be used to create, or register, a new case. But we also will want to create a Home Visit form which can be used to follow up with the pregnant woman, and a Birth form which can close the case and remove it from the phone.
Case Management Tutorial: Creating Follow-up Forms
In the Follow-up Form Building Part of the Case Management Tutorial you will learn:
How a form can be represented in spreadsheet form
More tools to use when building a form, including the "copy" function
1. Another Way to Represent Form Contents
When we created the Beginner's Tutorial we walked through adding questions step-by-step, so we won't do that again here. But you have a Registration Form which looks like this:
We could also represent these questions in a table format. For the beginner's tutorial above, it would look like this:
Question ID or Item Value | Type | Text (en) | Display Condition | Validation Condition | Validation Message | Calculate Condition | Required |
---|---|---|---|---|---|---|---|
village_name | Text Question | Village Name: |
|
|
|
| yes |
woman_name | Text Question | Woman's Name: |
|
|
|
| yes |
lmp | Date | Date of Last Menstrual Period |
|
|
|
| yes |
show_edd | Label | The woman's EDD is: <output value="#form/edd"/> |
|
|
|
| no |
living_children | Multiple Choice | Has the woman given birth to children that are still alive? |
|
|
|
| no |
yes | Answer | Yes |
|
|
|
|
|
no | Answer | No |
|
|
|
|
|
living_boys | Integer | How many living boys? | #form/living_children = 'yes' | . <= 15 | The number of living boys must be less than or equal to 15! |
| no |
living_girls | Integer | How many living girls? | #form/living_children = 'yes' | . <= 15 | The number of living girls must be less than or equal to 15! |
| no |
feeling_sick | Multiple Choice | Is the woman feeling sick today? |
|
|
|
| no |
yes | Answer | Yes |
|
|
|
|
|
no | Answer | No |
|
|
|
|
|
clinic_reminder | Label | Remind the pregnant woman to go to the clinic for her check-up! |
|
|
|
| no |
total_children | Hidden Value |
|
|
|
| #form/living_boys + #form/living_girls | no |
edd | Hidden Value |
|
|
|
| date(#form/lmp + 274) | no |
pregnancy_risk | Hidden Value |
|
|
|
| if(#form/total_children > 5 and #form/feeling_sick = 'yes', 'high_risk','low_risk') | no |
For each question you can see the Question ID, the question type, the label text, the display condition, any validation conditions and messages, any calculations, and whether the question is required or not. You know how to do all these things so creating another form should be easy!
Just so you know - there are various reasons why it is helpful to represent the questions like this, e.g. it provides an easy way to see details about each question and the relationships between questions, and serves as a discussion document for multiple people involved in the application design process. You can see any form in a similar format to this one by going to "Tools" then "Export Form Contents" in the Form Builder. (Instructions can be found here: Export Form Contents.)
2. Building a Home Visit Form
We want to build a new form:
In CommCareHQ, if you are not there already, go to Applications -> Village Health
Because you selected "Case List" when you started your application, a second form, titled "Follow Up" is ready as your second form.
Set the Form Name to "Home Visit" by clicking the edit pen next to the form name, and then click Save
You can now start working on your new form
We will walk through building this form, but much more quickly than in the Beginner Tutorial.
Let's start by prompting the mobile user to follow up if the woman stated she was feeling sick at the last visit.
Add a Label Question by using the dropdown menu next to the "T" in the Question Bar and make the following changes:
Question ID: previously_sick
Label Text: Last time this woman reported she was sick! Ask her if she recovered
You can see that later we are going to want to link this to the question from the Registration Form.
Next let's find out how she is feeling today.
Add a Single Answer Multiple Choice Question from the Question Bar and make the following changes:
Question ID: feeling_sick
Label Text: Is the woman feeling sick today?
Now add two choices- set the Item IDs/Label Text to: yes/Yes and no/No respectively
Now we are going to ask a couple of yes/no questions about whether or not the woman has gone to the clinic. We could add those questions just like we added the yes/no questions above, but since we already have a yes/no question we don't need to start from scratch. We can create a copy of the question "feeling_sick" and just change the Question ID and Label Text; we don't have to change Yes and No since they always remain the same.
Select the question "Is the woman feeling sick today" in the Question Tree and click Ctrl + C to copy the question, and then Ctrl + V to paste it.
Selecting Multiple Questions in the Form Builder using Ctrl + clicking on questions can help make your form builder easier in many ways:
Duplicate a series of questions within a form
Copy a series of questions from one form to another
Move multiple questions to a different place in the form
Delete multiple questions at once
Click on the newly created copy and make the following changes:
Question ID: clinic_visit_1
Label Text: Has woman been to clinic visit 1?
Make a copy of the question you just created, go to the newly created copy, and make the following changes:
clinic_visit_2
Has woman been to clinic visit 2?
We'll come back later and add all the logic, since it is a bit complex! Right now you should have a form like this:
3. Building a Birth Outcome Form
For this next form, we're just going to show you the desired form contents in table format. You are expert form builders so building a form using the table should be no problem!
If you don't have a second followup form you'll need to add one:
Click on "+" next to "Case List"
Change the Form Name to "Birth Outcome"
Build the form contents as follows:
Question ID | Type | Text (en) | Display Condition | Validation Condition | Validation Message | Calculate Condition | Required |
---|---|---|---|---|---|---|---|
pregnancy_outcome | Multiple Choice | Pregnancy Outcome: |
|
|
|
| yes |
live_birth | Choice | Live Birth |
|
|
|
|
|
still_birth | Choice | Still Birth |
|
|
|
|
|
abortion | Choice | Abortion |
|
|
|
|
|
birth_weight | Decimal | Weight at birth (kg): | #form/pregnancy_outcome = 'live_birth' |
|
|
|
|
baby_name | Text | Child's Name: | #form/pregnancy_outcome = 'live_birth' |
|
|
| yes |
dob | Date | Date of Birth: | #form/pregnancy_outcome = 'live_birth' | . <= today() | Date of Birth cannot be in the future! |
|
|
How do I make the validation condition for the date?
To make the validation condition for the question "dob" you can still use the expression builder; just drag the question to the left side (remember, it will be replaced by a dot), choose "less than or equal to" and then type in today(), which grabs today's date from the phone. This will ensure the user doesn't accidentally enter a date of birth in the future!
Make sure to save your changes. Your Question Tree should look like this:
4. Test your Application
Great! We now have three forms:
Registration Form - used to register a new pregnant mother in the phone
Home Visit Form - used to collect data and provide information at visits throughout the pregnancy
Birth Form - used to record the outcome of the pregnancy and remove the pregnant mother's name from the phone
Following the same procedure you used in the Beginner Tutorial, go to Deploy -> Make a New Version and install the application on your phone. Or test in CloudCare.
Try accessing each form. You will find that you can directly go to any of the forms.
That would be fine if they were all separate surveys, but we want them to be linked! We can use case management to get a workflow that links everything together
Just wait until you see how powerful case management can be!!! (You can see we're excited about it!)
In the next section will we set the Registration Form to open, or register, a new case.
Go to the Next Section.