Convert segments sent

Clovertech Forums Read Only Archives Cloverleaf Tcl Library Convert segments sent

  • Creator
    Topic
  • #55689
    donald faivre
    Participant

      Hi. We have a system that sends ZBX and ZBH segments. I have a proc that does a regsuub -all for ZBH and ZBX and makes them OBX. It does change the segments but it is also changing any string matching ZBH and ZBX in any field (it found ZBX in a encoded PDF string in OBX 5.4 and changed it to OBX causing the PDF to be malformed). Is there a way to only call out the segment and change it?

    Viewing 3 reply threads
    • Author
      Replies
      • #86174
        Jerry Tilsley
        Participant

          Instead of just searching for ZBH, try breaking the message into segments and searching for ^ZBH|.  This will force it to only find a ZBH at the beginning of the line followed by a pipe.  This should narrow it what is replaces.  Just be sure not to replace the pipe though.  

          Jerry

        • #86175
          donald faivre
          Participant

            Tried a few things and it isn’t working not sure what I am missing.

            run {

                       # ‘run’ mode always has a MSGID; fetch and process it

                       

                       keylget args MSGID mh

                               set msg [msgget $mh]

                       set sep [csubstr $msg 3 1]      ;# HL7 field separator            

                       set segments [split $msg r]

                       

                         foreach segment $segments {        

            # echo “Segment: $segment”

                       if [cequal [crange $segment 0 2] ^ZBH|] {    

                     regsub -all ^ZBH| $segment ^OBX| segment

                    }

                    echo “Segment: $segment”

                       if [cequal [crange $segment 0 2] ^ZBX|]  {

                       regsub -all ^ZBX| $segment ^OBX| segment

                           }

                       set msg [join $segments r]

                       }

               msgset $mh $msg

                       lappend dispList “CONTINUE $mh”

          • #86176
            Jerry Tilsley
            Participant

              Try something like this:

              Code:


                         set newMsg {}          

                         foreach segment $segments {        
                            regsub -all ^ZBH| $segment OBX newSegment
                            lappend newMsg $newSegment

                            set msg [join $newMsg r]
                         }

            • #86177
              donald faivre
              Participant

                I appreciate you looking at this with me Jerry.

                Tried the new code it replaced everything with OBX.

            Viewing 3 reply threads
            • The forum ‘Tcl Library’ is closed to new topics and replies.