1. Add a Date/Time field and call it 'edd'
- This field will capture the estimated date of delivery for this participant
2. Add a Calculated Value field and call it 'gestation_days'
- This will calculate and store (but not display) the participant's current gestation period (in days) as of the current date.
- Add the formula "=today() - ($edd - 40*7)"
- '$edd' refers to the date captured in the field above, the '40' refers to the average number of weeks for human gestation, and the '7' refers to the number of days in a week.
3. Add another Calculated Value field and call it 'trimester'
- This will calculate and store (but not display) the participant's current trimester based on the gestation period calculated in the field above.
- Add the formula: "=if($gestation_days / 7 <= 12, 'first', if($gestation_days / 7 <= 27, 'second', 'third'))"
- '$gestation_days' refers to the result captured in the field above, and the '7' refers to the number of days in a week (this is changing gestation period in days to gestation period in weeks)
- 'if' statements are then used to determine the current trimester:
- if the gestation period is less than or equal to 12, the participant is in her first trimester, else look at the second part of the 'if' statement (below)
- if the gestation period is less than or equal to 27 weeks, the participant is in her second trimester, else the participant is in her third trimester
Note: that if you want to display text as the result of an 'if' statement, you have to use inverted commas around the text as shown in the example above.
4. Finally, add an Information field to display all the above calculations to your fieldworker
- In the display text, type in: "Based on an expected delivery date of $edd, $name is currently =(int($gestation_days / 7)) weeks into her pregnancy ($trimester trimester)"
Select the Preview button from the toolbar to test your calculation and see how it will be displayed when using the mobile app.