Sha256: 3aca96967cfe8fda0a2806588a32d4147a009f3c8b9db7d542ac03a897e5a97b
Contents?: true
Size: 955 Bytes
Versions: 18
Compression:
Stored size: 955 Bytes
Contents
# frozen_string_literal: true require_dependency "renalware/clinics" # The body surface area (BSA) of a patient calculated using DuBois/DuBois # BSA = 0.007184 * Height^0.725 * Weight^0.425 # Resources: # - Calculators # - https://www.msdmanuals.com/en-gb/medical-calculators/BodySurfaceArea.htm # - http://www.medcalc.com/body.html module Renalware module Clinics class BodySurfaceArea pattr_initialize [:weight!, :height!] def self.calculate(weight:, height:, dp: 2) new(weight: weight, height: height).calculate(dp: dp) end def calculate(dp: 2) return if height_cm.zero? return if weight_kg.zero? # NB ** is ruby syntax for power of (^) result = 0.007184 * (weight_kg**0.425) * (height_cm**0.725) result.round(dp) end private def height_cm height.to_f * 100 end def weight_kg weight.to_f end end end end
Version data entries
18 entries across 18 versions & 1 rubygems