Sha256: 359ba062c63ddf961ca4b35aa578a402330370a02a194429fc92c429891ed755

Contents?: true

Size: 762 Bytes

Versions: 93

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/clinics"

module Renalware
  module Clinics
    class AppointmentQuery
      attr_reader :appointments, :query

      def initialize(q = {})
        @q = q
        @q[:s] = "starts_at ASC" if @q[:s].blank?
      end

      def call
        search.result.includes(:user, :clinic, patient: [current_modality: [:description]])
      end

      def search
        @search ||= QueryableAppointment.ransack(@q)
      end

      class QueryableAppointment < ActiveType::Record[Appointment]
        ransacker :starts_at, type: :date do
          Arel.sql("DATE(starts_at)")
        end

        ransacker :start_time, type: :datetime do
          Arel.sql("starts_at")
        end
      end
    end
  end
end

Version data entries

93 entries across 93 versions & 1 rubygems

Version Path
renalware-core-2.0.109 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.108 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.106 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.105 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.104 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.103 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.102 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.101 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.100 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.99 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.98 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.97 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.96 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.95 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.94 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.93 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.92 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.91 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.90 app/models/renalware/clinics/appointment_query.rb
renalware-core-2.0.89 app/models/renalware/clinics/appointment_query.rb