diff --git a/modules/timepoint_list/php/timepoint_list.class.inc b/modules/timepoint_list/php/timepoint_list.class.inc
index b7fc483b304..58cd3729f4a 100644
--- a/modules/timepoint_list/php/timepoint_list.class.inc
+++ b/modules/timepoint_list/php/timepoint_list.class.inc
@@ -104,7 +104,10 @@ class Timepoint_List extends \NDB_Menu
$this->tpl_data['candID'] = $this->candID;
$this->tpl_data['PSCID'] = $candidate->getPSCID();
$listOfTimePoints = $candidate->getListOfTimePoints();
- $this->tpl_data['candidate'] = $candidate->getData();
+ $this->tpl_data['candidate'] = array_merge(
+ $candidate->getData(),
+ array('Age' => $candidate->getAgeInMonths())
+ );
if (!empty($listOfTimePoints)) {
$user =& \User::singleton();
diff --git a/modules/timepoint_list/templates/menu_timepoint_list.tpl b/modules/timepoint_list/templates/menu_timepoint_list.tpl
index 7b859b246b5..6f300fbcc94 100644
--- a/modules/timepoint_list/templates/menu_timepoint_list.tpl
+++ b/modules/timepoint_list/templates/menu_timepoint_list.tpl
@@ -6,6 +6,9 @@
DOB
|
+
+ Age
+ |
{if $candidate.EDC!=""}
EDC
@@ -30,6 +33,9 @@
|
{$candidate.DoB}
|
+
+ {$candidate.Age}
+ |
{if $candidate.EDC!=""}
{$candidate.EDC}
diff --git a/php/libraries/Candidate.class.inc b/php/libraries/Candidate.class.inc
index b94a2afd097..aedc4c264ac 100644
--- a/php/libraries/Candidate.class.inc
+++ b/php/libraries/Candidate.class.inc
@@ -664,9 +664,12 @@ class Candidate
*/
public function getAge(): array
{
- return \Utility::calculateAge(
- $this->candidateInfo["DoB"],
- (new DateTime())->format('Y-m-d')
+ $dob = new DateTime($this->candidateInfo["DoB"]);
+ $age = $dob->diff(new DateTime('now'))->format('%y,%m,%d');
+
+ return array_combine(
+ array('year', 'mon', 'day'),
+ explode(",", $age)
);
}
@@ -677,7 +680,9 @@ class Candidate
*/
public function getAgeYears(): int
{
- return $this->getAge()['year'];
+ $dob = new DateTime($this->candidateInfo["DoB"]);
+
+ return (int)$dob->diff(new DateTime('now'))->format('%y');
}
/**
@@ -687,10 +692,9 @@ class Candidate
*/
public function getAgeInMonths(): int
{
- $age = $this->getAge();
- $months = $age['year']*12 + $age['mon'] + ($age['day']/30);
+ $dob = new DateTime($this->candidateInfo["DoB"]);
- return (round($months*10) / 10.0);
+ return (int)$dob->diff(new DateTime('now'))->format('%m') + 12 * $this->getAgeYears();
}
/**
@@ -700,9 +704,9 @@ class Candidate
*/
public function getAgeInDays(): int
{
- $age = $this->getAge();
+ $dob = new DateTime($this->candidateInfo["DoB"]);
- return $age['year']*365 + $age['mon']*30 + $age['day'];
+ return (int)$dob->diff(new DateTime('now'))->days;
}
/**
|