{
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
# Here we retrieve the data from our original message
set msg [msgget $mh]
# Now we need to determine our field and subcomponent seperatoprs
set field_sep [csubstr $msg 3 1] ;# HL7 field separator
set sub_sep [csubstr $msg 4 1] ;# HL7 subfield separator
# Here we spilt the original message into a list of the segments contained within
set segmentList [split $msg r]
# Now we iterate over each segment in our list.
foreach segment $segmentList {
if {[cequal [crange $segment 0 2] PID]} {
set fieldList [split $segment $field_sep]
set pid_3 [lindex $fieldList 3]
# split PID-3 on the sub-seperator
set pid_3_list [split $pid_3 $sub_sep]
# get the first element in PID-3
set pid_3_4 [lindex $pid_3_list 3]
if {[cequal [crange $segment 0 2] PV1]} {
set fieldList1 [split $segment $field_sep]
set pv1_18 [lindex $fieldList1 18]
# split PV1-18 on the sub-seperator
set pv1_18_list [split $pv1_18 $sub_sep]
# get the first element in PV1-18
set pv1_18_1 [lindex $pv1_18_list 0]
if {[cequal $pv1_18_1 “PAO”] && [cequal $pid_3_4 “W”]}{
lappend dispList “KILL $mh”
return $dispList
} else {
lappend dispList “CONTINUE $mh”
return $dispList
}
}
}
}
}