Skip to content
Reference

Callable workflows

Every setting of the Call workflow step, the inputs and outputs a workflow declares, releases, and what happens while a call waits.

On this page

A workflow can use another workflow as a step. The Call workflow step starts the other workflow (the child) and either waits for its answer or hands the message off and goes on. The child declares what it needs and what it returns, and callers pin one of its releases, so a change to the child reaches callers only when you choose.

How it works

In wait mode the calling run is suspended once the child has started. A suspended run holds no queue slot, so even an engine that runs one workflow at a time finishes a chain of calls. When the child finishes, the calling run resumes on the same step: earlier steps are not run again, and nothing they sent is sent twice. The suspended run is stored in the database, so a restart of the engine, or of every replica, loses nothing: the run resumes when the engine is back.

In hand off mode the child is started and the calling run goes on at once. Nothing comes back.

The child always runs in the same workspace, outside any ordering lane, so it never queues behind its caller. A chain of calls stops at five workflows deep.

Step settings

SettingWhat it doesDefault
What this step doesWait for the result, then continue, or Hand off and go on.Wait, for a new step
WorkflowThe workflow to call, in this workspace. A workflow can't call itself.
VersionA release (1.2.0), Newest release, or Follows the deployed version.The newest release when you pick the workflow
Save the answer asThe message key the child's outputs are saved under (wait only). Later steps read result.patientId.result
If it failsFail this step, or Continue, with the error saved as the answer (wait only).Fail this step
Wait up to (minutes)How long to wait for the child (wait only). From 1 second to 7 days.15 minutes
Extra input valuesValues added to the message the child receives.None

The child receives the current message, with the extra input values added. A raw message, such as HL7v2 text, is passed whole. When the calling step continues, a message that is a record gets the answer under the Save the answer as key. A raw message is kept under message, next to the answer.

With Continue on a failure, the answer is { "failed": true, "error": "...", "executionId": "..." }, so a later filter can test result.failed.

Where the step goes

In the Steps view, a call that waits is a source step: on the Source step, choose + Call a workflow. A hand-off is a destination: in a destination's Send to, choose Another workflow (hand off). Destinations don't offer a call that waits; put a lookup whose answer a destination needs in the source steps. In the Graph view, Call workflow is in the step palette.

A call that waits must be on the workflow's main path. Inside a loop, a parallel step or a destination, use hand off: saving refuses a wait there.

Inputs and outputs

A workflow declares what callers must send and what it returns under When another workflow calls this one, on its first step (Source). Each field has a name, a type and whether it is required.

TypeAccepts
textA string
numberAny number
whole numberAn integer
yes / notrue or false
recordAn object
listAn array
  • Inputs are checked before the child starts. A call whose message lacks a required input, or has one of the wrong type, fails the step and starts nothing.
  • Outputs are checked when the child finishes. The answer is the last step's result, reduced to the declared outputs: callers get only what the child promises, never the rest of its data. An answer that breaks the outputs fails the calling step.
  • A workflow with no inputs or outputs declared accepts any message and returns its last step's whole result.

The inputs and outputs are part of the definition, so each version, and each release, has its own.

Releases

A release is a version label, such as 1.2.0, on a deployed version. Cut one on the child's Versions tab, under Releases, after it is deployed.

Version settingRuns
A release (1.2.0)Exactly that version, even after the child deploys something newer.
Newest releaseThe highest release. A new deploy changes nothing until a new release is cut.
Follows the deployed versionWhatever the child has deployed now.
  • A release must be higher than every earlier one: 1.2.1 for a fix, 1.3.0 for an addition, 2.0.0 when callers must change.
  • A released version is never pruned from the version history.
  • A call to a release that doesn't exist, or to a workflow that is off, fails the step and is not retried.
  • Publishing a release shows its impact: every calling workflow and the release it pins. Run tests and Update selected / Update all move the callers that pin an older release to new drafts, holding back any whose tests fail; a breaking change to the inputs or outputs is flagged major. Audited as workflow.call_update. See Release impact and updates.

Steps made with the old Run workflow step are Call workflow, hand off steps that follow the deployed version, which is exactly what they did before. They show a Pin a release badge until you pick one.

While a call waits

StatusMeaning
Waiting for a called workflowThe run is suspended. It holds no queue slot and no heartbeat.
  • An ordered (FIFO) trigger, such as MLLP with ordering by sender, keeps its place: the sender's next message waits until the calling run has finished, so per-sender order holds. The wait is bounded by Wait up to.
  • A hand-off never holds the lane.
  • If the child fails and has workflow retries, the caller waits for the retries.
  • If the deadline passes first, the step fails (or continues with the error). The child is not stopped.
  • Cancelling a waiting run cancels it at once and frees its lane, whether you cancel it or the first attempt of its chain. The child keeps running.
  • A waiting run goes on with the version of the caller it started on. Deploying the caller while it waits changes only the runs that start after.
  • Execution retention never deletes a waiting run, however long ago it started.

Loops of calls

Saving and deploying refuse a loop of workflows that wait for each other, such as A waits for B and B waits for A, directly or through hand-offs. The check follows each call to the version it runs (its release, the newest release, or the deployed version) as well as the other workflows' saved drafts. The message names the loop. A loop made only of hand-offs is allowed, as Mirth allows channel loops; the depth limit stops it.

Following a call

  • An execution's page lists each Call workflow step with View sub-execution, and a called run shows Called by with a link back.
  • The Messages inspector shows View sub-execution for the runs a message's steps called.
  • Viewers without access to message content still see these links: they carry ids and workflow names only.

Reference