I have been trying to set the location in a TCL for each NTE segment and replace field 3 with an update spliting the field into 3 character fields separated by ~.
The lsearch will return the first instance of your pattern search unless you specify something like -all. Are you looking to perform your action to EACH NTE or just the first and last? You mentioned something about “not just the first and then the last“.
My first suggestion would be to do away with the foreach looping if it all possible. From the looks of your code there doesn’t appear to be anything that is vital to looping. That way you can use the lsearch more to your advantage.
I think Tom is right in that you probably do not need the foreach if you use lsearch. That said, I added some white space to the routine to help me visualize it better, and I think I found out why you may have been having problems with the shutdown and default arms. You have a closed brace out of order.
Your code (with added white space):
Code:
msgset $mh $msg
lappend dispList “CONTINUE $mh”
}
}
#shutdown {
# Doing some clean-up work
#}
More looking at the code and I have to ask. Can there be more than one ORC segment per message? If not, you can just do an lsearch to get the ORC segment and do your ORC.1 check to change MSH without using foreach. Then you get all of your NTE’s using lsearch -all and pick them off one by one using a foreach over the NTE list.
Hope this helps,
Robert Milfajt
Northwestern Medicine
Chicago, IL
Author
Replies
Viewing 2 reply threads
The forum ‘Cloverleaf’ is closed to new topics and replies.