Class: Renalware::HD::PatientsWithUnmetPreferencesQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/hd/patients_with_unmet_preferences_query.rb

Defined Under Namespace

Modules: Scopes

Instance Method Summary collapse

Constructor Details

#initialize(query = {}) ⇒ PatientsWithUnmetPreferencesQuery

Returns a new instance of PatientsWithUnmetPreferencesQuery.



8
9
10
# File 'app/models/renalware/hd/patients_with_unmet_preferences_query.rb', line 8

def initialize(query = {})
  @query = query
end

Instance Method Details

#callObject



12
13
14
# File 'app/models/renalware/hd/patients_with_unmet_preferences_query.rb', line 12

def call
  search.result
end

#searchObject



16
17
18
19
20
21
22
23
24
25
# File 'app/models/renalware/hd/patients_with_unmet_preferences_query.rb', line 16

def search
  HD::Patient
    .extend(Scopes)
    .includes(hd_profile: :hospital_unit)
    .includes(hd_preference_set: :hospital_unit)
    .eager_load(:hd_profile)
    .eager_load(:hd_preference_set)
    .having_an_unmet_preference
    .ransack(query)
end