Announcement

Collapse

NextGen (Mirth) Connect 3.9.1 Released!

NextGen (Mirth) Connect 3.9.1 is now available as an appliance update and on our GitHub page. This release contains bug fixes and adds support for eHealth Exchange UDDI providers in the Interoperability plugin. 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

Trailing white space on version number

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

  • Trailing white space on version number

    Hi,

    I just tried to process an ADT message with v1.3. I receive an exception and the problem stems from a trailing white space on the version number. It's '2.1 '. If I manually trim the trailing space the message is processed. (I just store it to a file for now.) I don't have control over the ADT system so I can't fix it there. Is there a way to remove the trailing space before the exception occurs?

    com.webreach.mirth.model.converters.SerializerExce ption: ca.uhn.hl7v2.HL7Exception: Can't process message of version '2.1 ' - version not recognized
    at com.webreach.mirth.model.converters.HAPIMessageSer ializer.deserialize(HAPIMessageSerializer.java:54)
    at com.webreach.mirth.server.mule.transformers.HL7ToM essageObject.doTransform(HL7ToMessageObject.java:7 2)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
    at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
    at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
    at org.mule.routing.inbound.SelectiveConsumer.isMatch (SelectiveConsumer.java:61)
    at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRouter.java:75)
    at org.mule.providers.AbstractMessageReceiver$Default InternalMessageListener.onMessage(AbstractMessageR eceiver.java:492)
    at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:271)
    at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:243)
    at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.processData(TcpMessageReceiver.java:305)
    at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.run(TcpMessageReceiver.java:274)
    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: ca.uhn.hl7v2.HL7Exception: Can't process message of version '2.1 ' - version not recognized
    at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:146)
    at com.webreach.mirth.model.converters.HAPIMessageSer ializer.deserialize(HAPIMessageSerializer.java:52)
    ... 16 more

  • #2
    Re: Trailing white space on version number

    You can use the preprocessor:

    Code:
    message = message.replaceAll("|2.1 ", "|2.1");
    (or you might have to do)

    Code:
    //regex version for js message
    message = message.replace(/\|2\.1 /g", "|2.1");
    That's assumign it's |2.1
    Just remove the | if you have issues.
    Chris Lang

    Comment


    • #3
      Re: Trailing white space on version number

      That space might actually be a \r or \n

      In that case, do
      Code:
      message = message.replaceAll("|2.1\r", "|2.1"); //or \n
      Chris Lang

      Comment


      • #4
        Re: Trailing white space on version number

        Thanks for the quick reply. I tried doing the replaceAll but with no luck. I received a different exception. This one says the "Cannot find function replaceAll". Could it be I put this little bit of code in the wrong place? The code is below. I tried just replacing the space and then the newline and carriage return individually. I put in the code below with all three replaceAll() calls just to ensure it wouldn't miss a condition. This code in the Edit Channel page in the "Preprocessing Script" section. This is correct, isn't it?

        // Modify the message variable below to pre process data
        message = message.replaceAll("|2.1 ", "|2.1");
        message = message.replaceAll("|2.1\n", "|2.1");
        message = message.replaceAll("|2.1\r", "|2.1");
        return message;



        INFO 2006-12-21 05:01:35,433 [Thread-0] com.webreach.mirth.server.Mirth: starti
        ng mirth server...
        Mirth 1.3.0 (December 18, 2006) server successfully started: Thu Dec 21 05:01:43
        EST 2006
        This product includes software developed by SymphonySoft Limited (http://www.sym
        phonysoft.com) and its contributors.
        Running Java 1.5.0_09 on Windows XP (5.1, x86)
        ERROR 2006-12-21 05:04:28,832 [a4a13346-a811-4bb6-a534-e4bff0c8295e_source_conne
        ctor._tcpEndpoint#-281997515.receiver.2] org.mule.impl.DefaultComponentException
        Strategy: Caught exception in Exception Strategy for: a4a13346-a811-4bb6-a534-e4
        bff0c8295e: org.mule.umo.routing.RoutingException: Failed to transform message b
        efore applying the filter. Failed to route event via endpoint: ImmutableMuleEndp
        oint{connector=org.mule.providers.tcp.TcpConnector @1de007d, endpointUri=tcp://12
        7.0.0.1:6661, transformer=Transformer{name='ByteArrayToStri ng', returnClass=fals
        e, returnClass=false, sourceTypes=[class [B, class java.lang.String]}, name='_tc
        pEndpoint#-281997515', type='receiver', properties={}, transactionConfig=org.mul
        [email protected], filter=null, deleteUnacceptedMessages=false
        , initialised=true, securityFilter=null, synchronous=null, initialState=started,
        createConnector=0}. Message payload is of type: java.lang.String
        org.mule.umo.routing.RoutingException: Failed to transform message before applyi
        ng the filter. Failed to route event via endpoint: ImmutableMuleEndpoint{connect
        [email protected], endpointUri=tcp://127.0.0.1:6661
        , transformer=Transformer{name='ByteArrayToStri ng', returnClass=false, returnCla
        ss=false, sourceTypes=[class [B, class java.lang.String]}, name='_tcpEndpoint#-2
        81997515', type='receiver', properties={}, transactionConfig=org.mule.impl.MuleT
        [email protected], filter=null, deleteUnacceptedMessages=false, initialise
        d=true, securityFilter=null, synchronous=null, initialState=started, createConne
        ctor=0}. Message payload is of type: java.lang.String
        at org.mule.routing.inbound.SelectiveConsumer.isMatch (SelectiveConsumer.
        java:64)
        at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRou
        ter.java:75)
        at org.mule.providers.AbstractMessageReceiver$Default InternalMessageList
        ener.onMessage(AbstractMessageReceiver.java:492)
        at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessa
        geReceiver.java:271)
        at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessa
        geReceiver.java:243)
        at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.processData(TcpMe
        ssageReceiver.java:305)
        at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.run(TcpMessageRec
        eiver.java:274)
        at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
        at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Wor
        ker.runTask(ThreadPoolExecutor.java:650)
        at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Wor
        ker.run(ThreadPoolExecutor.java:675)
        at java.lang.Thread.run(Unknown Source)
        Caused by: org.mule.umo.transformer.TransformerException: TypeError: Cannot find
        function replaceAll. (ed3148ee-43e3-4daa-8538-41d742c40a5e#3) (org.mozilla.java
        script.EcmaError)
        at com.webreach.mirth.server.mule.transformers.JavaSc riptPreprocessor.do
        Preprocess(JavaScriptPreprocessor.java:101)
        at com.webreach.mirth.server.mule.transformers.JavaSc riptPreprocessor.do
        Transform(JavaScriptPreprocessor.java:76)
        at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransform
        er.java:197)
        at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransform
        er.java:200)
        at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
        at org.mule.routing.inbound.SelectiveConsumer.isMatch (SelectiveConsumer.
        java:61)
        ... 10 more
        Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find function rep
        laceAll. (ed3148ee-43e3-4daa-8538-41d742c40a5e#3)
        at org.mozilla.javascript.ScriptRuntime.constructErro r(ScriptRuntime.jav
        a:3226)
        at org.mozilla.javascript.ScriptRuntime.constructErro r(ScriptRuntime.jav
        a:3216)
        at org.mozilla.javascript.ScriptRuntime.typeError(Scr iptRuntime.java:323
        2)
        at org.mozilla.javascript.ScriptRuntime.typeError1(Sc riptRuntime.java:32
        44)
        at org.mozilla.javascript.ScriptRuntime.notFunctionEr ror(ScriptRuntime.j
        ava:3304)
        at org.mozilla.javascript.ScriptRuntime.getPropFuncti onAndThis(ScriptRun
        time.java:1988)
        at org.mozilla.javascript.gen.c1._c1(ed3148ee-43e3-4daa-8538-41d742c40a5
        e:3)
        at org.mozilla.javascript.gen.c1.call(ed3148ee-43e3-4daa-8538-41d742c40a
        5e)
        at org.mozilla.javascript.optimizer.OptRuntime.callNa me0(OptRuntime.java
        :106)
        at org.mozilla.javascript.gen.c1._c0(ed3148ee-43e3-4daa-8538-41d742c40a5
        e:7)
        at org.mozilla.javascript.gen.c1.call(ed3148ee-43e3-4daa-8538-41d742c40a
        5e)
        at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:3
        37)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:275
        5)
        at org.mozilla.javascript.gen.c1.call(ed3148ee-43e3-4daa-8538-41d742c40a
        5e)
        at org.mozilla.javascript.gen.c1.exec(ed3148ee-43e3-4daa-8538-41d742c40a
        5e)
        at com.webreach.mirth.server.mule.transformers.JavaSc riptPreprocessor.do
        Preprocess(JavaScriptPreprocessor.java:91)
        ... 15 more

        Comment


        • #5
          Re: Trailing white space on version number

          Try using message.replace( instead of message.replaceAll(

          Comment


          • #6
            Re: Trailing white space on version number

            Ok. I changed it to:

            message = message.replace("|2.1 ", "|2.1");

            I have the output as a text file of the transformed data. The file gets created and it all seems correct but the exception below gets generated even though it looks like everything is ok. Am I misunderstanding something? I am simply having incoming LLP messages written out to a text file.

            p.s. The responses have been great. Quick and on the mark.


            INFO 2006-12-21 22:52:49,352 [Thread-0] com.webreach.mirth.server.Mirth: starti
            ng mirth server...
            Mirth 1.3.0 (December 18, 2006) server successfully started: Thu Dec 21 22:52:55
            EST 2006
            This product includes software developed by SymphonySoft Limited (http://www.sym
            phonysoft.com) and its contributors.
            Running Java 1.5.0_09 on Windows XP (5.1, x86)
            ca.uhn.hl7v2.HL7Exception: Couldn't create MSH for version 2.1 (does your class
            path include this version?) ...
            at ca.uhn.hl7v2.parser.Parser.makeControlMSH(Parser.j ava:299)
            at ca.uhn.hl7v2.parser.PipeParser.getCriticalResponse Data(PipeParser.jav
            a:648)
            at com.webreach.mirth.util.ACKGenerator.generateAckRe sponse(ACKGenerator
            .java:37)
            at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.generateACK(TcpMe
            ssageReceiver.java:321)
            at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.processData(TcpMe
            ssageReceiver.java:307)
            at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.run(TcpMessageRec
            eiver.java:274)
            at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
            at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Wor
            ker.runTask(ThreadPoolExecutor.java:650)
            at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Wor
            ker.run(ThreadPoolExecutor.java:675)
            at java.lang.Thread.run(Unknown Source)
            Caused by: java.lang.IllegalArgumentException: The version 2.1 is not recognize
            d
            at ca.uhn.hl7v2.model.GenericMessage.getGenericMessag eClass(GenericMessa
            ge.java:38)
            at ca.uhn.hl7v2.parser.Parser.makeControlMSH(Parser.j ava:289)
            ... 9 more
            ERROR 2006-12-21 22:53:43,901 [a603a0b1-a041-4755-b794-25b8052aece9_source_conne
            ctor._tcpEndpoint#-827647650.receiver.2] org.mule.impl.DefaultComponentException
            Strategy: Caught exception in Exception Strategy for: a603a0b1-a041-4755-b794-25
            b8052aece9: ca.uhn.hl7v2.HL7Exception: Can't parse critical fields from MSH segm
            ent (ca.uhn.hl7v2.HL7Exception: Couldn't create MSH for version 2.1 (does your
            classpath include this version?) ... ): MSH|^~\&|ADL|LHH|EAD|BEN|200609260920||A
            DT^A01|20060926092025|T|2.1
            ca.uhn.hl7v2.HL7Exception: Can't parse critical fields from MSH segment (ca.uhn.
            hl7v2.HL7Exception: Couldn't create MSH for version 2.1 (does your classpath in
            clude this version?) ... ): MSH|^~\&|ADL|LHH|EAD|BEN|200609260920||ADT^A01|200 60
            926092025|T|2.1
            at ca.uhn.hl7v2.parser.PipeParser.getCriticalResponse Data(PipeParser.jav
            a:662)
            at com.webreach.mirth.util.ACKGenerator.generateAckRe sponse(ACKGenerator
            .java:37)
            at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.generateACK(TcpMe
            ssageReceiver.java:321)
            at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.processData(TcpMe
            ssageReceiver.java:307)
            at org.mule.providers.tcp.TcpMessageReceiver$TcpWorke r.run(TcpMessageRec
            eiver.java:274)
            at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
            at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Wor
            ker.runTask(ThreadPoolExecutor.java:650)
            at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Wor
            ker.run(ThreadPoolExecutor.java:675)
            at java.lang.Thread.run(Unknown Source)
            Caused by: ca.uhn.hl7v2.HL7Exception: Couldn't create MSH for version 2.1 (does
            your classpath include this version?) ...
            at ca.uhn.hl7v2.parser.Parser.makeControlMSH(Parser.j ava:299)
            at ca.uhn.hl7v2.parser.PipeParser.getCriticalResponse Data(PipeParser.jav
            a:648)
            ... 8 more
            Caused by: java.lang.IllegalArgumentException: The version 2.1 is not recognize
            d
            at ca.uhn.hl7v2.model.GenericMessage.getGenericMessag eClass(GenericMessa
            ge.java:38)
            at ca.uhn.hl7v2.parser.Parser.makeControlMSH(Parser.j ava:289)
            ... 9 more

            Comment


            • #7
              Re: Trailing white space on version number

              Hmm...quite an interesting error. It appears this may be an error on the HAPI side or the message might be invalid. Thankfully the preprocessor will let us get around that. Try changing 2.1 to 2.2 - HL7 v2.1, 2.2 and 2.3 are very similar (with 2.3.1, 2.4 and 2.5 introducing several changes).

              -Chris
              Chris Lang

              Comment


              • #8
                Re: Trailing white space on version number

                Please, can you put the message?

                Comment


                • #9
                  Re: Trailing white space on version number

                  It still seems to have to do with the trailing space on the version number. If I trim the space manually in a text editor the message gets processed fine but like I said, the message comes from an ADT system that I don't control. The message is below but I'm not sure that cutting and pasting is here will give you the same result. Let me know if you need the channel. It's very simple. It receives the message LLP and then simply write the message to a file.

                  Thanks.


                  MSH|^~\&|ADL|LHH|EAD|BEN|200609260920||ADT^A01|200 60926092025|T|2.1
                  EVN|A01|200609260920|||XXXXXPID||004525|004525~||G REENXXXX^MXXXXX^|||U||OTH|^^^^|38||||U|OTH|004525| 068322609||||
                  NK1|| ^|O|^^ ^ ^|||NK|
                  NK1|| ^|O|^^^^|||EC|
                  PV1|||3TH FLR||||^|^||OTH|||||||^||||||||||||||||||||||||||| 20060925|| 0-00-00| 0-00-00|
                  ZP1||||004525^^^LHH||||||||||||||||||||||||||||||| ||004525^^^LHH|GREENXXXX^MXXXXX|^^^^||

                  Comment


                  • #10
                    Re: Trailing white space on version number

                    Yo can try:

                    message = message.replace("|2.1", "|2.1|");

                    If it doesn't work, please, send me the message to albersato *at* gmail *dot* com

                    Comment


                    • #11
                      Re: Trailing white space on version number

                      It might not be an actual space - it might be a control character (vertical tab, line feed, carriage return, etc).

                      You can try using a regex in the replace command - Google Javascript string replace regex. The format is similar to:

                      Code:
                      message = message.replace(\2\.1\w*\g,"2.1");
                      (I think \w is to capture any whitespace char, but I might be mistaken. The entire expression needs to be surrounded by \ \ and any special characters (| . * { } ( ) [ ] ^) needs to be escaped with a \. Also you should include 'g' at the end to express that you'd like a global search and replace in the string.

                      -Chris
                      Chris Lang

                      Comment


                      • #12
                        Re: Trailing white space on version number

                        Ok, this is the final solution (tested):

                        Code:
                        // Modify the message variable below to pre process data
                        message=message.replace(/\|2\.1 /i,'|2.1|');
                        message=message.replace(/[^\r]PID\|/i,'\rPID');
                        
                        return message;
                        In the message there are two problems: the version, and the lost of '\r' in the PID segment.

                        Comment

                        Working...
                        X