Class: MalawiHivProgramReports::Pepfar::TxTb

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

Overview

TxTb report rubocop:disable Metrics/ClassLength

Constant Summary

Constants included from Utils

Utils::COHORT_REGIMENS, Utils::FULL_3HP_COURSE_DAYS, Utils::FULL_6H_COURSE_PILLS

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Methods included from Utils

#drug_refills_and_external_consultation_list, #isoniazid_rifapentine_concept, #patient_completed_tpt?, #patient_on_3hp?, #patient_on_tb_treatment?, #pepfar_age_groups, #pepfar_patient_drilldown_information, #pepfar_patient_identifier_type, #rifapentine_concept

Constructor Details

#initialize(start_date:, end_date:, **kwargs) ⇒ TxTb

Returns a new instance of TxTb.



13
14
15
16
17
18
19
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 13

def initialize(start_date:, end_date:, **kwargs)
  @start_date = start_date.to_date.strftime('%Y-%m-%d 00:00:00')
  @end_date = end_date.to_date.strftime('%Y-%m-%d 23:59:59')
  @rebuild_outcome = ActiveModel::Type::Boolean.new.cast(kwargs[:rebuild_outcome]) || false
  @occupation = kwargs[:occupation]
  @location = kwargs[:location]
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



8
9
10
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 8

def end_date
  @end_date
end

#rebuild_outcomeObject

Returns the value of attribute rebuild_outcome.



8
9
10
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 8

def rebuild_outcome
  @rebuild_outcome
end

#reportObject

Returns the value of attribute report.



8
9
10
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 8

def report
  @report
end

#start_dateObject

Returns the value of attribute start_date.



8
9
10
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 8

def start_date
  @start_date
end

Instance Method Details

#find_reportObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 21

def find_report
  init_report
  build_cohort_tables
  process_patients_alive_and_on_art
  process_tb_screened
  process_tb_confirmed
  flatten_the_report
rescue StandardError => e
  Rails.logger.error("Error generating TxTb report: #{e.message}")
  Rails.logger.error(e.backtrace.join("\n"))
  raise e
end

#process_tb_dataObject



34
35
36
37
38
# File 'app/services/malawi_hiv_program_reports/pepfar/tx_tb.rb', line 34

def process_tb_data
  delete_patients_in_temp_table
  process_tb_screening
  process_tb_confirmed_and_on_treatment
end