Brio-IO Communication Server
Back to the blog
by Brio-IO-Team

“Will my Mirth scripts run?” — an honest answer, at last

Every Mirth replacement promises the old scripts keep working. Brio-IO waited to make that promise until it was true: real Rhino, real E4X, positional paths just like Mirth (msg['PID']['PID.5']['PID.5.1']), createSegment across all engines. And we tell you the limits too.

#mirth #migration #scripting #rhino #hl7

“Will my Mirth scripts run?” — an honest answer, at last

It’s the first question anyone asks who is thinking about moving off Mirth Connect: do my transformers keep working? And it’s the question where most migration promises go quiet — because “runs unchanged” is a sentence the audience verifies on day one. A Mirth practitioner types their usual path, hits deploy, and sees in ten seconds whether the promise holds.

This article exists because we once didn’t write it. An earlier version of the Brio-IO serializer named HL7 components after their data type, not their position — msg['PID']['PID.5']['PID.5.1'] returned an empty string against a real message. So we held the article back rather than print a promise that breaks on the first try. With the serializer modernisation (ADR-022) the sentence is now true — and here is exactly how far.

What carries over 1:1

Real Rhino, real E4X

Brio-IO runs js-legacy scripts on Mozilla Rhino — the engine your Mirth scripts were written for, not a reimplementation. E4X (the XML extension of JavaScript that runs through Mirth scripts) comes from the rhino-xml module on the classpath.

msg is already an E4X XML object, not a string. The new XML(msg) you used to put at the top of a script is gone — you access it directly:

// Rhino (js-legacy): msg is already E4X — access as in Mirth
var nachname = msg['PID']['PID.5']['PID.5.1'].toString();

The component paths — unchanged

This is the part that was false for a long time and is now true. Brio-IO numbers HL7 components by position, exactly like Mirth: PID-5.1 is the last name, PID-5.2 the first name, PID-3.1 the ID. Your Mirth idiom runs verbatim:

// Runs unchanged in Brio-IO js-legacy — same message, same paths
var nachname = msg['PID']['PID.5']['PID.5.1'].toString();   // "Schmidt"
var patId    = msg['PID']['PID.3']['PID.3.1'].toString();   // "12345"

Segment, field and component level stay exactly as you know them. No search-and-replace, no relearning the paths.

Mutate and return

The write mechanics are Mirth-familiar too: set a field, return msg at the end. The engine serialises the E4X object back to HL7 at its boundary automatically — you don’t serialise anything by hand:

// Set a field, return msg as the last expression
msg['PID']['PID.5']['PID.5.1'] = 'Mueller';
msg;

Creating Z-segments — the daily handwork

A transformer that creates a Z-segment is everyday Mirth work. In Brio-IO you do it with createSegment — across all three engines:

// Rhino (js-legacy): createSegment returns a reference you fill in
var zbr = createSegment('ZBR', msg);
zbr['ZBR.1'] = 'freigegeben';
msg;

The segment lands in the right position in the outgoing HL7. On the public demo you can see exactly this live: both example transformers create a ZBR and fill it.

What you should know — the honest limits

A migration promise is only worth its footnotes. Here they are, no fine print:

  • Rhino is deprecated on purpose. It exists for Mirth compatibility, not as the future. On every deploy of a channel with a Rhino script, Brio-IO warns — in the log and in the API response — and the sunset path is fixed (removal in Brio-IO 4.0, ~2029). You have years of runway to move script by script to Groovy or modern JavaScript — no big bang.
  • router.routeMessage() is not available yet. Channel-to-channel chaining you model today via an HTTP sender to an HTTP listener; the native router object comes later.
  • Mirth-specific Java calls (Packages.com.mirth.* and relatives) do not run — Brio-IO is a different server, not Mirth with a new coat of paint.

We don’t put this in the fine print but in a heading, because that is exactly the difference between “runs unchanged” as a sales line and as a checkable statement.

The best way to believe it: try it yourself

On the public demo channels run with real transformers, and the message browser shows you the canonical XML of every message — the very structure your paths run against. Type your usual Mirth idiom into a transformer and see in ten seconds whether it holds. The same ten seconds in which most promises fall.

And if you want your real Mirth channels translated — ask us for early access. Just tell us which interfaces you want to integrate.