Module: HL7::MessageBatchParser
- Included in:
- Message
- Defined in:
- lib/message_parser.rb
Instance Method Summary collapse
-
#parse(inobj) ⇒ Object
parse a String or Enumerable object into an HL7::Message if possible * returns a new HL7::Message if successful.
-
#parse_batch(batch) ⇒ Object
:yields: message.
Instance Method Details
#parse(inobj) ⇒ Object
parse a String or Enumerable object into an HL7::Message if possible
-
returns a new HL7::Message if successful
24 25 26 27 28 |
# File 'lib/message_parser.rb', line 24 def parse( inobj ) HL7::Message.new do |msg| msg.parse( inobj ) end end |
#parse_batch(batch) ⇒ Object
:yields: message
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/message_parser.rb', line 2 def parse_batch(batch) # :yields: message raise HL7::ParseError, 'badly_formed_batch_message' unless batch.hl7_batch? batch = clean_batch_for_jruby batch raise HL7::ParseError, 'empty_batch_message' unless match = /\rMSH/.match(batch) match.post_match.split(/\rMSH/).each do |_msg| if md = /\rBTS/.match(_msg) # TODO: Validate the message count in the BTS segment # should == index + 1 _msg = md.pre_match end yield 'MSH' + _msg end end |