Update value date agar bisa menerima format UTC
This commit is contained in:
parent
90ad785e49
commit
5c5d56b473
@ -280,10 +280,10 @@ class PatientModel extends Model {
|
|||||||
|
|
||||||
private function transformPatientData(array $patient): array {
|
private function transformPatientData(array $patient): array {
|
||||||
$patient["Age"] = $this->calculateAgeFromBirthdate($patient["Birthdate"], $patient["DeathDateTime"]);
|
$patient["Age"] = $this->calculateAgeFromBirthdate($patient["Birthdate"], $patient["DeathDateTime"]);
|
||||||
$patient["Birthdate"] = $this->formatedDate($patient["Birthdate"]);
|
// $patient["Birthdate"] = $this->formatedDate($patient["Birthdate"]);
|
||||||
$patient["CreateDate"] = $this->formatedDate($patient["CreateDate"]);
|
// $patient["CreateDate"] = $this->formatedDate($patient["CreateDate"]);
|
||||||
$patient["DelDate"] = $this->formatedDate($patient["DelDate"]);
|
// $patient["DelDate"] = $this->formatedDate($patient["DelDate"]);
|
||||||
$patient["DeathDateTime"] = $this->formatedDate($patient["DeathDateTime"]);
|
// $patient["DeathDateTime"] = $this->formatedDate($patient["DeathDateTime"]);
|
||||||
$patient["BirthdateConversion"] = $this->formatedDateForDisplay($patient["Birthdate"]);
|
$patient["BirthdateConversion"] = $this->formatedDateForDisplay($patient["Birthdate"]);
|
||||||
$patient["LinkTo"] = $this->getLinkedPatients($patient['LinkTo']);
|
$patient["LinkTo"] = $this->getLinkedPatients($patient['LinkTo']);
|
||||||
$patient["Custodian"] = $this->getCustodian($patient['Custodian']);
|
$patient["Custodian"] = $this->getCustodian($patient['Custodian']);
|
||||||
@ -344,19 +344,19 @@ class PatientModel extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Conversion Time to Format Y-m-d H:i
|
// Conversion Time to Format Y-m-d H:i
|
||||||
private function formatedDate($dateString) {
|
// private function formatedDate($dateString) {
|
||||||
$date = \DateTime::createFromFormat('Y-m-d H:i', $dateString);
|
// $date = \DateTime::createFromFormat('Y-m-d H:i', $dateString);
|
||||||
|
|
||||||
if (!$date) {
|
// if (!$date) {
|
||||||
$timestamp = strtotime($dateString);
|
// $timestamp = strtotime($dateString);
|
||||||
if ($timestamp) {
|
// if ($timestamp) {
|
||||||
return date('Y-m-d H:i', $timestamp);
|
// return date('Y-m-d H:i', $timestamp);
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return $date->format('Y-m-d H:i');
|
// return $date->format('Y-m-d H:i');
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Conversion Time to Format j M Y
|
// Conversion Time to Format j M Y
|
||||||
private function formatedDateForDisplay($dateString) {
|
private function formatedDateForDisplay($dateString) {
|
||||||
@ -385,17 +385,20 @@ class PatientModel extends Model {
|
|||||||
|
|
||||||
// Preventif 0000-00-00
|
// Preventif 0000-00-00
|
||||||
private function isValidDateTime($datetime) {
|
private function isValidDateTime($datetime) {
|
||||||
// Check datetime format
|
try {
|
||||||
$formats = ['Y-m-d', 'Y-m-d H:i:s'];
|
// Kalau input hanya Y-m-d (tanpa jam)
|
||||||
|
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $datetime)) {
|
||||||
|
$dt = \DateTime::createFromFormat('Y-m-d', $datetime);
|
||||||
|
return $dt ? $dt->format('Y-m-d') : null; // hanya tanggal
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($formats as $format) {
|
// Selain itu (ISO 8601 atau datetime lain), format ke Y-m-d H:i:s
|
||||||
$dt = \DateTime::createFromFormat($format, $datetime);
|
$dt = new \DateTime($datetime);
|
||||||
if ($dt !== false && $dt->format($format) === $datetime) {
|
return $dt->format('Y-m-d H:i:s');
|
||||||
return $datetime;
|
|
||||||
}
|
} catch (\Exception $e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user