Sha256: 8608820dce330060ff1151dcc1adbc9b9239ebb22ced700a6b96fa6eadde0fce

Contents?: true

Size: 1.43 KB

Versions: 106

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/pd"
require_dependency "renalware/events"

module Renalware
  module PD
    class DashboardPresenter
      include PresenterHelper

      attr_accessor :patient

      def initialize(patient)
        @patient = patient
      end

      def current_regime
        patient.pd_regimes.any? && patient.pd_regimes.current
      end

      def capd_regimes
        @capd_regimes ||= CAPDRegime.for_patient(patient).with_bags.ordered
      end

      def apd_regimes
        @apd_regimes ||= APDRegime.for_patient(patient).with_bags.ordered
      end

      def peritonitis_episodes
        @peritonitis_episodes ||= begin
          episodes = PeritonitisEpisode.for_patient(patient).ordered.includes(:episode_types)
          present(episodes, PeritonitisEpisodePresenter)
        end
      end

      def exit_site_infections
        @exit_site_infections ||= ExitSiteInfection.for_patient(patient).ordered
      end

      def pet_adequacies
        @pet_adequacies ||= PETAdequacyResult.for_patient(patient).ordered
      end

      def assessments
        @assessments ||= Assessment.for_patient(patient).ordered
      end

      def training_sessions
        @training_sessions ||= TrainingSession.for_patient(patient).ordered
      end

      def latest_pd_line_change_events
        @latest_pd_line_change_events ||= Events::LineChangeEventQuery.new(patient).call(limit: 1)
      end
    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
renalware-core-2.0.48 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.47 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.46 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.45 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.44 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.43 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.42 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.41 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.40 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.39 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.38 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.37 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.36 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.35 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.34 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.33 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.32 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.31 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.30 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.28 app/presenters/renalware/pd/dashboard_presenter.rb