def register
attendance_record =
@patient.attendance_records.find_or_initialize_by(
location: @session.location,
date: Date.current
)
attendance_record.session = @session
authorize attendance_record, :create?
ActiveRecord::Base.transaction do
attendance_record.update!(attending: params[:status] == "present")
PatientStatusUpdater.call(patient: @patient)
end
name = @patient.full_name
flash[:info] = if attendance_record.attending?
t("attendance_flash.present", name:)
else
t("attendance_flash.absent", name:)
end
redirect_to session_patients_path(@session)
end