We have upgraded from 3.8 to 5.8 recently and are in process of migrating interfaces to the new server. Had some tcl code on a couple raw routes that were working before that don't on the newer version that changed the value in MSH-9 from ORU^R01 to MDM^T02 so I am trying to rework them. Below is my code and it is working right except for the fact that it is creating an extra segment out of field in the OBR that has a space in it...here's the before and after:
Before:
MSH|^~&|SENDAPP|SENDFAC|RECVAPP|RECVFAC|201206201235||ORU^R01|2012062012353738|P|2.2|2012062012353738|
PID|||0456132||XXXX||19520407|FEMALE||White|^^^^64052|||||||1217200126|266086459|
OBR||SX12001454|||||20120620082759|20120620120727||||||||||||Archive Copy||||||||||||^Mahmood^Amber^CVT|
OBX|1||||\10.1.110.68PACSreportsXperReportsHA398_DOC_000.pdf|
After:
MSH|^~&|SENDAPP|SENDFAC|RECVAPP|RECVFAC|201206201235||MDM^T02|2012062012353738|P|2.2|2012062012353738|
PID|||0456132||XXXX||19520407|FEMALE||White|^^^^64052|||||||1217200126|266086459|
OBR||SX12001454|||||20120620082759|20120620120727||||||||||||Archive
Copy||||||||||||^Mahmood^Amber^CVT|
OBX|1||||10.1.110.68PACSreportsXperReportsHA398_DOC_000.pdf|
So I guess an extra carriage return is getting in there somehow and I can't seem to figure out how. Any improvement to this issue and other things you find in my code are welcome. Thanks!
# Now we iterate over each segment in our list.
foreach segment $segmentList {
if {[cequal [crange $segment 0 2] MSH]} {
set fieldList [split $segment $field_sep]
set msh_9 [lindex $fieldList 8]
set mtlist [split $msh_9 $sub_sep]
set msg_9_1 [lindex $mtlist 0]
if {[cequal $msg_9_1 "ORM"] || [cequal $msg_9_1 "ORU"] } {
set mtlist [lreplace $mtlist 0 0 "MDM"]
set mtlist [lreplace $mtlist 1 1 "T02"]
set msh_9 [join $mtlist $sub_sep]
set fieldList [lreplace $fieldList 8 8 $msh_9]
set fieldList [join $fieldList $field_sep]
set msg [lreplace $msg 0 0 $fieldList]
set msg [join $msg r]
echo $msg
msgset $mh $msg
lappend dispList "CONTINUE $mh"
} else {
lappend dispList "CONTINUE $mh"
return $dispList
}
}
}
}