Announcement

Collapse
No announcement yet.

Problem replacing CRLF with .br for ORU formatted text

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

  • Problem replacing CRLF with .br for ORU formatted text

    Mirth 1.3.1, Java 1.5_09 Windows XP Pro
    ==========

    Need to replace "Carriage Return" and/or "New Line" with "\.br" for ORU Transcription Formatted Text.

    ========= Transformer JavaScript Step =========

    var tempString = "Line1\nLine2\r\nLine3\nLine4\r\nLine5\n";

    tempString = tempString.replace(/[\r\n]/g, "\\.br\");
    =====================================

    I get tempString as

    ==========
    Line1\E\.br\E\Line2\E\.br\E\\E\.br\E\Line3\E\.br\E \Line4\E\.br\E\\E\.br\E\Line5\E\.br\E\==========

    I have tried various differnt ways but just keep getting "\E".

    I tried the same JavaScript in a Test.html web page and it works fine (I don't get the \E).

    Any help to resolve this problem would be appreciated.

    Thanks in advance

  • #2
    Re: Problem replacing CRLF with .br for ORU formatted text

    Try:
    Code:
    tempString = tempString.replace(/[\r\n]/g, "\.br");
    Chris Lang

    Comment


    • #3
      Re: Problem replacing CRLF with .br for ORU formatted text

      Chris,

      Thanks for the quick reply. I tried that before and tried it again (Did a copy and paste from the reply).

      "\.br" appears in red font and "Validate JavaScript" thorws error:

      ==========
      Error on line xx: unterminated string literal.
      ==========

      If changed to "\\.br\" the font changes to purple and JavaScript validation goes through successfully but get "\E" in the output.

      Comment


      • #4
        Re: Problem replacing CRLF with .br for ORU formatted text

        try adding a replace for \E with ""

        -Chris
        Chris Lang

        Comment


        • #5
          Re: Problem replacing CRLF with .br for ORU formatted text

          Chris,

          I tried that as well but the output still has \E.

          The problem appears to be with Mirth. Inside a javascript transformer step, if a string variable has a backslash Mirth is replacing it with a \E.

          To confirm this, here's what we tried:

          1. Removed the CRLF replace statement in the Mirth Transformer.

          2. Did the actual CRLF replacement to "\.br" on our server side code which saves the document in the database.

          3. When I copy and paste the data from SQL Server 2000 column to Notepad or any text editor I see just the "\.br" where expected.

          4. But when the document is read by Mirth (with no replace for CRLF to "\.br") and outputs an ORU transcription message it adds a \E for each backslash. That is, instead of "\.br" we get "\E\.br\E"

          Could it be related to Encoding?

          In the "Destination" tab it was set to "default". Tried US-ASCII and also windows-1250 but it did not help.

          I appreciate all your help!

          Thank you.

          Comment


          • #6
            Re: Problem replacing CRLF with .br for ORU formatted text

            More info. to help reproduce the problem.

            ==== Transformer JavaScrit test code ========
            var tempString = "Line1\\.br\\Line2TestPatient\\.br\\Line3\\.br\\Li ne4";
            logger.info('tempString is: ' + tempString);

            Note: logger.info works fine and shows the correct output.

            ===============
            INFO 2007-01-16 17:18:48,525 [739c7d6b-6e70-4d35-b766-fa217de48b85_destination_1_connector.dispatcher.1] outbound-transformation: tempString is: Line1\.br\Line2TestPatient\.br\Line3\.br\Line4
            ===============

            But the output HL7 Message from Mirth does not ( puts a \E ):

            ===============
            MSH|^~\&|TestConnect|TestSender|TestReceiver||2007 0116171847||ORU^R01|73c1964b-60b7-4a48-9cdd-87bc7a65f9f7|P|2.2
            PID|||107059^^^Test||TestPatient^Test^M||19601227| F|||123 Test Drive^^TestCity^TT^12345|||||||107059^^^Test|11122 1234
            PV1||O|||||142^AtndPhysician^Test^E|^RefPhy^Test
            OBR|||Test^TRANSCRIPTION|Test^MISC|||20050915||||| |||||||||||||F
            OBX||FT|||Line1\E\.br\E\Line2TestPatient\E\.br\E\L ine3\E\.br\E\Line4
            ===============

            Comment


            • #7
              Re: Problem replacing CRLF with .br for ORU formatted text

              Whre is the '\E' added.. ┬┐after the preprocessor or after the processor?

              Comment


              • #8
                Re: Problem replacing CRLF with .br for ORU formatted text

                It's an Outbound "Database to File Writer" Channel. The "\E" gets added when the message is written out to the file (it does not happen when you print it out in mirth.log file using logger.info)

                Thanks

                Comment


                • #9
                  Re: Problem replacing CRLF with .br for ORU formatted text

                  Ah yes. Because \ is an encoding character, the HL7 encoder uses \E\ to denote \. If you change the encoding character it should operate as expected.

                  -Chris
                  Chris Lang

                  Comment


                  • #10
                    Re: Problem replacing CRLF with .br for ORU formatted text

                    Chris,

                    Thank you very much for your reply. Where do I change the encoding character and to what character?

                    Thanks

                    Comment


                    • #11
                      Re: Problem replacing CRLF with .br for ORU formatted text

                      You can change it in the preprocesser (message.replace...) Change it to '*'. You then must change it back after the transformation happens. Use the "ER7 Encoder" (serializer) in the transformer to convert the msg or tmp XML to ER7.

                      -Chris
                      Chris Lang

                      Comment


                      • #12
                        Re: Problem replacing CRLF with .br for ORU formatted text

                        I get "Failed to invoke UMO Component" error.

                        Could you please let me what needs to be corrected? Thanks for your help.

                        Here's what I tried.

                        =======================
                        Summary Tab:

                        Preprocessing Script:

                        // Modify the message variable below to pre process data
                        message.replace(/[\E\]/g, "*");
                        return message;
                        =======================

                        Destinations Tab / Edit Transformer / Added a new JavaScript Step (Last Step)

                        message = message.replace(/[\*]/g, "\\E\");
                        serializer.fromXML(message);
                        ========================


                        ERROR 2007-01-16 23:52:41,008 [739c7d6b-6e70-4d35-b766-fa217de48b85.2] org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in Exception Strategy for: 739c7d6b-6e70-4d35-b766-fa217de48b85: org.mule.umo.MessagingException: Failed to invoke UMO Component: 739c7d6b-6e70-4d35-b766-fa217de48b85. Message payload is of type: org.apache.commons.dbutils.BasicRowProcessor$CaseI nsensitiveHashMap
                        org.mule.umo.MessagingException: Failed to invoke UMO Component: 739c7d6b-6e70-4d35-b766-fa217de48b85. Message payload is of type: org.apache.commons.dbutils.BasicRowProcessor$CaseI nsensitiveHashMap
                        at org.mule.impl.DefaultLifecycleAdapter.onCall(Defau ltLifecycleAdapter.java:193)
                        at org.mule.impl.DefaultLifecycleAdapter.intercept(De faultLifecycleAdapter.java:232)
                        at org.mule.impl.InterceptorsInvoker.execute(Intercep torsInvoker.java:53)
                        at org.mule.impl.model.DefaultMuleProxy.run(DefaultMu leProxy.java:388)
                        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.transformer.TransformerException: SyntaxError: Unterminated character class (org.mozilla.javascript.EcmaError)
                        at com.webreach.mirth.server.mule.transformers.JavaSc riptPreprocessor.doPreprocess(JavaScriptPreprocess or.java:101)
                        at com.webreach.mirth.server.mule.transformers.JavaSc riptPreprocessor.doTransform(JavaScriptPreprocesso r.java:76)
                        at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
                        at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
                        at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
                        at org.mule.impl.MuleEventContext.getTransformedMessa ge(MuleEventContext.java:100)
                        at com.webreach.mirth.server.mule.components.Channel. onCall(Channel.java:34)
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
                        at java.lang.reflect.Method.invoke(Unknown Source)
                        at org.mule.model.DynamicEntryPoint.invokeCurrent(Dyn amicEntryPoint.java:168)
                        at org.mule.model.DynamicEntryPoint.invoke(DynamicEnt ryPoint.java:90)
                        at org.mule.impl.DefaultLifecycleAdapter.onCall(Defau ltLifecycleAdapter.java:177)
                        ... 7 more
                        Caused by: org.mozilla.javascript.EcmaError: SyntaxError: Unterminated character class
                        at org.mozilla.javascript.ScriptRuntime.constructErro r(ScriptRuntime.java:3226)
                        at org.mozilla.javascript.ScriptRuntime.constructErro r(ScriptRuntime.java:3216)
                        at org.mozilla.javascript.regexp.NativeRegExp.reportE rror(NativeRegExp.java:2378)
                        at org.mozilla.javascript.regexp.NativeRegExp.parseTe rm(NativeRegExp.java:985)
                        at org.mozilla.javascript.regexp.NativeRegExp.parseAl ternative(NativeRegExp.java:466)
                        at org.mozilla.javascript.regexp.NativeRegExp.parseDi sjunction(NativeRegExp.java:427)
                        at org.mozilla.javascript.regexp.NativeRegExp.compile RE(NativeRegExp.java:294)
                        at org.mozilla.javascript.regexp.RegExpImpl.compileRe gExp(RegExpImpl.java:50)
                        at org.mozilla.javascript.gen.c28._reInit(27065676-b503-42f7-859d-76336c0f81d2)
                        at org.mozilla.javascript.gen.c28._i1(27065676-b503-42f7-859d-76336c0f81d2)
                        at org.mozilla.javascript.gen.c28.<init>(27065676-b503-42f7-859d-76336c0f81d2)
                        at org.mozilla.javascript.gen.c28._c0(27065676-b503-42f7-859d-76336c0f81d2)
                        at org.mozilla.javascript.gen.c28.call(27065676-b503-42f7-859d-76336c0f81d2)
                        at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:337)
                        at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:2755)
                        at org.mozilla.javascript.gen.c28.call(27065676-b503-42f7-859d-76336c0f81d2)
                        at org.mozilla.javascript.gen.c28.exec(27065676-b503-42f7-859d-76336c0f81d2)
                        at com.webreach.mirth.server.mule.transformers.JavaSc riptPreprocessor.doPreprocess(JavaScriptPreprocess or.java:91)
                        ... 20 more

                        Comment


                        • #13
                          Re: Problem replacing CRLF with .br for ORU formatted text

                          Code:
                          message.replace(/[\\E\\]/g, "*");
                          Chris Lang

                          Comment


                          • #14
                            Re: Problem replacing CRLF with .br for ORU formatted text

                            Chris,

                            Thank you for the reply. When I made the change and tried again, I get, "Error at tranformerorg.mule.umo.transformer.TransformerExce ption: Wrapped java.lang.NullPointerException (56ea1d1d-28f8-4728-8d89-924af57e2860#70) (org.mozilla.javascript.WrappedException)" exception.

                            logger.info(&#039;tempString is: &#039; + tempString.toString());
                            inside the transformer JavaScript steps show the text correctly.

                            It is only when Mirth tries to send the outbound message I get this error.

                            I would appreciate if you could help resovle this problem.

                            Thanks

                            =============== Error Message ============

                            ERROR 2007-01-21 09:14:11,994 [739c7d6b-6e70-4d35-b766-fa217de48b85_destination_1_connector.dispatcher.1] org.mule.providers.file.FileMessageDispatcher: Error at tranformerorg.mule.umo.transformer.TransformerExce ption: Wrapped java.lang.NullPointerException (56ea1d1d-28f8-4728-8d89-924af57e2860#70) (org.mozilla.javascript.WrappedException)
                            ERROR 2007-01-21 09:14:12,004 [739c7d6b-6e70-4d35-b766-fa217de48b85_destination_1_connector.dispatcher.1] org.mule.impl.DefaultComponentExceptionStrategy: Caught exception in Exception Strategy for: 739c7d6b-6e70-4d35-b766-fa217de48b85: org.mule.umo.transformer.TransformerException: Wrapped java.lang.NullPointerException (56ea1d1d-28f8-4728-8d89-924af57e2860#70) (org.mozilla.javascript.WrappedException)
                            org.mule.umo.transformer.TransformerException: Wrapped java.lang.NullPointerException (56ea1d1d-28f8-4728-8d89-924af57e2860#70) (org.mozilla.javascript.WrappedException)
                            at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateOutboundTransformerScript( JavaScriptTransformer.java:332)
                            at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.doTransform(JavaScriptTransformer. java:174)
                            at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
                            at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
                            at org.mule.providers.file.FileMessageDispatcher.doDi spatch(FileMessageDispatcher.java:74)
                            at org.mule.providers.AbstractMessageDispatcher$Worke r.run(AbstractMessageDispatcher.java:257)
                            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.mozilla.javascript.WrappedException: Wrapped java.lang.NullPointerException (56ea1d1d-28f8-4728-8d89-924af57e2860#70)
                            at org.mozilla.javascript.Context.throwAsScriptRuntim eEx(Context.java:1693)
                            at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:157)
                            at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:201)
                            at org.mozilla.javascript.optimizer.OptRuntime.call1( OptRuntime.java:64)
                            at org.mozilla.javascript.gen.c51._c2(56ea1d1d-28f8-4728-8d89-924af57e2860:70)
                            at org.mozilla.javascript.gen.c51.call(56ea1d1d-28f8-4728-8d89-924af57e2860)
                            at org.mozilla.javascript.optimizer.OptRuntime.callNa me0(OptRuntime.java:106)
                            at org.mozilla.javascript.gen.c51._c0(56ea1d1d-28f8-4728-8d89-924af57e2860:70)
                            at org.mozilla.javascript.gen.c51.call(56ea1d1d-28f8-4728-8d89-924af57e2860)
                            at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:337)
                            at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:2755)
                            at org.mozilla.javascript.gen.c51.call(56ea1d1d-28f8-4728-8d89-924af57e2860)
                            at org.mozilla.javascript.gen.c51.exec(56ea1d1d-28f8-4728-8d89-924af57e2860)
                            at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateOutboundTransformerScript( JavaScriptTransformer.java:307)
                            ... 9 more
                            Caused by: java.lang.NullPointerException
                            at ca.uhn.hl7v2.parser.XMLParser.supportsEncoding(XML Parser.java:137)
                            at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:139)
                            at com.webreach.mirth.model.converters.ER7Serializer. fromXML(ER7Serializer.java:77)
                            at com.webreach.mirth.model.converters.ER7Serializer. fromXML(ER7Serializer.java:35)
                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
                            at java.lang.reflect.Method.invoke(Unknown Source)
                            at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:142)
                            ... 21 more

                            Comment


                            • #15
                              Re: Problem replacing CRLF with .br for ORU formatted text

                              Let&#039;s try a different approach -

                              1) Replace "" in the preprocessor (in the message header):
                              Code:
                              return message.replace(/ ~ \ \ /,"~*"):
                              NOTE: REMOVE THE SPACES IN THE FIRST REPLACE PARAMETER (THE FORUM SOFTWARE WAS CAUSING ISSUES)

                              2) In the Javascript, perform your modifications and serialization as unnecessary. Let&#039;s assume we store this in a var called "er7".

                              3) Replace the * in the msh header with "":
                              Code:
                              er7 = er7.replace(/~\*/,"~\");
                              (You might just need "~" in that last replacement.)

                              This will cause the message mirth reads in to treat * as an encoding character (so that \ will not get replaced). In your file writer, make sure you specify "${er7}" as the output variable.

                              -Chris
                              Chris Lang

                              Comment

                              Working...
                              X