Class: MalawiHivProgramReports::Clinic::PatientsOnDtg
- Inherits:
-
Object
- Object
- MalawiHivProgramReports::Clinic::PatientsOnDtg
- Defined in:
- app/services/malawi_hiv_program_reports/clinic/patients_on_dtg.rb
Constant Summary collapse
- HIV_PROGRAM_ID =
1
- ARV_NUMBER_TYPE_ID =
4
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #find_report ⇒ Object
-
#initialize(start_date:, end_date:, **_) ⇒ PatientsOnDtg
constructor
A new instance of PatientsOnDtg.
Constructor Details
#initialize(start_date:, end_date:, **_) ⇒ PatientsOnDtg
Returns a new instance of PatientsOnDtg.
11 12 13 14 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_dtg.rb', line 11 def initialize(start_date:, end_date:, **_) @start_date = start_date @end_date = end_date 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/patients_on_dtg.rb', line 6 def end_date @end_date end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
6 7 8 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_dtg.rb', line 6 def start_date @start_date end |
Instance Method Details
#find_report ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_dtg.rb', line 16 def find_report ::DrugOrder.joins(:order) .joins('INNER JOIN encounter USING (encounter_id)') .joins('LEFT JOIN patient_identifier ON patient_identifier.patient_id = orders.patient_id') .where(drug: dtg_drugs, encounter: { program_id: HIV_PROGRAM_ID }, patient_identifier: { identifier_type: ARV_NUMBER_TYPE_ID }) .where('start_date BETWEEN ? AND ?', start_date, end_date) .group('orders.patient_id') .select('identifier') .map(&:identifier) end |