Class Age
java.lang.Object
org.monarchinitiative.lirical.core.model.Age
Convenience class to represent the age of a subject.
We represent both postnatal and gestational age. Use isGestational()
or isPostnatal() to tell them apart.
The postnatal age has getYears(), getMonths(), and getDays() fields set
and getWeeks() should be ignored.
The gestational age uses getWeeks() and getDays() fields.
- Author:
- Peter Robinson
-
Method Summary
Modifier and TypeMethodDescriptionstatic AgeageInDays(int d) Create a postnatal age to representddays of age.static AgeageInMonths(int m) Create a postnatal age to representmmonths of age.static AgeageInYears(int y) Create a postnatal age to representyyears of age.booleanstatic AgegestationalAge(int weeks, int days) Create a gestational age to representweeksanddays.intgetDays()intintgetWeeks()intgetYears()inthashCode()booleanbooleanstatic Ageof(int years, int months, int days) Create a postnatal age from given inputs.static AgetoString()
-
Method Details
-
getYears
public int getYears() -
getMonths
public int getMonths() -
getWeeks
public int getWeeks() -
getDays
public int getDays() -
isGestational
public boolean isGestational() -
isPostnatal
public boolean isPostnatal() -
ageInYears
Create a postnatal age to representyyears of age.- Parameters:
y- a non-negative number of years.
-
ageInMonths
Create a postnatal age to representmmonths of age.- Parameters:
m- a non-negative number of months.
-
ageInDays
Create a postnatal age to representddays of age.- Parameters:
d- a non-negative number of days.
-
parse
- Parameters:
period- representing postnatal (not gestational) age.
-
gestationalAge
Create a gestational age to representweeksanddays.weeksshould generally be not be greater than 42, and it must not be negative.daysmust be in range[0,6].- Parameters:
weeks- a non-negative number of completed gestational weeks.days- the number of completed gestational days.
-
of
Create a postnatal age from given inputs. -
equals
-
hashCode
public int hashCode() -
toString
-