Announcement

Collapse
No announcement yet.

String to HL7

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

  • String to HL7

    I have a channel that captures the raw source messages (which are simple HL7 V2 messages), with the following code:

    channelMap.put('sourceInbound',connectorMessage.ge tRawData());

    This channel has numerous destination connectors. On one (AND ONLY ONE) of the destination connectors, I need to manipulate the raw message from the source.

    So basically, on the destination there is a transformer that captures the raw source message with the following code-

    var toHL7 = $('RawInbound');

    I would like to use the native mirth functions such as:

    msg['MSH']['MSH.4']['MSH.4.1'] = "BlaBlaBla";
    msg['IN1']['IN1.4']['IN1.4.1'] = "BlaBlaBla";

    or even mirth's native interators such as

    for each (seg in msg.children()) {
    if (seg.name().toString() == "SEG") {
    var sample_value = seg['SEG.1']['SEG.1.1'].toString();
    }
    }

    However, since the destination transformer sees the raw message as a string, it is not recognizing the message as an HL7 message.
    What would be the best way to have the destination connector recognize the message as a HL7 message and not a string value?

    I have tried to convert to XML and convert back to HL7 using mirth’s built in functions, and it does the conversion, to XML and back to HL7, but it still does not recognize the message as an HL7 message, even after converting it back to HL7 from XML.

    Any ideas on how to have the destination connector recognize the value stored in the variable “toHL7” as an HL7 message, so that I can use the stated built in Mirth functions?

  • #2
    msg = new XML(toHL7);

    Comment


    • #3
      Cory_cole, I think we've tried that already, anyways, just tried again, and got this:

      Transformer error
      ERROR MESSAGE: Error evaluating transformer
      java.lang.NullPointerException
      at org.mozilla.javascript.xmlimpl.XmlNode$InternalLis t.add(XmlNode.java:835)
      at org.mozilla.javascript.xmlimpl.XMLList.replace(XML List.java:55)
      at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:151)
      at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:150)
      at org.mozilla.javascript.xmlimpl.XMLObjectImpl.put(X MLObjectImpl.java:261)
      at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1622)
      at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1615)
      at org.mozilla.javascript.Interpreter.doSetElem(Inter preter.java:2237)
      at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1268)
      at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
      at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
      at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:393)
      at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3280)
      at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
      at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:150)
      at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:143)
      at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
      at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
      at java.lang.Thread.run(Unknown Source)

      Comment


      • #4
        what do you get if you do

        logger.info(toHL7)?

        Comment


        • #5
          Originally posted by cory_cole View Post
          msg = new XML(toHL7);


          INFO (transformer:?):

          it's not doing the transform..

          Comment


          • #6
            Do just the logger.info. Don't do the msg = new XML()

            Comment


            • #7
              Getting the HL7 message:

              INFO (transformer:?): MSH|^~\&|***************************************** ****

              Starred off the actual message.

              Please feel free to try it out on your end, there are just a few transforms, one in the source, and 4 in the destination.
              Below are the transforms:

              Source Transform:
              channelMap.put('sourceInbound',connectorMessage.ge tRawData());

              Destination Transform:
              var toHL7 = $('sourceInbound');
              msg = new XML(toHL7);
              logger.info(toHL7);
              msg['MSH']['MSH.4']['MSH.4.1'] ="BlaBlaBLa";

              Comment


              • #8
                try this...

                msg = new XML(toHL7.toString());

                Comment


                • #9
                  Same error:

                  Transformer error
                  ERROR MESSAGE: Error evaluating transformer
                  java.lang.NullPointerException
                  at org.mozilla.javascript.xmlimpl.XmlNode$InternalLis t.add(XmlNode.java:835)
                  at org.mozilla.javascript.xmlimpl.XMLList.replace(XML List.java:55)
                  at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:151)
                  at org.mozilla.javascript.xmlimpl.XMLList.putXMLPrope rty(XMLList.java:150)
                  at org.mozilla.javascript.xmlimpl.XMLObjectImpl.put(X MLObjectImpl.java:261)
                  at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1622)
                  at org.mozilla.javascript.ScriptRuntime.setObjectElem (ScriptRuntime.java:1615)
                  at org.mozilla.javascript.Interpreter.doSetElem(Inter preter.java:2237)
                  at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1268)
                  at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
                  at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
                  at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:393)
                  at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3280)
                  at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
                  at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:150)
                  at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:143)
                  at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
                  at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
                  at java.util.concurrent.FutureTask.run(Unknown Source)
                  at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
                  at java.lang.Thread.run(Unknown Source)

                  Comment


                  • #10
                    Code:
                    msg = SerializerFactory.getSerializer('HL7V2').toXML($('RawInbound'));

                    Comment


                    • #11
                      Originally posted by odo View Post
                      Code:
                      msg = SerializerFactory.getSerializer('HL7V2').toXML($('RawInbound'));
                      Code:
                      msg = new XML(SerializerFactory.getSerializer('HL7V2').toXML($('RawInbound')));

                      Comment


                      • #12
                        Sorry, this is giving the error that I described at the beginning of this ticket:

                        Transformer error
                        ERROR MESSAGE: Error evaluating transformer
                        com.mirth.connect.server.MirthJavascriptTransforme rException:
                        CHANNEL: string2HL7
                        CONNECTOR: Destination 1
                        SCRIPT SOURCE: TRANSFORMER
                        SOURCE CODE:
                        1508:
                        1509: msg = SerializerFactory.getSerializer('HL7V2').toXML($(' RawInbound'));
                        1510:
                        1511:
                        1512:
                        1513: msg['MSH']['MSH.4']['MSH.4.1'] ="BlaBlaBLa";
                        1514: if ('xml' === typeof msg) {
                        1515: if (msg.hasSimpleContent()) {
                        1516: msg = msg.toXMLString();
                        1517: }
                        LINE NUMBER: 1513
                        DETAILS: TypeError: Cannot read property "MSH.4" from undefined
                        at 980b5155-c1e6-4c8e-a86c-01d79e2506f1:1513 (doTransform)
                        at 980b5155-c1e6-4c8e-a86c-01d79e2506f1:1535 (doScript)
                        at 980b5155-c1e6-4c8e-a86c-01d79e2506f1:1537
                        at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
                        at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
                        at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
                        at java.util.concurrent.FutureTask.run(Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
                        at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
                        at java.lang.Thread.run(Unknown Source)

                        Comment


                        • #13
                          Sorry, this is giving the error that I described in the beginning of this ticket:

                          Transformer error
                          ERROR MESSAGE: Error evaluating transformer
                          com.mirth.connect.server.MirthJavascriptTransforme rException:
                          CHANNEL: string2HL7
                          CONNECTOR: Destination 1
                          SCRIPT SOURCE: TRANSFORMER
                          SOURCE CODE:
                          1508:
                          1509: msg = SerializerFactory.getSerializer('HL7V2').toXML($(' RawInbound'));
                          1510:
                          1511:
                          1512:
                          1513: msg['MSH']['MSH.4']['MSH.4.1'] ="BlaBlaBLa";
                          1514: if ('xml' === typeof msg) {
                          1515: if (msg.hasSimpleContent()) {
                          1516: msg = msg.toXMLString();
                          1517: }
                          LINE NUMBER: 1513
                          DETAILS: TypeError: Cannot read property "MSH.4" from undefined
                          at 980b5155-c1e6-4c8e-a86c-01d79e2506f1:1513 (doTransform)
                          at 980b5155-c1e6-4c8e-a86c-01d79e2506f1:1535 (doScript)
                          at 980b5155-c1e6-4c8e-a86c-01d79e2506f1:1537
                          at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
                          at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
                          at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
                          at java.util.concurrent.FutureTask.run(Unknown Source)
                          at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
                          at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
                          at java.lang.Thread.run(Unknown Source)

                          Comment


                          • #14
                            Look at my previous post.

                            Comment


                            • #15
                              Thanks agermano, the below works !

                              msg = new XML(SerializerFactory.getSerializer('HL7V2').toXML ($('RawInbound')));

                              Comment

                              Working...
                              X