Sha256: c180218e8f8819e3c293c96613ab73f03bf815e6561b2d5ebd40670c99501e63

Contents?: true

Size: 715 Bytes

Versions: 8

Compression:

Stored size: 715 Bytes

Contents

require_dependency "renalware/clinics"

module Renalware
  module Clinics
    class VisitQuery
      attr_reader :visits, :query

      def initialize(q = {})
        @q = q
        @q[:s] = "date DESC" unless @q[:s].present?
      end

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

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

      class QueryableVisit < ActiveType::Record[ClinicVisit]
        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

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/clinics/visit_query.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/clinics/visit_query.rb