Appearance
Logic, Variables & Scoring
A Medipal questionnaire is more than a list of questions. Each question can carry actions that run when a respondent enters or answers it, and the questionnaire can hold variables and functions that compute scores while the respondent progresses. All of this is built visually in the designer, with an escape hatch to custom code for advanced cases.
How actions work
Select a question and open the Actions tab of the side panel. Actions are attached to one of two triggers:
| Trigger | When it runs | What it can see |
|---|---|---|
| When entering a question | Just before the question is displayed | The question definition |
| When answering a question | When the respondent confirms an answer and moves on | The question and the given answer |
Under a trigger you add one or more action groups. A group has:
- a condition (an expression that evaluates to true or false; an empty condition is always true),
- a list of actions to run if the condition is met,
- a list of actions to run else.
Groups run in order. If a question has no answer-time actions at all, the engine simply moves to the next question. As soon as you add an answer-time group, navigation becomes explicit: one of your actions must decide where to go next (for example Next Question), otherwise the respondent stays on the question.
Available actions
| Action | Effect |
|---|---|
| Next Question | Continue to the next question in order. |
| Skip Question | Jump over the following question. |
| Go To Question | Jump to a specific question chosen by reference name. |
| Go To Question Index | Jump to a question by its position. |
| Set Variable | Assign a value (or the result of an expression) to a questionnaire variable. |
| End Questionnaire | Finish immediately and submit the answers collected so far. |
| Custom Code | Run a JavaScript expression you write yourself. |
The expression builder
Conditions and values are composed from blocks rather than typed by hand. Blocks are grouped in the command panel; start typing to search.
| Group | Examples |
|---|---|
| Question References | The current answer, the raw answer value of any question, question properties. |
| Comparison | Equals, Not Equals, Less Than, Greater Than (and the "or equal" variants), Includes (for multiple choice). |
| Arithmetic | Addition, Subtraction, Multiplication, Division, Modulo, Exponentiation. |
| Logical | AND, OR, NOT, and grouping parentheses. |
| Text | Contains, Does Not Contain, Starts With, Ends With, case changes, trim, length, substring, replace, split. |
| Number | Round, Floor, Ceil, Absolute, To Fixed. |
| Boolean | Negate, cast to boolean. |
| Array and Object | Length, first/last item, get by index, map/filter/reduce, keys, values, entries. |
| Values | Literal text, numbers, true/false. |
| Variables and Functions | Read a variable, call a global function. |
Two illustrative conditions, as the builder assembles them:
Current Question Answer Equals "Yes"Raw Answer Value of "pain_score" Greater Than 7 AND Variable "visit_number" Equals 1Custom Code blocks accept a JavaScript expression when the built-in blocks are not enough. Expressions run in an isolated context with access only to the question, the answer and the questionnaire methods; they cannot reach the page or the network.
Variables
Open Variables in the questionnaire navigation to manage global variables. Each has a Name (letters, digits and underscores, starting with a letter or underscore), a Label, a Description, a Type (Number, String or Boolean) and a Default Value.
Variables hold state for the whole session: a running score, a flag set by an earlier answer, a value carried into later logic. Set them with Set Variable actions and read them anywhere in conditions. Their final values are stored with the submission and appear on the Scoring tab of every submission preview.
Schedules can also seed initial variables per enrollment (for example the visit number or a baseline value), so the same questionnaire behaves differently for different patients. See Scheduling & Enrollments.
Functions
Functions are reusable calculations defined once and called from any expression. A function has a Name, Label, Description, a list of typed Arguments, a Return Type and its Function Code in JavaScript.
Typical uses: computing an index from several answers (for example a BMI from weight and height), normalising a raw total to a 0–100 scale, or mapping a score to a category label. Use a Set Variable action to store the function result so that it is included in the submission's scoring.
Scoring actions
Beyond variables, the Scoring area lets you define scoring actions evaluated when the questionnaire is submitted. Each action combines a condition built from sections, questions, results, total score and comparison operators with one of:
- Alert: flag the submission for attention.
- Send email: notify an address with a subject and content you define.
These are the simplest way to react to a threshold (for example a high symptom score) without building a workflow. For richer automation across systems, use Workflows.
Simulation
Simulation runs the questionnaire with the real engine against your current draft, including unsaved changes, and shows what happens as you answer:
- which question is displayed next after each answer,
- the current value of every variable,
- the scoring output that would be submitted.
Use it to verify skip logic, dead ends and threshold rules before publishing. Nothing is stored; simulated answers are discarded when you leave the page.
Relations between questionnaires
Versions & Relations shows how a questionnaire relates to others: its version tree (earlier and later versions), duplicates made from it and the revision history. See Versions & Publishing.
Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
| The respondent is stuck on a question after answering | An answer-time action group exists but no navigation action runs on every path | Add Next Question to the else branch (or to the group) so a path always continues. |
| A condition is never true | Comparing the wrong value type (text vs number) or the wrong reference name | Check the answer's raw value in Simulation; use the type-safe blocks or a cast. |
| "Missing Argument" on an action | A block was left incomplete | Open the action and fill every argument; empty conditions are allowed, empty arguments are not. |
| A variable shows its default value in the submission | It was never set on the path the respondent took | Set it in the answer-time actions of the relevant questions or seed it from the schedule. |
| Changing languages broke an expression | Logic referenced an option label rather than a value | Compare against option values, which are language-independent. |
| A function call errors in simulation | Argument count or type mismatch, or the code has no return | Check the argument list and make sure the code returns a value. |