class Parent
Schema Information
Table name: parents
id :bigint not null, primary key contact_method_other_details :text contact_method_type :string email :string full_name :string phone :string phone_receive_updates :boolean default(FALSE), not null created_at :datetime not null updated_at :datetime not null
Indexes
index_parents_on_email (email)
Public Class Methods
Source
# File app/models/parent.rb, line 67 def self.match_existing(patient:, email:, phone:, full_name:) if email.present? && (parent = Parent.find_by(email:)) return parent end return unless patient # We don't match on phone numbers or names globally as they can be re-used. if phone.present? && (parent = patient.parents.find_by(phone:)) return parent end if full_name.present? && (parent = patient.parents.find_by(full_name:)) parent end end
Public Instance Methods
Source
# File app/models/parent.rb, line 93 def contact_label [email, phone].compact_blank.join(" / ") end
Source
# File app/models/parent.rb, line 97 def contact_method_description if contact_method_other? "Other – #{contact_method_other_details}" else human_enum_name(:contact_method_type) end end
Source
# File app/models/parent.rb, line 85 def contactable? email.present? || phone.present? end
Source
# File app/models/parent.rb, line 105 def email_delivery_status most_recent_notify_log_entry(:email, recipient: email)&.delivery_status end
Source
# File app/models/parent.rb, line 89 def label full_name.presence || "Parent or guardian (name unknown)" end
Source
# File app/models/parent.rb, line 109 def sms_delivery_status most_recent_notify_log_entry(:sms, recipient: phone)&.delivery_status end