java.lang.Object
org.monarchinitiative.lirical.core.model.Age

public class Age extends Object
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 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

      public static Age ageInYears(int y)
      Create a postnatal age to represent y years of age.
      Parameters:
      y - a non-negative number of years.
    • ageInMonths

      public static Age ageInMonths(int m)
      Create a postnatal age to represent m months of age.
      Parameters:
      m - a non-negative number of months.
    • ageInDays

      public static Age ageInDays(int d)
      Create a postnatal age to represent d days of age.
      Parameters:
      d - a non-negative number of days.
    • parse

      public static Age parse(Period period)
      Parameters:
      period - representing postnatal (not gestational) age.
    • gestationalAge

      public static Age gestationalAge(int weeks, int days)
      Create a gestational age to represent weeks and days.

      weeks should generally be not be greater than 42, and it must not be negative. days must be in range [0,6].

      Parameters:
      weeks - a non-negative number of completed gestational weeks.
      days - the number of completed gestational days.
    • of

      public static Age of(int years, int months, int days)
      Create a postnatal age from given inputs.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object