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.113 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.112 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.111 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.110 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.109 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.108 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.106 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.105 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.104 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.103 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.102 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.101 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.100 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.99 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.98 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.97 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.96 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.95 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.94 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.93 app/presenters/renalware/pd/dashboard_presenter.rb