Class: Renalware::Renal::Registry::PreflightChecks::DeathsQuery

Inherits:
Object
  • Object
show all
Includes:
ModalityScopes
Defined in:
app/models/renalware/renal/registry/preflight_checks/deaths_query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModalityScopes

#with_current_modality_matching, #with_current_modality_of_class

Constructor Details

#initialize(relation: nil, query_params: {}) ⇒ DeathsQuery

Returns a new instance of DeathsQuery.



14
15
16
17
18
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 14

def initialize(relation: nil, query_params: {})
  @relation = relation || default_relation
  @query_params = query_params
  @query_params[:s] = "modality_descriptions_name ASC" if @query_params[:s].blank?
end

Instance Attribute Details

#query_paramsObject (readonly)

Returns the value of attribute query_params.



12
13
14
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 12

def query_params
  @query_params
end

#relationObject (readonly)

Returns the value of attribute relation.



12
13
14
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 12

def relation
  @relation
end

Class Method Details

.missing_data_for(_patient) ⇒ Object



37
38
39
40
41
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 37

def self.missing_data_for(_patient)
  [
    :cause_of_death
  ]
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 24

def call
  search
    .result
    .extending(ModalityScopes)
    .preload(current_modality: [:description])
    .with_current_modality_of_class(Renalware::Deaths::ModalityDescription)
    .where("patients.first_cause_id is NULL AND renal_profiles.esrf_on IS NOT NULL")
end

#default_relationObject



20
21
22
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 20

def default_relation
  Renalware::Renal::Patient.left_outer_joins(:profile)
end

#searchObject



33
34
35
# File 'app/models/renalware/renal/registry/preflight_checks/deaths_query.rb', line 33

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