diff --git a/src/Informedica.GenPRES.Shared/Models.fs b/src/Informedica.GenPRES.Shared/Models.fs index 2bc1ee1f..ca3ebdf0 100644 --- a/src/Informedica.GenPRES.Shared/Models.fs +++ b/src/Informedica.GenPRES.Shared/Models.fs @@ -111,61 +111,6 @@ module Models = (Some((days - 7 * (days / 7)) * 1)) - let inline validateMinMax lbl min max n = - if n >= min && n <= max then - Result.Ok n - else - $"%s{lbl}: {int n} not >= {int min} and <= {int max}" |> Result.Error - - - let inline set setter lbl min max n age : Result = - n |> validateMinMax lbl min max >>= ((setter age) >> Result.Ok) - - - let setYears = set (fun age n -> { age with Years = n }) "Years" 0 100 - - - let setMonths mos age = - age - |> setYears (mos / 12) - >>= set (fun age n -> { age with Months = n }) "Months" 0 11 (mos % 12) - - - let setWeeks wks age = - let yrs = wks / 52 - let mos = (wks - yrs * 52) / 4 - let wks = wks - (mos * 4) - (yrs * 52) - - age - |> setYears yrs - >>= set (fun age n -> { age with Months = n }) "Months" 0 12 mos - >>= set (fun age n -> { age with Weeks = n }) "Weeks" 0 4 wks - - - let setDays dys age = - let dys = int dys - let c = 356. / 12. - let yrs = dys / 356 - - let mos = ((float dys) - (float yrs) * 356.) / c |> int - - let wks = - (float dys) - ((float mos) * c) - (yrs * 356 |> float) - |> int - |> fun x -> x / 7 - - let ds = - (float dys) - ((float mos) * c) - (yrs * 356 |> float) - |> int - |> fun x -> x % 7 - - age - |> setYears (yrs * 1) - >>= set (fun age n -> { age with Months = n }) "Months" 0 12 (mos * 1) - >>= set (fun age n -> { age with Weeks = n }) "Weeks" 0 4 (wks * 1) - >>= set (fun age n -> { age with Days = n }) "Days" 0 6 (ds * 1) - - let getYears { Age.Years = yrs } = yrs