Parallel runs
Incumbent API connections, shadow mode, the comparison rules and the cutover report of a parallel run beside Mirth Connect or Rhapsody.
On this page
A parallel run compares one MedHook workflow with an incumbent engine's channel on the same traffic before a cutover. MedHook runs the workflow in shadow mode, captures the incumbent's output for the same message, and diffs the two. The step-by-step guide is Run beside Mirth or Rhapsody, then cut over.
Incumbent connections
A connection is read-only. MedHook reads status and messages; it never deploys, starts, stops or changes anything on the incumbent.
| Engine | API | Sign-in | What MedHook reads |
|---|---|---|---|
| Mirth Connect | REST API, https://<host>:8443/api (3.x, 4.x, Open Integration Engine) | HTTP Basic or a session login; X-Requested-With sent on every request | Every channel's id and name, deployed channels' state and statistics, and a channel's processed messages with content |
| Rhapsody | REST management API, JSON | HTTP Basic | Routes and communication points with their state and counts |
The API URL must be https://; plain http:// is accepted only for a host listed in SSRF_ALLOWLIST. The password is encrypted with the engine's credential key, re-encrypted by key rotation and never returned. Every call goes through the engine's outbound guard: private and reserved addresses are refused unless listed in SSRF_ALLOWLIST, every address a host name resolves to is checked, and redirects are refused. A response over 5 MB is refused.
Self-signed certificates
TLS certificates are verified. Rhapsody (port 8444) and Mirth Connect (port 8443) ship a self-signed certificate by default, so a connection to one needs its trust set when you add it, as on Migration › Import's live connect. Send exactly one of these with POST /api/incumbents:
trustFingerprint: the server certificate's SHA-256 fingerprint (AA:BB:…). Only that certificate is accepted.caPem: the PEM CA certificate (or chain) that signed the server's certificate. The host name is checked too.
Sending both, a malformed fingerprint or a CA that can't be read answers 400 and stores nothing. Adding a connection sends nothing to the server. The trust is kept on the connection, and the connection's view shows pinnedFingerprint256 or customCa: true. It is audited as migration.source.cert_pinned (vendor, host and fingerprint) or migration.source.ca_uploaded (vendor, host, and the CA's fingerprint and subject). The PEM, the user name and the password are never in the audit record.
Every read of the connection (the channel status view, Mirth sync) checks the certificate against that trust. There is no "allow self-signed" setting.
| Code | When | details |
|---|---|---|
INCUMBENT_CERT_UNTRUSTED | The engine can't verify the certificate and nothing is pinned | certificate: its fingerprint256, subject, issuer, validFrom, validTo and selfSigned, to check on the server |
INCUMBENT_CERT_FINGERPRINT_CHANGED | The server presents another certificate than the pinned one | pinnedFingerprint256, and certificate (the new one) |
Both answer 502, and nothing is sent to the server. Check the fingerprint on the incumbent itself before you trust it.
To trust a new certificate, choose Channel status on the connection under Migration › Parallel runs › Set up a parallel run. When the certificate changed, MedHook shows the pinned and the new fingerprint side by side; choose Trust the new certificate and connect, check both fingerprints in the confirm, then Trust the new certificate. The connection is re-pinned in place and the channels are read again. You don't enter the password again, and the connection and the parallel runs that use it stay. Upload CA certificate (.pem) there replaces the trust with a CA instead. Viewers don't get the prompt.
Over the API, PATCH /api/incumbents/{id} (operator or admin) takes exactly one of:
trustFingerprint: re-pin to the certificate the server presents now. Send the fingerprint you checked on the server. MedHook reads the certificate again first (a TLS handshake, with no request and no credentials sent) and pins it only when it is that one; otherwise it answers409INCUMBENT_CERT_FINGERPRINT_CHANGEDwithdetails.certificate(what the server presents now),details.confirmedFingerprint256anddetails.pinnedFingerprint256, and stores nothing. A pin is never set without that check.caPem: replace the trust with a CA certificate (or chain). The host name is checked on every read.clearTrust: true: forget the pin or the CA; the next read answersINCUMBENT_CERT_UNTRUSTEDagain.
None, more than one, a malformed fingerprint, a CA that can't be read or any other field answers 400 and stores nothing. The changes are audited as migration.source.cert_pinned (with previousFingerprint256), migration.source.ca_uploaded, or migration.source.trust_cleared (vendor, host, and the previous fingerprint or previousCustomCa). Connecting to the same server from Migration › Import also updates the connection in place.
For Rhapsody, MedHook reads the component tree (GET /api/components/status), then each route (GET /api/route/{id}: processed count and queue sizes) and communication point (GET /api/commpoint/{id}: received, sent and failed counts, queue sizes), a few at a time. A route reports no sent or error count. A count the API does not report shows as a dash, never as zero, and so does a component whose own read fails.
Channel status view
Each incumbent channel is listed with its state and counts beside the MedHook workflow that replaces it. A channel matches a workflow by import first: a channel imported from Mirth, or a route imported from Rhapsody, keeps a fixed workflow id, so it matches after a rename. Otherwise names match without case, spaces or punctuation. Mirth channels that are not deployed are listed as UNDEPLOYED with no counts. Each read is a live call to the incumbent, so it needs the operator role.
Shadow mode
MedHook's side of each message is the workflow's dry run: the trigger's matching rules, then every step. Destinations report what they would send and are never called. Nothing is delivered, no execution is stored, nothing is retried or counted in metrics. Every destination is compared: a Mirth sync pairs each Mirth destination's output with the MedHook destination imported from it, by Mirth's metaDataId, whatever order they ran in (a workflow that was not imported is paired by position), and a destination only one side sent is a (destination) difference. A captured output (one per message, from the intake routes) is compared with the first destination's. A message the trigger filters out, or a step that fails, is recorded as a MedHook error for that message.
Correlation
Both sides of a message meet on a correlation key: the X-Correlation-Key header, ?correlationKey=, or correlationKey in a JSON body; otherwise MSH-10. A message without either (FHIR JSON, for example) must name its key. A key is used whole, up to 1,024 characters; a longer one is refused, never cut. Mirth sync uses the source message's MSH-10. Sending the same side again replaces it.
The key is stored as a keyed hash: HMAC-SHA256 under the run's own random key, made when the run starts and stored encrypted with the message encryption key, so rotating that key does not split a run's messages. The key itself is kept with the encrypted content. People who can see message content see the key in the report; viewers see a short label made from the hash.
Capture tokens
The intake routes, POST /api/parallel-run-intake/<id>/inbound and /incumbent-output, accept only the run's capture token, in the X-Capture-Token header or as Authorization: Bearer mhcap_…. Engine tokens and sign-in sessions are not accepted there. A token is random, belongs to one run, is shown once when the run starts or when an operator makes a new one, and is stored only as its SHA-256. Making a new token or revoking it takes effect at once and is audited. A wrong, revoked or other run's token gets 401.
Ignore rules
These are always ignored: MSH.7, MSH.10, meta.lastUpdated and meta.versionId. A run can add up to 100 more.
| Rule | Example | Ignores |
|---|---|---|
SEG | ZDS | The whole segment, every occurrence |
SEG.n | EVN.2 | One field |
SEG.n.m | PID.3.4 | One component; the rest of the field is still compared |
SEG[k]... | OBX[2].14 | The same, in the k-th occurrence only |
| JSON path | meta.source | That path and everything under it, wherever it starts |
[*] | entry[*].fullUrl | Any array index |
$. | $.id | Anchored at the root only |
Changing a run's rules compares every stored message again.
Comparison rules
HL7 v2 messages are compared segment by segment:
- separators come from each message's own MSH, so messages with different encoding characters compare by value;
- line endings, blank lines and trailing spaces are not differences, and neither are trailing empty fields, repetitions, components or subcomponents;
- segments pair up by name and occurrence; a name that repeats on either side is numbered, as in
OBX[2].5; - a missing or extra segment is one difference named after it; the same segments in another order is one
(segment order)difference.
JSON (including FHIR) is compared path by path after parsing, so key order and whitespace are not differences; a path present on one side only shows (missing) on the other. Other text is compared with line endings normalized. Two different formats are one (format) difference.
The report
| Field | Meaning |
|---|---|
compared | Messages with both outputs in (matched, mismatched and MedHook errors) |
matched | Compared with no difference after the ignore rules |
mismatched | Compared with at least one difference |
errors | The incumbent produced output but the shadow run failed or was filtered |
awaitingIncumbent | MedHook's side only so far; not in the match rate |
awaitingMedhook | The incumbent's side only so far; not in the match rate |
matchRate | matched / compared, four decimals; empty before anything is compared |
fieldMismatches | Per field: the compared messages where it differs, and their share of compared |
byMessageType | Per MSH-9: compared, matched and the match rate |
The summary holds counts and field names only. A field name is stored and shown to viewers only when it cannot hold message content: an HL7 path on a standard segment (v2.3 to v2.8) or a Z-segment, such as PID.5 or OBX[2].5.1; one of the markers (segment order), (format), (body) or (value); or, when both outputs are FHIR resources, a path of element names (entry[0].resource._birthDate). Every other name, including every path into JSON that is not FHIR, shows as [field]; the real name appears in the detailed report for people who can see message content. A line in an HL7 message that does not start with a standard segment id or a Z-segment id is treated as part of the line before it, never as a segment. The detailed report (JSON, or CSV with one line per differing field) adds both values of each differing field. The fields-only report (GET /api/parallel-runs/<id>/report?values=0, JSON only) is what Set up a parallel run reads: every role gets the viewer's rows, the summary's field names are masked the same way, and nothing is exported, so it is not audited as an export. In the CSV, a value that starts with =, +, - or @ is prefixed with ' so a spreadsheet does not run it.
A run holds at most 10,000 messages and each message at most 1 MB. The limit holds under concurrent writes: a new message is admitted under a per-run lock.
Retention
Stored messages follow execution retention: a message last written longer ago than the workflow's own retention, or else EXECUTION_RETENTION_DAYS, is deleted by the same periodic sweep that purges executions (0 keeps them). Deleting a run, its workflow or its workspace deletes its messages at once.
Roles, encryption and audit
| Action | Minimum role | Audit event |
|---|---|---|
| List connections, runs, report summary | Viewer | — |
| Channel status (a live call to the incumbent) | Operator | — |
| Read or export the detailed report | Viewer; values, keys and content-bearing field names are hidden below operator | parallel_run.report_exported (format and counts) |
Read the fields-only report (?values=0) | Viewer; no values, keys or content-bearing field names for any role | — |
| Add or delete a connection | Operator | incumbent.connection_created, incumbent.connection_deleted |
| Start, change, close or delete a run | Operator | parallel_run.created, parallel_run.updated, parallel_run.deleted |
| Sync from Mirth | Operator | parallel_run.synced (counts only) |
| Make or revoke a capture token | Operator | parallel_run.capture_token_rotated, parallel_run.capture_token_revoked |
| Send to the inbound or capture route | The run's capture token | One call per message, not audited; counts are in the report |
Both stored outputs are encrypted with the message encryption key, as executions are, when the workflow has Encrypt stored messages on, when ENCRYPT_STORED_MESSAGES is set, or when the workflow no longer exists. Each value is bound to its run, message and side. No audit entry or log line holds message content.