Originally posted by Robert Hamden
set f [open $fileName r]fconfigure $f -translation binaryset reports [read $f]close $f
Originally posted by Levy Lazarre
run { # 'run' mode always has a MSGID; fetch and process it keylget args MSGID mh set msg [msgget $mh] # Split the message on Carriage Return to get the segments in a list set segmentList [split $msg "x0d"] foreach segment $segmentList { # Remove any heading/trailing whitespace from the segment. # This is a precaution in case the HL7 message came in DOS format set segment [string trim $segment]
MSH|^~&|LAB|MET||92373198|20100803142459.0000-0400||ORU^R01|00000000000000715383|P|2.3
proc fix_cr_lf { 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] # Split the message on Carriage Return to get the segments in a list set segmentList [split $msg "x0d"] set newmsg {} ;# to contain the modified message foreach segment $segmentList { # Remove any heading/trailing whitespace from the segment. # This is a precaution in case the HL7 message came in DOS format set segment [string trim $segment] # Add the trimmed segment to the new message lappend newmsg $segment } # Build the new message with CR as the segment separator set newmsg [join $newmsg "r"] # Add the final terminator. HL7 message should end with newline append newmsg "rn" # Message handle for the new message set newmh [msgcopy $mh] msgset $newmh $newmsg # Continue the new message lappend dispList "CONTINUE $newmh" # Kill the original message lappend dispList "KILL $mh" } time { # Timer-based processing # N.B.: there may or may not be a MSGID key in args } shutdown { # Doing some clean-up work } } ;# end switch return $dispList} ;# end proc
# Add the final terminator. HL7 message should end with newline append newmsg "r"
# Add the trimmed segment to the new message if {[string length $segment]} { lappend newmsg $segment }