#########################################################################
# Name: A18_notification
# Purpose: This TPS is used as an outbound TPS on the sdk_in (or epic_in)
# process. It is intended to send a formatted message to
# to a printer in lab when ever a merge is done.
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (”start”, “run” or “time”)
# MSGID message handle
# ARGS user-supplied arguments:
# EMAILADDR – email address
#
# Returns: tps disposition list:
#
#
# Modification History:
# 03/20/00 CEK – cloned from tao_AHCCCS
# 08/07/03 LRM – added Lab Blood Bank printer
##########################################################################
proc A18_notification { 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
set DatList [datlist]
keylget args MSGID mh
keylget args ARGS uargs
set GRMin [grmcreate -msg $mh hl7 2.2 SDK ADT_A36]
# Grab merge info
set AdmitDrLast [datget [grmfetch $GRMin 0(0).PV1(0).00147(0).[1]] VALUE]
set AdmitDrFirst [datget [grmfetch $GRMin 0(0).PV1(0).00147(0).[2]] VALUE]
set AdmitDrMI [datget [grmfetch $GRMin 0(0).PV1(0).00147(0).[3]] VALUE]
set AdmitDrName “$AdmitDrLast, $AdmitDrFirst $AdmitDrMI”
set AdmitDrID [datget [grmfetch $GRMin 0(0).PV1(0).00147(0).[0]] VALUE]
set AdmitDrDeg [datget [grmfetch $GRMin 0(0).PV1(0).00147(0).[6]] VALUE]
set AttendDrLast [datget [grmfetch $GRMin 0(0).PV1(0).00137(0).[1]] VALUE]
set AttendDrFirst [datget [grmfetch $GRMin 0(0).PV1(0).00137(0).[2]] VALUE]
set AttendDrMI [datget [grmfetch $GRMin 0(0).PV1(0).00137(0).[3]] VALUE]
set AttendDrDeg [datget [grmfetch $GRMin 0(0).PV1(0).00137(0).[6]] VALUE]
set AdmitMonth [string trimleft [string range [datget [grmfetch $GRMin 0(0).PV1(0).00174(0).[0]] VALUE] 4 5] 0]
set AdmitYear [string trim [string range [datget [grmfetch $GRMin 0(0).PV1(0).00174(0).[0]] VALUE] 0 3]]
set AdmitDay [string trimleft [string range [datget [grmfetch $GRMin 0(0).PV1(0).00174(0).[0]] VALUE] 6 7] 0]
set AdmitHour [string range [datget [grmfetch $GRMin 0(0).PV1(0).00174(0).[0]] VALUE] 8 9]
set AdmitMinute [string range [datget [grmfetch $GRMin 0(0).PV1(0).00174(0).[0]] VALUE] 10 11]
set AdmitSecond [string range [datget [grmfetch $GRMin 0(0).PV1(0).00174(0).[0]] VALUE] 12 13]
set AdmitDate “$AdmitMonth/$AdmitDay/$AdmitYear $AdmitHour:$AdmitMinute:$AdmitSecond”
set PCPLast [datget [grmfetch $GRMin 0(0).ZP1(0).90001(0).[1]] VALUE]
set PCPFirst [datget [grmfetch $GRMin 0(0).ZP1(0).90001(0).[2]] VALUE]
set PCPMI [datget [grmfetch $GRMin 0(0).ZP1(0).90001(0).[3]] VALUE]
set PCPDeg [datget [grmfetch $GRMin 0(0).ZP1(0).90001(0).[6]] VALUE]
set PCPID [datget [grmfetch $GRMin 0(0).ZP1(0).90001(0).[0]] VALUE]
# PATIENT INFORMATION
set PatLast [datget [grmfetch $GRMin 0(0).PID(0).00108(0).[0]] VALUE]
set PatFirst [datget [grmfetch $GRMin 0(0).PID(0).00108(0).[1]] VALUE]
set PatMiddle [datget [grmfetch $GRMin 0(0).PID(0).00108(0).[2]] VALUE]
set MRN [format [datget [grmfetch $GRMin 0(0).PID(0).00106(0).[0]] VALUE] %09]
# calculate the patient’s age in years
set current_year [fmtclock [getclock] %Y]
set DOByr [string range [datget [grmfetch $GRMin 0(0).PID(0).00110(0).[0]] VALUE] 0 3]
set DOBmm [string range [datget [grmfetch $GRMin 0(0).PID(0).00110(0).[0]] VALUE] 4 5]
set DOBdd [string range [datget [grmfetch $GRMin 0(0).PID(0).00110(0).[0]] VALUE] 6 7]
set DOB “$DOBmm/$DOBdd/$DOByr”
set Age [expr $current_year – $DOByr]
set Sex [datget [grmfetch $GRMin 0(0).PID(0).00111(0).[0]] VALUE]
set Acct_Num [datget [grmfetch $GRMin 0(0).PID(0).00121(0).[0]] VALUE]
set Unit [format [datget [grmfetch $GRMin 0(0).PV1(0).00133(0).[0]] VALUE] %04s]
set Room [format [datget [grmfetch $GRMin 0(0).PV1(0).00133(0).[1]] VALUE] %04s]
set Bed [format [datget [grmfetch $GRMin 0(0).PV1(0).00133(0).[2]] VALUE] %02s]
set Location $Room-$Bed
set Adm_Diag1 [datget [grmfetch $GRMin 0(0).DG1(0).00378(0).[0]] VALUE]
set PriorPtID [datget [grmfetch $GRMin 0(0).MRG(0).00211(0).[0]] VALUE]
#format Date of Message
set DOMyr [string range [datget [grmfetch $GRMin 0(0).MSH(0).00007(0).[0]] VALUE] 0 3]
set DOMmm [string range [datget [grmfetch $GRMin 0(0).MSH(0).00007(0).[0]] VALUE] 4 5]
set DOMdd [string range [datget [grmfetch $GRMin 0(0).MSH(0).00007(0).[0]] VALUE] 6 7]
set DOMtm [string range [datget [grmfetch $GRMin 0(0).MSH(0).00007(0).[0]] VALUE] 8 11]
set MessageDate “$DOMmm/$DOMdd/$DOMyr $DOMtm”
set Pmessage ” ***ATTENTION BLOOD BANK*** n
THE FOLLOWING PATIENT’S ACCOUNT HAS BEEN TRANSFERRED FROM ONE n
MEDICAL RECORD TO ANOTHER. SDK HAS COMPLETED A MERGE FOR THIS n
PATIENT. PLEASE REVIEW THE ACCOUNT IN QUESTION FOR A MERGE IN MYSIS. n
n
Date: $MessageDate n
*========================================================================*
n
MERGE INFORMATION: n
Name : $PatLast, $PatFirst $PatMiddle. n
D.O.B : $DOB n
Age/Gender : $Age $Sex n
Account Num : $Acct_Num n
NEW MRN : $MRN n
OLD MRN : $PriorPtID n
n
*========================================================================* ”
set lp [open “|/usr/bin/lp -dlabis” w]
puts $lp $Pmessage
flush $lp
close $lp
set lp [open “|/usr/bin/lp -dLabBB” w]
puts $lp $Pmessage
flush $lp
close $lp
lappend dispList “CONTINUE $mh”
grmdestroy $GRMin
hcidatlistreset $DatList
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
default {
error “Unknown mode ‘$mode’ in tao_CIGNA”
}
}
return $dispList
}