Class: Renalware::PD::DashboardPresenter

Inherits:
Object
  • Object
show all
Includes:
PresenterHelper, Concerns::Pageable
Defined in:
app/presenters/renalware/pd/dashboard_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PresenterHelper

#present

Constructor Details

#initialize(patient) ⇒ DashboardPresenter

Returns a new instance of DashboardPresenter.



14
15
16
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 14

def initialize(patient)
  @patient = patient
end

Instance Attribute Details

#patientObject

Returns the value of attribute patient.



12
13
14
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 12

def patient
  @patient
end

Instance Method Details

#apd_regimesObject



26
27
28
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 26

def apd_regimes
  @apd_regimes ||= APDRegime.for_patient(patient).with_bags.ordered.page(1).per(5)
end

#assessmentsObject



45
46
47
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 45

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

#capd_regimesObject



22
23
24
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 22

def capd_regimes
  @capd_regimes ||= CAPDRegime.for_patient(patient).with_bags.ordered.page(1).per(5)
end

#current_regimeObject



18
19
20
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 18

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

#exit_site_infectionsObject



37
38
39
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 37

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

#latest_pd_line_change_eventsObject



53
54
55
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 53

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

#peritonitis_episodesObject



30
31
32
33
34
35
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 30

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

#pet_adequaciesObject



41
42
43
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 41

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

#training_sessionsObject



49
50
51
# File 'app/presenters/renalware/pd/dashboard_presenter.rb', line 49

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