Sha256: 3fa3014e6037ac61c737ace01831f362994e2f9c32be4f9a04844f264f6827eb

Contents?: true

Size: 1.4 KB

Versions: 18

Compression:

Stored size: 1.4 KB

Contents

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

18 entries across 18 versions & 1 rubygems

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