proc insurance_sheet { args } {
set mode [keylget args MODE]
switch -exact — $mode {
start {
}
run {
set mh [keylget args MSGID]
set msg [msgget $mh]
set fldSep [string index $msg 3] ; # Normally |
set seg_list [split $msg r]
foreach seg $seg_list {
set name [lindex [lregexp $seg_list {^MSH}] 0]
set ID [lindex [split $name $fldSep] 6]
set patient [lindex [lregexp $seg_list {^PID}] 0]
#set ID [lindex [split $seg $fldSep] 5]
set obr [lindex [lregexp $seg_list {^OBR}] 0]
set doctor [lindex [split $obr $fldSep] 16]
set test [lindex [split $obr $fldSep] 4]
set time [clock format [clock seconds] -format “%Y%m%d%H%M%S”]
set insur [lindex [lregexp $seg_list {^IN1}] 0]
set gurant [lindex [lregexp $seg_list {^GT1}] 0]
set insur2 [lindex [lregexp $seg_list {^IN1}] 1]
set data “{$patient}rnnn{$doctor}rnnn{$test}rnnn{$insur}rnnn{$insur2}rnnn{$gurant}”
set file [open $time w]
puts $file $data
#exec lpr -S 192.168.160.26 -P HP LaserJet 4000 Series PCL on SKAGIT_PATHOLOG $file
#exec print $file
return “{CONTINUE $mh}”
}
}
}
}
time {
}