web stats
how does the split function work in mirth - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 07-03-2012, 12:02 PM
akh2103 akh2103 is offline
Mirth Newb
Join Date: Jul 2011
Posts: 17
akh2103 is on a distinguished road
Default how does the split function work in mirth

I am maintaining a legacy mirth system. We get some incoming HL7 messages with a repeating ZP1.36 segment. As far as I can tell, mirth is dividing these repeating segments into an array of repeating segments via a split function.

var repeat36 = msg['ZP1']['ZP1.36'].toString().split("</ZP1.36>"); //I think returns an array of ZP1.36 segments
But in the raw data, I don't see the string ZP1.36...

I'm used to using split functions in VB/Java/C# that divide strings into tokens around a certain character, like this:

var myTokens = "hello^world".toString().Split("^"); //returns a 2 item array {"hello", "world"}
Mirth's split function doesn't seem to be working this way. It seems to be parsing the messages based on the assumed structure of the HL7 message.

Is this what's going on? Am I missing something? What are the rules for the split function in mirth?

Cross posted on stackoverflow
Reply With Quote
Old 07-03-2012, 12:25 PM
dans dans is offline
Mirth Employee
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point

You are working with xml and the ZP1.36 is already split up:
If you want to get the various sub elements you can do something like this:
var zp1361 = msg['ZP1']['ZP1.36']['ZP1.36.1'].toString();
var zp1362 = msg['ZP1']['ZP1.36']['ZP1.36.2'].toString();
You are using javascript when scripting in Mirth so if you do split it will work exactly like javascript:
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
Old 07-03-2012, 04:15 PM
akh2103 akh2103 is offline
Mirth Newb
Join Date: Jul 2011
Posts: 17
akh2103 is on a distinguished road

awesome. that makes it way more clear.
Reply With Quote

javascript, split

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 11:58 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation