Build: #65 was successful Changes by Veronica Mukuhi Muthee <veronica.mukuhi@gmail.com>
Code commits
openmrs-content-referenceapplication-demo
-
Veronica Mukuhi Muthee <veronica.mukuhi@gmail.com> 9663965efc02b65cb77790c5eb776610f036dae3
O3-5088: Add Automatic Calculation for PHQ-9 Total Score in Mental Health Assessment Form (#44)
* O3-5088: Add Automatic Calculation for PHQ-9 Total Score in Mental Health Assessment Form
1) Added a calculate object with a calculateExpression to the PHQ-9 score field that automatically sums all 9 questions
Scoring Logic.
2) Each answer is mapped to its correct score:
Not at all (160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) = 0
Several days (167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) = 1
More than half the days (167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) = 2
Nearly every day (167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) = 3
3) Read-only Field - Added a readonly behavior to the score field so users can't manually edit it
* Revise Automatic Calculation for PHQ-9 Total Score in Mental Health Assessment Form
Summary of Changes
Automated PHQ-9 Scoring
Forms now support automatic calculation of PHQ-9 scores (range: 0–27) without manual entry. The score is computed based on responses to the nine PHQ items at the point of form entry.
Refactor to Reusable Calculation Function
Instead of repeating long inline calculateExpression logic across forms, the scoring logic has been moved into a clean, reusable helper function within the front-end form engine. This simplifies form JSON, improves maintainability, and ensures consistent application of depression screening logic.
This update aligns with and builds on the enhancement implemented in PR: https://github.com/openmrs/openmrs-esm-patient-chart/pull/2787
* Update Mental Health Assessment Form.json
* Update PHQ-9 form structure and question types
Converted PHQ-2 Score field from obs to a display-only calculated field
* Add concept mappings for mental health assessment form- configuration/backend_configuration/ampathforms/Mental Health Assessment Form.json (version 9663965efc02b65cb77790c5eb776610f036dae3)