Class: MalawiHivProgramReports::Clinic::RegimensAndFormulations
- Inherits:
-
Object
- Object
- MalawiHivProgramReports::Clinic::RegimensAndFormulations
- Includes:
- Utils::CommonSqlQueryUtils
- Defined in:
- app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#formulation ⇒ Object
readonly
Returns the value of attribute formulation.
-
#regimen ⇒ Object
readonly
Returns the value of attribute regimen.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #find_report ⇒ Object
-
#initialize(start_date:, end_date:, regimen: nil, formulation: 'tablets', **kwargs) ⇒ RegimensAndFormulations
constructor
A new instance of RegimensAndFormulations.
- #patients ⇒ Object
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:, regimen: nil, formulation: 'tablets', **kwargs) ⇒ RegimensAndFormulations
Returns a new instance of RegimensAndFormulations.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 11 def initialize(start_date:, end_date:, regimen: nil, formulation: 'tablets', **kwargs) raise ::InvalidParameterError, 'regimen is required' unless regimen unless %w[granules tablets pellets].include?(formulation) raise ::InvalidParameterError, "Invalid formalation: #{formulation}" end @start_date = start_date.to_date @end_date = end_date.to_date @formulation = formulation @regimen = regimen @occupation = kwargs[:occupation] end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 9 def end_date @end_date end |
#formulation ⇒ Object (readonly)
Returns the value of attribute formulation.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 9 def formulation @formulation end |
#regimen ⇒ Object (readonly)
Returns the value of attribute regimen.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 9 def regimen @regimen end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
9 10 11 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 9 def start_date @start_date end |
Instance Method Details
#find_report ⇒ Object
25 26 27 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 25 def find_report patients end |
#patients ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/malawi_hiv_program_reports/clinic/regimens_and_formulations.rb', line 29 def patients patients_with_prescriptions.each_with_object([]) do |patient, matching_patients| prescribed_drugs = drugs_prescribed_to_patient(patient.patient_id, patient.prescription_date).map(&:drug_id) non_matching_drugs = Set.new(drugs) - prescribed_drugs next unless non_matching_drugs.empty? demographics = patient_demographics(patient.patient_id, patient.prescription_date) matching_patients << { patient_id: demographics.patient_id, arv_number: demographics.arv_number, birthdate: demographics.birthdate, gender: demographics.gender, weight: demographics.weight } end end |