Sha256: 10a65d2d0270c0b0b15f033fe97a63bc7074e93f13d5559da4a776b01641ebb0

Contents?: true

Size: 732 Bytes

Versions: 15

Compression:

Stored size: 732 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("(sent_to_ukrdc_at is null) or (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

15 entries across 15 versions & 1 rubygems

Version Path
renalware-core-2.0.53 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.52 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.51 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.50 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.48 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.47 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.46 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.45 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.44 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.43 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.42 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.41 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.40 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.39 app/models/renalware/ukrdc/patients_query.rb
renalware-core-2.0.38 app/models/renalware/ukrdc/patients_query.rb