Sha256: c6fb6134f3676396f4160fc6dd1916fae0ff5dab7ad8207f64b147ed4a69a45b

Contents?: true

Size: 803 Bytes

Versions: 8

Compression:

Stored size: 803 Bytes

Contents

module Renalware
  module HD
    module Sessions
      class ProtocolSessionsQuery

        def initialize(patient:, limit: 3)
          @patient = patient
          @limit = limit
        end

        def call(starting_on: 4.weeks.ago, ending_on: Time.zone.today, max_sessions: 12)
          Session.includes(:hospital_unit, :signed_off_by)
                 .extending(Scopes)
                 .for_patient(patient)
                 .not_dna
                 .limit(limit)
                 .ordered
        end

        private

        attr_reader :patient, :limit

        module Scopes
          def for_patient(patient)
            where(patient: patient)
          end

          def not_dna
            where.not(type: Session::DNA.sti_name)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/hd/sessions/protocol_sessions_query.rb