class GovukNotifyPersonalisation
Attributes
Public Class Methods
Source
# File app/lib/govuk_notify_personalisation.rb, line 14 def initialize( academic_year: nil, consent: nil, consent_form: nil, disease_types: nil, parent: nil, patient: nil, programme_types: nil, session: nil, team: nil, team_location: nil, vaccination_record: nil ) @academic_year = academic_year || consent&.academic_year || consent_form&.academic_year || session&.academic_year || vaccination_record&.academic_year || AcademicYear.pending @consent = consent @consent_form = consent_form @parent = parent || consent&.parent @patient = patient || consent&.patient || vaccination_record&.patient || Patient.find_by(id: consent_form&.matched_patient&.id) @session = session || consent_form&.session || vaccination_record&.session @team = team || session&.team || team_location&.team || consent_form&.team || consent&.team || vaccination_record&.team @team_location = session&.team_location || consent_form&.team_location || team_location @subteam = session&.subteam || team_location&.subteam || consent_form&.subteam || vaccination_record&.subteam @vaccination_record = vaccination_record @programmes = if programme_types.present? Programme.find_all(programme_types, disease_types:, patient: @patient) else consent_form&.programmes || [consent&.programme || vaccination_record&.programme].compact end end
Public Instance Methods
Source
# File app/lib/govuk_notify_personalisation.rb, line 171 def consent_details_presenter @consent_details_presenter ||= ConsentDetailsPresenter.new(self) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 117 def full_and_preferred_patient_name (consent_form || patient).full_name_with_known_as(context: :parents) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 121 def host if Rails.env.local? "http://localhost:4000" else "https://#{Settings.give_or_refuse_consent_host}" end end
Source
# File app/lib/govuk_notify_personalisation.rb, line 131 def location_name if vaccination_record vaccination_record_location(vaccination_record) else session&.location&.name end end
Source
# File app/lib/govuk_notify_personalisation.rb, line 179 def mmr_details_presenter @mmr_details_presenter ||= MmrDetailsPresenter.new(self) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 129 def outbreak? = session&.outbreak? def location_name if vaccination_record vaccination_record_location(vaccination_record) else session&.location&.name end end def patient_date_of_birth patient&.date_of_birth&.to_fs(:long) end def short_patient_name (consent_form || patient)&.short_name end def short_patient_name_apos apos = "’" apos += "s" unless short_patient_name.ends_with?("s") short_patient_name + apos end def subteam_email = (subteam || team).email def subteam_name = (subteam || team).name def subteam_phone format_phone_with_instructions(subteam || team) end private def session_dates_are_accurate? consent_form ? consent_form.session_dates_are_accurate? : true end def session_dates_presenter @session_dates_presenter ||= SessionDatesPresenter.new(self) end def consent_details_presenter @consent_details_presenter ||= ConsentDetailsPresenter.new(self) end def vaccination_details_presenter @vaccination_details_presenter ||= VaccinationDetailsPresenter.new(self) end def mmr_details_presenter @mmr_details_presenter ||= MmrDetailsPresenter.new(self) end def triage_details_presenter @triage_details_presenter ||= TriageDetailsPresenter.new(self)
Source
# File app/lib/govuk_notify_personalisation.rb, line 139 def patient_date_of_birth patient&.date_of_birth&.to_fs(:long) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 163 def session_dates_are_accurate? consent_form ? consent_form.session_dates_are_accurate? : true end
Source
# File app/lib/govuk_notify_personalisation.rb, line 167 def session_dates_presenter @session_dates_presenter ||= SessionDatesPresenter.new(self) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 143 def short_patient_name (consent_form || patient)&.short_name end
Source
# File app/lib/govuk_notify_personalisation.rb, line 147 def short_patient_name_apos apos = "’" apos += "s" unless short_patient_name.ends_with?("s") short_patient_name + apos end
Source
# File app/lib/govuk_notify_personalisation.rb, line 153 def subteam_email = (subteam || team).email def subteam_name = (subteam || team).name def subteam_phone format_phone_with_instructions(subteam || team) end private def session_dates_are_accurate? consent_form ? consent_form.session_dates_are_accurate? : true end def session_dates_presenter @session_dates_presenter ||= SessionDatesPresenter.new(self) end def consent_details_presenter @consent_details_presenter ||= ConsentDetailsPresenter.new(self) end def vaccination_details_presenter @vaccination_details_presenter ||= VaccinationDetailsPresenter.new(self) end def mmr_details_presenter @mmr_details_presenter ||= MmrDetailsPresenter.new(self) end def triage_details_presenter @triage_details_presenter ||= TriageDetailsPresenter.new(self) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 155 def subteam_name = (subteam || team).name def subteam_phone format_phone_with_instructions(subteam || team) end private def session_dates_are_accurate? consent_form ? consent_form.session_dates_are_accurate? : true end def session_dates_presenter @session_dates_presenter ||= SessionDatesPresenter.new(self) end def consent_details_presenter @consent_details_presenter ||= ConsentDetailsPresenter.new(self) end def vaccination_details_presenter @vaccination_details_presenter ||= VaccinationDetailsPresenter.new(self) end def mmr_details_presenter @mmr_details_presenter ||= MmrDetailsPresenter.new(self) end def triage_details_presenter @triage_details_presenter ||= TriageDetailsPresenter.new(self) end end
Source
# File app/lib/govuk_notify_personalisation.rb, line 157 def subteam_phone format_phone_with_instructions(subteam || team) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 183 def triage_details_presenter @triage_details_presenter ||= TriageDetailsPresenter.new(self) end
Source
# File app/lib/govuk_notify_personalisation.rb, line 175 def vaccination_details_presenter @vaccination_details_presenter ||= VaccinationDetailsPresenter.new(self) end