1
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
namespace Evergreen.Health.Application.Health.Policies;
|
||||
|
||||
/// <summary>Demo 起点,可由用户手动修改,不是医学或人体工学判断。</summary>
|
||||
public static class BmiFirmnessPolicy
|
||||
{
|
||||
public static decimal? Calculate(decimal? heightCm, decimal? weightKg)
|
||||
{
|
||||
if (heightCm is null or <= 0 || weightKg is null or <= 0) return null;
|
||||
try
|
||||
{
|
||||
var height = heightCm.Value / 100m;
|
||||
return Math.Round(weightKg.Value / (height * height), 1);
|
||||
}
|
||||
catch (ArithmeticException) { return null; }
|
||||
}
|
||||
|
||||
public static string? Firmness(decimal? bmi) => bmi switch
|
||||
{
|
||||
< 18.5m => "很软", < 24m => "稍软", < 28m => "稍硬",
|
||||
< 32m => "很硬", >= 32m => "最硬", _ => null
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user