Class: MalawiHivProgramReports::Clinic::ViralLoad

Inherits:
Object
  • Object
show all
Includes:
Utils::CommonSqlQueryUtils, Utils::ModelUtils
Defined in:
app/services/malawi_hiv_program_reports/clinic/viral_load.rb

Instance Method Summary collapse

Methods included from Utils::ModelUtils

#concept, #concept_id_to_name, #concept_name, #concept_name_to_id, #drug, #encounter_type, #global_property, #order_type, #patient_identifier_type, #program, #report_type, #user_property

Methods included from Utils::CommonSqlQueryUtils

#current_occupation_query, #external_client_query, #occupation_filter, #partition_by_site, #process_occupation

Constructor Details

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

Returns a new instance of ViralLoad.



9
10
11
12
13
14
15
16
17
18
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load.rb', line 9

def initialize(start_date:, end_date:, **kwargs)
  @start_date = start_date.to_date.strftime('%Y-%m-%d 00:00:00')
  @end_date = end_date.to_date.strftime('%Y-%m-%d 23:59:59')
  @program = ::Program.find_by_name 'HIV PROGRAM'
  @possible_milestones = possible_milestones
  @use_filing_number = ::GlobalProperty.find_by(property: 'use.filing.numbers')
                                       &.property_value
                                       &.casecmp?('true')
  @occupation = kwargs[:occupation]
end

Instance Method Details

#clients_dueObject



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

def clients_due
  clients = potential_get_clients
  return [] if clients.blank?

  clients_due_list = []

  clients.each do |person|
    vl_details = get_vl_due_details(person) # person[:patient_id], person[:appointment_date], person[:start_date])
    next if vl_details.blank?

    clients_due_list << vl_details
  end

  clients_due_list
end

#vl_resultsObject



36
37
38
# File 'app/services/malawi_hiv_program_reports/clinic/viral_load.rb', line 36

def vl_results
  read_results
end