Update Patient create, perbaikan Birthdate dan Age
This commit is contained in:
parent
51d9ac62cb
commit
98a69c245f
@ -81,6 +81,9 @@ class Patient extends Controller {
|
||||
|
||||
} else {
|
||||
|
||||
$patient["Age"] = $this->calculateAgeFromBirthdate($patient["Birthdate"]);
|
||||
$patient["Birthdate"] = date("d-m-Y", strtotime($patient["Birthdate"]));
|
||||
|
||||
if ($patient['LinkTo'] != null) {
|
||||
|
||||
$ids = explode(',', $patient['LinkTo']); // dari string jadi array
|
||||
@ -390,4 +393,13 @@ class Patient extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
private function calculateAgeFromBirthdate($birthdate) {
|
||||
$dob = new DateTime($birthdate);
|
||||
$today = new DateTime();
|
||||
$diff = $today->diff($dob);
|
||||
|
||||
$formattedAge = "{$diff->y} years {$diff->m} months {$diff->d} days";
|
||||
return $formattedAge;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user