Announcement

Collapse
No announcement yet.

Convert an OBX Segment to NTE Segment in Preprocessor Script

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

  • Convert an OBX Segment to NTE Segment in Preprocessor Script

    Hi ,

    I'm attempting to convert one OBX segment that has a value in the OBX.3.1 field to be NTE Segment . I'm attempting to do this in the Preprocessor Script. I'm very close to getting this to work just need a second pair of eyes to see the mistake in my code. Below is the logic I have in the Preprocesor script. I cannot seem to get the proper logic for the for loop.

    "for each (msg in msg.OBX) is causing me to get an error that says "Cannot Read property OBX.3.1 from undefined.

    var mymsg = new XML(SerializerFactory.getHL7Serializer().toXML(mes sage));
    //var number_of_OBX = mymsg.OBX.length();
    var obx;
    var msg;

    // for each (msg in msg.OBX) {
    logger.info('The value of OBX-3.1 is ' );
    logger.info(mymsg['OBX'][0]['OBX.3']['OBX.3.1'].toString());


    if (mymsg['OBX.3']['OBX.3.1'].toString() == 'ILDATE') {
    message = message.replace(/\rOBX/g, "\rNTE")
    }
    // }

    My logger info show the first OBX.3.1 valued to "AMIK" which is correct in the test HL7 Lab message. The last OBX of 6 OBX segments has the value of "ILDATE" this will vary by each Lab Messages sent.

    Attached is my channel.

    Last edited by pacmano; 05-02-2022, 10:45 AM.

  • #2
    Below is the example Lab ORU message that I'm trying to change the last two OBX segments to be NTE Segments.

    MSH|^~\&|IL|A|LA01|A|202204251417||ORU^R01|2211200 00005|P|2.2 PID|||2000856||BEAKER^ARUPONE||19910209|F||||||||| |2300018323 PV1||OS|MCOT||||O4095 ORC|RE|0000062219|H10001420 OBR|1|0000062219|H10001420|AMIKNR^Amikacin|||20220 4140711||||L|||20220425073400||O4095^UTMC,PATHOLOG Y||||||20220425141735||L|F||^^^202204140711^^ROU OBX|1|NM|AMIK^Amikacin|1|20.0|ug/mL|0.0-40.0||||F
    NTE|1||
    NTE|2||Reference Ranges
    NTE|3||Peak: 20.0 - 25.0
    NTE|4||Trough: 0.0 - 8.0
    OBX|2|NM|AMIKO^Dose amount|1|10||||||F
    OBX|3|NM|AMIKD^Date of last dose|1|04252022||||||F
    OBX|4|NM|AMIKT^Time of last dose|1|1200||||||F
    OBX|5|ST|ILDATE^IL||Test Performed by Mercy Laboratories 2222 Cherry St. Toledo, OH 43608 (419) 251.8383 - Released 04/25/2022 14:17||||||F
    OBX|6|ST|ILDATE^IL|| ||||||F

    Comment


    • #3
      Preprocessor is not the right place to do it. you can try a transformer for that.
      HL7v2.7 Certified Control Specialist!

      Comment


      • #4
        I've tried the logic in the transformer step . It does not work. I was looking for feedback to the code that I have posted. Not advice whether it's wrong or right. All solutions are not black and white.
        Hopefully someone else can offer some feedback to a solution to the code that I shared and maybe that might benefit others in the future.

        Thanks

        Comment


        • #5
          Well, looks like you will need to report a breach of PII and PHI since your exported channel has real data. Look at the inbound message template.
          Diridium Technologies, Inc.
          https://diridium.com

          Comment


          • #6
            I removed your attachment. I have moderator permissions here.
            Diridium Technologies, Inc.
            https://diridium.com

            Comment


            • #7
              Pacmano,

              This is a test HL7 example , there is no issue with PHI


              Thanks

              Comment


              • #8
                You sure? So we are taking about the same thing - this is the source transformer, inbound message template on the channel you exported and attached to this thread. That PID resolves to a real person in Swanton, OH including their home address and phone number. The doctor information in PV1 as well. Those 2 things are not PII of course, however the SSN and diags in the rest of the this message would be.

                Great if not.
                Diridium Technologies, Inc.
                https://diridium.com

                Comment


                • #9
                  On your original question though - while you could use a regex to change OBX to NTE that does not fix the segment index (sequence) numbering. I don't think your preprocessor code did that either. I'd expect you would "rebuild" the message correcting that prior to sending downstream. That could certainly be done in a preprocessor, but like already mentioned here, I'd do that in a transformer. As for your code posted, I would iterate backwards in your loop stopping after the second to last row of the string, not the serialized message. Also your .replace is global in your sample code posted.
                  Last edited by pacmano; 05-03-2022, 06:56 AM.
                  Diridium Technologies, Inc.
                  https://diridium.com

                  Comment


                  • #10
                    regex example, see https://regex101.com/r/LOtGKG/1 for walk through.

                    PHP Code:
                    return message.replace(/([\s\S]*)OBX(.*\n)OBX(.*)/g,"$1NTE$2NTE$3"
                    Last edited by pacmano; 05-03-2022, 01:21 PM.
                    Diridium Technologies, Inc.
                    https://diridium.com

                    Comment


                    • #11
                      Originally posted by pacmano View Post
                      regex example, see https://regex101.com/r/LOtGKG/1 for walk through.

                      PHP Code:
                      return message.replace(/([\s\S]*)OBX(.*\n)OBX(.*)/g,"$1NTE$2NTE$3"
                      I modified yours a bit https://regex101.com/r/PbuBhF/1

                      PHP Code:
                      return message.replace(/\rOBX\|(?=(?:[^\|]*\|){2}ILDATE[\|^])/g'\rNTE|'
                      I think this accomplishes what he was originally after. "for each OBX segment, if OBX-3.1 is "ILDATE" then rename segment to NTE."

                      Comment

                      Working...
                      X