class Roqua::Healthy::A19::PhoneParser
Attributes
message[R]
Public Class Methods
new(message)
click to toggle source
# File lib/roqua/healthy/a19/phone_parser.rb, line 8 def initialize(message) @message = message end
Public Instance Methods
to_s()
click to toggle source
this is a heuristic to pick likely dutch cell phone numbers from hl7 messages
# File lib/roqua/healthy/a19/phone_parser.rb, line 13 def to_s # prefer PRN (Primary Residence Number) that contains a cell phone number # otherwise choose the first occuring cell phone number # any number for which phone_cell_number? returns false is ignored phone_cell_record = first_matching_prn_record || first_matching_record strip_non_phone_number_characters(phone_cell_record.fetch('PID.13.1')) if phone_cell_record.present? end
Private Instance Methods
first_matching_prn_record()
click to toggle source
# File lib/roqua/healthy/a19/phone_parser.rb, line 28 def first_matching_prn_record pid13.find do |record| phone_cell_number?(record.fetch('PID.13.1', '') || '') && record.fetch('PID.13.2', :unknown_type_of_phone_record) == 'PRN' end end
first_matching_record()
click to toggle source
# File lib/roqua/healthy/a19/phone_parser.rb, line 35 def first_matching_record pid13.find do |record| phone_cell_number?(record.fetch('PID.13.1', '') || '') end end
phone_cell_number?(number)
click to toggle source
# File lib/roqua/healthy/a19/phone_parser.rb, line 45 def phone_cell_number?(number) Roqua::Healthy::A19::PhoneValidator.phone_cell_number? number end
pid13()
click to toggle source
# File lib/roqua/healthy/a19/phone_parser.rb, line 24 def pid13 @pid13 ||= message.dig('PID', 'PID.13') || [] end
strip_non_phone_number_characters(number)
click to toggle source
# File lib/roqua/healthy/a19/phone_parser.rb, line 41 def strip_non_phone_number_characters(number) Roqua::Healthy::A19::PhoneValidator.strip_non_phone_number_characters number end