Sha256: 07dbfd0be7099c6c99689837ee422acb0dffb66ac8525f6cdcb3f4362c3cbc45

Contents?: true

Size: 845 Bytes

Versions: 21

Compression:

Stored size: 845 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)
            .eager_load(patient: [current_modality: :description])
            .public_send(query[:named_filter].to_s)
            .ransack(query)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
renalware-core-2.0.41 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.40 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.39 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.38 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.37 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.36 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.35 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.34 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.33 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.32 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.31 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.30 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.28 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.27 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.26 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.25 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.24 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.23 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.22 app/models/renalware/renal/aki_alert_query.rb
renalware-core-2.0.21 app/models/renalware/renal/aki_alert_query.rb