June 3, 201312 yr I would like to be able to calculate age and report according to the guideline shown (knowing i input the hour of birth besides the day/month/year: I would like to be allowed the recording of date and time of birth (hour and minutes if known) and subsequently be able to express age in hours for the first 4 days of life, then in days from the 5th day of life through the first 28 days, then in weeks beginning on the 29th day of life through the first three completed months of life, and then in months beginning with the 4th month of life through age 2 years. Subsequent expressions of age may be expressed by year and month (2 years 6 months) or with a decimal place for expressing part of years (i.e. 2.5 years old) through age 18.
June 3, 201312 yr If you subtract one timestamp from another, you get the number of seconds difference. Divide by 60 to get minutes, etc. Is that enough to get you started? You might want to look over on briandunning.com to see if anyone's already made a function for this, or at least something similar.
June 3, 201312 yr Have you performed search for Age Calculations? Since this topic comes up every so often, you can find several treads on the subject by doing this search site: fmforums.com age There several custom functions having to do with age calculation at briandunning.com Most of these custom functions can be used in regular calculation field. HTH Lee
June 5, 201312 yr First of all, a disclaimer. You will not find a perfect age calculation. However, maybe this one will get you close - Elapsed
June 6, 201312 yr Author Thank you very much i have this function already in my solution however the CCHIT certification requires the function i posted above to pass the test. it is related to pediatric age and you may have newborns with age of hours.
June 6, 201312 yr You will have to use a Case statement. Let( [~under4days = <calculation of age in hours>; ~under28days = <calculation of age in days>; ~under3months = <calculation of age in weeks>; ~under2years = <calculation of age in months>; ~over2years = <calculation of age in years and months> ]; Case( Date(Get(CurrentTimestamp)) - Date(BirthTimestamp) > 730; ~over2years; Date(Get(CurrentTimestamp)) - Date(BirthTimestamp) > 90; ~under2years; <etc> ) ) The calculations would be derived from the hints given by Lee and Fitch.
June 7, 201312 yr But Under 4 days, Under 28 days, and Under 3 months are ALL Under 2 years, so something like greater than 4 days AND less than 28 days etc would work. Another way would be to have the first part of the Let be a Case statement. That way the first true value would be evaluated.
June 7, 201312 yr You're partly right. As written, all of the age formats are calculated, and then the correct one is chosen by the Case statement. I wrote it that way to make it clearer what is happening without having to build all the calculations and/or adding comments. By evaluating the Case from highest to lowest (with ">" operators), it automatically takes care of the "and less than..." part. But I agree the most efficient way is to write it as Case( Date(Get(CurrentTimestamp)) - Date(BirthTimestamp) > 730; <calculation of age in years and months>; Date(Get(CurrentTimestamp)) - Date(BirthTimestamp) > 90; <calculation of age in months>; <etc> )
June 10, 201312 yr If you're optimizing, you'd only want to calculate Date(Get(CurrentTimestamp)) - Date(BirthTimestamp) once.
Create an account or sign in to comment