Display a questionnaire and calculate scoring (e.g. PHQ-9)

Here's how you can use PhraseExpander to display a questionnaire and calculate the final score based on the selected items.


Create a Manual Input macro by clicking on  Macro → Manual Input
Set the display mode to Grid and enter all the questions, one per line, in the predefined values


Assign a custom format, so each item will be prepended with the number indicating its order in the list.


Enter the grid columns. They will be in the following format. You are using a varSet macro to assign a value to each item if it's selected.
The description (between square brackets) contains the text that is presented to the user.
What follows is what will be actually inserted in the text generated by PhraseExpander (the value entered, plus the varSet macro that is used to update the value of the Total variable)

[1]1{#varSet -[counter=1][start=1][name=Total][hide=1]#}
[2]2{#varSet -[counter=1][start=2][name=Total][hide=1][inc=2]#}
[3]3{#varSet -[counter=1][start=3][name=Total][hide=1][inc=3]#}<br>

To display the score, we insert the Total variable

Score {#var Total#}

Here's the final text of the macro that you can copy and paste into a new macro

{#inputForm -[title=Patient Health Questionnaire (PHQ-9)][hideSectionVisibility=1]#}Over the last 2 weeks, how often have you been bothered by any of the following problems?	
{#input Little interest or pleasure in doing things::Feeling down, depressed, or hopeless::Trouble falling or staying asleep, or sleeping too much::Feeling tired or having little energy::Poor appetite or overeating::Feeling bad about yourself::Trouble concentrating on things::Moving or speaking so slowly or the opposite::Thoughts that you would be better off dead -[desc=Over the last 2 weeks, how often have you been bothered by any of the following problems?][separator=#NL#][last=#NL#][display=grid][item=#N#. #ITEM#:][columns=0::[1]1{#varSet -[counter=1][start=1][name=Total][hide=1]#}::[2]2{#varSet -[counter=1][start=2][name=Total][hide=1][inc=2]#}::[3]3{#varSet -[counter=1][start=3][name=Total][hide=1][inc=3]#}][columnLast= and ][columnSeparator=, ]#}

Score {#var Total#}

Still need help? Contact Us Contact Us