Sha256: 24c249d08faf6bd9290396930457b86a17ed59fb5585fca7e7fd7bd8d7b16992

Contents?: true

Size: 957 Bytes

Versions: 44

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

module MalawiHivProgramReports
  module Clinic
    class PatientsDueForViralLoad
      attr_accessor :start_date, :end_date

      def initialize(start_date:, end_date:, **_kwargs)
        @start_date = start_date
        @end_date = end_date
      end

      def find_report
        patients_alive_and_on_treatment.select do |patient_id|
          patient_viral_load_due?(patient_id)
        end
      end

      private

      def patient_viral_load_due?(patient_id)
        reminder = viral_load_reminder(patient_id)
        reminder[:eligibile] # Yes its spelt eligibile not eligible...
      end

      def patients_alive_and_on_treatment
        PatientsAliveAndOnTreatment
          .new(start_date:, end_date:)
          .find_report
      end

      def viral_load_reminder(patient_id)
        ArtService::VlReminder
          .new(patient_id:, date: end_date)
          .vl_reminder_info
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
malawi_hiv_program_reports-1.1.18 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.17 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.16 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.15 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.14 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.13 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.12 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.11 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.10 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.9 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.8 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.7 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.6 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.5 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.4 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.3 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.2 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.1 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.1.0 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb
malawi_hiv_program_reports-1.0.27 app/services/malawi_hiv_program_reports/clinic/patients_due_for_viral_load.rb