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
228
229
230
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 228
def action
ACTIONS.fetch(type, :no_matching_command)
end
|
#event_type ⇒ Object
217
218
219
220
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 217
def event_type
parts = type.split("^")
parts.length == 2 && parts.last
end
|
#gp_code ⇒ Object
236
237
238
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 236
def gp_code
self[:PD1].e4.split("^")[0] if self[:PD1]
end
|
204
205
206
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 204
def
self[:MSH].message_control_id
end
|
#message_type ⇒ Object
213
214
215
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 213
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
122
123
124
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 122
def observation_requests
Array(self[:OBR]).map { |obr| ObservationRequest.new(obr) }
end
|
#patient_identification ⇒ Object
196
197
198
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 196
def patient_identification
PatientIdentification.new(self[:PID])
end
|
#practice_code ⇒ Object
232
233
234
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 232
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
209
210
211
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 209
def to_hl7
super
end
|
#type ⇒ Object
200
201
202
|
# File 'app/models/renalware/feeds/hl7_message.rb', line 200
def type
self[:MSH].message_type
end
|