Class: MalawiHivProgramReports::Moh::CumulativeOutcome
- Inherits:
-
Object
- Object
- MalawiHivProgramReports::Moh::CumulativeOutcome
- Includes:
- Utils::CommonSqlQueryUtils
- Defined in:
- app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb
Overview
This is the Cumulative Cohort Builder class rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#prev_date ⇒ Object
readonly
Returns the value of attribute prev_date.
-
#rebuild ⇒ Object
readonly
Returns the value of attribute rebuild.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #find_report ⇒ Object
- #handle_tables ⇒ Object
-
#initialize(end_date:, definition: 'moh', **kwargs) ⇒ CumulativeOutcome
constructor
A new instance of CumulativeOutcome.
- #update_outcomes_by_definition ⇒ Object
Methods included from Utils::CommonSqlQueryUtils
#current_occupation_query, #external_client_query, #occupation_filter, #partition_by_site, #process_occupation
Constructor Details
#initialize(end_date:, definition: 'moh', **kwargs) ⇒ CumulativeOutcome
Returns a new instance of CumulativeOutcome.
11 12 13 14 15 16 17 18 19 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 11 def initialize(end_date:, definition: 'moh', **kwargs) start_date = kwargs[:start_date] || (end_date.to_date - 2.months).beginning_of_month @end_date = ActiveRecord::Base.connection.quote(end_date.to_date) @start_date = ActiveRecord::Base.connection.quote(start_date.to_date) @prev_date = ActiveRecord::Base.connection.quote((start_date.to_date - 3.months).to_date) @definition = definition @rebuild = kwargs[:rebuild] @location = kwargs[:location] end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 9 def definition @definition end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 9 def end_date @end_date end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 9 def location @location end |
#prev_date ⇒ Object (readonly)
Returns the value of attribute prev_date.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 9 def prev_date @prev_date end |
#rebuild ⇒ Object (readonly)
Returns the value of attribute rebuild.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 9 def rebuild @rebuild end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 9 def start_date @start_date end |
Instance Method Details
#find_report ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 21 def find_report [false, true].each do |start| clear_tables(start:) if rebuild update_steps(start:, portion: false) unless rebuild process_data(start:) end end |
#handle_tables ⇒ Object
38 39 40 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 38 def handle_tables prepare_tables end |
#update_outcomes_by_definition ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/services/malawi_hiv_program_reports/moh/cumulative_outcome.rb', line 29 def update_outcomes_by_definition [false, true].each do |start| update_steps(start:, portion: true) load_patients_on_treatment(start:) load_without_clinical_contact(start:) load_defaulters(start:) end end |