Steven G

Forum Replies Created

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • in reply to: Strip a segment from a message based on a value in segment #118512
    Steven G
    Participant

      Here is what I used to kill multiple OBX segments I do not want based on OBX3 value. I did not bother to correct the segment counts in OBX2:

      run {
      #Set typical variables
      keylget args MSGID mh
      set msg [msgget $mh]
      set fieldSep [string index $msg 3]
      set subFieldSep [string index $msg 4]
      set segmentList [split $msg \r]
      set msgTRIG [getField $msg MSH 8 1]

      #Remove any OBX segment with a value of “Text Report File Name”
      set segCnt [llength $segmentList]
      for {set i 0} {$i<$segCnt} {incr i} {
      set seg [lindex $segmentList $i]
      set segFieldLst [split $seg $fieldSep]
      set segType [lindex $segFieldLst 0]
      set obxType [lindex $segFieldLst 2]
      #Remove any OBX that is not a Numeric Value
      if {[string equal $segType “OBX”] && [string equal $obxType “Text Report File Name”] } {
      set segmentList [lreplace $segmentList $i $i]
      set i [expr $i -1]
      }

      }
      #Apply all of the changes to the MH.
      set msg [join $segmentList \r]

      msgset $mh $msg
      lappend dispList “CONTINUE $mh”
      }

    Viewing 1 replies (of 1 total)