Build a channel with several destinations
Build a channel with an inbound filter and two destinations, each with its own filter and map. Test it, read a partial result and replay one destination.
On this page
A channel is one source with an inbound filter, followed by one or more destinations. Each destination has its own filter, its own output steps and its own send step, and they run independently: at the same time by default, or one after another. This guide builds a channel from scratch for ADT messages with two destinations, tests it with a synthetic message, and then shows how to read a partial result and replay only the destination that failed.
Here is the flow.
sequenceDiagram
participant Sender as Sending system (test)
participant Engine as MedHook engine
participant A as Bed board webhook
participant B as Registry webhook
Sender->>Engine: ADT^A01 over MLLP
Engine-->>Sender: ACK (AA)
Engine->>Engine: Inbound filter: message type is ADT
par Destination 1
Engine->>A: filter, map, POST
A-->>Engine: 2xx (sent)
and Destination 2
Engine->>B: filter, map, POST
B-->>Engine: 5xx (failed)
end
Engine->>Engine: Execution status: partialBefore you start
- A running engine and a signed-in user. See the Quick start.
- Two Generic REST adapter profiles, for example
Bed board webhookathttps://beds.example.test/hl7andRegistry webhookathttps://registry.example.test/hl7. Create them as in the JSON guide.
If the assistant is on (off by default), you can ask it on the Agent screen to "Draft a workflow that sends ADT over MLLP to two webhooks". It drafts a disabled workflow; choose Save as draft and use the steps below to check and finish it.
Steps
1. Create the workflow
Open Workflows and choose New workflow. On Start, pick Receive and forward and Blank workflow, then Continue. On Source, pick MLLP listener, with your Tunnel and Listener port, then Continue. On Sample, keep Bundled ADT^A01 and choose Continue. On Draft, enter the name ADT to two systems. Leave This workflow processes PHI on unless your license says otherwise. Choose Open in builder.
The builder opens with a Source step and no destinations. Choose Steps in the toolbar: this guide builds the channel in the Steps view, which lists the Source and one lane per destination. Clicking a card opens its editor over the list, and × or Esc closes it. For the rest of the builder, see Build and test in the workflow builder.
2. Filter what comes in
Open the Source card. Under Inbound filter, choose + Add rule and set:
| Field | Operator | Value |
|---|---|---|
MSH-9.1 | equals | ADT |
With the sample message loaded, the rule shows ✓ passes the sample. A message that fails the inbound filter reaches no destination.
3. Add the first destination
Choose + Add destination. The new destination is called Destination 1, and its editor opens. Set:
- Destination name to
Bed board. - The filter mode to Rules, then add the rule
PV1-2inI, E. This sends inpatient and emergency visits only. - Under Output, choose + Add output step, then set the new step to Data map → JSON. The Data Map table lists the fields of the sample. Type a Target path next to each field you want. For example,
PID-3.1tomrn,PID-5.1tofamilyName,PV1-2topatientClassandPV1-3.1tounit. Empty a target to remove the row. Mapped shows only your rows, and All shows every field in the sample. With the flat field-path view on (off by default), the table also lists each repetition and occurrence, such asPID.3(2).1orOBX[2].5, and the sample panel's Fields view lists every field with its name and Copy path. - Under Send, set Adapter profile to
Bed board webhook · generic-rest, then choose post under Action. Leave Endpoint and Body empty: the step POSTs the output to the profile's base URL.
Output steps run in order, each on the one before. Add more to chain conversions, for example HL7 → FHIR then JavaScript. Each step has ↑, ↓ and Remove. With no output step, the destination sends the message as it arrived.

4. Add the second destination
Choose + Add destination again and set:
- Destination name to
Patient registry. - The filter mode to Rules, with the rule
PID-5exists. - Under Output, + Add output step set to Data map → JSON, with its own targets. For example
PID-3.1toidentifier,PID-5.1tofamilyandPID-7tobirthDate. Turn on Include message metadata (messageType, controlId) to add those two values. - Send with Adapter profile
Registry webhook · generic-restand Action post.
Destinations run at the same time by default. Set Destinations run to one after another, in this order when a later destination needs an earlier one's reply. Its JavaScript output and filter can then read responses["Bed board"], which holds { status, data, error }: data is the earlier send's reply, such as a REST response body or an MLLP ACK. A failed or filtered destination never stops the next one. In this mode the run takes as long as all the destinations together.
status is sent, discarded (the destination is a Sink: it records the message and delivers nothing), queued, filtered, failed or not-run. In a dry run or step test nothing is sent, but scripts see what a live run would: a previewed send reads status: "sent" with dryRun: true, so a check like bed.status === "sent" passes in a test as it would live. Check dryRun when your code must tell the two apart. The test results still show the destination as WOULD SEND.
For example, a JavaScript output in Patient registry can add the bed board's reply:
const bed = responses["Bed board"];
return { ...input, bedBoardStatus: bed.status, bedId: bed.data?.id ?? null };Use ↑ Up and ↓ Down to reorder destinations, and Remove destination to delete one. Order only matters when destinations run one after another. Nothing changes until you save through Review & save. A destination without a profile, or two destinations with the same name, blocks Save and shows why under the header.
The Steps view now shows the Source card, then a lane for Bed board and one for Patient registry, each with its condition.
A send step's config decides where it sends. A message supplies only the adapter's data, such as a REST body or an MLLP message, never an endpoint, headers or a file path. To build a name from the message, use a template such as ${messageControlId} in the step's config. See What a message can set.
Decide what a response means
Under Send, the Response settings decide what the destination's answer means. Leave them empty and MedHook checks as it always has: an HTTP 2xx or an AA acknowledgement is a success, an AE is retried and an AR is not.
- When is a response a success? Rules on the answer replace that check. Rules read
status(the HTTP status, or the ACK codeAA,AE,AR,CA),body.<path>for a JSON body,headers.<name>,text, and ACK fields such asMSA.3orERR.3.1. For example,status in AA, AEtreats anAEas accepted, andbody.status not equals errorfails a200whose body says{"status":"error"}. - When can a failed response be retried? A failure these rules pass is retried with the step's retry settings, the workflow retry and the destination queue; one they fail is not. Leave them empty and a response your success rules failed is not retried, while MedHook's own failures keep their own decision.
- Save from the response saves a field into the channel map:
MSA.3intoackText, orbody.idintoorderId. Later steps read it asvars.ackText. When destinations run one after another, later ones also read it asresponses["Bed board"].values.ackText, whether the send succeeded or failed.
An ACK that names another message (its MSA-2 is not the control id that was sent) can never be turned into a success or a retry. A failure from these rules goes through the same retries, destination queue and Messages › Needs action as any other failure. Its error names the rules that failed, never a value from the response.
Open Try a response to paste an answer (a JSON body with an HTTP status, or an ACK) and see what the rules decide and what they would save. A test with Send for real shows the decision on the send step, for example Response: Success by your rules (the engine alone would have failed it). A dry run sends nothing, so it has no response to judge.
5. Run a test
Choose Replace on the sample panel, paste this synthetic message and choose Save sample:
MSH|^~\&|TESTSENDER|TESTFAC|MEDHOOK|DEMO|20260101120000||ADT^A01|MSG0001|P|2.5
EVN|A01|20260101120000
PID|1||MRN0001^^^TESTFAC^MR||TESTPATIENT^SYNTHETIC||19800101|F
PV1|1|I|WARD^101^1Choose Run test in the toolbar (⌘↵). It runs the sample through the inbound filter and every destination, with your unsaved edits, and delivers nothing. Each lane then says TAKEN or SKIPPED, and Test results under the pipeline lists each destination with a status:
| Status | Meaning |
|---|---|
WOULD SEND | The filter passed. Would send shows the body. |
FILTERED | The destination filter dropped the message, and says why. |
FAILED | A step failed. The error is shown. |
NOT RUN | The inbound filter dropped the message first. |
For this sample both destinations show WOULD SEND. Bed board would send:
{
"mrn": "MRN0001",
"familyName": "TESTPATIENT",
"patientClass": "I",
"unit": "WARD"
}Each filter rule shows what it read, for example PV1-2 in I, E · read I · passed. Now change PV1-2 in the sample from I to O and test again. Bed board shows FILTERED with Dropped by PV1-2 in I, E (read O), and Patient registry is still WOULD SEND. Change MSH-9 to ORU^R01 and both show NOT RUN, dropped by the inbound filter.
6. Save and deploy
Choose Save. Review & save lists your changes and runs any saved test cases. Add a note under What changed and choose Save as draft. An admin can choose Save and deploy v1 instead, which saves and asks a second admin to approve. To deploy, in Workflows, turn on the workflow's switch and choose Go to Deploy, then choose Deploy v1 to all messages on the Versions tab. Deploy needs a passing test newer than the last save, passing saved test cases (if the workflow has any) and an approval. An admin can deploy without them with Override and deploy, confirming Deploy anyway, and the audit log records it. See Save and deploy. See Save test cases.
🎉 The channel is live. Messages reach each destination on their own, so a failure in one never blocks the other.
Copy and edit an HL7 message
A destination can send the HL7 message on with a few fields changed, instead of building JSON. Add a Data map → JSON output step, then choose Copy and edit at the top of the Data Map (Build new is the default). The step copies the message and changes only the rows you map. In this mode a target such as hl7:PID.5.1 edits that HL7 field in place.
- Add row adds a row for a path the sample does not show: pick HL7 path or JSON path, then type the source and the target. With the flat field-path view on, a Retrohook key such as
PID.3[0].1is saved asPID.3(1).1, and the form says so. - A field that repeats in the sample shows Map all. It reads every repetition into an array, and paths such as
hl7:OBX[*].5orhl7:PID.3(*)name them. A target with one[*], such asobs[*].value, zips several fields into one array of objects. - The cog on a row opens its rules: a code table, When the code table has no entry, a Default value and Value ops, which run in order: Substring, Pad, Replace text, Date format (with a time zone), Type, Uppercase, Lowercase and Trim spaces.
A row that cannot be applied, such as a date that does not parse, fails the step and names the row, never the value. See Transforms: field mapping.
Read a partial result
When some destinations are sent and others fail, the execution ends as partial. It is terminal, and it counts as a failure in alerts, the Messages list and dashboards, so you hear about it.
To see one, make the registry endpoint answer with an error and send the sample over MLLP, as in the JSON guide. With the default ACK the sender: accept, the sender still gets an AA ACK, because the engine had recorded the message. Set ACK the sender to destination on the Source to answer AA only once every destination is sent, and AE or AR from their outcome. See MLLP and ACKs. Open the workflow's Runs tab and choose Failed: a partial run counts as failed. Its Result reads Failed at and the step, its Route lists the destinations, and its panel shows the failed step with the next step to try. A destination that failed on its first try is retried before it counts as failed, so the status appears after the retries run out. If the workflow allows workflow retries, a retry of a partial run sends only to the destinations that failed without sending. A destination whose result is uncertain, such as a timeout after the request left, is never retried automatically.
To see each destination's result, read the router step of the run:
curl -s "$ENGINE_URL/api/executions/$EXEC_ID" -H "Authorization: Bearer $TOKEN" \
| jq '.execution.nodeResults.router.data'{
"status": "partial",
"branches": [
{
"destinationId": "dest-m1abc",
"label": "Bed board",
"status": "sent",
"durationMs": 120
},
{
"destinationId": "dest-m1abd",
"label": "Patient registry",
"status": "failed",
"error": "HTTP 500",
"durationMs": 3400
}
]
}Each branch is sent, queued, filtered or failed. A destination that delivered nothing says so: discarded when it sends to a Sink (discard), and dry-run in a test run, where nothing leaves the engine. The destinationId is what a targeted replay takes. See Get execution.
Replay one destination
Fix the cause first, here the registry endpoint. Then replay.
The default replay does the safe thing. On a partial run, Replay on the message in Messages, or Reprocess in the run's panel on the workflow's Runs tab, re-runs only the destinations that failed. The confirmation says: "If the run partly delivered, only the destinations that failed are sent again." Bed board is not sent again. Resend to all destinations is a separate, confirmed action for when you want every destination to get the message again.
To choose the destination yourself, call the replay API with destinationIds:
curl -s -X POST "$ENGINE_URL/api/executions/$EXEC_ID/replay" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"destinationIds": ["dest-m1abd"]}'The reply is 202 with newExecutionId, originalExecutionId, workflowId and destinationIds, the destinations that re-ran. The new execution runs only those destinations. See Replay execution.
Troubleshooting
- Save is blocked. A destination has no adapter profile, or two destinations share a name. The reason shows under the header and on the destination.
- Every destination shows
NOT RUN. The inbound filter dropped the sample. Open Source and read the rule verdicts. A rule onMSH-9.1reads the message type. - Replay answers
409ALREADY_DELIVERED. Every destination already received the message. Name a destination withdestinationIds, or use Resend to all destinations. - Replay answers
409NO_FAILED_DESTINATION. The partial run recorded no failed destination. Name one withdestinationIds. - Replay answers
400UNKNOWN_DESTINATION. The id is not a destination of this workflow. Read thedestinationIdvalues from the router step as above. Ids change if you remove and re-add a destination. - Replay answers
403WORKFLOW_DISABLED. Deploy the workflow first.