Class: Renalware::HD::MDMPresenter

Inherits:
MDMPresenter show all
Defined in:
app/presenters/renalware/hd/mdm_presenter.rb

Constant Summary collapse

NullObject =
Naught.build do |config|
  config.black_hole
  config.define_explicit_conversions
  config.singleton
  config.predicates_return false
end

Constants inherited from MDMPresenter

MDMPresenter::NullAccess

Instance Attribute Summary

Attributes inherited from MDMPresenter

#patient, #view_context

Instance Method Summary collapse

Methods inherited from MDMPresenter

#access, #clinic_visits, #clinic_visits_having_measurements, #current_immunosuppressant_prescriptions, #current_pathology_for_code, #current_prescriptions, #current_problems, #current_transplant_status, #esa_prescriptions, #events_of_type, #historical_immunosuppressant_prescriptions, #historical_prescriptions, #initialize, #letters, #pathology, #pathology_for_codes

Constructor Details

This class inherits a constructor from Renalware::MDMPresenter

Instance Method Details

#auditsObject



46
47
48
# File 'app/presenters/renalware/hd/mdm_presenter.rb', line 46

def audits
  @audits ||= PatientStatistics.for_patient(patient).limit(6).ordered
end

#dry_weightsObject



36
37
38
39
40
# File 'app/presenters/renalware/hd/mdm_presenter.rb', line 36

def dry_weights
  @dry_weights ||= begin
    Clinical::DryWeight.for_patient(patient).ordered.includes(:assessor).limit(5)
  end
end

#hd_profileObject



25
26
27
28
29
30
31
32
33
34
# File 'app/presenters/renalware/hd/mdm_presenter.rb', line 25

def hd_profile
  @hd_profile ||= begin
    profile = HD::Profile.for_patient(patient).first
    if profile.present?
      HD::ProfilePresenter.new(profile)
    else
      NullObject.instance
    end
  end
end

#preference_setObject



42
43
44
# File 'app/presenters/renalware/hd/mdm_presenter.rb', line 42

def preference_set
  @preference_set ||= PreferenceSet.for_patient(patient).first || NullObject.instance
end

#rolling_auditObject



50
51
52
# File 'app/presenters/renalware/hd/mdm_presenter.rb', line 50

def rolling_audit
  @rolling_audit ||= audits.find_by(rolling: true)
end

#sessionsObject



15
16
17
18
19
20
21
22
23
# File 'app/presenters/renalware/hd/mdm_presenter.rb', line 15

def sessions
  @sessions ||= begin
    sessions = Sessions::LatestPatientSessionsQuery
                 .new(patient: patient)
                 .call(max_sessions: 6)
                 .includes(:patient, :hospital_unit, :signed_on_by, :signed_off_by)
    CollectionPresenter.new(sessions, SessionPresenter, view_context)
  end
end