- This topic has 3 replies, 2 voices, and was last updated 15 years, 4 months ago by .
-
Topic
-
I am trying to write a tcl script which will kill a message if two arguments match (if the ORC-1 = NW and the ORC-2.2 = IBEX) I am having some trouble getting it to work. I’d really appreciate it if any of you can take a look. I have the Script placed on the route with arguments defined as {ORIGIN IBEX} and {ORDCONTROL NW}
I am running Cloverleaf 5.4.1 which I believe limits me to an older tcl version….(8.3.1)
Here’s the script:
######################################################################
# Name: kill_IbexNW-ORM
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (“start”, “run” or “time”)
# MSGID message handle
# ARGS user-supplied arguments:
# ORIGIN Order Origination (ORC-2.2)
# ORDCONTROL Indicates if order is new (NW) or otherwise (ORC-1)
# Description: Kills message if the ORIGIN argument = value in ORC-2.2 AND the ORDCONTROL argument = value in ORC-1
# Returns: tps disposition list:
# $CONTINUE
# $KILL
proc kill_IbexNW-ORM { args } {
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
set msg [msgget $mh] ;# Get message
keylget args ARGS.ORIGIN origin ;# Fetch the origin arg
keylget args ARGS.ORDCONTROL ordcontrol ;# Fetch the order control arg
set field_sep [csubstr $msg 3 1] ;# HL7 field separator
set sub_sep [csubstr $msg 4 1] ;# HL7 subfield separator
set rep_sep [csubstr $msg 5 1] ;# HL7 field repetition separator
set subsub_sep [csubstr $msg 7 1] ;# HL7 sub subfield separator
set segmentList [split $msg r]
# Now we iterate over each segment in our list.
foreach segment $segmentList {
if {[cequal [crange $segment 0 2] ORC]} {
set fieldList [split $segment $field_sep]
set orc_1 [lindex $fieldList 0]
set orc_2 [lindex $fieldList 1]
set orc_2_2 [crange $orc_2 1 0]
if {[cequal $orc_1 $ordcontrol] && [cequal $orc_2_2 $origin]} {
lappend dispList “KILL $mh”
} else {
lappend dispList “CONTINUE $mh”
}
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Shutdown mode
echo “kill_IbexNW-ORM is shutting down”
}
default {
error “Unknown mode ‘$mode’ in kill_IbexNW-ORM”
}
}
return $dispList
}
- The forum ‘Cloverleaf’ is closed to new topics and replies.