Class: MalawiHivProgramReports::Pepfar::PatientStartVl
- Inherits:
-
Object
- Object
- MalawiHivProgramReports::Pepfar::PatientStartVl
- Includes:
- Adapters::Moh::Custom, Utils
- Defined in:
- app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb
Overview
this module returns all the patient records on when when the patient started ART plus the last viral load result
Constant Summary
Constants included from Utils
Utils::COHORT_REGIMENS, Utils::FULL_3HP_COURSE_DAYS, Utils::FULL_6H_COURSE_PILLS
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#patient_ids ⇒ Object
readonly
Returns the value of attribute patient_ids.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #find_report ⇒ Object
- #get_patients_last_vl_and_latest_result ⇒ Object
-
#initialize(start_date:, end_date:, **kwargs) ⇒ PatientStartVl
constructor
A new instance of PatientStartVl.
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
Methods included from Utils
#drug_refills_and_external_consultation_list, #isoniazid_rifapentine_concept, #patient_completed_tpt?, #patient_on_3hp?, #patient_on_tb_treatment?, #pepfar_age_groups, #pepfar_patient_drilldown_information, #pepfar_patient_identifier_type, #rifapentine_concept
Constructor Details
#initialize(start_date:, end_date:, **kwargs) ⇒ PatientStartVl
Returns a new instance of PatientStartVl.
15 16 17 18 19 20 21 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 15 def initialize(start_date:, end_date:, **kwargs) @start_date = start_date @end_date = end_date @location = kwargs[:location] @patient_ids = kwargs[:patient_ids] raise InvalidParameterError, 'Patient IDs are required' if patient_ids.blank? end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
10 11 12 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 10 def end_date @end_date end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
10 11 12 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 10 def location @location end |
#patient_ids ⇒ Object (readonly)
Returns the value of attribute patient_ids.
10 11 12 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 10 def patient_ids @patient_ids end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
10 11 12 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 10 def start_date @start_date end |
Instance Method Details
#find_report ⇒ Object
23 24 25 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 23 def find_report get_patients_last_vl_and_latest_result end |
#get_patients_last_vl_and_latest_result ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/malawi_hiv_program_reports/pepfar/patient_start_vl.rb', line 27 def get_patients_last_vl_and_latest_result ids = patient_ids.split(',') ActiveRecord::Base.connection.select_all <<~SQL SELECT p.person_id AS patient_id, patient_start_date(p.person_id) AS art_start_date, p.birthdate AS birthdate, p.gender, MIN(pi.identifier) FROM person #{current_partition} p LEFT JOIN patient_identifier #{current_partition} pi ON pi.patient_id = p.person_id AND pi.voided = 0 AND pi.identifier_type = 4 WHERE p.voided = 0 AND #{in_manager(column: 'p.person_id', values: ids)} #{site_manager(operator: 'AND', column: 'p.site_id', location: location)} GROUP BY p.person_id, p.birthdate, p.gender SQL end |