I have a script where I am creating 2 A31 msgs from an A05 and need to put in a 2sec delay after the A05 message but I can’t seem to get the delay working. Where do I put in the 2 sec. delay and what is the syntax? Here’s my script.
if {[cequal $msgTRIG “A05”] && [regexp {BABY} $sysBABY]} {
set babyFlag 1
#puts “the value of sysBABY is: $sysBABY”
#puts “the value of PV2_12 is: $PV2_12″
regsub -all {\-} $PV2_12 { } PV2_12
set PV2_12_list [split $PV2_12 ” “]
set mother_mrn [getField $msg GT1 2 0]
set mother_mrn [lindex $PV2_12_list 1]
#set mother_name [lindex $PV2_12_list 2]
#regsub -all {,} $mother_name {^} mother_name
set mother_name [getField $msg GT1 3]
set nk1cnt [countSegments $msg “NK1”]
for {set i 0} {$i < $nk1cnt} {incr i} {
set nk1_3_2 [getField $msg NK1<$i>.3.1]
if {[cequal $nk1_3_2 “MOTHER”]} {
set msg [setField $mother_mrn $msg NK1<$i> 33]}
}
#puts “the value of nk1_3_2 is: $nk1_3_2”
$oldmsg setMessage “$msg”
#Build the A31 message mother and add a 2 second delay
$newmsg setMessage [$oldmsg getSegment MSH]
after 2000
$newmsg appendSegment “EVN”
$newmsg setField EVN.1 A31
$newmsg setField EVN.2 [$oldmsg getField MSH.6]
$newmsg appendSegment “PID”
$newmsg setField PID.3 “$mother_mrn^^^ST01A^MR”
$newmsg setField PID.5 $mother_name
$newmsg appendSegment “NK1”
$newmsg setField NK1.1 “1”
$newmsg setField NK1.3 “D”
$newmsg setField NK1.7 “F”
$newmsg setField NK1.2 [$oldmsg getField PID.5]
$newmsg setField NK1.33 [$oldmsg getField PID.3.0]
$newmsg appendSegment “PV1”
$newmsg setField PV1.1 “1”
$newmsg setField PV1.2 “N”
after 2000
$newmsg setField MSH.8 “ADT^A31”
#Build the A31 message baby and add a 2 second delay
set babyname [$oldmsg getField PID.5]
set babymrn [$oldmsg getField PID.3.0]
$newmsg2 setMessage [$oldmsg getSegment MSH]
$newmsg2 appendSegment “EVN”
$newmsg2 setField EVN.1 A31
$newmsg2 setField EVN.2 [$oldmsg getField MSH.6]
$newmsg2 appendSegment “PID”
$newmsg2 setField PID.3 “$babymrn^^^ST01A^MR”
$newmsg2 setField PID.5 $babyname
$newmsg2 appendSegment “NK1”
$newmsg2 setField NK1.1 “1”
$newmsg2 setField NK1.3 “R”
$newmsg2 setField NK1.7 “F”
$newmsg2 setField NK1.2 $mother_name
$newmsg2 setField NK1.33 $mother_mrn
$newmsg2 appendSegment “PV1”
$newmsg2 setField PV1.1 “1”
$newmsg2 setField PV1.2 “N”
$newmsg2 setField MSH.8 “ADT^A31”
}
msgset $mh $msg
lappend dispList “CONTINUE $mh”
#puts “the confirms babyFlag is: $babyFlag”
if {$babyFlag == 1} {
set mh2 [msgcopy $mh]
msgset $mh2 [$newmsg getMessage]
lappend dispList “CONTINUE $mh2”
set mh3 [msgcopy $mh]
msgset $mh3 [$newmsg2 getMessage]
lappend dispList “CONTINUE $mh3”
}