Originally posted by Rick Pritchett
Im passing a list of arguments and trying to check if my variable is in the list if it is i set my variable. for some reason i am getting the opposite of what is expected and ideas? here is the code.
proc filter_pttype_ptloc_ptserv_midas_4 { args } {
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
switch -exact -- $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
# 'run' mode always has a MSGID; fetch and process it
# keylget args MSGID mh
#get the arguments
keylget args ARGS uargs
keylget args ARGS.types types
#split the argument list
set argList [split $types " "]
set mh [keylget args MSGID]
set dispList
set msg [msgget $mh] set ptclassflag "N" ;# Declare and set vaiables set pttypeflag "N" set locflag "N" set killflag "N" set fldSep [string index $msg 3] ;# Field seperator. set subSep [string index $msg 4] ;# Sub-Field seperator. set segList [split $msg r] ;# Create segment list using carriage return. set PV1 [lindex [lregexp $segList {^PV1}] 0] ;# Find PV-1 segment. set PV1flds [split $PV1 $fldSep] ;# Split PV-1 segment up into fields. set pttype [lindex $PV1flds 18] ;# Set variables to desired fileds. set ptlocationflds [lindex $PV1flds 3] set ptlocationsub [split $ptlocationflds $subSep] ;# Split field 3 into subfileds. set ptlocation [lindex $ptlocationsub 0] ;# set variable to desired sub-filed. #Check to see if patient class inpatient, newborn, emergency, SDOP foreach value $argList { if {[cequal $pttype $value]} { set killflag "N" } else { set killflag "Y" } ;#end if } echo $pttype echo $killflag echo $ptlocation #Check to see if patient location is in midas_locations.tbl #go through the midas_locations table and see if it finds a match set locflag [tbllookup -side input midas_locations.tbl $ptlocation] # Check to see if Pt Locations is "N" and Pt type is "CL". if {[string equal $locflag "N"] && [string equal $pttype "CL"]} { set killflag "Y" } else { set killflag "N" } ;# echo $killflag # continue or kill the message echo "Kill: $killflag" echo "loc_flag $locflag" if { $killflag == "Y" } { set dispList
return $dispList } else { return $dispList } ;#end if } time { # Timer-based processing # N.B.: there may or may not be a MSGID key in args } shutdown { # Doing some clean-up work } } return $dispList}