Skip to content
Guides

Call another workflow

Build a piece once as its own workflow, declare what it needs and returns, release it, and call it from other workflows, waiting for its answer or handing off.

On this page
Call another workflow. Say what a reusable patient lookup workflow needs and returns, deploy it and release it as 1.0.0, then call it from an ADT workflow that waits for the answer and saves it for the steps after it.

Some steps are the same in many workflows: look up a patient, find a medical record number, archive a copy. Build that piece once as its own workflow, then call it from every workflow that needs it. You will build a small "Look up the patient" workflow, release it, and call it from an ADT workflow that waits for the answer and uses it.

Here is the flow.

sequenceDiagram
    participant Sender as Demo Health ADT feed
    participant ADT as ADT workflow
    participant Lookup as Look up the patient
    participant API as Patient API

    Sender->>ADT: ADT^A01 (TESTPATIENT)
    ADT->>Lookup: Call workflow, wait ({ mrn })
    Note over ADT: Suspended, holds no queue slot
    Lookup->>API: Search by MRN
    API-->>Lookup: Patient
    Lookup-->>ADT: { patientId }
    ADT->>API: Post the admit with result.patientId

Before you start

  • An operator or admin role in the workspace.
  • A workflow that receives the messages, such as an MLLP or webhook workflow. See HL7v2 over MLLP to JSON.

Steps

1. Build the workflow to call

Create a workflow named Look up the patient with a Manual trigger. Give it the steps that do the lookup, for example a REST call and a data map. Its last step's result is its answer.

2. Say what it needs and returns

Open its first step (Source). Under When another workflow calls this one:

  1. In Inputs it needs, choose + Add an input, name it mrn, type text, and tick required.
  2. In Outputs it returns, choose + Add an output and name it patientId, type text.

Save. A call that sends no mrn is now refused before anything runs, and callers get only patientId back, never the rest of the lookup's data.

3. Deploy and release it

Open Versions, deploy the workflow as usual, then under Releases choose Publish release (v1) with the suggested label 1.0.0.

A release is what callers run. Deploying a new version later changes nothing for them until you cut a new release, such as 1.1.0.

Once callers pin a release, publishing the next one shows its impact under Releases: every workflow that calls this one and the release it pins. Run tests runs their test cases against the new release, and Update all gives each one that passes a new draft pinned to it (deploy it as usual); a failure is held back with the reason. A change to the inputs or outputs that callers rely on is flagged Breaking · major and needs an acknowledgement. See Release impact and updates.

4. Call it and wait for the answer

Open the ADT workflow. On its Source step, choose + Call a workflow. Then set:

SettingValue
What this step doesWait for the result, then continue
WorkflowLook up the patient
VersionRelease 1.0.0
Save the answer aspatient

The form shows what the workflow expects (mrn (text, required)) and returns (patientId (text)). Later steps read the answer as patient.patientId, for example in a data map.

5. Send a message and follow it

Send a test message to the ADT workflow. While the lookup runs, the ADT execution shows Waiting for a called workflow: it holds no queue slot, and a restart of the engine doesn't lose it. When the lookup finishes, the ADT run continues from the call.

On the ADT execution's page, View sub-execution opens the lookup's run; the lookup's page links back with Called by.

🎉 The ADT workflow now uses a lookup you can reuse from any other workflow. Read Callable workflows for every setting.

Hand off instead of waiting

When a workflow only needs to pass the message on, for example to an archive workflow, make it a destination: in the destination's Send to, choose Another workflow (hand off). The message is handed over and the workflow goes on; nothing comes back. This is the only way a destination calls a workflow: a lookup whose answer a destination needs goes in the Source steps, before the destinations.

Workflows that used the old Run workflow step keep working as they did: they hand off and follow whatever the other workflow has deployed. They show a Pin a release badge until you pick a release.

Reference