/health_seven

Ruby HL7 2.x messages parser

Primary LanguageRuby

ruby-hl7

R7::Message

Parse hl7 (2 < v < 3) message as segments tree

Example:

class TestMessage < R7::Message
   #define message structure
   define_message do
     msh
     pid
     pv1? { pv2? }
     orc {
       obrs { obxs { ntes? } }
     }
   end
 end

msg = TestMessage.parse "MSH|||||\rPID||||||\rORC||||||\rOBR|||||\rORX|code^val||\rORX|||\rOBR||||\rORX|||\rORX||||\r\n"
#access message tree
msg.orc.obrs.first.orx[1,2] #=> 'val'