Sha256: 29e80422323e165f27764a8b162be6104bd4fe277eeb609360624b58e38e7a4c

Contents?: true

Size: 584 Bytes

Versions: 114

Compression:

Stored size: 584 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/clinics"

module Renalware
  module Events
    class LineChangeEventQuery
      attr_reader :patient

      def initialize(patient)
        @patient = patient
      end

      def call(limit: 1)
        return [] if event_type.nil?

        Event.for_patient(patient)
             .where(event_type_id: event_type.id)
             .order(date_time: :desc)
             .limit(limit)
      end

      def event_type
        @event_type ||= Renalware::Events::Type.find_by(slug: :pd_line_changes)
      end
    end
  end
end

Version data entries

114 entries across 114 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.1.0 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.167 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.166 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.165 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.164 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.163 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.162 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.161 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.160 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.159 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.158 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.157 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.156 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.155 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.153 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.152 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.151 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.149 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.148 app/models/renalware/events/line_change_event_query.rb