class Notifier::Patient
Constants
- CONSENT_REMINDER_TYPES
Public Class Methods
Source
# File app/lib/notifier/patient.rb, line 8 def initialize(patient) @patient = patient end
Public Instance Methods
Source
# File app/lib/notifier/patient.rb, line 69 def can_send_clinic_invitation?( programmes, team:, academic_year:, include_vaccinated_programmes: false, include_already_invited_programmes: true ) return false unless send_notification?(team:) programmes_to_send_for = programmes_to_send_clinic_invitation_for( programmes, team:, academic_year:, include_vaccinated_programmes:, include_already_invited_programmes: ) programmes_to_send_for.present? end
Determine whether a clinic invitation can be sent to the parents of this patient.
Normally this would be true, but it can be false in some scenarios, for example, if the patient has no parent contact details or has already been invited to the clinic.
Source
# File app/lib/notifier/patient.rb, line 15 def can_send_consent_request?(programmes, academic_year:) programmes.any? do |programme| programme_status = patient.programme_status(programme, academic_year:) programme_status.needs_consent_no_response? || programme_status.needs_consent_request_scheduled? || programme_status.needs_consent_request_not_scheduled? end end
Determine whether a consent request can be sent to the parents of this patient.
Source
# File app/lib/notifier/patient.rb, line 103 def send_clinic_invitation( programmes, team:, academic_year:, sent_by:, include_vaccinated_programmes: false, include_already_invited_programmes: true ) return unless send_notification?(team:) programmes_to_send_for = programmes_to_send_clinic_invitation_for( programmes, team:, academic_year:, include_vaccinated_programmes:, include_already_invited_programmes: ) return if programmes_to_send_for.empty? type = if patient.invited_to_clinic?( programmes_to_send_for, team:, academic_year: ) :subsequent_invitation else :initial_invitation end programme_types = programmes_to_send_for.map(&:type) clinic_notification = ClinicNotification.create!( patient:, programme_types:, team:, academic_year:, type:, sent_at: Time.current, sent_by: ) template_name = find_clinic_template_name(type, team:) params = { academic_year:, patient:, programme_types:, sent_by:, team: } parents.each do |parent| EmailDeliveryJob.perform_later(template_name, parent:, **params) SMSDeliveryJob.perform_later(template_name, parent:, **params) end clinic_notification end
Send a clinic initiation email and SMS to the parents of this patient.
This determines the correct type of invitation to use (either an initial invitation or a subsequent invitation) based on the previous invitations which have been sent:
include_vaccinated_programmes allows for the sending of invitations for programmes where the patient has already been vaccinated.
include_already_invited_programmes allows for the sending of invitations for programmes where the patient has already been invited for in the past.
Source
# File app/lib/notifier/patient.rb, line 47 def send_consent_reminder(programmes, session:, sent_by:) already_sent_initial_reminder = programmes.all? do |programme| patient .consent_notifications .select { it.programmes.include?(programme) } .any?(&:initial_reminder?) end type = already_sent_initial_reminder ? :subsequent_reminder : :initial_reminder send_consent_notification(programmes, type:, session:, sent_by:) end
Send a consent reminder email and SMS to the parents of this patient.
This determines whether to send the initial reminder or subsequent reminder based on what has already been sent to this patient.
Source
# File app/lib/notifier/patient.rb, line 27 def send_consent_request( programmes, sent_by:, session: nil, team_location: nil ) send_consent_notification( programmes, type: :request, sent_by:, session:, team_location: ) end
Send a consent request email and SMS to the parents of this patient.