Open the errored message and read the stack trace — Mirth reports the transformer step and line number. The most common cause is a TypeError from reading a segment or field that isn't present in that particular message: HL7 is variable, so guard every access. The second most common: writing to msg when you meant tmp.
A transformer breaking your production feed?
Senior Mirth engineers debug JavaScript/Groovy fast — 15-minute response on Silver and above.
A transformer exception can silently drop or corrupt clinical data. If messages are erroring in production right now, get an engineer on it in parallel.
Get Help With a Broken Interface →Read the error first
Open the errored message in the Dashboard and read the stack trace. Mirth reports the transformer step and the line number. The most common errors:
1. TypeError: cannot read property of undefined / null.You're reading a segment or field that isn't present in this particular message. HL7 is variable — not every message has every segment or repetition. Guard your access: check the segment exists before reading it, rather than assuming msg['OBX']['OBX.5']['OBX.5.1'] is always there.
2. Referencing msg vs tmp incorrectly. In a transformer, msg is the inbound message and tmp is the outbound template. Writing to msg when you meant tmp(or reading the wrong one) is a frequent logic bug that produces wrong output without throwing an error. Confirm you're reading from msg and writing to tmp.
3. E4X / XML access mistakes (HL7 v2 in Mirth). Mirth represents parsed messages as E4X XML. Indexing repeating segments or fields incorrectly (or treating a single value as a list) throws errors or returns unexpected nodes. Use the correct repetition index, and convert nodes to strings with .toString() when you need a plain value.
4. Using Java/Groovy APIs that aren't imported. In Groovy transformers, calling a class without importing it fails. Add the import, or use the fully qualified class name.
5. Date, number, and encoding conversions.Parsing an HL7 date that's empty or in an unexpected format throws. Validate before converting and handle empty values explicitly.
6. Channel map / global map key errors. Reading a map variable that was never set returns null and then errors downstream. Set defaults and check for null.
Step-by-step debugging
- Open the errored message; note the transformer step and line.
- Add a
logger.info()(orlogger.debug()) statement just before the failing line to print the value you're accessing — view it in the server log. - Confirm the segment/field actually exists in thismessage; test with the specific message that failed, not a "happy path" sample.
- Add a null/existence guard around the access.
- Verify you're reading
msgand writingtmp. - Reprocess the failed message to confirm the fix.
How to prevent it
Write transformers defensively: never assume a segment or repetition exists, set map defaults, and convert nodes to strings explicitly. Test against real production message samples — including the malformed and partial ones — not just clean examples. Keep transformer code in version control (your own Git repo) so changes are reviewable. If you need senior hands on channel work, you can hire a Mirth Connect developer.
Can't pin down the transformer bug?
Send us the script and a failing message — we'll find it and harden the channel.
Get Help With a Broken Interface →