Class: Renalware::Clinical::ProfilePresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/renalware/clinical/profile_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patient:, params:) ⇒ ProfilePresenter

Returns a new instance of ProfilePresenter.



12
13
14
15
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 12

def initialize(patient:, params:)
  @params = params
  @patient = Clinical.cast_patient(patient)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 8

def params
  @params
end

#patientObject (readonly)

Returns the value of attribute patient.



8
9
10
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 8

def patient
  @patient
end

Instance Method Details

#alcohol_historyObject



28
29
30
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 28

def alcohol_history
  history.alcohol || NullObject.instance
end

#body_compositionsObject



46
47
48
49
50
51
52
53
54
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 46

def body_compositions
  @body_compositions ||= begin
    BodyComposition
      .for_patient(patient)
      .includes([:modality_description, :assessor])
      .ordered
      .limit(5)
  end
end

#dry_weightsObject



42
43
44
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 42

def dry_weights
  @dry_weights ||= DryWeight.for_patient(patient).ordered.limit(5)
end

#historyObject



32
33
34
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 32

def history
  document.history || NullObject.instance
end

#smoking_historyObject



24
25
26
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 24

def smoking_history
  history.smoking || NullObject.instance
end

#swabsObject



17
18
19
20
21
22
# File 'app/presenters/renalware/clinical/profile_presenter.rb', line 17

def swabs
  @swabs ||= Renalware::Events::Swab.for_patient(patient)
                                    .ordered
                                    .page(params[:page])
                                    .per(params.fetch(:per_page, 10))
end