Files
BE_IBL/application/controllers/v1/su/antrian/Nonlab.php
2026-04-15 15:23:57 +07:00

114 lines
4.9 KiB
PHP
Executable File

<?php
class Nonlab extends MY_Controller
{
function get_call($station_id=NULL,$trx_date=NULL,$status=NULL) {
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
T_SamplingQueueLastStatusID as trx_id,
T_SampleStationName as sample_station,
T_OrderHeaderLabNumber as nolab,
T_OrderHeaderLabNumberExt as nolab_ext
FROM t_sampling_queue_last_status
JOIN t_orderheader ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
JOIN t_samplestation ON T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
T_SampleStationIsActive = 'Y'
WHERE
T_SamplingQueueLastStatusT_SampleStationID = ? AND
T_SamplingQueueLastStatusT_SamplingQueueStatusID = ? AND
DATE(T_SamplingQueueLastStatusLastUpdated) = ? AND
T_SamplingQueueLastStatusIsActive = 'Y'";
$query = $this->db_onedev->query($sql,array($station_id,$status,$trx_date));
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
//echo $this->db_onedev->last_query();
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_data($station_id=NULL,$trx_date=NULL) {
$this->db_onedev = $this->load->database("onedev", true);
$sql = "SELECT T_OrderHeaderID as order_id,
T_OrderHeaderLabNumber as nolab,
T_OrderHeaderLabNumberExt as nolab_ext,
CONCAT(IFNULL(M_TitleName,''),' ',IFNULL(M_PatientPrefix,''),M_PatientName,IFNULL(M_PatientSuffix,'')) as patient_name,
IFNULL(T_SamplingQueueStatusName,'') as status
FROM t_orderheader
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
LEFT JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = ?
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
LEFT JOIN t_samplingso ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID AND
T_SamplingSoT_TestID = T_TestID AND
T_SamplingSoT_SampleStationID = T_SampleStationID AND
T_SamplingSoIsActive = 'Y'
LEFT JOIN t_sampling_queue_last_status ON T_OrderHeaderID = T_SamplingQueueLastStatusT_OrderHeaderID
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID AND
T_SamplingCallStatusIsActive = 'Y'
WHERE
T_OrderHeaderIsActive = 'Y' AND
( DATE(T_OrderHeaderAddonIsComingDate) = ? OR DATE(T_OrderHeaderDate) = ? )
GROUP BY T_OrderHeaderID
HAVING fn_fo_get_laststatus(T_OrderHeaderID) IN (3,5)
ORDER BY T_OrderHeaderIsCito DESC, T_OrderHeaderID ASC";
//echo $sql;
$query = $this->db_onedev->query($sql,array($station_id,$trx_date,$trx_date));
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
//echo $this->db_onedev->last_query();
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
function get_station(){
$this->db_onedev = $this->load->database("onedev", true);
$sql = " SELECT T_SampleStationID as id,
T_SampleStationCode as code,
T_SampleStationName as name,
T_SampleStationIsNonLab as is_nonlab
FROM t_samplestation
WHERE
T_SampleStationIsActive = 'Y'";
$query = $this->db_onedev->query($sql);
if ($query)
{
$row = $query->result_array();
$s_data = $row;
$this->sys_ok($s_data);
exit;
}
$this->sys_error_db("NOT FOUND CALL", $this->db_onedev);
}
}
?>