Class: Renalware::Feeds::HL7Message

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/models/renalware/feeds/hl7_message.rb

Overview

Responsible for representing an HL7 message. Fields can be queried via chained method calls. For example, accessing the patient identifier field in the PID segment can be accessed by calling:

HL7Message.new(raw_message).patient_identification.internal_id

Defined Under Namespace

Classes: Observation, ObservationRequest, PatientIdentification

Instance Method Summary collapse

Constructor Details

#initialize(message_string) ⇒ HL7Message

Returns a new instance of HL7Message.



14
15
16
17
# File 'app/models/renalware/feeds/hl7_message.rb', line 14

def initialize(message_string)
  @message_string = message_string
  super(::HL7::Message.new(message_string.lines))
end

Instance Method Details

#header_idObject



144
145
146
# File 'app/models/renalware/feeds/hl7_message.rb', line 144

def header_id
  self[:MSH].message_control_id
end

#observation_requestsObject

There is a problem here is there are < 1 OBR i.e. self could be an array



104
105
106
# File 'app/models/renalware/feeds/hl7_message.rb', line 104

def observation_requests
  Array(self[:OBR]).map{ |obr| ObservationRequest.new(obr) }
end

#patient_identificationObject



136
137
138
# File 'app/models/renalware/feeds/hl7_message.rb', line 136

def patient_identification
  PatientIdentification.new(self[:PID])
end

#to_sObject



148
149
150
# File 'app/models/renalware/feeds/hl7_message.rb', line 148

def to_s
  @message_string.tr("\r", "\n")
end

#typeObject



140
141
142
# File 'app/models/renalware/feeds/hl7_message.rb', line 140

def type
  self[:MSH].message_type
end