Clinical forms often include calculations that transform patient responses into a meaningful score or priority level. This could be a validated screening tool (like a nutrition assessment, frailty index, or standardized questionnaire) or a custom score your team has designed, such as a triage priority score, acuity rating, or intake risk flag. Thrive lets you configure these calculations directly on the form so scores are computed automatically when a patient submits. Once set up, scores are available to use in your clinical summaries and automations.
How It Works
You add two expression questions to your form, both hidden from patients:
-
Score: a number calculated from patient responses (e.g.,
cnstScore = 2) -
Category: a label derived from the score (e.g.,
cnstCategory = "At Risk for Malnutrition")
Setting up both means the mapping logic is defined once on the form. Summaries can reference either value directly, and automations can trigger on the category label with no need to re-define thresholds elsewhere.
Configuring Your Expressions
Setting up score expressions requires writing a small amount of form logic, but you don't need to do it alone. An AI tool like Claude or ChatGPT can write the expressions for you based on your scoring rules.
Currently, there are two main ways to add score expressions to a form.
Method A: Using the form builder
Add each expression question individually through the form builder. Good if you prefer working through the form builder workspace step by step.
Step 1: Add the score expression
- Open the form template in edit mode
- Add a new question and choose the type Expression (read-only)
- Set the Expression name. This is the internal ID for the score, used when referencing it in summaries and automations. Use camelCase with no spaces (e.g.,
cnstScore,bmiScore). - Leave Visible toggled off
- Enter the expression in the Expression field (see Writing your expressions below for help)
- Save
Step 2: Add the category expression
Repeat the same steps with a second expression question:
- Set the Expression name to your category variable name (e.g.,
cnstCategory,bmiCategory) - The expression references your score variable using
{cnstScore}, so configure the score first
Method B: Edit the form JSON
Ask an AI tool like Claude or ChatGPT to add both expressions to your form's JSON and return the updated file in one step.
- Open the form template in edit mode and click the JSON tab
- Select all the content (Ctrl+A on Windows, Cmd+A on Mac) and copy it
-
Paste it into an AI tool like Claude or ChatGPT along with this prompt, replacing the bracketed parts with your own scoring rules:
"Here is my SurveyJS form JSON. I want to add two hidden expression questions: a score named
[yourScoreName]and a category named[yourCategoryName]. Here are the scoring rules:[paste your scoring table here — see the examples below for the format]
Both questions should have
visible: falseso they don't appear to patients. Add them to the form'selementsarray and return the full updated JSON." - Once the AI returns the updated JSON, ask it: "Can you confirm the new questions you added and what they calculate?" Read its summary to check it matches what you intended before continuing.
- Go back to the JSON tab. Select all the existing content (Ctrl+A on Windows, Cmd+A on Mac) and delete it, then paste the updated JSON and save
Writing your expressions
Expressions follow SurveyJS syntax. You don't need to learn it; just use an AI tool like Claude or ChatGPT to write them for you. The basics, so you can understand what gets produced:
| Syntax | What it does |
|---|---|
{questionName} |
References a patient's answer to a form question |
{panelName.questionName} |
References an answer inside a grouped section |
+ |
Adds values together |
iif(condition, valueIfTrue, valueIfFalse) |
Returns one of two values based on a condition |
Example 1: CNST Nutrition Score (validated PROM)
| Question | Yes | No |
|---|---|---|
| Unintentional weight loss | 1 point | 0 points |
| Reduced appetite | 1 point | 0 points |
| Score | Category |
|---|---|
| 2 or more | At Risk for Malnutrition |
| 0–1 | Low Risk for Malnutrition |
Expression strings:
- Score:
iif({unintentionalWeightLoss} = 'yes', 1, 0) + iif({reducedAppetite} = 'yes', 1, 0) - Category:
iif({cnstScore} >= 2, 'At Risk for Malnutrition', 'Low Risk for Malnutrition')
Example 2: Custom Triage Priority Score
This example shows a custom score that combines multiple intake factors to produce a triage priority. The question names and point values are illustrative — your actual score will reflect your form's question names and your clinic's triage criteria.
| Question | Answer | Points |
|---|---|---|
| Symptom severity | Severe | 3 |
| Symptom severity | Moderate | 2 |
| Symptom severity | Mild/other | 1 |
| Functional impact | Yes | 2 |
| Waiting more than 8 weeks | Yes | 1 |
| Score | Category |
|---|---|
| 5 or more | Urgent |
| 3–4 | Moderate |
| 0–2 | Routine |
Expression strings:
- Score:
iif({symptomSeverity} = 'severe', 3, iif({symptomSeverity} = 'moderate', 2, 1)) + iif({functionalImpact} = 'yes', 2, 0) + iif({waitingMoreThan8Weeks} = 'yes', 1, 0) - Category:
iif({triageScore} >= 5, 'Urgent', iif({triageScore} >= 3, 'Moderate', 'Routine'))
Getting the expression strings (for Method A)
If you're using Method A and just need the expression strings to paste into the form builder, start by laying out your scoring rules in a table using the format from the examples above. Then paste your table into an AI tool along with this prompt:
If you have the form JSON (most accurate):
Open the JSON tab, copy all the content, and send it to the AI tool along with your scoring table:
"Here is my SurveyJS form JSON, followed by my scoring rules as a table. Please write two SurveyJS expression strings — just the expression values, not the full JSON: a score named
[yourScoreName]and a category named[yourCategoryName]. Use the exact questionnamevalues from the JSON.[paste your scoring table here. See above for examples.]"
Copy each returned expression string into the corresponding Expression field in the form builder.
If you don't have the JSON handy:
Find the exact question name (the internal ID your form uses) directly in the form builder:
- Open the form template in edit mode
- Click on the question you want to reference
- Click the Settings icon for that question
- Look for the Name field — this is the question's internal ID used by the system in expressions. Copy it exactly, including capitalisation.
Once you have the question names, send your scoring table to the AI tool:
"I'm configuring a clinical score. Here are my scoring rules as a table, with question names from my form. Please write two SurveyJS expression strings: a score named
[yourScoreName]and a category named[yourCategoryName].[paste your scoring table here. See above for examples.]"
Testing Your Expressions
Use the summary testing tool to verify both expressions work before configuring automations.
- Create a new summary template on the form (or use an existing one temporarily)
-
Add a line that references both variables. Use the variable picker in the summary editor to insert them. Include the score name so it's clear which score you're viewing — useful if you're testing multiple scores at once:
CNST Score: {{ submission["data"]["cnstScore"] }} — Category: {{ submission["data"]["cnstCategory"] }}
- Switch to Test Mode and fill in the questions relevant to the score (you don't need to complete the full form, just the questions the score depends on)
- Review the live summary preview. Confirm the score value and category label appear as expected.
- Try different answer combinations to confirm the category switches correctly at each threshold
- If a value is blank or incorrect, check that the question names in your expression exactly match the Name field in the question settings (expressions are case-sensitive)
- Once validated, remove the test content from your summary template or delete it
Using Scores in Summaries
Once your expressions are on the form, reference them directly in any summary template using the variable picker.
- Numeric score:
{{ submission["data"]["cnstScore"] }} - Category label:
{{ submission["data"]["cnstCategory"] }}
See Creating Clinical Summaries for more on building summary templates.
Using Scores in Automations
Once your expressions are on the form, both the score and category variables appear automatically in the automation conditions dropdown.
Using the category label in conditions is simpler than numeric ranges. For example, cnstCategory equals "High Risk" is easier to configure than setting a numeric threshold, because the threshold logic is already encoded in the expression.
To surface the category on your worklist, you'll need a custom field and one automation per tier. See Automating Workflows for a step-by-step walkthrough.
Troubleshooting
| Problem | Solution |
|---|---|
| Score shows blank in the test summary | Check that the expression name exactly matches the variable name (case-sensitive). Check that the question names in the expression match the Name field in the question settings |
| Category shows blank but score is correct | Confirm the category expression references the score using {scoreName}, not the display title |
| Expression question is visible to patients | Toggle Visible to off in the question settings |
| JSON tab shows an error after pasting | The JSON may be malformed. Restore your original copy and try again, or ask the AI tool to validate the JSON structure |