Skip to content
Guides

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
Connect workflows with topics. Create an adt.admit topic, publish each admission to it from an ADT intake workflow, and let a FHIR store and a notification workflow subscribe, each delivered and retried on its own, with a dead letter you can replay.

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 delivery

Before 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

  1. Open Workflows, open the ··· menu and choose Topics.
  2. Choose New topic and name it adt.admit.
  3. Choose Use an example under Event schema to start from an admission schema, and adjust it to the fields you publish.
  4. To keep each facility's events in order, set Ordering key to $.facility (or MSH.4 when you publish the raw HL7 v2 message).
  5. Choose Create topic. The topic's page opens and tells you nobody publishes or subscribes yet.

2. Publish from the intake workflow

  1. Open the intake workflow.
  2. Add a destination and name it Admissions.
  3. Add a Data map output that produces the fields of the schema: patientId, facility and admittedAt.
  4. Under Send, set Send to to a topic and pick adt.admit.
  5. Save. Run with sample shows the subscribers the event would reach, without sending anything.

3. Subscribe

  1. Open, or create, the workflow that should react, for example one that writes a FHIR Encounter.
  2. Select its trigger and set Trigger type to topic, then pick adt.admit.
  3. Build its steps as usual. Its input is the event as published.
  4. Do the same for each other subscriber.
  5. 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.

Reference