111 lines
3.9 KiB
PHP
111 lines
3.9 KiB
PHP
<?php
|
|
|
|
class Servicedoctor extends MY_Controller
|
|
{
|
|
var $db_antrione;
|
|
var $load;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_antrione = $this->load->database("antrione", true);
|
|
}
|
|
function index()
|
|
{
|
|
echo ('API SERVICE DOCTOR');
|
|
}
|
|
|
|
function layanan_dokter()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$serviceId = "serviceId";
|
|
if (isset($prm['serviceId'])) {
|
|
$serviceId = trim($prm["serviceId"]);
|
|
}
|
|
|
|
// belum dilayani
|
|
$sql_belum_dilayani = "SELECT queueID,
|
|
serviceID,
|
|
queueCreated,
|
|
statusID,
|
|
statusCode,
|
|
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
|
|
( CASE
|
|
WHEN statusID = 2 THEN 1
|
|
WHEN statusID = 1 THEN 2
|
|
WHEN statusID = 5 THEN 3
|
|
END ) as order_status
|
|
FROM queue
|
|
JOIN service
|
|
ON serviceID = queueServiceID
|
|
AND serviceIsActive = 'Y'
|
|
JOIN status
|
|
ON statusID = queueStatusID
|
|
WHERE queueIsActive = 'Y'
|
|
AND statusID IN (1,2,5)
|
|
AND serviceIsConsultDoctor = 'Y'
|
|
AND serviceId = ?
|
|
ORDER BY order_status, queueCreated asc";
|
|
|
|
$qry_belum_dilayani = $this->db_antrione->query($sql_belum_dilayani, array($serviceId));
|
|
$last_qry = $this->db_antrione->last_query();
|
|
if (!$qry_belum_dilayani) {
|
|
$error = array(
|
|
"message" => $this->db_antrione->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
$belum_dilayani = $qry_belum_dilayani->result_array();
|
|
|
|
// sedang dilayani
|
|
$sql_sedang_dilayani = "SELECT queueID,
|
|
serviceID,
|
|
queueCreated,
|
|
statusID,
|
|
statusCode,
|
|
CONCAT(queueNumber,'-',serviceDoctorName) as antrian_selanjutnya,
|
|
( CASE
|
|
WHEN statusID = 3 THEN 1
|
|
END ) as order_status
|
|
FROM queue
|
|
JOIN service
|
|
ON serviceID = queueServiceID
|
|
AND serviceIsActive = 'Y'
|
|
JOIN status
|
|
ON statusID = queueStatusID
|
|
WHERE queueIsActive = 'Y'
|
|
AND statusID IN (3)
|
|
AND serviceIsConsultDoctor = 'Y'
|
|
AND serviceId = ?
|
|
ORDER BY order_status, queueCreated asc";
|
|
$qry_sedang_dilayani = $this->db_antrione->query($sql_sedang_dilayani, array($serviceId));
|
|
$last_qry = $this->db_antrione->last_query();
|
|
if (!$qry_sedang_dilayani) {
|
|
$error = array(
|
|
"message" => $this->db_antrione->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
$sedang_dilayani = $qry_sedang_dilayani->result_array();
|
|
|
|
$result = array(
|
|
"belum_dilayani" => $belum_dilayani,
|
|
"sedang_dilayani" => $sedang_dilayani
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|
|
?>
|