Class: MalawiHivProgramReports::Cohort::Outcomes

Inherits:
Object
  • Object
show all
Includes:
Adapters::Moh::Custom, Utils::ModelUtils
Defined in:
app/services/malawi_hiv_program_reports/cohort/outcomes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::ModelUtils

#concept, #concept_id_to_name, #concept_name, #concept_name_to_id, #drug, #encounter_type, #global_property, #order_type, #patient_identifier_type, #program, #report_type, #user_property

Methods included from Adapters::Moh::Custom

#cast_manager, #current_partition, #exe_create_drill_down_table, #exe_temp_cohort_members_table, #exe_temp_order_details_table, #exe_temp_other_patient_types, #exe_temp_register_start_date_table, #exe_tmp_patient_table, #function_manager, #group_by_columns, #in_manager, #interval_manager, #min_filt, #site_manager, #timestampdiff_manager

Constructor Details

#initialize(end_date:, definition: 'moh', location: nil) ⇒ Outcomes

Returns a new instance of Outcomes.

Raises:

  • (::ArgumentError)


10
11
12
13
14
15
16
17
18
# File 'app/services/malawi_hiv_program_reports/cohort/outcomes.rb', line 10

def initialize(end_date:, definition: 'moh', location: nil)
  definition = definition.downcase
  raise ::ArgumentError, "Invalid outcomes definition: #{definition}" unless %w[moh pepfar].include?(definition)

  @adapter = ActiveRecord::Base.connection.adapter_name.downcase
  @end_date = end_date.to_date
  @definition = definition
  @location = location
end

Instance Attribute Details

#end_dateObject (readonly)

Returns the value of attribute end_date.



8
9
10
# File 'app/services/malawi_hiv_program_reports/cohort/outcomes.rb', line 8

def end_date
  @end_date
end

Instance Method Details

#update_cummulative_outcomesObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/malawi_hiv_program_reports/cohort/outcomes.rb', line 20

def update_cummulative_outcomes
  initialize_table
  create_tmp_max_drug_orders
  create_tmp_min_auto_expire_date

  # HIC SUNT DRACONIS: The order of the operations below matters,
  # do not change it unless you know what you are doing!!!
  load_patients_who_died
  load_patients_who_stopped_treatment
  load_patients_on_pre_art
  load_patients_without_state
  load_patients_without_drug_orders
  load_patients_on_treatment
  load_defaulters
end