app/controllers/community/appointments_controller.rb
# Schedules appointment
# rubocop:disable Metrics/AbcSize
Schedules appointment
rubocop:disable Metrics/AbcSize
Schedules appointment rubocop : disable Metrics / AbcSize
def index
      appointment_can_cancel_and_reschedule
      ubs_id = Appointment.where(id: current_patient.doses.pick(:appointment_id)).pick(:ubs_id)
      ubs_id = allowed_ubs_ids if ubs_id.blank?
      @days = parse_days
      @appointments = scheduler.open_times_per_ubs(from: @days.days.from_now.beginning_of_day,
                                                   to: @days.days.from_now.end_of_day,
                                                   filter_ubs_id: ubs_id)
                               .sort_by { |ubs, _appointments| ubs.name }
    rescue AppointmentScheduler::NoFreeSlotsAhead
      redirect_to home_community_appointments_path, flash: { alert: 'Não há vagas disponíveis para reagendamento.' }
    rescue CannotCancelAndReschedule
      redirect_to home_community_appointments_path, flash: { alert: 'Você não pode cancelar ou reagendar.' }
    end
def index appointment_can_cancel_and_reschedule ubs_id = Appointment . where ( id : current_patient . doses . pick ( :appointment_id ) ) . pick ( :ubs_id ) ubs_id = allowed_ubs_ids if ubs_id . blank? @days = parse_days @appointments = scheduler . open_times_per_ubs ( from : @days . days . from_now . beginning_of_day , to : @days . days . from_now . end_of_day , filter_ubs_id : ubs_id ) . sort_by { | ubs , _appointments | ubs . name } rescue AppointmentScheduler :: NoFreeSlotsAhead redirect_to home_community_appointments_path , flash : { alert : 'Não há vagas disponíveis para reagendamento.' } rescue CannotCancelAndReschedule redirect_to home_community_appointments_path , flash : { alert : 'Você não pode cancelar ou reagendar.' } end
Schedules appointment
rubocop:disable Metrics/AbcSize
Schedules appointment rubocop : disable Metrics / AbcSize
# If patient already had a dose, keep it in the same UBS. # This is an optimized query, hence a little odd using +pick+s. # Otherwise limit to where they can schedule