Sha256: 5d10e457cb2b99fefe8d3bbcd96cd9f33b17ea4acda90ff52e991e2b8b2ca2bf

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/clinics"

module Renalware
  module Renal
    class AKIAlertQuery
      DEFAULT_SORT = "aki_date :desc"
      attr_reader :query

      def initialize(query = nil)
        @query = query || {}
        @query[:s] = DEFAULT_SORT if @query[:s].blank?
      end

      def self.call(query)
        new(query).call
      end

      def call
        search.result
      end

      def search
        @search ||= begin
          AKIAlert
            .joins(:patient) # required for PatientsRansackHelper - see Admission
            .includes(:patient, :updated_by, :action, hospital_ward: :hospital_unit)
            .ransack(query)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
renalware-core-2.0.13 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.12 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.11 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.9 app/models/renalware/renal/aki_alert_query.rb