Connect workflows with topics
Publish an event from one workflow and have any number of other workflows react to it, each on its own, with retries, dead letters and replay.
On this page
You will build an ADT intake workflow that publishes every admission to a topic, and two workflows that subscribe to it. The intake stays small: it receives and publishes. Each subscriber does one job, and you can add another later without touching the intake.
Here is the flow.
sequenceDiagram
participant EHR as EHR (test system)
participant Intake as ADT intake
participant Engine as MedHook engine
participant Store as FHIR store
participant Notify as Notifications
EHR->>Intake: ADT^A01 over MLLP
Intake->>Engine: Publish to topic adt.admit
Engine->>Store: Its own delivery
Engine->>Notify: Its own deliveryBefore you start
- An engine you can sign in to as an operator or admin.
- A workflow that receives ADT messages (an MLLP or webhook trigger), or a manual workflow for testing.
Steps
1. Create the topic
- Open Workflows, open the ··· menu and choose Topics.
- Choose New topic and name it
adt.admit. - Choose Use an example under Event schema to start from an admission schema, and adjust it to the fields you publish.
- To keep each facility's events in order, set Ordering key to
$.facility(orMSH.4when you publish the raw HL7 v2 message). - Choose Create topic. The topic's page opens and tells you nobody publishes or subscribes yet.
2. Publish from the intake workflow
- Open the intake workflow.
- Add a destination and name it
Admissions. - Add a Data map output that produces the fields of the schema:
patientId,facilityandadmittedAt. - Under Send, set Send to to a topic and pick
adt.admit. - Save. Run with sample shows the subscribers the event would reach, without sending anything.
3. Subscribe
- Open, or create, the workflow that should react, for example one that writes a FHIR Encounter.
- Select its trigger and set Trigger type to topic, then pick
adt.admit. - Build its steps as usual. Its input is the event as published.
- Do the same for each other subscriber.
- Deploy each workflow. A workflow that was deployed before gets the topic's events only once the version with the Topic trigger is deployed, and the intake publishes only once the version with the topic destination is deployed: a saved draft never changes production traffic.
4. Watch the deliveries
Send an admission. On Workflows → Topics → adt.admit:
- Recent events shows the event and a state for each subscriber: waiting, running, delivered, retrying or dead letter.
- Subscribers shows each subscriber's lag.
- Dead letters lists deliveries that ran out of retries, with the last error. Fix the cause, then choose Replay.
🎉 Admissions now reach every subscriber on their own. To add a destination for admissions, add a workflow with a Topic trigger: the intake does not change.
To change the topic later, edit Schema and settings on its page. When deployed workflows use it, Save changes first shows who is affected and, for a new schema, how many recent events it would reject.