web stats
Postprocessor script question - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-17-2012, 06:09 AM
psanders psanders is offline
OBX.2 Kenobi
 
Join Date: Nov 2011
Posts: 55
psanders is on a distinguished road
Default Postprocessor script question

Hi all,
Trying to do a global search and replace on the segments of a batch HL7 message. Right now, I have the segments terminated by a carriage return, but I need it terminated by a carriage return line feed instead. So I thought the best place to do this would be in a postprocessor script. I wrote this script:

// This script executes once after a message has been processed
var filecontent = messageObject.getRawData(); // Get the message
//logger.info('filecontent is = ' + filecontent.toString());
// replace carriage returns with carriage return line feeds
var newfilecontent = filecontent.replace('\r','\r\n');

logger.info('newfilecontent is :' + newfilecontent.toString());
return newfilecontent;

doesn't seem to work as I expect it to. Question is do I need to return newfilecontent to the messageObject? If so, what method do I call?

Thanks.
Reply With Quote
  #2  
Old 08-17-2012, 07:22 AM
wello007 wello007 is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 160
wello007 is an unknown quantity at this point
Default

You should do that in the preprocessor script
__________________
WD
Reply With Quote
  #3  
Old 08-17-2012, 07:27 AM
psanders psanders is offline
OBX.2 Kenobi
 
Join Date: Nov 2011
Posts: 55
psanders is on a distinguished road
Default

Thanks for the reply. How would that be different? Would the script be the same? I read in the raw message and then return the changed string.
Reply With Quote
  #4  
Old 08-17-2012, 07:30 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Are you wanting to make that change before your source connector accepts the message, or right before the destination connector is about to send the message?
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #5  
Old 08-17-2012, 07:36 AM
psanders psanders is offline
OBX.2 Kenobi
 
Join Date: Nov 2011
Posts: 55
psanders is on a distinguished road
Default

I have some transformations I do before the postprocessor script, and so this would be the last step before I sFTP the file to the trading partner. So right before the destination connector is about the send the message.
Reply With Quote
  #6  
Old 08-17-2012, 08:43 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,119
narupley is on a distinguished road
Default

Here's one way (of many):

Put this in your transformer:

Code:
$co('CRLF','\r\n');
Then put this in your destination template (assuming you're using the encoded data):

Code:
${message.encodedData.replaceAll('\r',${CRLF})}
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Tags
batched hl7, postprocessor

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 05:08 PM.


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