Class: Renalware::Transplants::Registrations::WaitListQuery
- Inherits:
-
Object
- Object
- Renalware::Transplants::Registrations::WaitListQuery
- Defined in:
- app/models/renalware/transplants/registrations/wait_list_query.rb
Defined Under Namespace
Modules: Scopes Classes: QueryableRegistration
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(named_filter:, ukt_recipient_number: nil, q: nil) ⇒ WaitListQuery
constructor
A new instance of WaitListQuery.
- #search ⇒ Object
Constructor Details
#initialize(named_filter:, ukt_recipient_number: nil, q: nil) ⇒ WaitListQuery
Returns a new instance of WaitListQuery.
9 10 11 12 13 |
# File 'app/models/renalware/transplants/registrations/wait_list_query.rb', line 9 def initialize(named_filter:, ukt_recipient_number: nil, q: nil) @named_filter = named_filter&.to_sym || :active @q = (q || ActionController::Parameters.new).permit(:s, :q) @ukt_recipient_number = ukt_recipient_number end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/models/renalware/transplants/registrations/wait_list_query.rb', line 15 def call search .result .extending(Scopes) .apply_filter(named_filter) .having_ukt_recipient_number(ukt_recipient_number) end |
#search ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/renalware/transplants/registrations/wait_list_query.rb', line 23 def search @search ||= begin query = query_for_filter(named_filter).merge(q) QueryableRegistration .eager_load(patient: [current_modality: :description]) .eager_load(current_status: :description) .merge(HD::Patient.with_profile) .merge(Renal::Patient.with_profile) .ransack(query).tap do |s| s.sorts = ["patient_family_name, patient_given_name"] end end end |