Class: MalawiHivProgramReports::Clinic::PatientsOnAntiretrovirals
- Inherits:
-
Object
- Object
- MalawiHivProgramReports::Clinic::PatientsOnAntiretrovirals
- Defined in:
- app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb
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.
Class Method Summary collapse
Instance Method Summary collapse
- #find_report ⇒ Object
-
#initialize(start_date:, end_date:, **_kwargs) ⇒ PatientsOnAntiretrovirals
constructor
A new instance of PatientsOnAntiretrovirals.
- #patients ⇒ Object
Constructor Details
#initialize(start_date:, end_date:, **_kwargs) ⇒ PatientsOnAntiretrovirals
Returns a new instance of PatientsOnAntiretrovirals.
9 10 11 12 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb', line 9 def initialize(start_date:, end_date:, **_kwargs) @start_date = start_date @end_date = end_date end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
7 8 9 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb', line 7 def end_date @end_date end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
7 8 9 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb', line 7 def start_date @start_date end |
Class Method Details
.within(start_date, end_date) ⇒ Object
14 15 16 17 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb', line 14 def self.within(start_date, end_date) PatientsOnAntiretrovirals.new(start_date:, end_date:) .patients end |
Instance Method Details
#find_report ⇒ Object
19 20 21 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb', line 19 def find_report patients end |
#patients ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/malawi_hiv_program_reports/clinic/patients_on_antiretrovirals.rb', line 23 def patients ::DrugOrder.select('orders.patient_id AS patient_id') .joins(:order) .merge(art_orders) .where(drug_inventory_id: ArtService::RegimenEngine.arv_drugs, quantity: 1..Float::INFINITY) .where('start_date BETWEEN :start_date AND :end_date OR auto_expire_date BETWEEN :start_date AND :end_date OR (start_date <= :start_date AND auto_expire_date >= :end_date)', start_date:, end_date:) .group('orders.patient_id') end |