Skip to content
Guides

Migrate from Mirth Connect

Import Mirth Connect channels as draft workflows, and export MedHook workflows back to Mirth for a parallel run or a rollback.

On this page
Migrate from Mirth Connect. Upload a synthetic Mirth Connect export, read the dry run's findings for each channel, import the channels as disabled draft workflows, then open one draft, look at the JavaScript its Mirth Message Builder step became, and test it with a synthetic ADT^A01 message.

You can move channels in both directions. Import turns a Mirth Connect export into disabled draft workflows and a review report. Export turns a MedHook workflow into a Mirth channel and a fidelity report. The two directions are not mirror images, so this guide says what each one covers.

sequenceDiagram
    participant You
    participant Mirth as Mirth Connect
    participant Engine as MedHook engine

    You->>Mirth: Export channels (XML)
    You->>Engine: Migration › Import (dry run)
    Engine-->>You: How much of each channel converts
    You->>Engine: Convert N to drafts
    Engine-->>You: Disabled draft workflows
    You->>Engine: Review, Mark reviewed, test, enable
    You->>Engine: Migration › Export to Mirth (rollback or parallel run)
    Engine-->>You: Channel XML or .zip + fidelity report
    You->>Mirth: Import Channel, enter credentials

What each direction covers

Import (Mirth to MedHook)Export (MedHook to Mirth)
ResultDisabled draft workflowsA channel XML file, or a .zip of several
QualityA draft conversion. You review it.Verified in CI, with a report of every difference
CredentialsNever importedNever exported
Safe to run liveNot until you review and test itAfter you read the report and enter credentials

Before you start

  • An engine you can sign in to. Importing needs the operator role. Exporting works for any signed-in role.
  • A Mirth export as XML: one channel, a list of channels, or a full server configuration, from Mirth 3.x or 4.x.
  • A way to test. See Test with sample messages.

Import Mirth channels

1. Open the importer

Open Migration, then the Import tab (New import at the top of the page opens it too). Choose Mirth Connect export. A file the card doesn't read is refused with the card that does, for example a locker .zip dropped here names Rhapsody locker export.

To read the channels from a running Mirth instead, choose Mirth Connect server, enter the Server URL, an API user (medhook-readonly to start with) and the Password, which is write-only and never kept, then choose Connect read-only and discover. MedHook lists and reads, and never deploys, starts or stops anything on the server. The Mirth Integration Engine card (NextGen 4.x and later; it works for Mirth Connect too) connects the same way, then lists the server's channels: tick the ones you want and choose Pull n and dry run. MedHook reads those channels, the code template libraries, the configuration map and the global scripts as one server backup, and the dry run is the same as for an uploaded export, then Convert n to drafts. It only sends HTTP GET requests with HTTP Basic auth, never a login, deploy, start or stop. The password is stored encrypted, like an adapter's credentials, and never shown again; remove the connection under Migration › Parallel runs when you are done. A server on a private network must be listed in SSRF_ALLOWLIST on the engine, and the connect then says so. Each request times out after 15 seconds, and the pulled channels may be at most 5 MB. Mirth's API on port 8443 uses a self-signed certificate unless someone replaced it, and MedHook does not trust that on its own: the connect stops and shows the certificate's SHA-256 fingerprint, subject, issuer and validity. Compare the fingerprint with the one on the Mirth server (for example keytool -list -v on its keystore), then choose Trust this certificate and connect to pin exactly that certificate on the connection, or Upload CA certificate (.pem) when your organization's CA signed it. Every later pull, convert and parallel run checks the pin. If the server's certificate changes, MedHook sends nothing to it, shows the pinned and the new fingerprint, and waits for you to trust the new one. The pin is audited as migration.source.cert_pinned and a CA upload as migration.source.ca_uploaded, with the host and the fingerprint only. The guided Mirth onboarding, which also lists the systems the channels talk to and replays recent Mirth messages through a draft, stays on the Workflows page under Import › Import from Mirth or Rhapsody. A server read is a one-time read, not a live sync.

2. Drop the export file

Drop the XML on the striped area, or click it to pick the file. Use sample export loads a synthetic one. The engine runs a dry run at once. It reads the file only, and changes nothing on the old server. You see five totals (channels, code templates, global maps, connections, certificates), then every channel with what it is (channel · TCP Listener → HTTP Sender) and how much of it converts on its own:

EstimateMeaning
fully automaticEvery step converts with nothing to review.
about N%That share of its steps converts on its own; the rest need your eyes.
needs reviewA person checks it before it runs.
(the reason)No MedHook equivalent yet. The channel is not converted and can't be selected.

A plain-FTP File Writer keeps its estimate, with plain FTP · switch to SFTP or FTPS beside it: it converts with plain FTP and a finding.

The code templates are one more row, Code templates (N), with how many convert on their own. They come over with the channels that use them.

3. Convert the channels you want

Every channel starts selected. Clear the ones you don't want, then choose Convert N to drafts. Each one becomes a draft workflow, and all of them are disabled. A draft takes no traffic until you deploy it: an HL7 message that only a draft would match gets AR (No matching triggers for message type …), not a paused AE, so a sender pointed at MedHook early does not queue it forever. The page switches to In progress, where they wait under Needs review; open one to read its findings on the review page. The engine also creates an adapter profile for each destination, with no credentials. Under Adapters, re-enter the credentials on every profile marked as needing them. Each converted step keeps a Was line in the builder, such as Was: Transformer · JavaScript (E4X), so you can find your way back to the Mirth channel.

Importing the same channel again does not make a copy. The engine reports the existing draft.

Migration › Import after a dry run of a Mirth export: the five totals, then each channel with what it is and how much of it converts on its own, every row selected, and Convert N to drafts

What import converts

MirthMedHook
TCP Listener (MLLP)MLLP trigger. When your operator has declared a listener in Helm mllp.listeners on the channel's Mirth port, the import picks it. Otherwise the trigger is on the shared default listener, and the finding is a REVIEW that names every channel sharing it: each workflow on a listener gets every message it receives unless its trigger filters by message type or sending facility.
TCP Listener (Basic TCP, Frame, MLLP with custom bytes)MLLP trigger. A finding gives the raw TCP listener to declare in Helm mllp.listeners (its framing, bytes, response, connection cap and idle timeout); pick it under Listener. See Raw TCP.
HTTP ListenerWebhook trigger with a new URL
Channel ReaderManual trigger
JavaScript ReaderA polling trigger. A script that is a plain HTTP poll with a literal URL gets a Generic REST profile with its headers and cursor; any other script gets a polling trigger with no profile, and a finding asks you to set one.
Database Reader (PostgreSQL, SQL Server, MySQL, MariaDB, Oracle)A polling trigger on an SQL database profile. The SELECT carries over, and the update statement runs per row as the post-process, with ${col} as :col. See the Database Reader recipe.
Database Writer (PostgreSQL, SQL Server, MySQL, MariaDB, Oracle)An SQL database execute step. ${var} in the statement becomes :var, read from the step input's params.
TCP Sender (MLLP)MLLP adapter step
TCP Sender (Basic TCP, Frame, MLLP with custom bytes)MLLP adapter step with the same framing; the response is checked as an HL7 ACK for HL7 data and returned unchecked otherwise
TCP Listener or TCP Sender over TLS (NextGen's SSL Manager, BridgeLink's SSL Settings plugin, or the connector's own TLS settings)TLS stays on. A sender becomes an MLLP adapter step whose profile has tlsEnabled, with the TLS 1.3 floor when Mirth allowed only TLS 1.3. A listener's trigger is on the TLS listener mirth-tls-<port>, and a REVIEW finding gives its Helm mllp.listeners entry with the tls block (and requireClientCert when Mirth required client certificates); when a TLS listener is already declared on the Mirth port, the import picks it. Certificates, keys and keystore passwords stay in Mirth: a TODO TLS finding names each one to upload (the CA as tlsCaPem, the client certificate as tlsClientCertPem and tlsClientKeyPem or tlsClientPfx, the listener's certificate in its Secret). Trusting every certificate, accepting expired ones, host name checks, subject DN checks, revocation checks and cipher lists each get a finding; MedHook keeps verifying the peer. A SHA-256 leaf pin becomes tlsFingerprint256. Keystore and truststore passwords are never read.
HTTP SenderGeneric REST adapter step
File Writer over SFTPSFTP adapter step
File Writer over S3S3 adapter step (putObject): bucket and folder on the profile, the file name as the object key
File Writer over FILE, FTP, SMB or WebDAVAn upload step on a file, FTP, SMB or WebDAV profile; append and error-if-exists go on the profile
File Reader over SFTPAn SFTP pickup trigger. The file filter, after-processing action, move and error folders, file age and size cap carry over.
File Reader over FILE, FTP, SMB, WebDAV or S3A file pickup trigger on a file, FTP, SMB, WebDAV or S3 profile, with the same options as the SFTP pickup plus subfolders, size limits, binary and more charsets.
JMS ListenerA JMS trigger on a JMS profile. The broker's host and port come from the broker URL (OpenWire and JNDI with a finding); the password is re-entered.
JMS SenderA JMS send step to the same queue or topic.
Web Service ListenerA SOAP trigger at /api/triggers/soap/mirth-<channel id> that serves a WSDL for Mirth's acceptMessage. HTTP authentication is not imported: set WS-Security or an HMAC secret. See Migrate a Mirth JMS or Web Service Listener channel.
SMTP SenderAn SMTP send step. Host, port and encryption go on the profile; recipients, subject, body and attachments on the step. The login is re-entered.
JavaScript WriterA JavaScript Writer step. The script runs in the sandbox with Mirth's destination semantics.
Document WriterA Document Writer step that renders a PDF or RTF. The PDF password is re-entered.
Web Service SenderA SOAP adapter step. The endpoint, WSDL URL, SOAPAction and envelope carry over.
DICOM ListenerA dicom trigger; the AE title senders call becomes its called AE title. The port, TLS and storage folder belong to the MedHook DICOM listener (Helm dicom.*), so the finding names them. See the imaging recipe.
DICOM SenderA DICOM send step. Host, port, both AE titles, the timeout and the TLS mode carry over; keystores, truststores and the user name and passcode are re-entered.
Delimited, XML or NCPDP data typeA CSV parse, CSV generate, fixed-width or XML parse step
Channel WriterA Run workflow step that blocks deploy (see below)
Several destinationsA router with one branch per destination (d<metaDataId>)
Source filter on MSH-9.1 equals a valueThe MLLP trigger's message types when every rule is ANDed; otherwise a filter rule
Rule Builder filterA rules-mode filter step
JavaScript filterA filter step with one expression, marked for review
Other source filter on MLLP or webhookThe trigger's filter. A JavaScript one is a script filter marked for review.
Mapper and Message BuilderA data map that edits the message (Copy and edit) on HL7 v2, when each step sets an HL7 field from an HL7 path, a text value or a Mapper variable. Otherwise the JavaScript Mirth generates for the step
Transformer scriptsA JavaScript transform step marked for review
Preprocessor scriptThe workflow's first JavaScript step, marked for review: message is the raw message text, what the script returns replaces it, and returning nothing keeps it
Postprocessor scriptA JavaScript step after every destination, marked for review: responseMap holds each destination's response by name and by d1, d2, ...; the channel's destinations run one after another
Global preprocessor and postprocessorThe same steps in every workflow imported from the server backup: the global preprocessor before the channel's, the global postprocessor after the channel's

For a whole channel built from these pieces, see the recipes Lab results from a Windows share (a File Reader) and Database Reader to FHIR.

Connector settings carry over where MedHook has them:

  • Process Batch on a TCP or HTTP Listener turns on batch splitting. MedHook splits by MSH segment. A JavaScript batch script is not imported, and the finding says so.
  • Charset on a TCP Listener, HTTP Listener or TCP Sender becomes the character set of the trigger or MLLP profile.
  • Transmission mode on a TCP Listener or TCP Sender carries over in every mode. MLLP stays MLLP. Basic TCP, Frame, and MLLP with bytes other than 0B and 1C0D become frame framing with the same start and end bytes (Mirth's 0x0B and <VT> spellings are read too); Basic TCP with no end bytes becomes eos (the message ends when the connection closes). A listener's framing belongs to a port, so the finding gives the Helm mllp.listeners entry to declare. MLLP release 2 (useMLLPv2) and a listener in client mode get a finding each. See Raw TCP.
  • Queue on a destination turns on Queue until delivered on the send step, with Mirth's retry interval. See Queue until delivered. Queued destinations show on Messages › Queues.
  • An HTTP Sender proxy becomes the profile's proxy URL. The proxy password and SSL Manager certificates are not in a channel export, so the finding asks you to enter them. See Connection options.

How filters import

A Mirth filter accepts or rejects a message, and a rejected message is FILTERED, not an error. The import keeps that meaning.

  • Each destination is a router branch with its filter as a filter step. A destination whose filter rejects the message is filtered, and a message that every destination rejects completes. Executions show the outcome per destination, and you can replay one destination.
  • Rule Builder rules become a rules-mode filter when MedHook reads them the same way: an HL7 field, EQUALS, NOT_EQUAL, EXISTS, NOT_EXIST, CONTAINS or NOT_CONTAIN, and one AND or OR for the whole filter. They keep Mirth's meaning. Mirth compares the field as text, so EQUALS '' matches an empty field, and CONTAINS is case-sensitive, so it imports as a literal regex rule. The rules read the HL7 message on every trigger, including a raw HL7 body posted to a webhook as text/plain.
  • Anything else (JavaScript rules, mixed AND and OR, a value that is a JavaScript expression) becomes one JavaScript expression in which only true accepts, as in Mirth. A term that cannot be converted rejects the message (fails closed) and is reported, so no destination receives a message Mirth would have filtered before you review the step.
  • A source filter on an MLLP or webhook source becomes the trigger's filter, so a rejected message is dropped at intake and audited as filtered. A JavaScript source filter becomes a script filter with no rules: if its script throws, the message is rejected. On other sources the source filter is added to every destination's filter. On an MLLP source, an MSH-9.1 equals rule becomes the trigger's message types only when every rule is ANDed; in an OR filter it stays a filter rule, so a message Mirth accepts is not rejected.
  • Converted steps and script filters carry needsReview. The builder header counts them, the source panel has Mark reviewed, and validation warns NEEDS_REVIEW. They do not block deploy, but read each one: msg is Mirth's message tree for HL7 v2 and XML, but literal E4X syntax in the script does not run.

Drafts imported before this behaviour shipped keep their old JavaScript filter steps, which fail the execution when they reject a message. Import the channel again to get filter steps.

What import does not do

  • Literal E4X syntax does not run. Mirth's message tree does: msg['PID']['PID.5']['PID.5.1'] reads and writes, [n], length(), delete, new XML(text) and createSegment work as in Mirth (see Mirth msg and tmp), and the finding is an INFO. Syntax no JavaScript engine parses, such as XML literals (<PID/>), msg..OBX, x.@id, for each and default xml namespace, is copied but does not run. The import adds a REVIEW finding for each such step ("uses E4X, which MedHook's JavaScript doesn't run; rewrite with hl7.get/set or SerializerFactory") and the channel's finding says "Uses E4X XML syntax, which the sandbox can't run", and saving warns E4X_LITERAL. A test run of such a step fails with the same words and the line in the step's own script. Rewrite those lines by hand, or suggest an AI rewrite and review it.
  • Mirth's script APIs run, within limits. router.routeMessage, DatabaseConnectionFactory, FileUtil, DateUtil, StringUtils, UUIDGenerator, SerializerFactory, XmlUtil, JsonUtil and a few Java classes (java.lang.String, java.text.SimpleDateFormat, java.util.Date, java.util.UUID, java.util.ArrayList) work in imported steps, through the engine and in the workflow's workspace (see Mirth APIs for each one's limits). A script that calls them gets an INFO finding. A script that calls anything else, such as java.io.File or SMTPConnectionFactory, gets a REVIEW finding and an import warning naming it, and saving the step warns MIRTH_API_UNSUPPORTED. See Port a Mirth JavaScript transformer that looks up a database and routes to another channel.
  • Move database credentials into an adapter profile. A script that connects with DatabaseConnectionFactory.createDatabaseConnection(driver, url, user, password) keeps its credentials in the step's code, which is stored as plain text. The import redacts the password where it can see it (a literal argument, literals joined with +, a credential-named variable such as var dbPassword = '...', and ;password= or Oracle user/password@ in a JDBC URL), but it cannot see a password the script computes at run time. Create an SQL database profile and connect with createDatabaseConnection('profile:NAME') instead; its password stays encrypted.
  • Mapper and Message Builder steps run as Mirth's own code. A step that sets an HL7 field from an HL7 path, a text value or a Mapper variable becomes a data map row (see the concept map). Any other step, on an HL7 v2, XML, JSON or delimited channel, becomes the JavaScript Mirth generates for it: a Mapper puts its mapping into its scope's map through validate(), and a Message Builder assigns validate(...) to its msg or tmp path. JavaScript mappings, regular-expression replacements, every scope and tmp carry over. A finding says why each step is not a data map. With an outbound template, tmp starts as the template and the step sends tmp, as Mirth does. On a delimited channel msg is Mirth's delimited tree (msg['row'][0]['column1']), written back as delimited text. A destination whose steps read XML or delimited data gets the source's text, and the source's parse step moves to the other destinations. A step stays unconverted, kept as a comment with its settings on a // mirth-step-config: line while the message passes through unchanged, when its outbound template can't be imported (another data type, over 1 MB, or holding a credential), when its delimited properties can't be read (column widths that aren't whole numbers, a column name that isn't an XML name), or when the SFTP pickup splits the delimited file into rows. A step whose settings hold a credential-looking value also stays unconverted, with the value redacted. A step that uses tmp in a transformer with no outbound template is converted, with a finding: tmp is undefined there, so the step fails, as it does in Mirth.
  • Code template libraries become shared libraries. Each library is created at v1 with its functions exported, and the JavaScript steps of the channels it is enabled for pin it, so calls such as fmt(msg.name) keep working. A library function that reads the tree a step passes it (pid(msg) with m['PID']['PID.3']) is pinned and runs. A library that uses literal E4X, or reads msg or tmp as globals it cannot see, is not pinned: its finding asks you to rewrite it with AI and save it under Settings → Libraries. See Shared libraries.
  • The global map is per workflow. $g, $gc, globalMap and globalChannelMap read and write the workflow's own global map, which keeps strings, numbers and booleans across messages. Mirth's global map is server-wide, shared by every channel; MedHook's is not, and each read or write gets a finding that says so. For a value several channels share, use a workspace variable. A deploy script's literal puts (globalMap.put('site', 'DEMO'), $g, globalChannelMap.put, $gc, with a string, number or boolean) are imported as globals: the global Deploy script's into each workflow that reads the key, a channel's own into its workflow. A key that looks like a credential is never imported.
  • The configuration map becomes workspace variables. Each entry is created as a workspace variable, and $cfg reads it. An entry that looks like a credential, by its key (sftp.pass, dbPwd, privateKey) or its value (a password in a URL, a PEM block, a Bearer header), becomes a secret with no value: enter it in Settings → Secrets & variables before you deploy.
  • Scripts and handlers MedHook has no place for are named, never dropped. Each non-default one is a REVIEW finding that names it and says what to do: the deploy script past its literal global map puts, the undeploy script, a destination's response transformer (read the reply in a step after the send), a custom metadata column (Mirth's own SOURCE and TYPE are not), and an attachment handler other than None. A global script's finding is on every channel, since Mirth ran it for all of them.
  • Preprocessor and postprocessor scripts become steps. The channel's preprocessor is the workflow's first JavaScript step and the server's global one runs before it, on the raw message, as in Mirth: message is the text, the script's return value replaces it, and returning nothing keeps it. An MLLP message keeps its shape and its parsed copy follows the new text. The postprocessor is the last destination: a JavaScript step that runs after every other destination, so the channel's destinations run one after another, then a sink. responseMap.get('d1') and $r('Destination name') return each destination's response (getStatus(), getMessage(), getError()), and the global postprocessor runs after the channel's. All of them use the same Mirth shims and shared libraries as transformer steps, and each is a REVIEW finding to check before enabling. The Mirth export writes an unedited preprocessor and postprocessor back as the channel's scripts; the global ones stay in Mirth's global scripts.
  • Map values carry within one message. Channel map ($c) and response map ($r) values that an earlier JavaScript step of the same message set carry over, through the step's vars. Values that Mirth or another channel sets do not, and the finding says so. Mirth's destination responses (responseMap.get('d1').getMessage()), sourceMap (originalFilename, remoteAddress) and connectorMessage members other than getRawData() and getEncodedData() are not there: a step that uses them gets a REVIEW finding, not "ported to sandboxed JS". connectorMessage.getRawData() returns the step's input text and getEncodedData() the message as the step has it.
  • A Channel Writer does not deliver. It becomes a Run workflow step, which starts the other channel's workflow but is not a send, so the destination would never be reported as delivered. Validation reports it as ROUTER_BRANCH_NO_SEND, and deploy is blocked until you remove the destination or replace it with a send step.
  • A Document Writer's attachment is not a Mirth attachment. The Document Writer, SMTP Sender and JavaScript Writer are imported (see the concept map), but the document is the step's output rather than a stored attachment, so an SMTP Sender that attaches it with ${ATTACH:...} gets a finding: turn on attachInputDocument and run the SMTP step after the Document Writer. The PDF password and the SMTP login are re-entered. See ORU lab results to a PDF report and email.
  • Plain FTP and plain HTTP WebDAV are imported with a finding. They send the login and every file in clear text; switch the profile to FTPS or https:// when the server allows it. A local folder must be mounted into the engine and listed in FILE_ADAPTER_ROOTS.
  • Some connectors are not supported. Database readers and writers on a JDBC driver other than PostgreSQL, SQL Server, MySQL, MariaDB or Oracle, database connectors that run a script, and others are listed as unsupported or start manually. A channel whose source cannot be mapped is Blocked. A destination that cannot be mapped is left out, and the finding names it and says why: "has no MedHook adapter" only when the transport has none, otherwise the reason, such as a Database Writer statement with ? placeholders (name each value as ${var} in Mirth or :var in MedHook).
  • Disabled destinations are skipped, and a stopped channel is noted.
  • Partial destination order is not kept. Mirth can chain some destinations with "Wait for previous destination" and run others in parallel. MedHook runs a channel's destinations either all at the same time or all one after another. If any destination waits, the import runs every destination in Mirth's order, and a finding names each one that Mirth ran in parallel.
  • Credentials are never imported. Headers that look like credentials are dropped, and the report says where to re-enter them.

Review each interface

Migration › In progress shows every imported channel or route, as a Board or a Table. The board has five columns, Imported, Needs review, Ready to test, Parallel run and Live, and each card is tagged MIRTH or RHAPSODY, with how much of it converted on its own. The old servers stay read-only to MedHook throughout. Review queue (N) opens the first interface that waits for a person. A card in Parallel run opens its run on the Parallel runs tab.

Migration › In progress after converting five Mirth channels: Board and Table, the summary, Review queue (5), and the five columns with each card's MIRTH tag, how much converted and what still needs a person

The review page (/migration/review/<id>) shows one interface. The header has ← Migration, the interface's stage, its place in the queue (2 of 5 in queue), Open draft in builder, Mark reviewed and Next →. The tabs are:

TabWhat it lists
ComponentsEach Mirth part, what it became in MedHook, and a result for it
Code templatesThe code template libraries the channel uses, converted once and shared
Global mapsThe global map entries, which become code tables and credentials
ConnectionsThe connections and credentials to fill in. The badge counts what is still missing

Each component's result is Converted, Works differently, Needs a person, Blocked, or Rewritten · checked after an accepted rewrite. Select a row to read its note and its original code. Mark reviewed shows N to resolve and stays off while a row needs a person or is blocked. Once nothing is left, it moves the interface to Ready to test, records migration.interface_reviewed in the audit log, and opens the next interface in the queue. Viewers can read the page, but can't mark an interface reviewed.

The review page for ADT_IN_EXAMPLE under Needs review: 3 of 5 in queue, Open draft in builder, Mark reviewed showing 2 to resolve, Next, the four tabs, and a JavaScript transformer that needs a person, with its note and original code

Rewrite E4X and mapper steps with AI

An imported step that uses literal E4X syntax, or that the import left as a Mapper or Message Builder placeholder, can be rewritten by the AI model as a JavaScript transform the sandbox runs, or as a Data Map. You review every rewrite side by side and accept or reject it. A Rhapsody mapper placeholder left by an import gets the same option.

What is sent, and what is not

Only the step's code and its mapper settings are sent. Before anything leaves the engine:

  • Comments are removed, so a sample message pasted into a comment is never sent.
  • Every string, regular expression and number of five or more digits becomes a placeholder such as [value-3]. Field paths such as 'PID.5.1' and standard segment IDs such as 'PID' stay, because they say what the step reads. Any other short string, such as a surname or initials, is replaced.
  • An E4X XML literal keeps its tag names, which are field paths, and its text, attribute values and CDATA become placeholders. Comments inside it are removed. If the engine can't read a literal, everything from that point to the end of the script is replaced.
  • The engine puts the original values back into the answer, so the rewrite still compares against the real values.
  • Names in the code itself, such as variable and function names, are sent as written. If a script names a variable after a patient or holds a password in a variable name, rename it before you choose Rewrite with Agent.
  • Step names are not sent. Sample messages, test runs and credentials are never part of the request.

1. Open the review

Open the interface's review page and select the step on Components. In the builder, the N steps to review label links to the same page when a step can be rewritten, and /migration/rewrite/<workflow id> redirects there. A step that can be rewritten was flagged for E4X, for a Mirth Mapper or Message Builder placeholder, for a Rhapsody mapper placeholder or for Rhapsody JavaScript.

2. Rewrite with Agent

Choose Rewrite with Agent. The engine asks the model once and checks the answer before you see it:

  • It must parse, and must not use E4X, require or import, network calls, Java or Mirth APIs (channelMap, $c, router), eval or async code.
  • It must run in the sandbox on a synthetic HL7 message that the engine builds from the field paths the step uses (TESTPATIENT, SYN-OBX-5, and so on). Your samples are never used.

The Original code is shown above the Agent's rewrite, with a line that says how it was checked: Ran in the sandbox on a synthetic message: it runs without errors. Once a business associate agreement is signed and the interface has stored history (from the onboarding or a parallel run), the rewrite also runs on up to 50 recent Mirth messages, or 200 Rhapsody ones, and the line reads, for example, Ran on 50 recent messages from Mirth's history: outputs match Mirth on 50 of 50. That history never goes to the model. A rewrite that fails the check lists why, and Use this stays off.

3. Use it or keep the original

Use this saves the step as the rewrite, the same as a save in the builder: a new version is kept, so you can roll back. The step's review mark is cleared. The audit log records migration.rewrite_accepted with the workflow, the step and the kind of output, but not the code. The row then reads Rewritten · checked. If the step was edited after the suggestion, saving answers 409, and you rewrite it again. Keep the original logic leaves the step unchanged, so it still needs a person before you can mark the interface reviewed.

Or ask the assistant

The assistant can do the import, the rewrites and a first test in one go: ask it to migrate the export on Migration. You get one disabled draft per channel with every E4X and mapper step it could rewrite, each draft dry-run on the channel's sample from the export (or on synthetic samples), and a list of what did not convert and why. It saves nothing; apply the import here when the drafts look right.

Export a workflow to Mirth

1. Open the export dialog

Open the workflow in the builder and choose Export to Mirth. The dialog exports the saved version, so save first. It shows the fidelity report before you download anything.

2. Pick the Mirth version

Choose Mirth 4.5 (4.5.2, the default) or Mirth 3.12 (3.12.0).

3. Read the report

Every difference is listed in plain words, most urgent first.

HeadingWhat it meansWhat you do
Included but switched offThe element is in the channel, but disabled so Mirth never runs it half set up.Finish the setup in Mirth, then enable it.
Not exportedThe element is not in the file.Rebuild it in Mirth if the channel needs it.
Set up in MirthThe element is in the channel, but someone must set it up before it works.Set it up, for example the port a sender must use.
Credentials to enter in MirthA credential was left blank on purpose.Enter it in Mirth before you deploy.
Scripts that use MedHook-only featuresA script calls something only the MedHook sandbox has.Rewrite those lines for Mirth.
Works differently in MirthThe element is exported, but behaves a little differently.Test it with sample messages.

An MLLP destination or trigger that uses TLS exports its TLS settings as SSL Manager settings on the TCP Sender or TCP Listener: TLS on, client authentication, host name verification, and the certificate aliases to create (medhook-peer-ca, medhook-client, medhook-listener, medhook-senders-ca). Certificates and keys are never in the file. The TCP Sender is exported switched off: add the CA and any client certificate in Mirth's SSL Manager, then enable it. For a listener, add its server certificate there.

The report lists differences in retry behavior, in how a failed destination is handled, in the ACK a sender gets when a filter drops a message, and in the body an HTTP destination posts.

A channel whose destinations run one after another exports with Wait for previous destination on every destination, in the order the builder shows. Mirth has no responses, so a JavaScript output or filter that reads an earlier destination's reply gets it built from Mirth's response map at the top of its script: each reply by its destination name, with its status (sent, failed, filtered) and its body as data (parsed when it is JSON). The report lists the script so you check it in Mirth, and the destination names it reads must match Mirth's.

4. Download and import into Mirth

Choose Download XML. In Mirth, use Channels, Import Channel. Enter the credentials the report lists, enable anything it switched off, and deploy.

Export several workflows as a .zip

Open Migration › Export to Mirth. It lists the workflows that have been deployed at least once; drafts and workflows waiting for approval or a first message aren't listed. Each row gives the trigger, the deployed version and how faithfully it maps to Mirth, for example 8 exact · 2 differ · 1 not exported.

  1. Pick the workflows. The panel's title follows the selection, for example 2 workflows → 2 channels.
  2. Under Target, choose Mirth Connect 4.5 or Mirth Connect 3.12.
  3. Leave Include code templates and Include README.md with credentials to enter on, or turn either off. The code templates option names the functions it carries.
  4. Read the report, in three groups: Included but switched off (review these in Mirth before enabling them), Not exported (set these up in Mirth by hand; the README lists each one) and Works differently in Mirth (same result, different mechanics).
  5. Choose Download .zip for Mirth 4.5 (or 3.12). It stays off, with "Pick at least one workflow", until you pick one. The result line names what you got, for example medhook-mirth-4.5-export.zip · 2 channels · 1 code template · README.md. Changing the target or the selection clears it. Changing an option keeps it, since it names the file you already downloaded.

The .zip holds one channel XML per workflow under channels/, the shared libraries the workflows call as Mirth code template libraries under code-templates/, and README.md, which lists the credentials and settings to enter in Mirth for each channel, never their values. In Mirth, import the code templates first (Channels, Edit Code Templates, Import Libraries), then each channel (Channels, Import Channel). An agent-written script exports as a disabled Agent-written script step, with its destination switched off, and the report lists it as "kept as a disabled JavaScript step".

Every role can export, Viewers included, because the export only reads. Each download is in the audit log as workflow.exported.

Export several workflows with the API

POST /api/workflows/export/mirth takes up to 50 workflow ids and returns one Mirth serverConfiguration in a "MedHook export" channel group. Add format=zip to get the same .zip as the Export to Mirth tab. Each MLLP or HTTP listener gets its own port, and no two channels share an id.

bash
curl -s -X POST "$ENGINE_URL/api/workflows/export/mirth?version=4.5.2" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ids": ["wf_example_a", "wf_example_b"]}' \
  -o medhook-channels.mirth.xml

Add format=json to get the XML, the report and a report per channel. An id that is not in your workspace returns 404, and nothing is exported.

A workflow that you imported from Mirth keeps its original channel id when you export it.

Test it

Export a workflow, then send this message to the Mirth channel it creates.

text
MSH|^~\&|SENDER|FAC|RECEIVER|FAC|20260101120000||ADT^A01|MSG0001|P|2.5.1
PID|1||MRN0001^^^FAC^MR||TESTPATIENT^SAMPLE||19800101|F

The destination should receive the same payload that the workflow's Test run shows for the same message. If it does not, look for the element in the report under "Works differently in Mirth".

Troubleshooting

ProblemFix
The importer says "Not a Mirth Connect export"The file must hold a <channel>, a <list> of channels or a <serverConfiguration>. Export it again from Mirth.
A channel is BlockedIts source has no MedHook equivalent. Rebuild it by hand, or exclude it.
A Channel Writer step warns about relinkingThe target channel was not in the import. Import it, then relink the step.
Export answers 404The workflow is not in the current workspace. Send X-Workspace-Id or switch workspace.
Export answers 429Single exports allow 30 a minute and multi-channel exports allow 10. Wait and retry.
The import finding says "Uses E4X XML syntax, which the sandbox can't run", or saving warns E4X_LITERAL with "uses E4X syntax the sandbox can't run"The step's script holds syntax no JavaScript engine parses, such as an XML literal, msg..OBX, .@id, for each or default xml namespace. The warning lists which. The step saves, but fails when it runs, with "Custom code execution failed:" and a syntax error. Rewrite those lines with brackets (msg['PID']['PID.5']), or suggest an AI rewrite when your administrator has turned AI features on.
An imported File Reader or File Writer fails with "No folders are allowed: the operator sets FILE_ADAPTER_ROOTS (Helm fileAdapter.mounts)"The engine reads and writes local folders only when your operator lists them in FILE_ADAPTER_ROOTS. With none listed, every pickup and step on a file profile is refused, and saving the profile warns the same. Mount the folder into the engine and list it: see Folders for the Local File adapter. A folder outside the list fails with "baseDir must be inside one of the folders in FILE_ADAPTER_ROOTS".

Reference

Recipes for channels moving off Mirth:

Guides and API: