Update Patient
This commit is contained in:
parent
97350a1f18
commit
6111c63cf4
@ -83,28 +83,9 @@ class Patient extends Controller {
|
|||||||
|
|
||||||
$patient["Age"] = $this->calculateAgeFromBirthdate($patient["Birthdate"]);
|
$patient["Age"] = $this->calculateAgeFromBirthdate($patient["Birthdate"]);
|
||||||
|
|
||||||
$Birthdate = \DateTime::createFromFormat('Y-m-d H:i', $patient["Birthdate"]);
|
$patient["Birthdate"] = $this->formatDateForDB($patient["Birthdate"]);
|
||||||
if ($Birthdate) {
|
$patient["DeathDateTime"] = $this->formatDateForDB($patient["DeathDateTime"]);
|
||||||
$patient["Birthdate"] = $Birthdate->format('Y-m-d H:i'); // Format database
|
$patient["BirthdateConversion"] = $this->formatDateForDisplay($patient["Birthdate"]);
|
||||||
$patient["BirthdateConversion"] = $Birthdate->format('j M Y'); // Format tampilan
|
|
||||||
} else {
|
|
||||||
$patient["Birthdate"] = null;
|
|
||||||
$patient["BirthdateConversion"] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$CreateDate = \DateTime::createFromFormat('Y-m-d H:i', $patient["CreateDate"]);
|
|
||||||
if ($CreateDate) {
|
|
||||||
$patient["CreateDate"] = $CreateDate->format('Y-m-d H:i');
|
|
||||||
} else {
|
|
||||||
$patient["CreateDate"] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $DisableDate = \DateTime::createFromFormat('Y-m-d H:i', $patient["CreateDate"]);
|
|
||||||
// if ($CreateDate) {
|
|
||||||
// $patient["CreateDate"] = $CreateDate->format('Y-m-d H:i');
|
|
||||||
// } else {
|
|
||||||
// $patient["CreateDate"] = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if ($patient['LinkTo'] != null) {
|
if ($patient['LinkTo'] != null) {
|
||||||
|
|
||||||
@ -558,16 +539,49 @@ class Patient extends Controller {
|
|||||||
|
|
||||||
$formattedAge = "";
|
$formattedAge = "";
|
||||||
if ($diff->y > 0){
|
if ($diff->y > 0){
|
||||||
$formattedAge .= "{$diff->y} Tahun ";
|
$formattedAge .= "{$diff->y} Years ";
|
||||||
}
|
}
|
||||||
if ($diff->m > 0){
|
if ($diff->m > 0){
|
||||||
$formattedAge .= "{$diff->m} Bulan ";
|
$formattedAge .= "{$diff->m} Months ";
|
||||||
}
|
}
|
||||||
if ($diff->d > 0){
|
if ($diff->d > 0){
|
||||||
$formattedAge .= "{$diff->d} Hari";
|
$formattedAge .= "{$diff->d} Days";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $formattedAge;
|
return $formattedAge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function formatDateForDB($dateString) {
|
||||||
|
// Ubah ke format Y-m-d H:i
|
||||||
|
$date = \DateTime::createFromFormat('Y-m-d H:i', $dateString);
|
||||||
|
|
||||||
|
// Kalau gagal, coba parse bebas
|
||||||
|
if (!$date) {
|
||||||
|
$timestamp = strtotime($dateString);
|
||||||
|
if ($timestamp) {
|
||||||
|
return date('Y-m-d H:i', $timestamp);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date->format('Y-m-d H:i');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatDateForDisplay($dateString) {
|
||||||
|
// Ubah ke format j M Y
|
||||||
|
$date = \DateTime::createFromFormat('Y-m-d H:i', $dateString);
|
||||||
|
|
||||||
|
// Kalau gagal, coba parse bebas
|
||||||
|
if (!$date) {
|
||||||
|
$timestamp = strtotime($dateString);
|
||||||
|
if ($timestamp) {
|
||||||
|
return date('j M Y', $timestamp);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date->format('j M Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user