Skip to content

Commit 8414969

Browse files
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
1 parent 61131b9 commit 8414969

File tree

1 file changed

+59
-37
lines changed

1 file changed

+59
-37
lines changed

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

Lines changed: 59 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",
@@ -18,7 +18,11 @@
1818
},
1919
"id": "fooMarkdown",
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"
@@ -121,6 +117,16 @@
121117
"questionOptions": {
122118
"rendering": "radio",
123119
"concept": "167007AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
120+
"conceptMappings": [
121+
{
122+
"type": "CIEL",
123+
"value": "167007"
124+
},
125+
{
126+
"type": "LOINC",
127+
"value": "44255-8"
128+
}
129+
],
124130
"answers": [
125131
{
126132
"concept": "160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
@@ -142,16 +148,6 @@
142148
"label": "Nearly every day",
143149
"conceptMappings": []
144150
}
145-
],
146-
"conceptMappings": [
147-
{
148-
"type": "CIEL",
149-
"value": "167007"
150-
},
151-
{
152-
"type": "LOINC",
153-
"value": "44255-8"
154-
}
155151
]
156152
},
157153
"behaviours": [
@@ -171,7 +167,7 @@
171167
]
172168
},
173169
{
174-
"label": "PHQ-9",
170+
"label": "PHQ-9 Additional Questions",
175171
"sections": [
176172
{
177173
"label": "Further evaluation",
@@ -547,23 +543,52 @@
547543
]
548544
},
549545
{
550-
"label": "PHQ-9 score",
546+
"label": "Scoring and Results",
551547
"sections": [
552548
{
553-
"label": "Total scores",
549+
"label": "PHQ-9 Scoring",
554550
"isExpanded": "true",
555551
"questions": [
556552
{
557-
"label": "PHQ-9 score obtained by adding score for each question",
553+
"label": "PHQ-2 Score (Questions 1-2)",
554+
"type": "obs",
555+
"questionOptions": {
556+
"rendering": "number",
557+
"concept": "165137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
558+
"max": "6",
559+
"min": "0",
560+
"calculate": {
561+
"calculateExpression": "calcPHQ9Score(phq2_1, phq2_2)"
562+
},
563+
"conceptMappings": [
564+
{
565+
"type": "SNOMED-CT",
566+
"value": "720433000"
567+
},
568+
{
569+
"type": "CIEL",
570+
"value": "165137"
571+
}
572+
]
573+
},
574+
"behaviours": [
575+
{
576+
"intent": "*",
577+
"readonly": "true"
578+
}
579+
],
580+
"id": "phq2Score"
581+
},
582+
{
583+
"label": "PHQ-9 Total Score (Questions 1-9)",
558584
"type": "obs",
559585
"questionOptions": {
560586
"rendering": "number",
561587
"concept": "165137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
562588
"max": "27",
563589
"min": "0",
564-
"showDate": "",
565590
"calculate": {
566-
"calculateExpression": "(phq2_1 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq2_1 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq2_1 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq2_1 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq2_2 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq2_2 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq2_2 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq2_2 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_3 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_3 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_3 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_3 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_4 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_4 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_4 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_4 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_5 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_5 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_5 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_5 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_6 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_6 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_6 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_6 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_7 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_7 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_7 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_7 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_8 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_8 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_8 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_8 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0) + (phq9_9 === '160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 0 : phq9_9 === '167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 1 : phq9_9 === '167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 2 : phq9_9 === '167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' ? 3 : 0)"
591+
"calculateExpression": "calcPHQ9Score(phq2_1, phq2_2, phq9_3, phq9_4, phq9_5, phq9_6, phq9_7, phq9_8, phq9_9)"
567592
},
568593
"conceptMappings": [
569594
{
@@ -576,13 +601,13 @@
576601
}
577602
]
578603
},
579-
"id": "phq9Score",
580604
"behaviours": [
581605
{
582606
"intent": "*",
583607
"readonly": "true"
584608
}
585-
]
609+
],
610+
"id": "phq9TotalScore"
586611
}
587612
]
588613
}
@@ -592,21 +617,17 @@
592617
"label": "Notes",
593618
"sections": [
594619
{
595-
"label": "Notes",
620+
"label": "Additional Notes",
596621
"isExpanded": "true",
597622
"questions": [
598623
{
599-
"label": "Mental Health Assessment Notes",
624+
"label": "Clinician Notes",
600625
"type": "obs",
601626
"questionOptions": {
602627
"rendering": "textarea",
603628
"concept": "165095AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
604629
"rows": "",
605630
"conceptMappings": [
606-
{
607-
"type": "AMPATH",
608-
"value": "1915"
609-
},
610631
{
611632
"type": "AMPATH",
612633
"value": "1915"
@@ -621,7 +642,7 @@
621642
}
622643
]
623644
},
624-
"id": "phq9Notes"
645+
"id": "clinicianNotes"
625646
}
626647
]
627648
}
@@ -635,8 +656,9 @@
635656
}
636657
],
637658
"processor": "EncounterFormProcessor",
638-
"uuid": "2069bd57-d534-3de9-ae24-f1d4e4b2de83",
659+
"uuid": "953da2ce-e8bc-405a-be67-ff73c03a9720",
639660
"referencedForms": [],
640661
"encounterType": "36db5123-0ad5-41c0-9037-625b46e0ceef",
641-
"encounter": "Mental Health Assessment"
662+
"encounter": "Mental Health Assessment",
663+
"description": "A form used for screening, diagnosing, monitoring and measuring the severity of depression"
642664
}

0 commit comments

Comments
 (0)