Sha256: a4015525e9b31df9c13296731b56a2ee9fa51a45458b0cec55a017b35473d5ea

Contents?: true

Size: 719 Bytes

Versions: 10

Compression:

Stored size: 719 Bytes

Contents

require_dependency "renalware/clinics"

module Renalware
  module Events
    class EventQuery
      attr_reader :query, :patient

      def initialize(patient:, query: {})
        @query = query
        @patient = patient
        @query[:s] = "datetime DESC" if @query[:s].blank?
      end

      def call
        search.result.for_patient(patient)
                     .includes(:event_type)
                     .eager_load(:event_type)
                     .includes(:created_by)
                     .eager_load(:created_by)
                     .page(query[:page]).per(query[:per_page])
                     .ordered
      end

      def search
        @search ||= Event.ransack(query)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/events/event_query.rb
renalware-core-2.0.7 app/models/renalware/events/event_query.rb
renalware-core-2.0.5 app/models/renalware/events/event_query.rb
renalware-core-2.0.4 app/models/renalware/events/event_query.rb
renalware-core-2.0.3 app/models/renalware/events/event_query.rb
renalware-core-2.0.2 app/models/renalware/events/event_query.rb
renalware-core-2.0.1 app/models/renalware/events/event_query.rb
renalware-core-2.0.0 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/events/event_query.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/events/event_query.rb