I have already written code to remove OBX segment if OBX 5 has the value “SUPRESSED”, and then resequence the OBXs. The problem is that after it removes the segment it replaces it with a blank line, then adds the next segment after the blank line. What did I do wrong in the code where it is placing a blank segment in place of the suppresed segment?
Here is the output after the segment was removed:
OBX|12|CE||||
OBX|13|CE||||
BLANK LINE
OBX|14|CE|||||||
All 3 segments should be together. The code is below.
set New_Seg_List “”
set obx_cnt 1
foreach Segment $Seg_List {
set Seg_ID [crange $Segment 0 2]
if { ($Seg_ID == “OBX”) } {
set Field_List [split $Segment $Fld_Sep]
set Result_Value [lindex $Field_List 5]
if {$Result_Value ==”SUPRESSED” } {
set Segment “”
incr obx_cnt -1
}
set Segment [replaceHL7Field $Segment OBX 1 $obx_cnt]
incr obx_cnt
}
set New_Seg_List [lappend New_Seg_List $Segment]
set msg [join $New_Seg_List r]
# Replace message with new one created.
msgset $mh $msg
}
}
# Assume change was made
#msgset $mh [join $segments r]
}
return “{CONTINUE $mh}”
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
default {
error “Unknown mode ‘$mode’ in OBX Suppress”
}
}
return $dispList
}