Originally posted by Amdy Diene
####################################################################### Name: tpsKillA31WithPV1Empty## Purpose: Kills all A31's going to CareManager that have no information# in the PV1 segment..## UPoC type: tps# Args: tps keyedlist containing the following keys:# MODE run mode ("start", "run" or "time")# MSGID message handle# # Returns: tps disposition list:# # KILL when ADT = A31 and patient has no PV1 information # CONTINUE all others#proc tpsKillA31WithPV1Empty { args } { keylget args MODE mode ;# Fetch mode global HciConnName set procName "tpsKillA31WithPV1Empty" set dispList {} ;# Nothing to return set foundA31 {} set assignedPatientLocation {} 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 set msgtext [msgget $mh] set fieldsep [crange $msgtext 3 3] set subfieldsep [crange $msgtext 4 4] set segments [split $msgtext "r"] foreach seg $segments { if {[cequal [crange $seg 0 2] "MSH"]} { # this segment (seg) is MSH # get the field data set data [split $seg $fieldsep] set field [lindex $data 8] set data [split $field $subfieldsep] set triggerType [lindex $data 0] set triggerEvent [lindex $data 1] # Check for an ADT and A31 trigger Event. if {[cequal $triggerType "ADT"] && [cequal $triggerEvent "A31"]} then { set foundA31 "YES"#echo foundA31: $foundA31 } } elseif {[cequal [crange $seg 0 2] "PID"]} { # this segment (seg) is PID set data [split $seg $fieldsep] set patientAccount [lindex $data 18] set patientName [lindex $data 5] } elseif {[cequal [crange $seg 0 2] "PV1"]} { # this segment (seg) is PV1 set data [split $seg $fieldsep] # set patientType [lindex $data 2] set assignedPatientLocation [lindex $data 2] # Check for a Assigned Patient Location. if {[cequal $assignedPatientLocation ""]} then { set assignedPatientLocation "NO" } } } # # If the ADT trigger event is an A31 and the assigned patient location is not loaded then # kill the message, otherwise continue it. # if {[cequal $foundA31 "YES"] && [cequal $assignedPatientLocation "NO"]} {# puts $msgtext puts "$HciConnName\$procName - KILLING A31 for patient: $patientName - $patientAccount" echo lappend dispList "KILL $mh"# } else {# puts $msgtext# puts "$HciConnName\$procName - CONTINUING ADT for Patient: $patientName - $patientAccount"# echo lappend dispList "CONTINUE $mh" } return $dispList } time { # Timer-based processing # N.B.: there may or may not be a MSGID key in args } shutdown { # Doing some clean-up work } default { error "Unknown mode '$mode' in tpsKillA31WithPV1Empty" } } return $dispList}
{ EXPRESSION { (%PV1.3.2% ne '' && %PV1.3.3% ne '') || [lsearch -exact { A01 A02 A12 A13 } %MSH.9.2%] < 0 } }