Class HL7::Message
In: lib/ruby-hl7.rb
Parent: Object

Ruby Object representation of an hl7 2.x message the message object is actually a "smart" collection of hl7 segments

Examples

Creating a new HL7 message

 # create a message
 msg = HL7::Message.new

 # create a MSH segment for our new message
 msh = HL7::Message::Segment::MSH.new
 msh.recv_app = "ruby hl7"
 msh.recv_facility = "my office"
 msh.processing_id = rand(10000).to_s

 msg << msh # add the MSH segment to the message

 puts msg.to_s # readable version of the message

 puts msg.to_hl7 # hl7 version of the message (as a string)

 puts msg.to_mllp # mllp version of the message (as a string)

Parse an existing HL7 message

 raw_input = open( "my_hl7_msg.txt" ).readlines
 msg = HL7::Message.new( raw_input )

 puts "message type: %s" % msg[:MSH].message_type

Methods

<<   []   []=   each   index   length   new   parse   parse   sequence_segments   to_hl7   to_mllp   to_s  

Included Modules

Enumerable

Classes and Modules

Class HL7::Message::Segment

Attributes

element_delim  [R] 
item_delim  [R] 
segment_delim  [R] 

Public Class methods

setup a new hl7 message

raw_msg:is an optional object containing an hl7 message it can either be a string or an Enumerable object

parse a String or Enumerable object into an HL7::Message if possible

Public Instance methods

add a segment to the message

  • will force auto set_id sequencing for segments containing set_id‘s

access a segment of the message

index:can be a Range, Fixnum or anything that responds to to_sym

modify a segment of the message

index:can be a Range, Fixnum or anything that responds to to_sym
value:an HL7::Message::Segment object

yield each segment in the message

return the index of the value if it exists, nil otherwise

value:is expected to be a string

return the segment count

parse the provided String or Enumerable object into this message

auto-set the set_id fields of any message segments that provide it and have more than one instance in the message

provide a HL7 spec version of the message

provide the HL7 spec version of the message wrapped in MLLP

provide a screen-readable version of the message

[Validate]