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.



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

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



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

def alcohol_history
  history.alcohol || NullObject.instance
end

#body_compositionsObject



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

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

#dry_weightsObject



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

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

#historyObject



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

def history
  document.history || NullObject.instance
end

#smoking_historyObject



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

def smoking_history
  history.smoking || NullObject.instance
end

#swabsObject



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

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