Sha256: 6bd8433c10229f32012a587c5093239ad9c4228a866252732d66d43a9bfcd47f

Contents?: true

Size: 583 Bytes

Versions: 35

Compression:

Stored size: 583 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

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.46 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.45 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.44 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.43 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.42 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.41 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.40 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.39 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.38 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.37 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.36 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.35 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.34 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.33 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.32 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.31 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.30 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.28 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.27 app/models/renalware/events/line_change_event_query.rb
renalware-core-2.0.26 app/models/renalware/events/line_change_event_query.rb