web stats
Parsing in Preprocessor - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-29-2015, 12:04 PM
GregD GregD is offline
Mirth Guru
 
Join Date: May 2010
Posts: 234
GregD is on a distinguished road
Default Parsing in Preprocessor

At a remote site I'm pulling HL7 out of a database field and sending the messages to my instance of Mirth (2.2.3). Sometimes these are batch messages, but have lost some formatting for Mirth to detect they are batched. In the pre-processor script I am trying to break the message up and send them in one at a time.

I accidentally wrote an infinite loop in our production Mirth so I wrote it in Android Studio so I could debug it and then tested it in Mirth 3.2.2, which I hope to move to soon. It seems to act like an infinite loop in Mirth 3.2.2. I get received = 1, but nothing after that. I can't stop the channel and after stopping the Mirth service I can't restart it without killing the service and starting over.

I went back and tried this code in Mirth 2.2.3 and it works. I've attached a sample message file with three messages in it.

var ProcessMessage = true;

if (message.substring(0,1) != 'M') {

message = message.substring(1);

var SecondMsgInt = message.toString().indexOf("MSH", 4);
var WholeMsg = message;
var k = 0;

if (SecondMsgInt > 0 ) {

//router.routeMessage('Labs from Planned Parenthood', message.substring(SecondMsgInt));
while (SecondMsgInt >= 0) {

router.routeMessage('Labs from Planned Parenthood', WholeMsg.substring(0, SecondMsgInt));

WholeMsg = WholeMsg.substring(WholeMsg.substring(0, SecondMsgInt).length);
SecondMsgInt = WholeMsg.toString().indexOf("MSH", 4);

k += 1;
if (k === 10) {break;}
}

ProcessMessage = false;
router.routeMessage('Labs from Planned Parenthood', WholeMsg);
}

logger.info('k: ' + k)
}


globalChannelMap.put('ProcessMessage',ProcessMessa ge)

return message;
Attached Images
File Type: png Loop.png (3.2 KB, 11 views)
Attached Files
File Type: txt PP3.txt (7.3 KB, 13 views)

Last edited by GregD; 06-29-2015 at 01:21 PM.
Reply With Quote
 

Tags
preprocessor

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 02:47 AM.


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