Class: Renalware::Patients::WorryQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/patients/worry_query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_params) ⇒ WorryQuery

Returns a new instance of WorryQuery.



10
11
12
13
# File 'app/models/renalware/patients/worry_query.rb', line 10

def initialize(query_params)
  @query_params = query_params
  @query_params[:s] = "date_time DESC" if @query_params[:s].blank?
end

Instance Attribute Details

#query_paramsObject (readonly)

Returns the value of attribute query_params.



8
9
10
# File 'app/models/renalware/patients/worry_query.rb', line 8

def query_params
  @query_params
end

Instance Method Details

#callObject



15
16
17
18
19
20
# File 'app/models/renalware/patients/worry_query.rb', line 15

def call
  search
    .result
    .includes(:created_by, patient: { current_modality: [:description] })
    .order(created_at: :asc)
end

#searchObject



22
23
24
# File 'app/models/renalware/patients/worry_query.rb', line 22

def search
  @search ||= Worry.ransack(query_params)
end