I typed this out quickly, so not sure if the syntax is correct. Basically, get the incoming message. Go through each segment. If the segment is one that you want, append that segment to a variable. If the segment is one that you don’t want, don’t append that segment (skipping it). Then set your outgoing message to that variable.
keylget args MSGID mh ;# Get message handle
set msg [msgget $mh] ;# Get message
set segments [split $msg r] ;# Get segments
set OutBoundMsg “”
foreach seg $segments {
if [cequal $seg “”] { continue } ;# Just in case
set segtype [csubstr $seg 0 3] ;# segment name
if {[cequal $segtype MSH]} {
#Use this segment
append OutBoundMsg $seg
}
if {[cequal $segtype PID]} {
#Use this segment
append OutBoundMsg $seg
}
if {[cequal $segtype NTE]} {
#do not send this segment, so do not append to OutBoundMsg
}
} ;#end if
}
msgset $mh $OutBoundMsg
return “{CONTINUE $mh}”