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



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

def address
  super.split("^")
end

#family_nameObject



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

def family_name
  patient_name[0]
end

#given_nameObject



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

def given_name
  patient_name[1]
end

#internal_idObject



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

def internal_id
  return unless defined?(patient_id_list)

  patient_id_list.split("^").first
end

#nameObject



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

def name
  Name.new(patient_name)
end

#nhs_numberObject



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

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/



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

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

#suffixObject



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

def suffix
  patient_name[3]
end

#titleObject



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

def title
  patient_name[4]
end