-
Notifications
You must be signed in to change notification settings - Fork 24
O3-5088: Add Automatic Calculation for PHQ-9 Total Score in Mental Health Assessment Form #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
61131b9
8414969
b675736
3db85a0
6cde4cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| "retired": false, | ||
| "pages": [ | ||
| { | ||
| "label": "PHQ-2", | ||
| "label": "PHQ-2 Screening", | ||
| "sections": [ | ||
| { | ||
| "label": "Introduction", | ||
|
|
@@ -18,7 +18,11 @@ | |
| }, | ||
| "id": "fooMarkdown", | ||
denniskigen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "value": [ | ||
| "**This form is used :** for screening, diagnosing, monitoring and measuring the severity of depression." | ||
| "**PHQ-9 Depression Screening**", | ||
| "", | ||
| "This form is used for screening, diagnosing, monitoring and measuring the severity of depression.", | ||
| "", | ||
| "**Instructions:** Over the last 2 weeks, how often have you been bothered by any of the following problems?" | ||
| ] | ||
| } | ||
| ] | ||
|
|
@@ -38,14 +42,6 @@ | |
| "type": "CIEL", | ||
| "value": "160753" | ||
| }, | ||
| { | ||
| "type": "CIEL", | ||
| "value": "160753" | ||
| }, | ||
| { | ||
| "type": "SNOMED-CT", | ||
| "value": "439771001" | ||
| }, | ||
| { | ||
| "type": "SNOMED-CT", | ||
| "value": "439771001" | ||
|
|
@@ -121,6 +117,16 @@ | |
| "questionOptions": { | ||
| "rendering": "radio", | ||
| "concept": "167007AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "conceptMappings": [ | ||
| { | ||
| "type": "CIEL", | ||
| "value": "167007" | ||
| }, | ||
| { | ||
| "type": "LOINC", | ||
| "value": "44255-8" | ||
| } | ||
| ], | ||
| "answers": [ | ||
| { | ||
| "concept": "160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
|
|
@@ -142,16 +148,6 @@ | |
| "label": "Nearly every day", | ||
| "conceptMappings": [] | ||
| } | ||
| ], | ||
| "conceptMappings": [ | ||
| { | ||
| "type": "CIEL", | ||
| "value": "167007" | ||
| }, | ||
| { | ||
| "type": "LOINC", | ||
| "value": "44255-8" | ||
| } | ||
| ] | ||
| }, | ||
| "behaviours": [ | ||
|
|
@@ -171,7 +167,7 @@ | |
| ] | ||
| }, | ||
| { | ||
| "label": "PHQ-9", | ||
| "label": "PHQ-9 Additional Questions", | ||
| "sections": [ | ||
| { | ||
| "label": "Further evaluation", | ||
|
|
@@ -331,7 +327,7 @@ | |
| "id": "phq9_5" | ||
| }, | ||
| { | ||
| "label": "6. Feeling bad about yourself - or that you’re a failure or have let yourself or your family down", | ||
| "label": "6. Feeling bad about yourself - or that you're a failure or have let yourself or your family down", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "radio", | ||
|
|
@@ -547,21 +543,53 @@ | |
| ] | ||
| }, | ||
| { | ||
| "label": "PHQ-9 score", | ||
| "label": "Scoring and Results", | ||
| "sections": [ | ||
| { | ||
| "label": "Total scores", | ||
| "label": "PHQ-9 Scoring", | ||
| "isExpanded": "true", | ||
| "questions": [ | ||
| { | ||
| "label": "PHQ-9 score obtained by adding score for each question", | ||
| "label": "PHQ-2 Score (Questions 1-2)", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "number", | ||
| "concept": "165137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
denniskigen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "max": "6", | ||
| "min": "0", | ||
| "calculate": { | ||
| "calculateExpression": "calcPHQ9Score(phq2_1, phq2_2)" | ||
| }, | ||
| "conceptMappings": [ | ||
| { | ||
| "type": "SNOMED-CT", | ||
| "value": "720433000" | ||
| }, | ||
| { | ||
| "type": "CIEL", | ||
| "value": "165137" | ||
| } | ||
| ] | ||
| }, | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "readonly": "true" | ||
| } | ||
| ], | ||
| "id": "phq2Score" | ||
| }, | ||
| { | ||
| "label": "PHQ-9 Total Score (Questions 1-9)", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "number", | ||
| "concept": "165137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "max": "27", | ||
| "min": "0", | ||
| "showDate": "", | ||
| "calculate": { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inline We could add a /**
* Calculates PHQ-9 (Patient Health Questionnaire-9) depression screening score
* Supports both PHQ-2 (questions 1-2) and full PHQ-9 (questions 1-9)
* Handles hidden/conditional questions by treating undefined/null values as 0
*
* @param responses - Variable number of PHQ question responses (concept UUIDs)
* @returns Total score (0-27 for full PHQ-9, 0-6 for PHQ-2 only)
*
* @example
* // PHQ-2 negative screen (questions 3-9 hidden)
* calcPHQ9Score(phq2_1, phq2_2, phq9_3, phq9_4, phq9_5, phq9_6, phq9_7, phq9_8, phq9_9)
* // Returns: 0 if both answered "Not at all"
*
* @example
* // Full PHQ-9
* calcPHQ9Score(phq2_1, phq2_2, phq9_3, phq9_4, phq9_5, phq9_6, phq9_7, phq9_8, phq9_9)
* // Returns: Sum of all 9 responses (0-27)
*/
calcPHQ9Score = (...responses: (string | null | undefined)[]): number => {
const scoreMap: Record<string, number> = {
'160215AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 0, // Not at all
'167000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 1, // Several days
'167001AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 2, // More than half the days
'167002AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA': 3, // Nearly every day
};
return responses.reduce((sum, answer) => {
return sum + (answer ? (scoreMap[answer] ?? 0) : 0);
}, 0);
};And then we could simplify the "calculate": {
"calculateExpression": "calcPHQ9Score(phq2_1, phq2_2, phq9_3, phq9_4, phq9_5, phq9_6, phq9_7, phq9_8, phq9_9)"
}Benefits of this approach:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @denniskigen thanks for your feedback, are you suggesting that the change (custom expression helper function) should be implemented in the form engine’s codebase, not directly in the form JSON? @samuelmale is this something you can assist us?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. And here's the PR openmrs/openmrs-esm-form-engine-lib#650
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: PR merged. Should be available soon. |
||
| "calculateExpression": "calcPHQ9Score(phq2_1, phq2_2, phq9_3, phq9_4, phq9_5, phq9_6, phq9_7, phq9_8, phq9_9)" | ||
| }, | ||
| "conceptMappings": [ | ||
| { | ||
| "type": "SNOMED-CT", | ||
|
|
@@ -573,7 +601,13 @@ | |
| } | ||
| ] | ||
| }, | ||
| "id": "phq9Score" | ||
| "behaviours": [ | ||
| { | ||
| "intent": "*", | ||
| "readonly": "true" | ||
| } | ||
| ], | ||
| "id": "phq9TotalScore" | ||
| } | ||
| ] | ||
| } | ||
|
|
@@ -583,21 +617,17 @@ | |
| "label": "Notes", | ||
| "sections": [ | ||
| { | ||
| "label": "Notes", | ||
| "label": "Additional Notes", | ||
| "isExpanded": "true", | ||
| "questions": [ | ||
| { | ||
| "label": "Mental Health Assessment Notes", | ||
| "label": "Clinician Notes", | ||
| "type": "obs", | ||
| "questionOptions": { | ||
| "rendering": "textarea", | ||
| "concept": "165095AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", | ||
| "rows": "", | ||
| "conceptMappings": [ | ||
| { | ||
| "type": "AMPATH", | ||
| "value": "1915" | ||
| }, | ||
| { | ||
| "type": "AMPATH", | ||
| "value": "1915" | ||
|
|
@@ -612,7 +642,7 @@ | |
| } | ||
| ] | ||
| }, | ||
| "id": "phq9Notes" | ||
| "id": "clinicianNotes" | ||
| } | ||
| ] | ||
| } | ||
|
|
@@ -629,5 +659,6 @@ | |
| "uuid": "2069bd57-d534-3de9-ae24-f1d4e4b2de83", | ||
| "referencedForms": [], | ||
| "encounterType": "36db5123-0ad5-41c0-9037-625b46e0ceef", | ||
| "encounter": "Mental Health Assessment" | ||
| } | ||
| "encounter": "Mental Health Assessment", | ||
| "description": "A form used for screening, diagnosing, monitoring and measuring the severity of depression" | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.