Skip to content

Commit 9663965

Browse files
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: openmrs/openmrs-esm-patient-chart#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
1 parent d5eb529 commit 9663965

File tree

1 file changed

+67
-37
lines changed

1 file changed

+67
-37
lines changed

configuration/backend_configuration/ampathforms/Mental Health Assessment Form.json

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"retired": false,
66
"pages": [
77
{
8-
"label": "PHQ-2",
8+
"label": "PHQ-2 Screening",
99
"sections": [
1010
{
1111
"label": "Introduction",
@@ -16,9 +16,13 @@
1616
"questionOptions": {
1717
"rendering": "markdown"
1818
},
19-
"id": "fooMarkdown",
19+
"id": "phq9Intro",
2020
"value": [
21-
"**This form is used :** for screening, diagnosing, monitoring and measuring the severity of depression."
21+
"**PHQ-9 Depression Screening**",
22+
"",
23+
"This form is used for screening, diagnosing, monitoring and measuring the severity of depression.",
24+
"",
25+
"**Instructions:** Over the last 2 weeks, how often have you been bothered by any of the following problems?"
2226
]
2327
}
2428
]
@@ -38,14 +42,6 @@
3842
"type": "CIEL",
3943
"value": "160753"
4044
},
41-
{
42-
"type": "CIEL",
43-
"value": "160753"
44-
},
45-
{
46-
"type": "SNOMED-CT",
47-
"value": "439771001"
48-
},
4945
{
5046
"type": "SNOMED-CT",
5147
"value": "439771001"
@@ -80,6 +76,16 @@
8076
"questionOptions": {
8177
"rendering": "radio",
8278
"concept": "167006AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
79+
"conceptMappings": [
80+
{
81+
"type": "CIEL",
82+
"value": "167006"
83+
},
84+
{
85+
"type": "LOINC",
86+
"value": "44250-9"
87+
}
88+
],
8389
"answers": [
8490
{
8591
"concept": "160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
@@ -121,6 +127,16 @@
121127
"questionOptions": {
122128
"rendering": "radio",
123129
"concept": "167007AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
130+
"conceptMappings": [
131+
{
132+
"type": "CIEL",
133+
"value": "167007"
134+
},
135+
{
136+
"type": "LOINC",
137+
"value": "44255-8"
138+
}
139+
],
124140
"answers": [
125141
{
126142
"concept": "160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
@@ -142,16 +158,6 @@
142158
"label": "Nearly every day",
143159
"conceptMappings": []
144160
}
145-
],
146-
"conceptMappings": [
147-
{
148-
"type": "CIEL",
149-
"value": "167007"
150-
},
151-
{
152-
"type": "LOINC",
153-
"value": "44255-8"
154-
}
155161
]
156162
},
157163
"behaviours": [
@@ -171,7 +177,7 @@
171177
]
172178
},
173179
{
174-
"label": "PHQ-9",
180+
"label": "PHQ-9 Additional Questions",
175181
"sections": [
176182
{
177183
"label": "Further evaluation",
@@ -331,7 +337,7 @@
331337
"id": "phq9_5"
332338
},
333339
{
334-
"label": "6. Feeling bad about yourself - or that youre a failure or have let yourself or your family down",
340+
"label": "6. Feeling bad about yourself - or that you're a failure or have let yourself or your family down",
335341
"type": "obs",
336342
"questionOptions": {
337343
"rendering": "radio",
@@ -547,21 +553,42 @@
547553
]
548554
},
549555
{
550-
"label": "PHQ-9 score",
556+
"label": "Scoring and Results",
551557
"sections": [
552558
{
553-
"label": "Total scores",
559+
"label": "PHQ-9 Scoring",
554560
"isExpanded": "true",
555561
"questions": [
556562
{
557-
"label": "PHQ-9 score obtained by adding score for each question",
563+
"label": "PHQ-2 Score (Questions 1-2)",
564+
"type": "display",
565+
"questionOptions": {
566+
"rendering": "number",
567+
"max": "6",
568+
"min": "0",
569+
"calculate": {
570+
"calculateExpression": "calcPHQ9Score(phq2_1, phq2_2)"
571+
}
572+
},
573+
"behaviours": [
574+
{
575+
"intent": "*",
576+
"readonly": "true"
577+
}
578+
],
579+
"id": "phq2Score"
580+
},
581+
{
582+
"label": "PHQ-9 Total Score (Questions 1-9)",
558583
"type": "obs",
559584
"questionOptions": {
560585
"rendering": "number",
561586
"concept": "165137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
562587
"max": "27",
563588
"min": "0",
564-
"showDate": "",
589+
"calculate": {
590+
"calculateExpression": "calcPHQ9Score(phq2_1, phq2_2, phq9_3, phq9_4, phq9_5, phq9_6, phq9_7, phq9_8, phq9_9)"
591+
},
565592
"conceptMappings": [
566593
{
567594
"type": "SNOMED-CT",
@@ -573,7 +600,13 @@
573600
}
574601
]
575602
},
576-
"id": "phq9Score"
603+
"behaviours": [
604+
{
605+
"intent": "*",
606+
"readonly": "true"
607+
}
608+
],
609+
"id": "phq9TotalScore"
577610
}
578611
]
579612
}
@@ -583,21 +616,17 @@
583616
"label": "Notes",
584617
"sections": [
585618
{
586-
"label": "Notes",
619+
"label": "Additional Notes",
587620
"isExpanded": "true",
588621
"questions": [
589622
{
590-
"label": "Mental Health Assessment Notes",
623+
"label": "Clinician Notes",
591624
"type": "obs",
592625
"questionOptions": {
593626
"rendering": "textarea",
594627
"concept": "165095AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
595628
"rows": "",
596629
"conceptMappings": [
597-
{
598-
"type": "AMPATH",
599-
"value": "1915"
600-
},
601630
{
602631
"type": "AMPATH",
603632
"value": "1915"
@@ -612,7 +641,7 @@
612641
}
613642
]
614643
},
615-
"id": "phq9Notes"
644+
"id": "clinicianNotes"
616645
}
617646
]
618647
}
@@ -629,5 +658,6 @@
629658
"uuid": "2069bd57-d534-3de9-ae24-f1d4e4b2de83",
630659
"referencedForms": [],
631660
"encounterType": "36db5123-0ad5-41c0-9037-625b46e0ceef",
632-
"encounter": "Mental Health Assessment"
633-
}
661+
"encounter": "Mental Health Assessment",
662+
"description": "A form used for screening, diagnosing, monitoring and measuring the severity of depression"
663+
}

0 commit comments

Comments
 (0)