Class: MalawiHivProgramReports::Clinic::HypertensionReport

Inherits:
Object
  • Object
show all
Defined in:
app/services/malawi_hiv_program_reports/clinic/hypertension_report.rb

Overview

Generates a hypertension report for a clinic rubocop:disable Metrics/ClassLength

Constant Summary collapse

AGE_GROUPS =
[
  '20-24 years',
  '25-29 years', '30-34 years',
  '35-39 years', '40-44 years',
  '45-49 years', '50-54 years',
  '55-59 years', '60-64 years',
  '65-69 years', '70-74 years',
  '75-79 years', '80-84 years',
  '85-89 years',
  '90 plus years'
].freeze
GENDER =
%w[M F].freeze
DRUG_MAPPING =
{
  'Hydrochlorothiazide (25mg tablet)' => :hydrochlorothiazide_25mg,
  'HCZ (25mg tablet)' => :hydrochlorothiazide_25mg,
  'Hctz (25mg)' => :hydrochlorothiazide_25mg,
  'Amlodipine (5mg tablet)' => :amlodipine_5mg,
  'Amlodipine 5mg' => :amlodipine_5mg,
  'Amlodipine (5mg)' => :amlodipine_5mg,
  'Amlodipine (10mg tablet)' => :amlodipine_10mg,
  'Enalapril (5mg tablet)' => :enalapril_5mg,
  'Enalapril (5mg)' => :enalapril_5mg,
  'Enalapril (10mg tablet)' => :enalapril_10mg,
  'Enalapril (10mg)' => :enalapril_10mg,
  'Atenolol (50mg tablet)' => :atenolol_50mg,
  'Atenolol (50mg)' => :atenolol_50mg,
  'Atenolol (100mg tablet)' => :atenolol_100mg
}.freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HypertensionReport.



39
40
41
42
# File 'app/services/malawi_hiv_program_reports/clinic/hypertension_report.rb', line 39

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 Method Details

#find_reportObject



44
45
46
47
48
49
50
51
52
# File 'app/services/malawi_hiv_program_reports/clinic/hypertension_report.rb', line 44

def find_report
  @report = init_report
  process_data
  @report
rescue StandardError => e
  puts e.message
  puts e.backtrace.join("\n")
  raise e
end