Class: MalawiHivProgramReports::Pepfar::RegimenSwitch

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

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

Constructor Details

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

Returns a new instance of RegimenSwitch.



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

def initialize(start_date:, end_date:, **kwargs)
  @start_date = start_date
  @end_date = end_date
  @occupation = kwargs[:occupation]
  @location = kwargs[:location]
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



10
11
12
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 10

def end_date
  @end_date
end

#locationObject

Returns the value of attribute location.



10
11
12
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 10

def location
  @location
end

#occupationObject

Returns the value of attribute occupation.



10
11
12
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 10

def occupation
  @occupation
end

#start_dateObject

Returns the value of attribute start_date.



10
11
12
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 10

def start_date
  @start_date
end

Instance Method Details

#find_reportObject



19
20
21
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 19

def find_report
  regimen_switch('pepfar')
end

#latest_regimen_dispensed(rebuild_outcome) ⇒ Object



33
34
35
36
37
38
39
40
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 33

def latest_regimen_dispensed(rebuild_outcome)
  if rebuild_outcome || @occupation.present?
    MalawiHivProgramReports::Moh::CohortBuilder.new(outcomes_definition: 'moh', location: @location)
                                      .init_temporary_tables(@start_date, @end_date, @occupation)
  end

  latest_regimens
end

#regimen_report(type) ⇒ Object



27
28
29
30
31
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 27

def regimen_report(type)
  MalawiHivProgramReports::Clinic::RegimenDispensationData.new(type: type, start_date: @start_date,
                                                   end_date: @end_date, occupation: @occupation, location: @location)
                                              .find_report
end

#regimen_switch(pepfar) ⇒ Object



23
24
25
# File 'app/services/malawi_hiv_program_reports/pepfar/regimen_switch.rb', line 23

def regimen_switch(pepfar)
  swicth_report(pepfar)
end