Here ya go. What this proc does it take the text from final diagnosis and source and places them in OBX 2 and 4 respectively. I run it thru and ORU to vrl xlate.
proc datadsurg { args } {
keylget args MODE mode ;# Fetch mode
set dispList {}
set signed_flag “”
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]
set fieldSep [string index $msg 3]
set segmentList [split $msg r]
set obx [lrange [lregexp $segmentList {^OBX}] 0 end]
set obxlist2 “”
set obxlist “”
foreach segment $obx {
set field [lindex [split $segment $fieldSep] 5]
set field [string trim $field]
append obxlist2 “$field”
set obxlist3 “”
set signed [string first “FINAL DIAGNOSIS” $obxlist2]
set obxlist3 [string range $obxlist2 $signed end]
set list “”
set source “”
regexp — {(SPECIMEN:.*?)CLINICAL HISTORY} $obxlist2 {} source
set found ” “
set item “”
set line “PROCEDURE/ADDENDA:”
regexp — {(FINAL DIAGNOSIS:.*?)GROSS DESCRIPTION} $obxlist3 {} item
echo $item
if {[regexp — $line $obxlist3]} {
regexp — {(PROCEDURE/ADDENDA:.*?)Electronically Signed Out} $obxlist3 {} list
set obxlist [append item “$found” “$list”]
} else {
regexp — {(FINAL DIAGNOSIS:.*?)GROSS DESCRIPTION} $obxlist3 {} obxlist
}
set final [join $obxlist { }]
set obx1 [lindex $obx 1]
set obxa [lindex $obx 3]
set obxb [split $obxa $fieldSep]
set obx2 [split $obx1 $fieldSep]
set obx3 [lindex $obx2 6]
set obxe [lreplace $obxb 6 6 $source]
set obx1 “”
set obx6 [lreplace $obx2 6 6 $final]
set obxa “”
set segment [join $obx6 $fieldSep]
set segment1 [join $obxe $fieldSep]
set nmh [lindex $segmentList 5]
set segmentList [lreplace $segmentList 6 6 $segment]
set segmentList [lreplace $segmentList 8 8 $segment1]
}
msgset $mh [join $segmentList r]
set dispList “”
lappend dispList “CONTINUE $mh”
return $dispList
} ;# end run mode
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
}
#return $dispList
}