Originally posted by Tom Arrowsmith
Hello,
I am trying to write a tcl script that will kill any A04 messages where the account field is empty. Because I am relatively new to programming, and very new to tcl, I generally start with a script which is similar and edit it to perform the desired new outcome.
In this case, I am starting with a script that kills any messages except A03's, when those non-A03 messages have a populated "when discontinued" timestamp.
Here's an example of the pertinent part of that code, which I hope to change:
if {[cequal [crange $segment 0 2] MSH]} {
set fieldList [split $segment $field_sep]
set msh_9 [lindex $fieldList 8]
set msh_9_list [split $msh_9 $sub_sep]
set msh_9_1 [lindex $msh_9_list 0]
set msh_9_2 [lindex $msh_9_list 1]
if {[cequal $msh_9_2 "A03"]} {
set disposition "CONTINUE"
}
} elseif {[cequal [crange $segment 0 2] PV1]} {
set fieldList [split $segment $field_sep]
set pv1_45 [lindex $fieldList 45]
if {[string length $pv1_45] == 0 } {
set disposition "CONTINUE"
} elseif {[cequal $pv1_45 """"]} {
set disposition "KILL"
I wish to change it to say (expressed in "pseudo" code):
If message is an A04, check to see if the account field (PID-18.1) is null, if it's null - kill the message.
I am not familiar with how to make the "cequal" to be "not cequal". I have found the "ne" operator, but am unsure whether to use that rather than somehow keeping the "cequal" functionality expressed negatively.
I am thinking that the first half of this code snippet could be re-written somewhat like this (I am using "ne" here - and changing A03 to A04):
if {[cequal [crange $segment 0 2] MSH]} {
set fieldList [split $segment $field_sep]
set msh_9 [lindex $fieldList 8]
set msh_9_list [split $msh_9 $sub_sep]
set msh_9_1 [lindex $msh_9_list 0]
set msh_9_2 [lindex $msh_9_list 1]
if {ne $msh_9_2 "A04"]} {
set disposition "CONTINUE"
Then in the second half, I'll have to change it to key in on the PID-18.1 ..... not sure I trust my expertise to do this, although it looks somewhat understandable to me ....
I appreciate any help I can get!
Tom Arrowsmith
Inova Loudoun Hospital