- If you have selected formula as your question type, you will enter your formula in the "Formula" field, located in the Scripting and More tab of the eForm Editor.
- Formulas are especially useful in scored forms, where the final score for the form is the sum, average, etc. of the points accrued while the patient is completing the form.
Generating a total score:
The GAD-7 is a good example of this functionality. It contains all of the clinical scoring questions in a section named 'gad7Qs' and then uses the following formula in a hidden formula item to calculate the sum of all of the scores of that section:
ScriptUtil.sum(gad7Qs)
Copy Rule
Note: The formula item containing the script above must be located outside of the section that is being summed, to prevent the formula from summing itself.
Displaying a formula result:
If you would like to display the value calculated by your formula you can do so by adding "$$" to the "Caption" field (in the General tab). You can also use the "$$" in the "Custom Note" field (in the Note Formatting tab) if you don't want to display the value to the patient but would like to capture it in the patient chart.
Example: GAD-7 eForm
The GAD-7 Ocean eForm is a good example of generating a total score and displaying the result:
- The GAD-7 questionnaire contains seven questions to be scored. These questions are placed within a single section of the eForm named 'gad7Qs'.
- Each of the seven questions are configured with pre-defined responses for the patient to choose from, and each response value is associated with a different point value.
- In this case, we can see that the response of "Not at all" is associated with a point value of "0", while the response value of "Several days" is associated with a point value of "1".
- A hidden formula item exists near the end of the form containing the "ScriptUtil.sum(gad7Qs)" script to calculate the sum of all of the point values for the seven questions.
- In this case, we can see that two responses of "Several days" have been input, and since each of those responses are worth a point value of "1", the sum of all points in the section is "2".
More resources:
To learn how to round your formula answers to the nearest digit, please refer to: "Limiting the Number of Decimal Places in Formula Calculations".
For more examples of possible score calculations and more advanced scripting articles, please refer to: