#7914 - Fix for contacts being empty or s tring (#7915)
[openemr.git] / src / Common / Utils / MeasurementUtils.php
blob3f1c2f30814521f303df6425a81c9b5de9040c66
1 <?php
3 /**
4 * MeasurementUtils.php
5 * @package openemr
6 * @link http://www.open-emr.org
7 * @author Stephen Nielson <stephen@nielson.org>
8 * @copyright Copyright (c) 2021 Stephen Nielson <stephen@nielson.org>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 namespace OpenEMR\Common\Utils;
14 class MeasurementUtils
16 const MEASUREMENT_PRECISION = 6;
18 public static function kgToLb($val)
20 return number_format($val * 2.20462262185, self::MEASUREMENT_PRECISION);
22 public static function lbToKg($val)
24 return number_format($val * 0.45359237, self::MEASUREMENT_PRECISION);
26 public static function cmToInches($val)
28 return number_format(round($val / 2.54, self::MEASUREMENT_PRECISION), self::MEASUREMENT_PRECISION);
30 public static function inchesToCm($val)
32 return number_format(round($val * 2.54, self::MEASUREMENT_PRECISION), self::MEASUREMENT_PRECISION);
34 public static function fhToCelsius($val)
36 return number_format(round(($val - 32) * (5 / 9), self::MEASUREMENT_PRECISION), self::MEASUREMENT_PRECISION);
39 public static function celsiusToFh($val)
41 return number_format(round(((9 / 5) * $val) + 32, self::MEASUREMENT_PRECISION), self::MEASUREMENT_PRECISION);