Sha256: f8f8b817bae7fede7c949f812a570728e61ba6a4c23d7e37b5e48f75939f797f

Contents?: true

Size: 833 Bytes

Versions: 149

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

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

149 entries across 149 versions & 1 rubygems

Version Path
renalware-core-2.0.84 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.83 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.82 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.81 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.80 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.79 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.78 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.77 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.76 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.75 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.74 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.73 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.72 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.71 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.70 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.69 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.68 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.67 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.64 app/models/renalware/hd/sessions/protocol_sessions_query.rb
renalware-core-2.0.63 app/models/renalware/hd/sessions/protocol_sessions_query.rb