Originally posted by Mark Brown
There's a subfield that one of the ancillary systems wants the first three characters stripped. Not being a tcl programmer, I cobbled together some code from a couple of procs to try to do this. At first, it looks like it works okay. But when I use more than one record in the testing tool, the field that I'm replacing the subfield in, is for some reason enclosed in braces ({}). I'm not putting braces anywhere that I can see.
When I place an 'echo' to look at the field that contains the subfield, it looks okay. But if I 'echo' the whole segment, that field is surrounded by braces.
Here's a snippet of the code:
set msg [msgget $mh]
set segmentList [split $msg r]
set fieldSep [csubstr $msg 3 1]
set subFieldSep [csubstr $msg 4 1]
foreach segment $segmentList {
if [regexp {RXE} [crange $segment 0 2]] {
set fieldList [split $segment $fieldSep]
set fieldTwo [lindex $fieldList 2]
set fieldTwoList [split $fieldTwo $subFieldSep]
set cdm [lindex $fieldTwoList 0]
set description [lindex $fieldTwoList 1]
set code [lindex $fieldTwoList 2]
set drugData [string range $cdm 3 end]
set fieldTwo [lreplace $fieldTwo 0 2 $drugData^$description^$code]
set fieldList [lreplace $fieldList 2 2 $fieldTwo]
set segment [join $fieldList $fieldSep]
}
append outBuff ${segment}r
}
Here's an example output for the segment I'm changing. The shortened field is subfield 1 of RXE-2 (the 5905...etc).
RXE|1^QD&2100&&1J1234567&&&99NSF^INDEF^200604072100^^R^^ONCE A DAY^^|{5905^STERILE WATER INJ.^L}|367||ML|SOLP||||4|SOLP|3.67||DIVANHOE|8620.1||||367||""||42|ML/HR||||||||||||||||||S||||||
Any idea why the braces are showing up?
Thanks,