chore(growth): return nil when measure isn't set
This commit is contained in:
@@ -2,9 +2,9 @@ defmodule Growth.Calc.Centile do
|
||||
@moduledoc """
|
||||
Calculate percentile for a given measurement and the fitted values of Box-Cox by age/height:
|
||||
|
||||
* power
|
||||
* median
|
||||
* coefficientof variation
|
||||
* **power** `t:Growth.Calc.ZScore.l/0`
|
||||
* **median** `t:Growth.Calc.ZScore.m/0`
|
||||
* **coefficientof variation** `t:Growth.Calc.ZScore.s/0`
|
||||
|
||||
This calculation is described in the [instructions provided by the World Health Organization](https://cdn.who.int/media/docs/default-source/child-growth/growth-reference-5-19-years/computation.pdf).
|
||||
|
||||
@@ -23,7 +23,7 @@ defmodule Growth.Calc.Centile do
|
||||
|
||||
alias Growth.Calc.ZScore
|
||||
|
||||
@spec compute(number(), number(), number(), number()) :: number() | :na
|
||||
@spec compute(number(), ZScore.l(), ZScore.m(), ZScore.s()) :: number() | :na | nil
|
||||
@doc """
|
||||
Compute the centile for a given measurement (`y`) and the Box-Cox values: power (`l`), median (`m`), and
|
||||
coefficient of variation (`s`).
|
||||
@@ -36,6 +36,10 @@ defmodule Growth.Calc.Centile do
|
||||
19.0
|
||||
|
||||
"""
|
||||
def compute(nil, _, _, _) do
|
||||
nil
|
||||
end
|
||||
|
||||
def compute(y, l, m, s) do
|
||||
zscore = ZScore.raw(y, l, m, s)
|
||||
|
||||
|
Reference in New Issue
Block a user