Class: MalawiHivProgramReports::Pepfar::TbPrev2

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
app/services/malawi_hiv_program_reports/pepfar/tb_prev2.rb

Overview

Patients who started TPT just before the start of the current and have finished within the current reporting period.

Constant Summary

Constants included from Utils

Utils::COHORT_REGIMENS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#drug_refills_and_external_consultation_list, #patient_completed_tpt?, #patient_on_tb_treatment?, #pepfar_age_groups, #pepfar_patient_drilldown_information, #pepfar_patient_identifier_type

Constructor Details

#initialize(start_date:, end_date:, **_kwargs) ⇒ TbPrev2

Returns a new instance of TbPrev2.



13
14
15
16
# File 'app/services/malawi_hiv_program_reports/pepfar/tb_prev2.rb', line 13

def initialize(start_date:, end_date:, **_kwargs)
  @start_date = ActiveRecord::Base.connection.quote(start_date)
  @end_date = ActiveRecord::Base.connection.quote(end_date)
end

Instance Attribute Details

#end_dateObject (readonly)

Returns the value of attribute end_date.



9
10
11
# File 'app/services/malawi_hiv_program_reports/pepfar/tb_prev2.rb', line 9

def end_date
  @end_date
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



9
10
11
# File 'app/services/malawi_hiv_program_reports/pepfar/tb_prev2.rb', line 9

def start_date
  @start_date
end

Instance Method Details

#find_reportObject



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

def find_report
  report = init_report
  patients = group_patients_by_tpt_course(patients_on_tpt)

  load_patients_into_report(report, patients.six_h, '6H') do |patient|
    # 6H has a constant dosage of 1 pill per day
    patient['total_pills_taken'].to_i >= FULL_6H_COURSE_PILLS
  end

  load_patients_into_report(report, patients.three_hp, '3HP') do |patient|
    # 3HP daily dosages vary by patient weight can't use easily use pills
    # to determine course completion
    patient['total_days_on_medication'].days >= FULL_3HP_COURSE_DAYS
  end

  report
end