Sha256: c94bafdecc216469cee3af0ad2d314bc5c2a98bb2bac41363ffe24ccb62e6d92
Contents?: true
Size: 1.54 KB
Versions: 10
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require_dependency "renalware/letters" module Renalware module Clinics # TODO: Unused? class CurrentObservations NULL_DATE = nil pattr_initialize :patient Observation = Struct.new(:date, :measurement) # Returns [date, weight] 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 # Returns [date, height] 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 # Returns [date, [systolic_bp, diastolic_bp]] 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 def bmi bmi = BMI.new( height: height.measurement, weight: weight.measurement ) Observation.new(NULL_DATE, bmi.to_f) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems