Announcement

Collapse
No announcement yet.

Postprocessor script question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    You should do that in the preprocessor script
    WD

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment


          • #6
            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.

            Comment

            Working...
            X