Howdy all,
So I’ve come across a rather odd issue. We have a script that is running some data and placing it in a field then passing that field on to the translate. However, when rejoining the string, it breaks the way the lists are set up and I cannot figure out /why/.
Here is the code. there’s a lot commented out as we’re moving pieces back into the translate, but this script breaks the message before it gets back.
proc tps_epic2athg_ORUfilter { args } {
global HciConnName
keylget args MODE mode
set ctx “” ; keylget args CONTEXT ctx
set module “tps_res2athg_ORUfilter/$HciConnName/$ctx”
set uargs {} ; keylget args ARGS uargs
set debug 0
catch {keylget uargs DEBUG debug}
set dispList {}
set disp “KILL”
switch -exact — $mode {
start {}
run {
keylget args MSGID mh
set msg [msgget $mh]
set fieldSep [string index $msg 3]
set subSep [string index $msg 4]
set repSep [string index $msg 5]
set segList [split $msg \r]
set MSH [lsearch -all -inline -regexp $segList “^MSH”]
# echo $MSH
set MSHSplit [split $MSH $fieldSep]
echo “MSHSPlit: $MSHSplit”
set PID [lsearch -all -inline -regexp $segList “^PID”]
set PIDSplit [split $PID $fieldSep]
set PV1 [lsearch -all -inline -regexp $segList “^PV1”]
set obrList [lsearch -all -inline -regexp $segList “^OBR”]
set obrCount 0
# set obr16_ID “”
foreach obr $obrList {
set obr25 [lindex [split $obr $fieldSep] 25]
# if { $obrCount == 0} {
# set obr16_ID [lindex [split [lindex [split $obr $fieldSep] 16] $subSep] 0]
# set obrCount 1
# }
if {$obr25 == “F”} {
set disp “CONTINUE”
# echo $disp
break
}
}
# set MSHSplit [lreplace $MSHSplit 5 5 “”]
# set PIDSplit [lreplace $PIDSplit 3 3 “”]
#build data to send
set thread [msgmetaget $mh DESTCONN]
set dbName “db_eMFCC_PatList”
set env [lindex [split $::env(HCISITE) _] 0]
set mode “select”
set fac [lindex $MSHSplit 3]
set key [lindex [split $PV1 $fieldSep] 19]
# DB call and return.
set ret [sub_dataBase “thread=$thread” “dbName=$dbName” “env=$env” “mode=$mode” “fac=$fac” “key=$key”]
echo “PidSplitb4: $PIDSplit”
set retStatus [lindex [split $ret |] 0]
set retData [lindex [split $ret |] 2]
if { $retStatus != “Okay” } {
set disp “KILL”
} else {
set PIDSplit [lreplace $PIDSplit 3 3 $retData]
# set retDatLen [string length $retData]
# echo $retDatLen
# if {$retDatLen > 0} {
# set MSHSplit [lreplace $MSHSplit 5 5 “1215”]
# } else {
# set MSH6 [tbllookup epic2athG-context.tbl $obr16_ID]
# echo $MSH6
# echo $obr16_ID
# if {$MSH6 != “UNKNOWN”} {
# set MSHSplit [lreplace $MSHSplit 5 5 $MSH6]
# } else {
# set disp “KILL”
# }
# }
}
echo “Before $segList”
set segList [lreplace $segList 1 1 [join $PIDSplit $fieldSep]]
echo “After: $segList”
set msg [join $segList \r]
# echo $msg
msgset $mh $msg
# echo $mh
lappend dispList “$disp $mh”
# echo $dispList
}
time {}
shutdown {}
default {
error “Unknown mode ‘$mode’ in $module”
}
}
return $dispList
}
Ironically, I’ve done this in another script and it works fine. I cannot see why. Here is the output with a lot of segments and whatnot removed, but the problem is still there (look at the after line):
Please Wait ……
Command Issued: hcitpstest -r run -x ASCII -f nl -c sms_ib_data -e “hcitpstestshowbydisp ” /opt/cloverleaf/cis20.1/integrator/sd_lab1/indata/jmr “tps_epic2athg_ORUfilter”
Command output:
Command Arguments: thread= dbName=db_eMFCC_PatList env=sd mode=select fac=MRH key= {Error: Thread Name Required.
}
PidSplitb4: \{PID 1 {} 12345678^^^EPI^MR {} LAST^FIRST^MIDDLE {} \}
RetData:
Before {MSH|^~\&|Epic|MRH|||} {PID|1||12345678^^^EPI^MR||LAST^FIRST^MIDDLE|} {NK1|1|LAST^FIRST} {PV1|1|Emergency}
After: {MSH|^~\&|Epic|MRH|||} {{PID|1||12345678^^^EPI^MR||LAST^FIRST^MIDDLE|}} {NK1|1|LAST^FIRST} {PV1|1|Emergency}
KILL: ‘MSH|^~\&|Epic|MRH|||
{PID|1||12345678^^^EPI^MR||LAST^FIRST^MIDDLE|}
NK1|1|LAST^FIRST
I honestly at the end of my rope with this, I have no clue why it’s doing this.