Announcement

Collapse
No announcement yet.

move PID5 to PID6

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

  • move PID5 to PID6

    Dear all
    my request is simple, but I can't find the right way by my own, so I need your help.
    I would like to split the PID5 segment and move a part to the PID6 segment
    Before
    PID|1||20002181^^^OM1242000^PI||TEST^Hl7^^^ME^^L~NAISSANCE^Hl7^^^ME^^M||19501212|

    After
    PID|1||20002181^^^OM1242000^PI||TEST^Hl7^^^ME^^L|NAISSANCE^Hl7^^^ME^^M|19501212

    the "~" is not recognize by mirth, so indexOf is not working, nor split.
    Thanks

  • #2
    msg['PID']['PID.6'] = msg['PID']['PID.5'][1]['PID.5.1'].toString();
    msg['PID']['PID.5'] = msg['PID']['PID.5'][0]['PID.5.1'].toString();

    Comment


    • #3
      looks easy, but the results is
      PID|1||20002181^^^OM1242000^PI||TEST|NAISSANCE|19501212|

      Comment


      • #4
        msg['PID']['PID.6'] = msg['PID']['PID.5'][1];
        msg['PID']['PID.5'] = msg['PID']['PID.5'][0];
        HL7v2.7 Certified Control Specialist!

        Comment


        • #5
          It's wierd
          If I do :
          msg['PID']['PID.6'] = msg['PID']['PID.5'][1];
          msg['PID']['PID.5'] = msg['PID']['PID.5'][0];
          there is nothing in PID6
          PID|1||20002181^^^OM1242000^PI||TEST^Hl7^^^ME^^L|| 19501212|

          this way :
          msg['PID']['PID.5'] = msg['PID']['PID.5'][0];
          msg['PID']['PID.6'] = msg['PID']['PID.5'][1];

          PID6 is "undefined"
          PID|1||20002181^^^OM1242000^PI||TEST^Hl7^^^ME^^L|u ndefined|19501212|

          Comment


          • #6
            If it's not clear from the answers given so far, the ~ is recognized, but it is the field repetition character, so your message has two different values for PID.5.

            Originally posted by riven974 View Post
            It's wierd
            If I do :
            msg['PID']['PID.6'] = msg['PID']['PID.5'][1];
            msg['PID']['PID.5'] = msg['PID']['PID.5'][0];
            there is nothing in PID6
            PID|1||20002181^^^OM1242000^PI||TEST^Hl7^^^ME^^L|| 19501212|
            The first line actually replaces PID.6 with another copy of the second PID.5, leaving you with 3 PID.5 repetitions and no PID.6 at all. The second line replaces all PID.5 repetitions collectively with the first occurrence, leaving you with the result you are seeing.

            Originally posted by riven974 View Post
            this way :
            msg['PID']['PID.5'] = msg['PID']['PID.5'][0];
            msg['PID']['PID.6'] = msg['PID']['PID.5'][1];

            PID6 is "undefined"
            PID|1||20002181^^^OM1242000^PI||TEST^Hl7^^^ME^^L|u ndefined|19501212|
            The first line effectively removes the second occurrence (see above explaination) so that when the second line runs there is no msg['PID']['PID.5'][1].

            The easiest way to do this is to use this code template. https://github.com/nextgenhealthcare...%20HL7%20Field

            Code:
            msg['PID']['PID.6'] = renameField(msg['PID']['PID.5'][1], 'PID.6');
            msg['PID']['PID.5'] = msg['PID']['PID.5'][0];

            Comment


            • #7
              I would do that in the preprocessor with a regex replace like:

              Code:
              return message.replace(/(^PID(?:\|[^\|]*){5})(~)([^\|]*)\|/m, "$1|$3");

              Comment


              • #8
                Thank you guys !
                Finally the regex replacement in preprocessor has been successfull!

                PS: if you can, stay home for your safety !

                Comment


                • #9
                  Be careful with using regexes in preprocessor though..
                  HL7v2.7 Certified Control Specialist!

                  Comment


                  • #10
                    OK I will

                    Comment


                    • #11
                      I would definitely not do this is a preprocessor script.
                      Best,

                      Kirby

                      Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

                      Appliance Version 3.11.4
                      Mirth Connect Version 3.8.0
                      Java Version 1.6.0_45-b06
                      Java (64 bit) Version 1.6.0_45-b06
                      Java 7 (64 bit) Version 1.7.0_151-b15
                      Java 8 (64 bit) Version 1.8.0_181-b13
                      PostgreSQL Version 9.6.8

                      Comment

                      Working...
                      X