Class: Renalware::Clinics::CurrentObservations

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/clinics/current_observations.rb

Overview

TODO: Unused?

Defined Under Namespace

Classes: Observation

Constant Summary collapse

NULL_DATE =
nil

Instance Method Summary collapse

Instance Method Details

#blood_pressureObject

Returns [date, [systolic_bp, diastolic_bp]]



39
40
41
42
43
44
45
46
47
48
# File 'app/models/renalware/clinics/current_observations.rb', line 39

def blood_pressure
  @blood_pressure ||= begin
    result = ClinicVisit
              .most_recent_for_patient(patient)
              .where("systolic_bp is not null and diastolic_bp is not null")
              .pluck(:date, :systolic_bp, :diastolic_bp).first || [nil, nil, nil]

    Observation.new(result[0], [result[1], result[2]])
  end
end

#bmiObject



50
51
52
53
54
55
56
# File 'app/models/renalware/clinics/current_observations.rb', line 50

def bmi
  bmi = BMI.new(
    height: height.measurement,
    weight: weight.measurement
  )
  Observation.new(NULL_DATE, bmi.to_f)
end

#heightObject

Returns [date, height]



27
28
29
30
31
32
33
34
35
36
# File 'app/models/renalware/clinics/current_observations.rb', line 27

def height
  @height ||= begin
    result = ClinicVisit
              .most_recent_for_patient(patient)
              .where.not(height: nil)
              .pluck(:date, :height).first || []

    Observation.new(result.first, result.last)
  end
end

#weightObject

Returns [date, weight]



15
16
17
18
19
20
21
22
23
24
# File 'app/models/renalware/clinics/current_observations.rb', line 15

def weight
  @weight ||= begin
    result = ClinicVisit
              .most_recent_for_patient(patient)
              .where.not(weight: nil)
              .pluck(:date, :weight).first || []

    Observation.new(result.first, result.last)
  end
end