Class: Renalware::Feeds::HL7Message::PatientIdentification

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

Instance Method Summary collapse

Instance Method Details

#addressObject



164
165
166
# File 'app/models/renalware/feeds/hl7_message.rb', line 164

def address
  super.split("^")
end

#family_nameObject



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

def family_name
  patient_name[0]
end

#given_nameObject



152
153
154
# File 'app/models/renalware/feeds/hl7_message.rb', line 152

def given_name
  patient_name[1]
end

#internal_idObject



132
133
134
135
136
# File 'app/models/renalware/feeds/hl7_message.rb', line 132

def internal_id
  return unless defined?(patient_id_list)

  patient_id_list.split("^").first
end

#nameObject



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

def name
  Name.new(patient_name)
end

#nhs_numberObject



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

def nhs_number
  return unless defined?(patient_id)

  patient_id.split("^").first
end

#sexObject Also known as: admin_sex

We don’t use the HL7::Message#sex_admin method (from the ruby hl7 gem) because it raises an error during reading if the sex value in the PID is not in (F|M|O|U|A|N|C). I think that behaviour is a not quite right as a hospital might not use those values in their HL7 PID implementation, especially in the UK. KCH does not for instance. So instead we read the PID array directly, and map whatever is in there to its Renalware equivalent, then overwrite the existing #admin_sex method so the HL7::Message version cannot be called. If we can’t map it we just return whatever is in there and its up to calling code to handle any coercion issues. The hl7_pid_sex_map hash can be configured by the host app to support whatever sex values it uses intenrally. I think some work needs to be done on Renalware sex and gender (which are slightly conflated in Renalware). For example:

  • the LOINC names for administrative sex: Male Female Unknown (loinc.org/72143-1/)

  • the LOINC names for sex at birth: Male Female Unknown (loinc.org/LL3324-2/)

  • HL7’s definitions: F Female, M Male, O Other, U Unknown, A Ambiguous, N Not applicable

  • gender: 7 options loinc.org/76691-5/



183
184
185
186
# File 'app/models/renalware/feeds/hl7_message.rb', line 183

def sex
  pid_sex = self[8]&.upcase
  Renalware.config.hl7_pid_sex_map.fetch(pid_sex, pid_sex)
end

#suffixObject



156
157
158
# File 'app/models/renalware/feeds/hl7_message.rb', line 156

def suffix
  patient_name[3]
end

#titleObject



160
161
162
# File 'app/models/renalware/feeds/hl7_message.rb', line 160

def title
  patient_name[4]
end