lib/planner/kansa_importer.rb
# Try to find the person in the DB based on their name
Try to find the person in the DB based on their name
Try to find the person in the DB based on their name
def find_person(first_name: nil, last_name: nil, legal_name: nil)
      person = nil
      if !first_name.blank? && !last_name.blank?
        person = Person.find_by({
          first_name: first_name.strip,
          last_name: last_name.strip
        })
      end
      if !person && !legal_name.blank?
        name_parts = legal_name.split
        first_name_candidate = name_parts.first
        last_name_candidate = name_parts.last
        _candidate
        _candidate
        person = Person.find_by({
          first_name: first_name_candidate.strip,
          last_name: last_name_candidate.strip
        }) if !first_name_candidate.blank? && !last_name_candidate.blank?
        if !person
          last_name_candidate = name_parts[1..name_parts.size].join(" ").strip
          person = Person.find_by({
            first_name: first_name_candidate.strip,
            last_name: last_name_candidate.strip
          })
        end
        if !person
          first_name_candidate = name_parts[0..(name_parts.size-1)].join(" ").strip
          person = Person.find_by({
            first_name: first_name_candidate.strip,
            last_name: last_name_candidate.strip
          })
        end
      end
      person
    end
def find_person ( first_name : nil , last_name : nil , legal_name : nil ) person = nil if ! first_name . blank? && ! last_name . blank? person = Person . find_by ( { first_name : first_name . strip , last_name : last_name . strip } ) end if ! person && ! legal_name . blank? name_parts = legal_name . split first_name_candidate = name_parts . first last_name_candidate = name_parts . last person = Person . find_by ( { first_name : first_name_candidate . strip , last_name : last_name_candidate . strip } ) if ! first_name_candidate . blank? && ! last_name_candidate . blank? if ! person last_name_candidate = name_parts [ 1 .. name_parts . size ] . join ( " " ) . strip person = Person . find_by ( { first_name : first_name_candidate . strip , last_name : last_name_candidate . strip } ) end if ! person first_name_candidate = name_parts [ 0 .. ( name_parts . size - 1 ) ] . join ( " " ) . strip person = Person . find_by ( { first_name : first_name_candidate . strip , last_name : last_name_candidate . strip } ) end end person end
Try to find the person in the DB based on their name
Try to find the person in the DB based on their name
# puts "** first and last" # puts first_name # puts last_name # puts "** first and last candidate" # puts first_name_candidate # puts last_name_candidate
first_name
<not_specific>
last_name
<not_specific>
legal_name
<not_specific>