Test with sample messages
Run a message through a workflow without delivering it, check each destination, replay a batch from another engine, and replay a past execution.
On this page
You can test a workflow before any real traffic reaches it. This guide covers six tools, from smallest to largest: Run with sample on one step or a few, a sample message with a dry run, the Run test verdict for each destination, batch replay of messages from another engine, replay of one past execution, and saved test cases that every deploy runs.
sequenceDiagram
participant You
participant Builder as Workflow builder
participant Engine as MedHook engine
You->>Builder: Paste a sample message
Builder->>Engine: Save sample (encrypted)
You->>Builder: Run test
Engine->>Engine: Dry run: filters, steps, no delivery
Engine-->>Builder: Verdict per destination + what it would send
You->>Builder: Replay a batch (export file)
Engine-->>Builder: Output and diff per message
You->>Engine: Replay a past execution
Engine-->>You: New executionBefore you start
- A workflow with a trigger and at least one destination.
- Dry run, Run test and reading a sample or a message body need the
operatorrole in that workspace. Viewers see only that a sample exists, never its content. Replay a batch needsoperatororadmin. - The builder shows a saved sample and every run on it masked, for every role. Show PHI with a reason reveals the values and is audited. See PHI in the builder.
- Synthetic messages only. A sample can hold PHI, so use made-up patients when you can.
Steps
1. Add a sample message
Open the workflow in the builder. In the Sample message panel, choose Paste a sample and paste a message.
MSH|^~\&|SENDER|FAC|RECEIVER|FAC|20260101120000||ADT^A01|MSG0001|P|2.5.1
EVN|A01|20260101120000
PID|1||MRN0001^^^FAC^MR||TESTPATIENT^SAMPLE||19800101|F
PV1|1|I|WARD^101^1Choose Save sample. The engine stores one sample per workflow, encrypted, and you can keep up to 50 more as test cases. It audits every read and change without logging the content. It accepts HL7v2 or JSON, up to 1 MB. The panel loads a saved sample only when you choose Load sample, and shows it masked: segment names, delimiters and JSON keys stay, and only the values are masked. Show PHI asks for a reason (Troubleshooting, Patient request or Audit), records phi.revealed, and then shows the values in the panel, the Data Map and the field rules for that sample. A sample you paste is masked the same way once it is saved.
With the flat field-path view on (off by default), a loaded sample gets a Raw / Fields toggle. Fields lists every value as a path, such as PID.3(2).1 or OBX[2].5, with its HL7 name, a filter and Copy path. The list is built in your browser.
No sample yet? Choose Send sample ADT^A01 in the Test run panel. It runs a bundled synthetic message and saves nothing.
Generate synthetic samples
To make a sample instead of pasting one, choose Generate samples in the paste dialog. Pick a format (HL7 v2, FHIR R4, X12, CDA, JSON or CSV), a type such as ADT^A04, ORU^R01, Patient, 837 or 270, and a count of up to 50, then choose Generate. Use this sample puts one in the box; choose Save sample as usual.
The samples are made up in your browser and never come from engine data: the patient's family name is always TESTPATIENT, MRNs look like TP-123456, facilities are Demo Health clinics, and HL7 v2 messages carry processing ID T. They parse and validate with the engine's own parsers. The same Seed gives the same samples, so a test is repeatable. The optional Description is read for hints only, for example 3 clinics, some with missing PID-13.
The Messages screen has the same Generate samples button, to copy samples for a sender or a test file. The assistant can also generate samples when you ask for them; it uses the same generator, and a structure you paste for it to copy (a message or a resource) gives only its segments and fields, never its values.
The same panel is available over the API:
curl -s -X PUT "$ENGINE_URL/api/workflows/wf_example/sample" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"message": "MSH|^~\\&|SENDER|FAC|RECEIVER|FAC|20260101120000||ADT^A01|MSG0001|P|2.5.1\rPID|1||MRN0001^^^FAC^MR||TESTPATIENT^SAMPLE"}'2. Run a dry run
Choose Run test in the builder's toolbar. The engine runs the saved sample through every step, including edits you have not saved, and delivers nothing. A dry run follows the same path as a live message: the trigger's rules first, then each step. Adapters report what they would send. Nothing is stored, retried or counted.
The Test run panel prints one line per step. For the API, call Dry run workflow with an optional message. The response holds matched, a reason when the trigger dropped the message, and the output of each step.

3. Read the verdict for each destination
For a channel, Run test adds a Test results list with one row per destination. Each row has one status:
| Status | Meaning |
|---|---|
| WOULD SEND | The message passed the filter. The row shows what it Would send. |
| FILTERED | The destination's filter dropped the message. The row names the rule and what it read, for example PV1-2 equals O · read I · failed. |
| FAILED | A step failed. The row shows the error. |
| NOT RUN | The inbound filter dropped the message, or the run failed before the destination. |
Open a WOULD SEND row to see the payload the adapter would send. Use FILTERED rows to check that each filter does what you intend: a filter should drop the messages meant for another destination.
4. Replay a batch from another engine
Batch replay answers the cutover question: does the new workflow produce what the old engine produced? In the Test run panel choose Replay a batch.
File. Choose a Batch file. The engine reads what Rhapsody and Mirth export and what a wire capture holds:
- one or many HL7v2 messages, with segments ended by CR, LF or CRLF;
- HL7 batch files (
FHS/BHStoBTS/FTS). The envelope is stripped and the trailer counts are checked, and a mismatch is a warning; - MLLP captures, back to back or one per line. ACKs in a two-way capture are skipped.
The limits are 5 MB and 500 messages per replay. A malformed message is rejected with its position and a reason that never quotes the message.
Mode. Choose one.
| Mode | What it does |
|---|---|
| Dry run | Runs every message through the saved workflow, delivers nothing, and returns the output of each message as a field map. |
| Send over MLLP | Sends each message to a host and port, one at a time, and records each ACK code. |
Dry run with an expected output. Add an Expected output (JSON lines) file to get a field-level diff. Each line is one object:
{ "controlId": "MSG0001", "output": { "PID.5": "TESTPATIENT^SAMPLE" } }A line can match by controlId (MSH-10), by index (position in the file), or, with neither, by line order. The result for each message says matches expected, no expected output, or lists the fields that differ, with the expected and the actual value.
Send over MLLP. Enter Host, Port and Per second (default 5, at most 50). The target must be listed in MLLP_REPLAY_TARGETS on the engine (host:port, comma-separated). If the variable is unset, MLLP replay is off and the engine answers 403. One request sends for at most 240 seconds. Messages not sent by then come back as "Not sent: time limit", and the replay also stops if you close the page. For longer runs, use apps/engine/scripts/demo/replay-hl7.mjs.
The summary line reads like 12 messages · 11 ok, 1 failed · 2 of 12 compared differ, or to host:port: AA 12, AE 0, AR 0, 0 errors in MLLP mode.
5. Replay one past execution
To run a message that already went through a workflow again, find it in Messages, open it and choose Replay in the message panel. A dry run shows what would be sent first, and nothing is sent until you confirm. See Replay and Edit & replay.
You can also replay from the workflow's page: open its Runs tab, choose the run, then Reprocess in its panel and confirm.
- A replay uses the original trigger input, so you do not need the message.
- By default it sends only to destinations that failed or have not received the message yet. To send to every one, including those that already received it, call the replay API with
allDestinations: true. - To merge changes into the original input first, call the replay API with
modifyInput. See Replay.
The replay is a new execution. It is queued like any other run and keeps the message's place in its ordering lane. Two replays of the same message at once are refused: only one is written. For the API, see Replay execution.
Watch each step as you build
In the builder's Steps view, the step you have open shows a Live proof under its settings. Every edit re-runs the workflow up to that step on the sample, a moment after you stop typing, and shows:
- each of the step's parts with its input, its output and the changes between them;
- the save checks' messages for the step while you type, before you choose Save (the step in the list shows NEEDS FIX);
- for a destination, what it would send, marked Would send · nothing was sent, and the changes between its input and that payload. While values are masked, a change to a masked field still counts and its line is highlighted (it reads
•••on both sides until you choose Show PHI); when masking changes the payload's line layout, only the counts show; - values masked unless the sample is a bundled synthetic one, with Show PHI to reveal them for a reason, audited;
- a short note on the output: a step that fails, a mapped field that comes out empty (with its source path), or an output the next step or the destination cannot take, such as JSON going to an HL7 v2 destination. When you ask the assistant to comment on a step, its note shows there too.
The sample is the one in the sample panel (choose Load sample for the saved one), or a synthetic Demo Health sample of the trigger's type when none is loaded. Nothing is sent and nothing is stored: the live proof runs like Run with sample with Send for real off, and only an operator or admin's builder runs it. A viewer sees the save checks only.
To keep a step's behaviour, enter a name under the step and choose Save as test case. The case keeps what the step received and what it produced. From then on, the saved test cases re-run on your unsaved edits as you work, at most once every few seconds and always on your latest edit, and a step whose case no longer passes turns red, with TEST BROKE in the step list and the case's name on the step.
Runs are rate limited (20 step runs and 10 test case runs a minute per person). When the step runs hit the limit, the live proof says it is paused and resumes on your next edit. When the test case runs hit it, the panel says the test case checks are paused and that the red marks may be out of date; they resume by themselves when the limit resets and check your latest edit.
Live runs are audited without flooding the audit log: while you edit, the engine writes one workflow.step_test row and one workflow.test_cases_run row (with unsaved: true) per person and workflow every 10 minutes. Each row carries live: true and coalescedRuns, the number of live runs the previous row stood for. A run that reads stored content or sends for real is still audited every time.
Test some steps with Run with sample
A dry run tests the whole workflow. To debug one step, or a few in a row, test only those steps and see what each one received and produced.
- In the builder's Steps view, open the Source or a destination. Above the Source transformer or the destination's Output, choose Run with sample. The dialog opens with that list's steps picked. (Anywhere else, choose Run steps with sample in the Test run panel. In the Graph view, the selected step starts picked.)
- Tick the steps to test: one step, or several in a row. In the Graph view, any steps joined by edges that start from one step.
- Choose the sample: Paste (the sample panel's message is filled in), Sample library (the saved sample, a bundled synthetic message or a saved test case) or Past message (one of the workflow's recent messages; you need permission to view message content).
- Leave The sample is on Message as received: the steps before your pick run first, without sending. Choose First step's input to paste exactly what the first picked step receives.
- Choose Run.
Each picked step shows its input, its output, the changes between them and its console lines. A destination shows what it would send and Would send · nothing was sent. A Run workflow step shows Not run in a test. Nothing after your pick runs. Send for real makes the picked destinations really send; it is off by default.
When every step completed, enter a name and choose what the case checks, then choose Save as test case. Check the whole output (on by default) keeps each step's output and fails if any of it changes. Check these fields checks fields of the last step's output and fails when one is wrong, even when the message still reaches its destination: for each field choose Add a field check, enter the field (the box suggests the output's fields, such as MSH.9 or patient.mrn), the check (equals, exists, is absent or contains) and, for equals and contains, the value. Use either or both. The deploy checklist runs the case with the other test cases. See Run with sample for every option.
Save test cases
A workflow can keep up to 50 test cases. Each is an input message of up to 1 MB and, optionally, what the workflow should produce: an expected output, compared field by field, and field checks (assertions) on output fields (equals, exists, absent, contains). A field is an HL7 path such as PID.5 for an HL7 output, or a JSON path such as name[0].family (or $.name[0].family) for a JSON one. HL7 paths read like the data map's: a component or subcomponent (PID.5.1, MSH.9.2), a repetition (PID.3(2).1), a repeated segment by occurrence (OBX[2].5; plain OBX.5 is the first OBX), and HL7 notation with a dash (PID-5.1) all work. A case with neither passes when the message reaches a destination. Cases are stored encrypted. Results name fields and counts; a failed field check also shows the value it expected and read, masked like the message panel.
-
Save a sample in the builder as in step 1.
-
Open the workflow's Versions tab, or choose the version number in the Build toolbar. In Test cases, enter a Case name and choose Save sample as case. To keep a real run as a case instead, open it in the Runs tab and choose Save as test case.
-
To check fields, choose Edit checks on the case: add, change or remove field checks (up to 100 per case; a field is at most 200 characters) and choose Save checks. Only the checks change; the case's expected output stays. A case saved from a real message shows its values masked: Show PHI asks for a reason and is audited, and a value you enter again saves without it. Changes are audited as
workflow.test_case_updatedwith the case name and how many checks it has, never the values. To add a whole expected output, create the case through the API instead:bashcurl -s -X POST "$ENGINE_URL/api/workflows/wf_example/test-cases" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"name": "ADT A01 inpatient", "input": "MSH|^~\\&|SENDER|FAC|RECEIVER|FAC|20260101120000||ADT^A01|MSG0001|P|2.5.1\rPID|1||MRN0001^^^FAC^MR||TESTPATIENT^SAMPLE", "expected": {"assertions": [{"field": "familyName", "op": "equals", "value": "TESTPATIENT"}]}}' -
Choose Run all. Each row shows Passed, the fields that differ, Filtered by the trigger or Timed out. A failed field check is listed under its case with what it expected and what it read, for example
MSH.9 equals ADT^A04 (got ADT^A08); a patient's name or identifier reads as•••. A case saved from Run with sample says how many steps it tests, and fails when a step's output changes, when its steps are gone or when the sample stops before them.
Deploy dry-runs every case and needs each one to pass. A failing case, or cases not run since the last save, blocks it with 409 and missing: ["test-cases"]. An admin can deploy anyway, and the engine audits that. Each run is audited as workflow.test_cases_run. For the API, see Create a test case and Run the test cases.
Test it
- Save the sample from step 1 on a workflow with an MLLP trigger and one destination.
- Choose Run test.
You should see the destination as WOULD SEND with a Would send payload, masked until you choose Show PHI, and nothing delivered. Revealed, it holds TESTPATIENT. Change the destination's filter to a rule that the sample fails, such as PV1-2 equals O, and run it again. The row should now read FILTERED with PV1-2 equals O · read I · failed.
To test single steps, add two steps to the Source transformer (a data map, then JavaScript), choose Run with sample above them and Run. You should see two steps, the second one's input equal to the first one's output, and "nothing was sent".
Troubleshooting
| Problem | Fix |
|---|---|
| "Send a message or save a sample message for this workflow first" | The workflow has no saved sample. Paste one, or call dry run with a message. |
| The run reports not matched | The trigger's message type, facility or filter dropped the sample. The reason says which. |
Replay answers 403 for MLLP | MLLP_REPLAY_TARGETS is unset or does not list that host:port. An admin sets it. |
Replay answers 400 about the file | The file has no HL7v2 messages, more than 500 messages, or an invalid expected-output line. The message names the line, never its content. |
Replay answers 413 | The file is over 5 MB. Split it. |
| Run with sample says the steps "must follow on from each other" | The pick has a gap. Tick the steps in between, or test fewer steps. |
| Run with sample says the sample stopped at a step | A filter or the trigger's routing rules dropped the sample before your pick. Use a sample that passes, or start from the first step's input. |
Deploy answers 409 with missing: ["test-cases"] | A saved test case fails, or the cases have not run since the last save. Choose Run all on the Versions tab and fix the failing case. |
| Every batch message shows "differs" | Compare the first diff. A constant difference, such as a date format, is usually one mapping to fix. |