Sha256: 3b33ba14bae2890b0786e6ce6b8a0d1aecd83bdbde9b6e8767add937cf97340c

Contents?: true

Size: 900 Bytes

Versions: 139

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/admissions"
require "attr_extras"

module Renalware
  module Admissions
    class AdmissionQuery
      pattr_initialize :query

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

      def call
        search.result
      end

      def search
        @search ||= begin
          Admission
            .extending(Scopes)
            .joins(:patient) # required for PatientsRansackHelper - see Admission
            .includes(
              hospital_ward: [:hospital_unit],
              patient: { current_modality: [:description] }
            )
            .order(created_at: :desc)
            .ransack(query)
        end
      end

      module Scopes
        def ransackable_scopes(_auth_object = nil)
          %i(currently_admitted discharged_but_missing_a_summary identity_match)
        end
      end
    end
  end
end

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
renalware-core-2.0.74 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.73 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.72 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.71 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.70 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.69 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.68 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.67 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.64 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.63 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.62 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.61 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.60 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.58 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.57 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.56 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.55 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.54 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.53 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.52 app/models/renalware/admissions/admission_query.rb