Sha256: 60fc2ee44ca34dd0b34dfe3e74c81dd97bd044eff2c30a7604241ce9a837d902

Contents?: true

Size: 878 Bytes

Versions: 10

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/admissions"

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

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/admissions/admission_query.rb
renalware-core-2.1.0 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.167 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.166 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.165 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.164 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.163 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.162 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.161 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.160 app/models/renalware/admissions/admission_query.rb