Sha256: 2c1c00efc98be2cfec01fd93a209f4ba98bb2aa2d49f69db24c43060457e3752

Contents?: true

Size: 942 Bytes

Versions: 35

Compression:

Stored size: 942 Bytes

Contents

require_dependency "renalware/clinics"

module Renalware
  module Clinics
    class AppointmentsController < BaseController
      include Renalware::Concerns::Pageable

      def index
        appointments_query = AppointmentQuery.new(query_params)
        appointments = appointments_query.call.page(page).per(per_page)
        authorize appointments

        render :index, locals: {
          appointments: appointments,
          query: appointments_query.search,
          clinics: Clinic.ordered,
          users: User.ordered,
          request_html_form_params: build_params_for_html_form(appointments)
        }
      end

      private

      def build_params_for_html_form(appointments)
        OpenStruct.new(
          patient_ids: appointments.map(&:patient_id).uniq
        )
      end

      def query_params
        params
          .fetch(:q, {})
          .merge(page: page, per_page: per_page)
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.15 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.14 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.13 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.12 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.11 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.9 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.8 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.7 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.5 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.4 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.3 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.2 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.1 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.0 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/clinics/appointments_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/clinics/appointments_controller.rb