[WIP] Implement growth assessment using WHO indicators #80

Draft
joao.dubas wants to merge 93 commits from jpd-feat-add-bmi-module-with-live-view into main
41 changed files with 31931 additions and 501 deletions
Showing only changes of commit d3c1aa9b6b - Show all commits

View File

@@ -3,6 +3,8 @@ defmodule Growth.Calc.Age do
Calculate the age in months. Calculate the age in months.
""" """
@type precision :: :day | :week | :month | :year
# NOTE: (jpd): based on [WHO instructions][0] # NOTE: (jpd): based on [WHO instructions][0]
# [0]: https://cdn.who.int/media/docs/default-source/child-growth/child-growth-standards/indicators/instructions-en.pdf # [0]: https://cdn.who.int/media/docs/default-source/child-growth/child-growth-standards/indicators/instructions-en.pdf
@day_in_month 30.4375 @day_in_month 30.4375
@@ -10,16 +12,22 @@ defmodule Growth.Calc.Age do
@day_in_week 7.0 @day_in_week 7.0
@doc """ @doc """
Calculate the age with the precision of day, or week, or month. For age in weeks or months, considers completed ones, removing decimal value. Calculate the age with the precision of `:day`, or `:week`, or `:month`, considering the measurement date as today.
If only date of birth is available, assumes that measurement date is today. For age in weeks or months, considers completed ones, removing decimal value.
""" """
@spec calculate(:day | :week | :month, Date.t(), Date.t()) :: pos_integer() @spec calculate(precision(), Date.t(), Date.t()) :: pos_integer()
def calculate(precision, date_of_birth) do def calculate(precision, date_of_birth) do
calculate(precision, date_of_birth, Date.utc_today()) calculate(precision, date_of_birth, Date.utc_today())
end end
@doc """
Calculate the age with the precision of `:day`, or `:week`, or `:month`.
For age in weeks or months, considers completed ones, removing decimal value.
"""
def calculate(:month, date_of_birth, date_of_measurement) do def calculate(:month, date_of_birth, date_of_measurement) do
:day :day
|> calculate(date_of_birth, date_of_measurement) |> calculate(date_of_birth, date_of_measurement)