Class: Renalware::Patients::MessageParamParser

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/patients/message_param_parser.rb

Overview

Responsible for transforming an HL7 message payload into a params hash that can be persisted by Patient.

Instance Method Summary collapse

Instance Method Details

#parse(hl7_message) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/renalware/patients/message_param_parser.rb', line 11

def parse(hl7_message)
  pi = hl7_message.patient_identification

  {
    patient: {
      nhs_number: pi.external_id,
      local_patient_id: pi.internal_id,
      family_name: pi.family_name,
      given_name: pi.given_name,
      sex: pi.sex,
      born_on: Date.parse(pi.dob).to_s
    }
  }
end