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.159 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.158 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.157 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.156 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.155 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.153 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.152 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.151 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.149 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.148 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.147 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.146 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.145 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.144 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.143 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.142 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.141 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.140 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.139 app/models/renalware/admissions/admission_query.rb
renalware-core-2.0.138 app/models/renalware/admissions/admission_query.rb