Skip to content
Reference

Run with sample

Test one step, or a group of steps, on a sample message, see each step's input and output, and save the run as a test case that runs on every deploy.

On this page

Run with sample runs only the steps you pick on a sample message and shows what each one received, what it produced, what changed and any JavaScript console lines. By default nothing leaves MedHook: destinations show what they would send, and other workflows are not started. Use it to debug a mapping one step at a time, then keep the run as a test case.

How it works

Open a workflow in the builder. Choose Run with sample above a list of steps (the Source transformer, or a destination's Output), or Run steps with sample in the Test run panel. In the dialog, tick the steps to test.

  • In the Steps view, pick one step or several in a row. A run can start in the source transformer and continue into one destination.
  • In the Graph view, pick any steps joined by edges that start from one step. The step selected in the graph starts picked.
  • The dialog refuses a pick with a gap ("The selected steps must follow on from each other"), one that starts in two places, or one that takes both branches of a condition (a sample only takes one, so the other branch could never run), and says why.

Choose where the sample comes from, how it reaches the steps, then Run.

Sample sources

SourceWhat it isWho can use it
PasteHL7v2, JSON or text you paste. The sample panel's message is filled in for you.Operators and admins
Sample libraryThe workflow's saved sample, the bundled synthetic messages (ADT^A01, SIU^S12), or a saved test case's input.Operators and admins; the library lists names only
Past messageThe input of one of the workflow's recent messages, as received.Only people who may view message content (operators, admins)

One sender's samples

A workflow that serves many senders has a sample set per sender. With Sample library or Past message, a Sender list appears when the workflow knows more than one sender: its sender table, the senders in its per-sender connections, and the sending facility (MSH-4) of each sample. Choose one to see only that sender's samples and recent messages; Every sender shows them all. Save a test case from a sender's message and it joins that sender's set.

A destination with a connection per sender shows which connection it would use for the sample, for example "Connection: North API, for sender DH-NORTH".

The sample is

ChoiceWhat runs
Message as receivedThe trigger's routing rules first, then the steps that lead to your pick, then your pick. Earlier steps never send. Nothing after your pick runs.
First step's inputOnly the steps you picked. The sample (JSON, else text) is what the first one receives.

What each step shows

PartMeans
InputWhat the step received.
OutputWhat it produced. A destination shows Output (what it would send).
Changes · +n −nThe line diff between input and output.
ConsoleA JavaScript step's console.log lines.
Not sent: dry runA destination that reported what it would send.
Sent for realA destination that sent, because you turned on Send for real.
Not run in a testA Run workflow step. The other workflow is never started in a test.
not runThe sample stopped before this step, for example at a filter. The dialog names the step it stopped at.

Sending for real

Send for real is off by default. Turned on, the destinations you picked really send; destinations before your pick still only dry-run, and Run workflow steps still start nothing. The audit entry records that the run sent.

Save as test case

After a run where every step completed, name it and choose Save as test case. The case keeps the sample, the steps, how the sample reached them and each step's output. The deploy checklist runs it with the workflow's other test cases and fails it when a step's output changes, when its steps are no longer in the workflow, or when the sample no longer reaches them. A test case never sends. A run that sent for real can't be saved; run it again without sending.

A case compares only what is the same on every run:

  • A destination's send is compared as the message it would send, field by field. For HL7v2, MSH-7 (the message time) is ignored, as for whole-workflow test cases.
  • The hidden router that joins the source transformer to a destination runs, but is not compared: it reports timings that change on every run. Its destination's steps are compared.

The steps must be in the saved workflow: save the workflow before you save a test case for steps you just added.

Privacy and audit

  • The run's response holds message content and is never cached.
  • Each run is audited as workflow.step_test with the number of steps, the sample's source and the id of the record it came from, whether it sent for real and the outcome. A run that fails is audited too. Never the content.
  • A stored sample is audited as the read it is: a past message as message.viewed with the message's id, a test case as workflow.test_case_read with its id, the saved sample as workflow.sample_read.
  • A past message must be one of this workflow's messages.
  • Test cases are stored encrypted, like saved samples.

API

Reference