Announcement

Collapse

NextGen (Mirth) Connect 3.10.0 Released!

NextGen (Mirth) Connect 3.10.0 is now available as an appliance update and on our GitHub page. This release includes better SQL Server database support, security improvements through fixes and library updates, and improvements for the Advanced Clustering plugin with a focus on improving performance of many of the tasks that are carried out on a frequent interval. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Mirth Output of new line and carriage return chars

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

  • Mirth Output of new line and carriage return chars

    Hello,

    I am having an issue while outputing a file in Mirth. All normal characters are printed fine, however, right where a new line should begin i get a small box(unprintable character) and no new line. I'm pretty sure the unprintable character is a carriage return. Does anyone know of any fixes to this problem?
    ~Patrick
    P.S. The same problem occurs when trying to send the file over LLP

  • #2
    Re:Mirth Output of new line and carriage return chars

    The standard HL7 end of segment character is a carriage return. If your text editor does not support carriage returns, it will display them as a small box. This is the standard for LLP transmission as well.

    You can transform the message and replace all carriage returns with newlines. The syntax is:
    Code:
    var newMessage = messageObject.getRawData().replace(/\\r/g, "\\n"«»);
    This is setting the new message to the original message, but with all \\r (carriage returns) replaced with newlines (\\n). Put this code in a new transformer step, Javascript type.
    Chris Lang

    Comment


    • #3
      Re:Mirth Output of new line and carriage return chars

      hi! I'm having this question on the start block, end block and carriage returns. How do you add this hexa characters like 0B, 1C, 0D on my outgoing message (HL7)?
      Please help.. THank u!
      Tonet

      Comment


      • #4
        Originally posted by chrisl View Post
        The standard HL7 end of segment character is a carriage return. If your text editor does not support carriage returns, it will display them as a small box. This is the standard for LLP transmission as well.

        You can transform the message and replace all carriage returns with newlines. The syntax is:
        Code:
        var newMessage = messageObject.getRawData().replace(/\\r/g, "\\n"«»);
        This is setting the new message to the original message, but with all \\r (carriage returns) replaced with newlines (\\n). Put this code in a new transformer step, Javascript type.
        This would be extremely useful if it didn't bomb upon running. Below are the exceptions thrown when I put a transformer with this code on the destination connector:


        [2009-10-07 11:59:38,095] ERROR (org.mule.impl.DefaultComponentExceptionStrategy:9 5): Caught exception in Exception Strategy for: 02d4cc83-f2a9-466d-a299-12a2687b776d: org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.webreach.mirth.model.MessageObject
        org.mule.umo.routing.RoutingException: Failed to route event via endpoint: null. Message payload is of type: com.webreach.mirth.model.MessageObject
        at org.mule.routing.outbound.OutboundMessageRouter.ro ute(OutboundMessageRouter.java:84)
        at org.mule.impl.model.DefaultMuleProxy.onCall(Defaul tMuleProxy.java:247)
        at org.mule.impl.model.seda.SedaComponent.doSend(Seda Component.java:209)
        at org.mule.impl.model.AbstractComponent.sendEvent(Ab stractComponent.java:277)
        at org.mule.impl.MuleSession.sendEvent(MuleSession.ja va:201)
        at org.mule.routing.inbound.InboundMessageRouter.send (InboundMessageRouter.java:180)
        at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRouter.java:147)
        at org.mule.providers.AbstractMessageReceiver$Default InternalMessageListener.onMessage(AbstractMessageR eceiver.java:493)
        at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:272)
        at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:231)
        at com.webreach.mirth.connectors.file.FileMessageRece iver.processFile(FileMessageReceiver.java:235)
        at com.webreach.mirth.connectors.file.FileMessageRece iver.poll(FileMessageReceiver.java:124)
        at org.mule.providers.PollingMessageReceiver.run(Poll ingMessageReceiver.java:90)
        at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
        at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.runTask(ThreadPoolExecutor. java:650)
        at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(ThreadPoolExecutor.java :675)
        at java.lang.Thread.run(Unknown Source)Caused by: org.mule.umo.routing.CouldNotRouteOutboundMessageE xception: Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.webreach.mirth [email protected], endpointUri=file://C:/Program%20Files/Clinical%20Computing/Interfaces/Lab%20Results/LabCorp/Data, transformer=Transformer{name='02d4cc83-f2a9-466d-a299-12a2687b776d_destination_1_transformer', returnClass=false, returnClass=false, sourceTypes=[]}, name='_fileEndpoint#1651152214', type='sender', properties={}, transactionConfig=org.mule.impl.MuleTransactionCon [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: com.webreach.mirth.model.MessageObject
        at org.mule.routing.outbound.FilteringMulticastingRou ter.route(FilteringMulticastingRouter.java:63)
        at org.mule.routing.outbound.OutboundMessageRouter$1. doInTransaction(OutboundMessageRouter.java:78)
        at org.mule.transaction.TransactionTemplate.execute(T ransactionTemplate.java:48)
        at org.mule.routing.outbound.OutboundMessageRouter.ro ute(OutboundMessageRouter.java:82)
        ... 16 moreCaused by: org.mule.umo.provider.DispatchException: Failed to route event via endpoint: ImmutableMuleEndpoint{connector=com.webreach.mirth [email protected], endpointUri=file://C:/Program%20Files/Clinical%20Computing/Interfaces/Lab%20Results/LabCorp/Data, transformer=Transformer{name='02d4cc83-f2a9-466d-a299-12a2687b776d_destination_1_transformer', returnClass=false, returnClass=false, sourceTypes=[]}, name='_fileEndpoint#1651152214', type='sender', properties={}, transactionConfig=org.mule.impl.MuleTransactionCon [email protected], filter=null, deleteUnacceptedMessages=false, initialised=true, securityFilter=null, synchronous=true, initialState=started, createConnector=0}. Message payload is of type: com.webreach.mirth.model.MessageObject
        at org.mule.providers.AbstractMessageDispatcher.send( AbstractMessageDispatcher.java:180)
        at org.mule.impl.MuleSession.sendEvent(MuleSession.ja va:191)
        at org.mule.impl.MuleSession.sendEvent(MuleSession.ja va:130)
        at org.mule.routing.outbound.AbstractOutboundRouter.s end(AbstractOutboundRouter.java:85)
        at org.mule.routing.outbound.FilteringMulticastingRou ter.route(FilteringMulticastingRouter.java:45)
        ... 19 moreCaused by: org.mule.umo.transformer.TransformerException:
        CHANNEL:
        LabCorp
        CONNECTOR:
        Destination 1
        SCRIPT SOURCE:

        LINE NUMBER:
        3
        DETAILS:
        The choice of Java constructor replace matching JavaScript argument types (function,string) is ambiguous; candidate constructors are:
        class java.lang.String replace(char,char)
        class java.lang.String replace(java.lang.CharSequence,java.lang.CharSeque nce) (com.webreach.mirth.server.MirthJavascriptTransfor merException)
        at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateScript(JavaScriptTransform er.java:457)
        at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.transform(JavaScriptTransformer.ja va:350)
        at org.mule.transformers.AbstractEventAwareTransforme r.doTransform(AbstractEventAwareTransformer.java:4 8)
        at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
        at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
        at com.webreach.mirth.server.controllers.DefaultMessa geObjectController.getMessageObjectFromEvent(Defau ltMessageObjectController.java:624)
        at com.webreach.mirth.connectors.file.FileMessageDisp atcher.doDispatch(FileMessageDispatcher.java:65)
        at com.webreach.mirth.connectors.file.FileMessageDisp atcher.doSend(FileMessageDispatcher.java:144)
        at org.mule.providers.AbstractMessageDispatcher.send( AbstractMessageDispatcher.java:167)
        ... 23 moreCaused by: com.webreach.mirth.server.MirthJavascriptTransform erException:
        CHANNEL:
        LabCorp
        CONNECTOR:
        Destination 1
        SCRIPT SOURCE:

        LINE NUMBER:
        3
        DETAILS:
        The choice of Java constructor replace matching JavaScript argument types (function,string) is ambiguous; candidate constructors are:
        class java.lang.String replace(char,char)
        class java.lang.String replace(java.lang.CharSequence,java.lang.CharSeque nce)
        at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateScript(JavaScriptTransform er.java:448)
        ... 31 more

        Comment


        • #5
          Perhaps the next could work:


          var newMessage = messageObject.getRawData().replace(/\r/g, "\\n");

          Comment


          • #6
            I actually found another somewhat unrelated post that explains the problem with the original code provided. It seems that the string returned by getRawData is some sort of Java string rather than a Javascript string. Therefore, when you call the replace() function you are not getting exactly the function you think you are getting. You actually have to call replaceAll() which is a function on the Java String object. It takes two strings as parameters and the following code will work in re-inserting the carriage returns that are trashed when the file writer outputs the file via LLP. There is also another line of code that wasn't mentioned that is required if you want the writer to actually write the data out. The previous line of code just sent the data to a variable which was never used. Keep in mind that you will need to make sure that the template on the destination connector is spitting out the message's raw data instead of the encoded data. Otherwise this code will still be for nothing:


            Code:
            // Replace the \r created by Mirth with a \r\n.
            var newMessage = messageObject.getRawData().replaceAll("\r", "\r\n");
            
            // Set the raw data to our newly modified string.
            messageObject.setRawData(newMessage);
            That's it. If you are using a file writer connector in Mirth and want the \r\n carriage return, then this will become a standard part of your connector's transformer. I've also tested this as I needed the solution myself and it does work (without bombing). We should all probably make sure that we do that before posting code for other users that will only provide them with further headaches.

            Comment


            • #7
              [QUOTE=miamigrandmaster;11134]

              Code:
              // Replace the \r created by Mirth with a \r\n.
              var newMessage = messageObject.getRawData().replaceAll("\r", "\r\n");
              
              // Set the raw data to our newly modified string.
              messageObject.setRawData(newMessage);
              QUOTE]

              Would this work for an LLP outbound message?

              Comment

              Working...
              X