Hi,
I am novice tcl programmer.
Need help with the tcl error below:
Please Wait ......Command Issued: hcitpstest -r run -x UTF-8 -f nl -c sms_ib_data -e "hcitpstestshowbydisp " /cloverleaf/cis19.1/integrator/site_cvis/TestMessages/NO_MR_ORDERS-OUT.12.2431267.nl "tpsMissingMRN"Command output:[0:TEST] Tcl error:msgId= message0proc= 'tpsMissingMRN'args= ''result= 'can't read "level": no such variable'errorInfo: 'can't read "level": no such variable while executing"lindex { segment segrep field fieldrep component subcomponent } $level" (procedure "::hl7::field_parse" line 93) invoked from within"::hl7::field_parse hl7 $mode $field" (procedure "::hl7::getset_2" line 6) invoked from within"::hl7::getset_2 GET hl7 $field """ (procedure "hl7::get_field" line 3) invoked from within"hl7::get_field hl7 MSH.5.0" (procedure "tpsMissingMRN" line 20) invoked from within"tpsMissingMRN {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}"'I have attached 2 files:1. Missing_MRN_Email.tbl
2. tpsMissingMRN.tcl
******************************************
tcl code:proc tpsMissingMRN { args } {
global HciConnName
keylget args MODE mode
set ctx "" ; keylget args CONTEXT ctx
set module "tpsMissingMRN/$HciConnName/$ctx"
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}
switch -exact -- $mode {
start {}
run {
keylget args MSGID mh
package require hl7
set hl7 [hl7::parse_msg [msgget $mh]]
set MSH_3 [hl7::get_field hl7 MSH.3]
set MSH_5 [hl7::get_field hl7 MSH.5.0]
set MSH_10 [hl7::get_field hl7 MSH.10]
set PID_3_0 [hl7::get_field hl7 PID.3]
set PID_3_5 [hl7::get_field hl7 PID.3.5]
#echo "MSH_3: $MSH_3"
#echo "MSH_5: $MSH_5"
#echo "PID_3_0: $PID_3_0"
#echo "PID_3.5: $PID_3_5"
# Handle the condition when PID.3.0 is empty and PID.3.5 is not equal to MR
#if {$PID_3_0 eq "" && $PID_3_5 ne "MR"} {
# set errormsg "Missing PID-3 with PID-3.5 not equal to MR."
# } else {
# echo "PID segment not found."
# }
# Initialize counter outside the loop
set pid_counter 0
#Increment counter inside the loop
for { set i 1 } { $i <= [hl7::count hl7 PID.3] } { incr i } {
incr pid_counter
#Grab the PID-3 iteration where PID-3.5= "MR" and Process PID.3 data using $pid_counter
if { [hl7::get_field hl7 PID.3($i).5] eq "MR" } {
set mrn [hl7::get_field hl7 PID.3($i).1]
}
}
#SOURCECONN is the name of the thread that initially receives the message (CARD_Orders_from_Meditech)
set sourceconn [msgmetaget $mh SOURCECONN]
set errormsg ""
if {$sourceconn eq ""} {
set sourceconn TestTool
}
#Create the e-mail
set mailfrom [tbllookup Missing_MRN_Email "MailFrom"]
set mailhost [tbllookup Missing_MRN_Email "MailHost"]
set PORT [tbllookup Missing_MRN_Email "MailPort"]
set mailsubjectprefix [tbllookup Missing_MRN_Email "MailSubjectPrefix"]
set subject "$mailsubjectprefix Meditech sent an HL7 Order Message without the MRM number to Cloverleaf"
set errorMsg "This is the message ID: $MSH_10 \n\n This is the reason why:\n\n$errormsg \n Patient X Number: (PID.3) $PID_3_1"
#echo "This is errorMsg: |$errorMsg|"
set emailbody $errorMsg
if {$errormsg eq ""} {
echo "Killing message with Message Control ID: |$MSH_10| because of $errorMsg"
SendEmailAsAlert $mailto "" $emailbody $subject $mailfrom "" "" $mailhost $PORT "0" "0"
###echo "email should have been send now"
#Continue Message
lappend dispList "KILL $mh"
} else {
#Continue Message
lappend dispList "CONTINUE $mh"
}
}
time {}
shutdown {}
default {
error "Unknown mode '$mode' in $module"
}
return $dispList
}
}
*********************************************************
Any help would be appreciated.
Thanks.