Class: MalawiHivProgramReports::Pepfar::ViralLoadCoverage

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

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 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(**params) ⇒ ViralLoadCoverage

Returns a new instance of ViralLoadCoverage.

Raises:

  • (::InvalidParameterError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/malawi_hiv_program_reports/pepfar/viral_load_coverage.rb', line 10

def initialize(**params)
  @start_date = params[:start_date]&.to_date
  raise ::InvalidParameterError, 'start_date is required' unless @start_date

  @end_date = params[:end_date]&.to_date || (@start_date + 12.months)
  raise ::InvalidParameterError, "start_date can't be greater than end_date" if @start_date > @end_date

  @tx_curr_definition = params.fetch(:tx_curr_definition, 'pepfar')&.downcase
  unless %w[moh pepfar].include?(@tx_curr_definition)
    raise ::InvalidParameterError, "tx_curr_definition can only moh or pepfar not #{@tx_curr_definition}"
  end

  @rebuild_outcomes = params.fetch(:rebuild_outcomes, 'true')&.casecmp?('true')
  @type = params.fetch(:application, 'poc')
end

Instance Attribute Details

#end_dateObject (readonly)

Returns the value of attribute end_date.



6
7
8
# File 'app/services/malawi_hiv_program_reports/pepfar/viral_load_coverage.rb', line 6

def end_date
  @end_date
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



6
7
8
# File 'app/services/malawi_hiv_program_reports/pepfar/viral_load_coverage.rb', line 6

def start_date
  @start_date
end

Instance Method Details

#find_reportObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/services/malawi_hiv_program_reports/pepfar/viral_load_coverage.rb', line 26

def find_report
  report = init_report

  case @type
  when /poc/i then build_poc_report(report)
  when /emastercard/i then build_emastercard_report(report)
  else raise ::InvalidParameterError, "Report type must be one of [poc, emastercard] not #{@type}"
  end

  report
end

#vl_maternal_status(patient_list) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'app/services/malawi_hiv_program_reports/pepfar/viral_load_coverage.rb', line 38

def vl_maternal_status(patient_list)
  pregnant = pregnant_women(patient_list).map { |woman| woman['person_id'].to_i }
  feeding = breast_feeding(patient_list - pregnant).map { |woman| woman['person_id'].to_i }

  {
    FP: pregnant,
    FBf: feeding
  }
end