ohctech_p8/api2/appointment_view.php
2024-10-16 19:18:52 +05:30

45 lines
2.0 KiB
PHP

<?php
error_reporting(0);
include "../includes/config/config.php";
include "functions.php";
include 'log_entry.php';
$response = array();
if ($conn) {
// $sql = "SELECT a.doctor_id , a.date , a.slot_id , a.day , a.app_type , a.status , TIME_FORMAT(appoinment_slots.slot, '%h:%i %p') as slot from appointment_details a where a.emp_id='".$_REQUEST['emp_id']."'";
$sql = "SELECT *,app_type as a_type ,TIME_FORMAT(appoinment_slots.slot, '%h:%i %p') as slot,TIME_FORMAT(appoinment_slots.slot_end, '%h:%i %p') as slot_end,appointment_details.id as id FROM appointment_details left join appoinment_slots on appoinment_slots.slot_id=appointment_details.time WHERE emp_id='" . $_REQUEST['emp_id'] . "'";
error_log("errr" . $sql);
$result = mysqli_query($conn, $sql);
if ($result) {
$i = 0;
$d = 1;
while ($row = mysqli_fetch_assoc($result)) {
$response[$i]['srno'] = $d;
$response[$i]['doctor_id'] = getTableFieldValue('patient_master', 'patient_name', 'id', $row['doctor_id'], '');
$response[$i]['date'] = date_format(date_create($row['date']), "d-m-Y");
// $time_in_12_hour_format = date("g:i a", strtotime(getTableFieldValue('appoinment_slots', 'slot', 'slot_id', $row['slot_id'], '')));
$response[$i]['time'] = $row['slot'];
$response[$i]['day'] = $row['day'];
$response[$i]['id'] = $row['id'];
$_Type = '';
if ($row['a_type'] == 'MED') {
$_Type = 'Periodic Health Checkup';
} else if ($row['a_type'] == 'FIT') {
$_Type = 'Sickness/Fitness';
} else if ($row['a_type'] == 'INJ') {
$_Type = 'Injury';
} else {
$_Type = 'OPD';
}
error_log("errpr ".$_Type);
$response[$i]['app_type'] = $_Type;
$response[$i]['status'] = $row['status'];
$i++;
$d++;
}
error_log(print_r($response, true));
echo json_encode($response, JSON_PRETTY_PRINT);
}
}