Sha256: 51e870b113e349612545be2f22464fee2296f4aa4255ffec80cb93dcdb97dc89

Contents?: true

Size: 700 Bytes

Versions: 23

Compression:

Stored size: 700 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/ukrdc"

module Renalware
  module UKRDC
    # If the optional :changed_since argument is passed we select all RPV
    # patients how have been updated since that date. Otherwise we select all RPV
    # patients who have changed since the last time they were exported.
    class PatientsQuery
      def call(changed_since: nil)
        if changed_since.present?
          rpv_patients.where("updated_at > ?", changed_since)
        else
          rpv_patients.where("updated_at > sent_to_ukrdc_at")
        end
      end

      private

      def rpv_patients
        Renalware::Patient.where(send_to_rpv: true)
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
renalware-core-2.0.12 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.11 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.9 app/models/renalware/ukrdc/patients_query.rb