How can I configure clinical scores? (Advanced)

Thrive Health Support
Thrive Health Support
  • Updated

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:

  1. Score: a number calculated from patient responses (e.g., cnstScore = 2)
  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.

💡Tip: Configure both expressions before building automations or summaries. Once they're on the form, you can test them together using the summary testing tool.

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.

ℹ️ Coming soon: An in-app AI assistant that understands your clinic's setup and can help you configure forms, build scores, create summaries, and more.

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

  1. Open the form template in edit mode
  2. Add a new question and choose the type Expression (read-only)
  3. 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., cnstScorebmiScore).
  4. Leave Visible toggled off
  5. Enter the expression in the Expression field (see Writing your expressions below for help)
  6. 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., cnstCategorybmiCategory)
  • The expression references your score variable using {cnstScore}, so configure the score first
💡Tip: Keep expression names short and descriptive, using camelCase (capital letter at the start of each new word, no spaces or underscores). For example, cnstScore and cnstCategory for a CNST nutrition screen, or bmiScore and bmiCategory for a BMI-based score. You'll use these names when building summaries and automations, so clear naming makes a difference.

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.

  1. Open the form template in edit mode and click the JSON tab
  2. Select all the content (Ctrl+A on Windows, Cmd+A on Mac) and copy it
  3. 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: false so they don't appear to patients. Add them to the form's elements array and return the full updated JSON."

  4. 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.
  5. 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
⚠️ Before replacing: Copy your original JSON somewhere safe first so you can restore it if needed.

 

⚠️ Important: Always test AI-generated expressions before using them with real patient data. AI tools can misinterpret question names or scoring logic. Use the steps in Testing Your Expressions to verify the output before building automations or summaries.

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
💡Tip: For the full list of supported operators and functions, see the SurveyJS expression syntax reference.

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 question name values 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:

  1. Open the form template in edit mode
  2. Click on the question you want to reference
  3. Click the Settings icon for that question
  4. 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.]"

💡Tip: Providing the full JSON always gives better results. The AI tool can see the exact question names and structure without you needing to look them up manually.

 

⚠️ Important: Always test AI-generated expressions before using them with real patient data. AI tools can misinterpret question names or scoring logic. Use the steps in Testing Your Expressions to verify the output before building automations or summaries.

Testing Your Expressions

Use the summary testing tool to verify both expressions work before configuring automations.

  1. Create a new summary template on the form (or use an existing one temporarily)
  2. 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"] }}
     

  3. 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)
  4. Review the live summary preview. Confirm the score value and category label appear as expected.
  5. Try different answer combinations to confirm the category switches correctly at each threshold
  6. 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)
  7. Once validated, remove the test content from your summary template or delete it
💡Tip: Testing the score and category together here means you can be confident they're correct before you build automations that depend on them.

Using Scores in Summaries

Once your expressions are on the form, reference them directly in any summary template using the variable picker.

ℹ️ Note: Summary templates use a templating language called Jinja2 to pull in data from your form - that's what the {{ }} notation is. You can use the variable picker in the summary editor to insert these automatically.
  • 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