Skip to content

Workflows ​

Workflows are automations that run inside your Medipal instance when something happens: a questionnaire is submitted, a patient is created, a questionnaire is published. You design them visually as a graph of steps, test them with sample events, and monitor every run.

What workflows enable ​

GoalHow a workflow does it
Alert a clinician when a score crosses a thresholdTrigger on Questionnaire Submitted, compute the score, branch on it, send an email through the email plugin.
Push results into another systemTrigger on submission, map the answers into the target's format, call its REST API with an HTTP step.
Remind a patient after a delayTrigger on enrollment or submission, wait, then send a message.
Keep an external register in syncTrigger on patient or questionnaire events and call the register's API.
Combine questionnaire scores with clinical valuesRead the patient's latest observations from the connected EHR before deciding what to do.

Workflows run on the server, so they continue to work when nobody is signed in.

Building blocks ​

  • Trigger (event subscription). Every workflow listens to one event type. Optional filters narrow it to one questionnaire, folder or user, and an advanced condition can inspect any field of the event.
  • Nodes. The steps. Each node has a type, a configuration and, where relevant, an input mapping that says which values from earlier steps it receives.
  • Execution connections. Arrows between nodes that define the order. A connection can carry a condition; the next node runs only when the condition is true.
  • Data connections. Links that hand one node's output to another node's input, drawn from the output pins to the input pins of a step.
  • Runs. Each time the trigger fires, a run is created with a status per node, its inputs, outputs, errors and timings.

Events you can trigger on ​

FamilyEvents
QuestionnairesCreated, Updated, Published, Archived, Restored, Deleted
SubmissionsQuestionnaire Submitted, Anonymous Submission, Submission Updated, Submission Deleted
UsersUser Created, User Updated, User Deleted, Password Changed
FoldersFolder Created, Folder Updated, Folder Deleted
Sign-inLogin Succeeded, Login Failed, Token Refreshed, Password Reset Requested/Completed, MFA Enabled, MFA Challenge Failed

Submission events carry the answers and the questionnaire structure, so conditions can refer to specific questions and scoring variables.

Node types ​

NodeWhat it does
ActionCalls an action of a plugin instance: send an email, call an API described by an OpenAPI document, read platform data.
ComputeEvaluates an expression and stores the result for later steps (a score, a flag, a formatted string).
SwitchBranches. Each outgoing connection has its own condition; the first branch whose condition is true is taken.
JoinWaits for several branches. Modes: all branches, any branch, or a given number of branches.
DelayPauses for a duration or until a computed time before continuing.
HTTPSends an HTTP request. Method, URL, headers, query and body can all use values from earlier steps.
MapperBuilds a new object from fields of earlier steps, ready to feed an Action or HTTP node.
EndMarks the end of a path.

Every node also has advanced settings: a timeout, a retry policy (number of attempts and back-off), and continue on error, which lets the run proceed even if this step fails.

Conditions and expressions ​

Conditions on triggers, connections and Compute nodes are written in JSON Logic, a small, safe expression language. The editor provides a visual tree editor and pickers for event fields, questionnaire questions and variables, and the outputs of earlier nodes, so you rarely type an expression by hand. A condition that checks a scoring variable looks like this:

json
{ ">=": [{ "var": "event.data.variables.phq9_total" }, 20] }

Comparison, boolean, arithmetic, string, array and date operators are available.

Working with data between steps ​

  • Use data connections to pass a node's output to another node's input. The editor shows what each node exposes: for an HTTP node the status code, headers and body; for an Action the fields declared by the plugin.
  • Use a Mapper when the target expects a different shape than what you have, for instance to build the request body for an external API.
  • Reference vault entries in mappings and configurations with $secret:name or $var:name. They are resolved on the server at execution time and never appear in run history. See Vault.

Creating a workflow ​

  1. Open Admin Panel → Workflows and choose Create Workflow.
  2. Give it a name and pick the event type. Optionally restrict it to a questionnaire, folder or user, or add an advanced condition.
  3. Open the editor. Add nodes from the palette, connect them, and configure each node in the side panel.
  4. Save, then Test: provide a sample event (the editor pre-fills the shape for the chosen event type) and review which nodes ran, which branches were taken and what each step produced. Tests never call plugins, send requests or wait on delays.
  5. Enable the workflow. Disabled workflows keep their definition but ignore events.

Monitoring runs ​

Admin Panel → Workflows → Runs lists every execution with its workflow, event type, start and end time, and status:

StatusMeaning
PendingCreated, not started yet.
RunningOne or more nodes are executing.
CompletedAll nodes resolved.
FailedA node failed and continue on error was off.

A run's detail page shows each node with its own status (pending, running, completed, failed or skipped), its input, output, error and duration. Skipped means the node was on a branch that was not taken.

Related delivery activity is visible under Admin Panel → Events, which lists how each event was handed to workflows and webhooks, with attempts and retry times.

Recipes ​

Email on a high score. Trigger: Questionnaire Submitted, filtered to the questionnaire. Switch on the total-score variable. On the high branch, an Action node using the email plugin instance with the clinician's address, subject and a body built from the patient's name and score. End.

Forward to an external API. Trigger: Questionnaire Submitted. Mapper builds the payload the external system expects. HTTP node posts it, with the API key taken from $secret:partner_api_key. Switch on the response status code to log or retry.

Delayed reminder. Trigger: Questionnaire Submitted. Delay of a fixed duration. Action node sends the reminder through the email plugin.

Permissions ​

Viewing workflows and runs requires workflow read rights; creating and editing require workflow write rights, which are not part of the standard clinician role. See Users, Roles & Scopes.

Troubleshooting ​

SymptomLikely causeWhat to do
The workflow never runsIt is disabled, or the trigger filters do not match the eventEnable it; test with a real event copied from the Events page.
A node fails with a validation errorThe input mapping does not match what the action expectsOpen the node, compare with the action's input fields, use a Mapper.
The run stops after a SwitchNo branch condition was trueAdd a default branch with no condition.
Secrets show as $secret:... in the runExpected: references are resolved only at execution and never loggedNo action.
HTTP node times outSlow or unreachable targetRaise the timeout, add a retry policy, check the target from the Events page.
The test passes but the real run failsTests skip plugin calls and requestsCheck plugin instance configuration and credentials; see Plugins.