I’m still a novice at tcl coding, so probably not the best person to help you, but I was curious because it looked like your code should work, so I tried it in interactive tcl:
hcitcl>set field “1234^567^890”
hcitcl>echo $field
1234^567^890
hcitcl>echo [lindex [split $field “^”] 1]
567
hcitcl>
Seems to do what you’d expect, if in fact what you wanted was the second subfield. Remember, the counting for the index number in a list starts at zero in tcl, so if you wanted the ID number of the Ordering Provider field you probably want to use:
set filter [lindex [split $orc_fld12 “^”] 0]
If that isn’t the problem, perhaps you could post an example ORC segment from one of your test messages, in case there is something about the formatting of that field that is throwing this off.