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

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2012, 01: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
http://stackoverflow.com/questions/1...aning-in-mirth
Reply With Quote
  #2  
Old 07-03-2012, 01: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
Default

You are working with xml and the ZP1.36 is already split up:
Code:
<ZP1.36>
   <ZP1.36.1>Hello</ZP1.36.1>
   <ZP1.36.2>World</ZP1.36.2>
<ZP1.36>
If you want to get the various sub elements you can do something like this:
Code:
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:
http://www.w3schools.com/jsref/jsref_split.asp
__________________
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
  #3  
Old 07-03-2012, 05:15 PM
akh2103 akh2103 is offline
Mirth Newb
 
Join Date: Jul 2011
Posts: 17
akh2103 is on a distinguished road
Default

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

Tags
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 -7. The time now is 04:35 PM.


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