Announcement

Collapse
No announcement yet.

Change message type inside the transformer with the msg object

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

  • Change message type inside the transformer with the msg object

    Hi,
    I have a bad problem: I have a channel receving HL7 Messages like this :

    MSH|^~\&|RIS|RIS|AOB HL7 Gateway|AOB|||ORM^O01|1|P|2.3.1||||||8859/1
    PID|||10104665^^^AOB~XXXXXX45E66C351W^^^CF||Duck^R ocker||19770703|M|||VIA COLOMBA ANTONIETTI 14^^092009^092^00043^ITALIA^P~^^^^^^H||555-1234~|||||XXXXXX45E66C351W^^^AOB|||||092009|||0003 1
    PV1|||||||||||||||||||2070011966^^^AOB|||||||||||| ||||||||||||||||||||V
    ORC|SN|^AOB|42251^RIS|2070011970|SC||^^^2007012912 1400||20070129123242|^00009038||^[email protected]|dhe_s p||||^dhe_sp
    OBR||^AOB|42251^RIS|8706^8706 - FAR^MedTrak^8706^8706 - FAR^RIS|||||||||\F\\F\R0\F\\F\|||^[email protected]||358 45|35742|69013||||CR|||^^^20070129121400||||^\F\\F \R0\F\\F\
    

    inside my transformer I have to fill some information (ORC-2 and OBR-2) and to answer with an outbound hl7 message which is similar to the inbound above, but of a different type:

    MSH|^~\&|RIS|RIS|AOB HL7 Gateway|AOB|||ORR^O02|1|P|2.3.1||||||8859/1
    MSA|AA|1||||
    PID|||10104665^^^AOB~XXXXXX45E66C351W^^^CF||Duck^R ocker||19770703|M|||VIA COLOMBA ANTONIETTI 14^^092009^092^00043^ITALIA^P~^^^^^^H||555-1234~|||||XXXXXX45E66C351W^^^AOB|||||092009|||0003 1
    PV1|||||||||||||||||||2070011966^^^AOB|||||||||||| ||||||||||||||||||||V
    ORC|SN|123^AOB|42251^RIS|2070011970|SC||^^^2007012 9121400||20070129123242|^00009038||^[email protected]|dh e_sp||||^dhe_sp
    OBR||123^AOB|42251^RIS|8706^8706 - FAR^MedTrak^8706^8706 - FAR^RIS|||||||||\F\\F\R0\F\\F\|||^[email protected]||358 45|35742|69013||||CR|||^^^20070129121400||||^\F\\F \R0\F\\F\

    The problem is that I am working with the msg object, that if I have unserstood correctli it is the incoming message representation object and,after the trasformations, the message that will be sent. I am not able to change the message type from ORM^O01 to ORR^O02 inside this object. I have tried to delete all the MSH segment and to subsitute it to an XML new one; it was the only way to change the MSH-9 fields. But after the transmission I see that the XML representation of the transformed message always starts with:
    <ORM_O01 xmlns="urn:hl7-org:v2xml">
    so the message type is always ORM^O01.
    Finally, is there a way, with the msg oblect, to add the MSA segment correctly and change the message type from ORM^O01 to ORM^O02??
    What can I should do??

    Thanks in advance,
    asulis

  • #2
    Re: Change message type inside the transformer with the msg object

    When you say "I need to answer with a ORM^O02" I suppose your&#039;re taking about a different TCP stream isnt&#039;t it? For this version, there is no custom ACK.

    If you need to create a different message, you can try the next code:

    Code:
    incomingMsg=msg;
    msg=serializer.toXML(template_message_O02);

    Comment


    • #3
      Re: Change message type inside the transformer with the msg object

      Hi alberto,
      thanks for your reply. Yes, I have to send the second message, that, as you can see, it is similat to the first. I was looging for a way to build the second message without having to re-write all the template and to re-fill it with all information.
      I don&#039;t know what are the steps/transformation to do with the msg objects on order to obtain this.....

      Comment


      • #4
        Re: Change message type inside the transformer with the msg object

        You can try a different approach:

        1. Get the ER7 code of the inncoming message (this can be done at preprocess level, or in one JS step usinng the getRawData function)
        Code:
        var new_er7_string=messageObject.getRawData()
        2. Change the ORM^O01 string to a ORR^O02 string (using the replace JS function) in the ER7 string
        3. Insert the "MSA|AA|1||||" string before the "PID" in the ER7 string.
        4. Create the XML message using msg=serializer.toXML(new_er7_string);
        5. Populate the fields you need in the new structure.


        Comment


        • #5
          Re: Change message type inside the transformer with the msg object

          Hi alberto,
          thank you very much for your help. Your approach is good, by making your steps I am able to change the message type. I can see the outbound message correctly. But if I add a transformet step that fills info into the new msg objects, I still have problems.
          This is the code making your steps:
          Code:
          var new_er7_string=messageObject.getRawData();
          new_er7_string = new_er7_string.replace (&#039;ORM^O01&#039;,&#039;ORR^O02&#039;);
          var index = new_er7_string.indexOf(&#039;PID&#039;);
          var part1 =  new_er7_string.substring(0,index-1); var length = new_er7_string.length();
          var part2 =  new_er7_string.substring(index,length);
          var msa = &#039;\rMSA|AA|1|\r&#039;;
          var finalString = part1+msa+part2;
          msg = serializer.toXML(finalString);
          And this is an extraction of the XML transformed message:

          Code:
          <?xml version="1.0"?>
          <RRO_O02 xmlns="urn:hl7-org:v2xml">
              <MSH>
                .........................
              </MSH>
              <MSA>
               .........................
              </MSA>
              <ERR/>
              <NTE/>
              <RRO_O02.PIDNTEORCRXONTERXRRXCNTE>
                  <RRO_O02.PIDNTE>
                      <PID>
          	.....................................
                      </PID>
                      <NTE/>
                      <PV1>
          	</PV1>
                  </RRO_O02.PIDNTE>
                  <RRO_O02.ORCRXONTERXRRXCNTE>
                      <ORC>
                          <ORC.1>SN</ORC.1>
                          <ORC.2>
                              <EI.2>AOB</EI.2>
                          </ORC.2>
                          <ORC.3>
                              <EI.1>42251</EI.1>
                              <EI.2>EbitRIS</EI.2>
                          </ORC.3>
                          <ORC.4>
                              <EI.1>2070011970</EI.1>
                          </ORC.4>
          	    .......................................
                      </ORC>
                      <RRO_O02.RXONTERXRRXCNTE>
                          <RXO/>
                          <NTE/>
                          <RXR/>
                          <RXC/>
                          <NTE/>
                          <OBR>
          	     ..................................................
                         </OBR>
                      </RRO_O02.RXONTERXRRXCNTE>
                  </RRO_O02.ORCRXONTERXRRXCNTE>
              </RRO_O02.PIDNTEORCRXONTERXRRXCNTE>
          </RRO_O02>
          I think that the long strange tags are built by the system. Now, if I add a transformer step trying to do:
          Code:
          var orm_path = &#039;RRO_O02.PIDNTEORCRXONTERXRRXCNTE&#039;;
          var orm_path1 = &#039;RRO_O02.RXONTERXRRXCNTE&#039;;
          var orc4 = msg[orm_path][orm_path1][&#039;ORC&#039;][&#039;ORC.4&#039;][&#039;EI.1&#039;];
          I get the following error:
          Code:
          org.mozilla.javascript.EcmaError: TypeError: Cannot read property "RRO_O02.RXONTERXRRXCNTE" from undefined (e5f9f2ef-c375-4c75-8ea3-7575b29b52ec#14)
          It is interesting to say that if i try to access to the first node (orm_path) all goes well. So, the problem is exaclty at the PID level, when I broke the incoming message in order to insert the MSA field. The starnge thing is that without making this last transformation step all goes well and I see into the encoding window the right transformed message.
          Where the problem can be? It is very important for me to make this transformation able to work properly!!!!!!

          Many thanks,
          asulis

          Comment


          • #6
            Re: Change message type inside the transformer with the msg object

            there was an error in my last post, but the problem is the same.
            Code:
            var orm_path = &#039;RRO_O02.PIDNTEORCRXONTERXRRXCNTE&#039;;
            var orm_path1 = &#039;RRO_O02.ORCRXONTERXRRXCNTE&#039;;
            var orc4 = msg[orm_path][orm_path1][&#039;ORC&#039;][&#039;ORC.4&#039;][&#039;EI.1&#039;];
            this is the error:
            Code:
            org.mozilla.javascript.EcmaError: TypeError: Cannot read property "RRO_O02.ORCRXONTERXRRXCNTE" from undefined (d913d667-98cb-4d0a-881c-f538dc21e82c#14)
            Thanks and sorry for the mistake.
            Any help is fully appreciated.
            asulis

            Comment


            • #7
              Re: Change message type inside the transformer with the msg object

              You&#039;re right. It seems than serializer.toXML returns an string. You need to get the XML object from it:

              Code:
              var new_er7_string=messageObject.getRawData();
              new_er7_string = new_er7_string.replace (&#039;ORM^O01&#039;,&#039;ORR^O02&#039;);
              var index = new_er7_string.indexOf(&#039;PID&#039;);
              var part1 =  new_er7_string.substring(0,index-1); var length = new_er7_string.length();
              var part2 =  new_er7_string.substring(index,length);
              var msa = &#039;\rMSA|AA|1|\r&#039;;
              message= part1+msa+part2;
              msg = new XML(serializer.toXML(message));
              var orm_path = &#039;RRO_O02.PIDNTEORCRXONTERXRRXCNTE&#039;;
              var orm_path1 = &#039;RRO_O02.ORCRXONTERXRRXCNTE&#039;;
              var orc4 = msg[orm_path][orm_path1][&#039;ORC&#039;][&#039;ORC.4&#039;][&#039;EI.1&#039;];
              BTW, the long names of the XML elements are because they are the official ones (as HL7 Int. defined) for 2.3.1 messages. For 2.4, 2.5, 2.5.1 and 2.6 there are other rules.

              Comment


              • #8
                Re: Change message type inside the transformer with the msg object

                Hi Alberto,
                I investigated about this frustrating error. I tried to put some logs in order to see output. Well, first of all I&#039;ve tried to log the object output exactly at the path point where there is the error;so I have:
                Code:
                var orm_path = &#039;RRO_O02.PIDNTEORCRXONTERXRRXCNTE&#039;;
                var orm_path1 = &#039;RRO_O02.ORCRXONTERXRRXCNTE&#039;;
                var prova = msg[orm_path];
                logger.info(&#039;PATH:&#039;+prova);
                I have applied this code with two different situations:

                1) The msg object is my transformed message, it is that obtained by the posted code:the msg object that appears into your previous post code

                2)I put my transformed raw message:
                Code:
                MSH|^~\&|RIS|RIS|AOB HL7 Gateway|AOB|||ORR^O02|1|P|2.3.1||||||8859/1
                MSA|AA|1||||
                PID|||10104665^^^AOB~XXXXXX45E66C351W^^^CF||Duck^Rocker||19770703|M|||VIA COLOMBA ANTONIETTI 14^^092009^092^00043^ITALIA^P~^^^^^^H||555-1234~|||||XXXXXX45E66C351W^^^AOB|||||092009|||00031
                PV1|||||||||||||||||||2070011966^^^AOB||||||||||||||||||||||||||||||||V
                ORC|SN|123^AOB|42251^RIS|2070011970|SC||^^^20070129121400||20070129123242|^00009038||^[email protected]|dhe_sp||||^dhe_sp
                OBR||123^AOB|42251^RIS|8706^8706 - FAR^MedTrak^8706^8706 - FAR^RIS|||||||||\F\\F\R0\F\\F\|||^[email protected]||35845|35742|69013||||CR|||^^^20070129121400||||^\F\\F\R0\F\\F\
                into a file, and I load direcly this file. In this case I receieve this output:
                Code:
                INFO  2007-02-12 15:36:24,365 [12cbf3d4-3b2c-4e95-afc4-d91e95ca2399_source_connector._fileEndpoint#75089797.receiver.1] inbound-transformation: PATH:<RRO_O02.PIDNTEORCRXONTERXRRXCNTE xmlns="urn:hl7-org:v2xml">
                followed by all the XML.
                But in the first case, the same output is:
                Code:
                INFO  2007-02-12 15:46:29,247 [01da28d0-a302-4a4c-bd65-3074f1f67bc1_source_connector._fileEndpoint#1262163069.receiver.1] inbound-transformation: PATH:
                As you can see, in this second case, the PATH is empty. So, the code is the same, but when the message has been loaded directly form a file, it works correctly. When the message is that obtained by :
                Code:
                var new_er7_string=messageObject.getRawData();
                new_er7_string = new_er7_string.replace (&#039;ORM^O01&#039;,&#039;ORR^O02&#039;);
                var index = new_er7_string.indexOf(&#039;PID&#039;);
                var part1 =  new_er7_string.substring(0,index-1); var length = new_er7_string.length();
                var part2 =  new_er7_string.substring(index,length);
                var msa = &#039;\rMSA|AA|1|\r&#039;;
                var finalString = part1+msa+part2;
                msg = serializer.toXML(finalString);
                it fails. Why? Where could be the problem? Is the message loaded by file serialized in a different way than inside my code?
                Thanks and regards,
                asulis

                Comment


                • #9
                  Re: Change message type inside the transformer with the msg object

                  I have missed a thing : in the first case, the output is:
                  Code:
                  INFO  2007-02-12 16:02:29,033 [01da28d0-a302-4a4c-bd65-3074f1f67bc1_source_connector._fileEndpoint#-1329970264.receiver.1] inbound-transformation: PATH:undefined
                  so there is some output info, but it is undefined. Ant this is why I cannot retrieve any info from Undefined!!!!!It is compliant with the previous error:
                  Code:
                  org.mozilla.javascript.EcmaError: TypeError: Cannot read property "RRO_O02.ORCRXONTERXRRXCNTE" from undefined (d913d667-98cb-4d0a-881c-f538dc21e82c#14)
                  seen last week.
                  Thanks for your help ans sorry for the missing
                  asulis

                  Comment


                  • #10
                    Re: Change message type inside the transformer with the msg object

                    please, read again my post. You need to change your line:

                    Code:
                    msg = new XML(serializer.toXML(finalString));

                    Comment


                    • #11
                      Re: Change message type inside the transformer with the msg object

                      Ouch!!!!I&#039;m very sorry, Alberto. The code into your post seemed to me like mine. I didn&#039;t notice your changed line. But the very good thing is that now all works fine!!!!Thank you very much!!!!!

                      asulis

                      Comment


                      • #12
                        Re: Change message type inside the transformer with the msg object

                        Glad everything is working! Thanks for helping out Alberto.
                        Chris Lang

                        Comment

                        Working...
                        X