Class: Renalware::Feeds::HL7Message
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Renalware::Feeds::HL7Message
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
Constant Summary
collapse
- ACTIONS =
{
"ADT^A28" => :add_person_information,
"ADT^A31" => :update_person_information,
"ADT^A08" => :update_admission,
"ADT^A01" => :admit_patient,
"ADT^A02" => :transfer_patient,
"ADT^A03" => :discharge_patient,
"ADT^A11" => :cancel_admission,
"MFN^M02" => :add_consultant, "ADT^A34" => :merge_patient, "ADT^A13" => :cancel_discharge,
"ORU^R01" => :add_pathology_observations
}.freeze
Instance Method Summary
collapse
Instance Method Details
#action ⇒ Object
227
228
229
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 227
def action
ACTIONS.fetch(type, :no_matching_command)
end
|
#event_type ⇒ Object
216
217
218
219
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 216
def event_type
parts = type.split("^")
parts.length == 2 && parts.last
end
|
#gp_code ⇒ Object
235
236
237
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 235
def gp_code
self[:PD1].e4.split("^")[0] if self[:PD1]
end
|
203
204
205
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 203
def
self[:MSH].message_control_id
end
|
#message_type ⇒ Object
212
213
214
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 212
def message_type
type.split("^").first
end
|
#observation_requests ⇒ Object
There is a problem here is there are < 1 OBR i.e. self could be an array
121
122
123
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 121
def observation_requests
Array(self[:OBR]).map { |obr| ObservationRequest.new(obr) }
end
|
#patient_identification ⇒ Object
195
196
197
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 195
def patient_identification
PatientIdentification.new(self[:PID])
end
|
#practice_code ⇒ Object
231
232
233
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 231
def practice_code
self[:PD1].e3.split("^")[2] if self[:PD1]
end
|
#to_hl7 ⇒ Object
Adding this so it is part of the interface and we can mock an HL7Message in tests
208
209
210
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 208
def to_hl7
super
end
|
#type ⇒ Object
199
200
201
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 199
def type
self[:MSH].message_type
end
|