Sha256: 75acf9ef79e31fbc0df110f5c1f85c14c8bddb9fa4a84f6b55d7927492e286bf

Contents?: true

Size: 884 Bytes

Versions: 18

Compression:

Stored size: 884 Bytes

Contents

require_dependency "renalware/events"

module Renalware
  module Events
    class EventsPresenter < SimpleDelegator
      attr_reader :patient

      def initialize(patient, events)
        @patient = patient
        super(events)
      end

      def users_for_filtering
        User.where(id: ids_of_users_having_created_events_for_this_patient)
            .distinct
            .order(family_name: :asc)
      end

      def event_types_for_filtering
        Events::Type
          .where(id: all_event_type_ids_in_use_for_this_patient)
          .distinct
          .order(name: :asc)
      end

      private

      def ids_of_users_having_created_events_for_this_patient
        Event.for_patient(patient).pluck(:created_by_id)
      end

      def all_event_type_ids_in_use_for_this_patient
        Event.for_patient(patient).pluck(:event_type_id)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc11 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc10 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc9 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc8 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc7 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc6 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc5 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc4 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc3 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.rc1 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta12 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta11 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta10 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta9 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta8 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta7 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta6 app/presenters/renalware/events/events_presenter.rb
renalware-core-2.0.0.pre.beta5 app/presenters/renalware/events/events_presenter.rb