Sha256: de214f49561f47f6e5f4652acce5b560a1ad78e8f4a22d0afeb870e11b12907f

Contents?: true

Size: 1.48 KB

Versions: 20

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/dashboard"
require_dependency "collection_presenter"

module Renalware
  module Dashboard
    class DashboardPresenter
      def initialize(user)
        @user = user
      end

      attr_reader :user

      def bookmarks
        @bookmarks ||= begin
          Patients.cast_user(user)
                  .bookmarks
                  .ordered
                  .includes(patient: [current_modality: :description])
        end
      end

      def letters_in_progress
        @letters_in_progress ||= begin
          present_letters(
            Letters::Letter
              .where("author_id = ? or created_by_id = ?", user.id, user.id)
              .in_progress
              .reverse
          )
          # Renalware::Letters.cast_author(user)
        end
      end

      def unread_messages_receipts
        @unread_messages_receipts ||= begin
          receipts = Messaging::Internal.cast_recipient(user).receipts.unread
          CollectionPresenter.new(receipts, Messaging::Internal::ReceiptPresenter)
        end
      end

      def unread_electronic_ccs
        @unread_electronic_ccs ||= begin
          receipts = Letters::ElectronicReceipt.unread.for_recipient(user.id).ordered
          CollectionPresenter.new(receipts, Letters::ElectronicReceiptPresenter)
        end
      end

      private

      def present_letters(letters)
        CollectionPresenter.new(letters, Letters::LetterPresenterFactory)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
renalware-core-2.0.32 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.31 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.30 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.28 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.27 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.26 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.25 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.24 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.23 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.22 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.21 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.20 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.18 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.17 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.16 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.15 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.14 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.13 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.12 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.11 app/presenters/renalware/dashboard/dashboard_presenter.rb