web stats
Remove LF in middle of segment - Page 2 - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #11  
Old 09-12-2013, 06:30 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,348
cory_cole is on a distinguished road
Default

Try this in the preprocessor...

var segments = message.toString().split('/r');
var newMessage = '';

for(i = 0; i < segments.length; i++)
{
var newSegment = segments[i]. (/'\r'/g,'');
newMessage += newSegment + '\r';
}

return newMessage;
Reply With Quote
  #12  
Old 09-12-2013, 06:35 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 398
rutledj is on a distinguished road
Default

It makes it into the for loop then dies with same error.
Reply With Quote
  #13  
Old 09-12-2013, 06:38 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 398
rutledj is on a distinguished road
Default

It is erroring on this code:

var newSegment = segments[i].(/'\r'/g,'');
Reply With Quote
  #14  
Old 09-12-2013, 06:38 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,348
cory_cole is on a distinguished road
Default

var newSegment = segments[i].('\r','');
Reply With Quote
  #15  
Old 09-12-2013, 06:40 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 398
rutledj is on a distinguished road
Default

shouldn't there be a replace in there?

var newSegment = segments[i].replace(/'\r'/g,'');
Reply With Quote
  #16  
Old 09-12-2013, 06:42 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 398
rutledj is on a distinguished road
Default

It isn't splitting it properly.

With this code:

var segments = message.toString().split('/r');
var newMessage = '';

logger.info('len ' + segments.length);

the length is only 1
Reply With Quote
  #17  
Old 09-12-2013, 06:44 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,348
cory_cole is on a distinguished road
Default

sorry. Should be '\r' not '/r'
Reply With Quote
  #18  
Old 09-12-2013, 06:48 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 398
rutledj is on a distinguished road
Default

Better but the problem is that the initial split is also splitting the message where that \r is inside the SCH segment.
Reply With Quote
  #19  
Old 09-12-2013, 06:53 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,348
cory_cole is on a distinguished road
Default

for(i = 0; i < segments.length; i++)
{
var newSegment;
if( segments[i].substring(0,3) == 'SCH'
{
newSegment = segments[i] + segments[++i] + '\r';
}
else
{
newSegment = segments[i] + '\r';
}
newMessage += newSegment + '\r';
}
Reply With Quote
  #20  
Old 09-12-2013, 06:57 AM
rutledj rutledj is offline
Mirth Guru
 
Join Date: Nov 2010
Location: North Carolina
Posts: 398
rutledj is on a distinguished road
Default

I'm beginning to believe there isn't a way to handle this. Now I get the same result as if I do a global replace on the 0d. It clears everything after the EVN segment

[2013-09-12 09:56:09,749] INFO (js-connector:?): dest out MSH|^~\&|AcumenPM||HITSG|AcumenEHR|201309120956||S IU^||T|2.3.1
EVN||201309120956
SCH||||||||||||||||
PID||||||||||||||||||||||
PV1||||||||
Reply With Quote
Reply

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


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