Class: MalawiHivProgramReports::Clinic::ViralLoadDisaggregated
- Inherits:
-
Object
- Object
- MalawiHivProgramReports::Clinic::ViralLoadDisaggregated
- Defined in:
- app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #find_report ⇒ Object
-
#initialize(start_date:, end_date:, from: nil, to: nil, **_kwargs) ⇒ ViralLoadDisaggregated
constructor
A new instance of ViralLoadDisaggregated.
Constructor Details
#initialize(start_date:, end_date:, from: nil, to: nil, **_kwargs) ⇒ ViralLoadDisaggregated
Returns a new instance of ViralLoadDisaggregated.
8 9 10 11 12 13 |
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb', line 8 def initialize(start_date:, end_date:, from: nil, to: nil, **_kwargs) @start_date = start_date.to_date @end_date = end_date.to_date @from = from&.to_f @to = to&.to_f end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
6 7 8 |
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb', line 6 def end_date @end_date end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb', line 6 def from @from end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
6 7 8 |
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb', line 6 def start_date @start_date end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb', line 6 def to @to end |
Instance Method Details
#find_report ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load_disaggregated.rb', line 15 def find_report patients.each_with_object({}) do |patient, report| age_group = find_age_group(patient.birthdate) regimen = patient.regimen&.upcase report[age_group] ||= {} if report[age_group].include?(regimen) report[age_group][regimen] += 1 else report[age_group][regimen] = 1 end end end |