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.72 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.71 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.70 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.69 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.68 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.67 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.64 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.63 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.62 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.61 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.60 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.58 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.57 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.56 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.55 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.54 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.53 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.52 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.51 app/presenters/renalware/pd/dashboard_presenter.rb
renalware-core-2.0.50 app/presenters/renalware/pd/dashboard_presenter.rb