Class: MsgErrorHandler
- Inherits:
-
Object
- Object
- MsgErrorHandler
- Defined in:
- lib/ez7gen/msg_error_handler.rb
Constant Summary collapse
- ERR_HEAD =
"ERROR <Ens>ErrGeneral:"
Instance Method Summary collapse
Instance Method Details
#handle(resp) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ez7gen/msg_error_handler.rb', line 7 def handle(resp) # segs = message #segs = resp.split("\r") resp.chomp!() # msg = HL7::Message.new(segs) # msg = HL7::Message.parse(message) # seg = msg[:ERR] if(! resp.include?(ERR_HEAD)) return nil end # if there are errors, make response easy on the eye resp.gsub!("\\X0D\\\\X0A\\", "\r") resp.gsub!("\r+\r", "\r") resp.gsub!(ERR_HEAD, "\r"+ERR_HEAD) resp.gsub!("\r\r","\r") # remove empty lines # get errors for toaster display errors = resp.split(ERR_HEAD).reject {|e| e.empty?} errors.delete_at(0) # remove part of the message before errors return errors end |