Here is a script we use for our immunization interface to evaluate ACKs/NAKs.
We run two procs in inbound replies.
vx_kill_AE_nak and tps_checkhl7_ack_argv
We have checked await replies and set the timeout to 60. (See attachment)
The first proc below checks to see if it has received a valid ack or not.
If it is a valid NAK, we kill the reply which makes the thread think it hasn’t received a response and retries the same message every 60 seconds until it gets an ACK.
Occasionally some NAKs aren’t so bad, so we change them to ACKs and let them process, otherwise if it is a real NAK like “System unavailable” reason, we alert after receiving 5 consecutive NAKs. (The alert will happen every 5 minutes until we receive the ACK or Interface Analyst intervention is taken.
######################################################################
# Name: vx_kill_AE_nak
# Purpose:
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (”start”, “run” or “time”)
# MSGID message handle
# ARGS user-supplied arguments:
#
#
# Returns: tps disposition list:
#
#
proc vx_kill_AE_nak { args } {
keylget args MODE mode
global HciSite HciConnName AEcnt DuplicateCount ob_save
set procname [lindex [info level [info level]] 0]
set module “$HciSite/$HciConnName/$procname: ”
set dispList {}
switch -exact — $mode {
start {
set AEcnt 0
set DuplicateCount 0
}
run {
keylget args MSGID mh
set vmenv TEST
if {[string equal [string range $HciSite 0 2] vmp]} {
set vmenv PROD
}
set msg [msgget $mh]
set outmsg [msgget $ob_save]
set outmsgid [vm_getHL7 $outmsg MSH 0 9]
set inmsgid [vm_getHL7 $msg MSH 0 9]
set response [vm_getHL7 $msg MSA 0 1]
set reason [vm_getHL7 $msg MSA 0 3]
if {![string equal [string first “E||||next of kin name first is invalid” $msg] -1]} {
set response AA
set msg [vm_setHL7 $msg $response MSA 0 1]
set notifylist “interfaceteam@myhosp.org”
exec echo $msgnn$outmsg | mail -s “$module $vmenv – $HciConnName NAK response overridden and skipped” $notifylist
msgset $mh $msg
}
if {[string equal $response AA]} {
set AEcnt 0
} else {
incr AEcnt
if {[expr $AEcnt % 5] < 1} {
set notifylist "interfaceteam@myhosp"
exec echo $msg | mail -s "$module $vmenv – VX $HciConnName NAK response(s) received $AEcnt" $notifylist
return "{ERROR $mh}"
}
echo $module – VX $HciConnName NAK received – NAK Message killedn$msgn
return "{KILL $mh}"
}
lappend dispList "CONTINUE $mh"
}
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
}