MDIS/src/appointment_feed.php

43 lines
1.0 KiB
PHP
Raw Normal View History

<?php
include 'appointment_management.php';
function computeEndTime(&$data){
foreach($data as &$row){
$time = new DateTime($row["hora"]);
$time->modify("+{$row["duracion"]} minutes");
$time_string = $time->format('H:i:s');
$row += ["end" => $time_string];
}
}
2020-07-14 21:36:43 +02:00
function formatArray($data){
computeEndTime($data);
$events = array();
foreach($data as $row){
$events[] = array(
"id" => $row["id"],
2020-07-13 19:03:06 +02:00
"title" => $row["apellido"] . ", " . $row["nombre"],
"start" => $row["fecha"] . " " . $row["hora"],
2020-07-13 19:03:06 +02:00
"description" => $row["observaciones"],
"patient" => $row["documento_identificativo"],
"end" => $row["fecha"] . " " . $row["end"],
);
}
return $events;
}
function fetchDatabase(){
$pdo = connectDatabase();
$data = listEvents($pdo);
closeDatabase($pdo);
return $data;
}
$result = fetchDatabase();
2020-07-14 21:36:43 +02:00
$events = formatArray($result);
echo json_encode($events);
?>