227 lines
5.5 KiB
PHP
227 lines
5.5 KiB
PHP
<?php
|
|
class XFohandover extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Email API";
|
|
/*truncate result_authorization;
|
|
truncate result_office;
|
|
truncate result_email;
|
|
truncate t_orderauthorization;*/
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$sql_join_result_email = '';
|
|
$sql_where = '';
|
|
$sqlx = '';
|
|
if($prm['name'] != '')
|
|
$sql_where .= " AND M_PatientName LIKE CONCAT('%','{$prm['name']}','%')";
|
|
|
|
if($prm['nolab'] != '')
|
|
$sql_where .= " AND T_OrderHeaderLabNumber LIKE CONCAT('%','{$prm['nolab']}','%')";
|
|
|
|
|
|
if($prm['filter_status'] = 'ready'){
|
|
$sqlx = "SELECT
|
|
T_OrderHeaderID as orderid,
|
|
T_OrderPromiseID as promiseid,
|
|
T_OrderHeaderLabNumber as labnumber,
|
|
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
|
DATE_FORMAT(T_OrderHeaderDate,'%d-%m-%Y') as date_order,
|
|
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%m') as date_promise,
|
|
'' as xgroups
|
|
FROM result_office
|
|
JOIN t_orderpromise ON Result_OfficeT_OrderPromiseID = T_OrderPromiseID
|
|
JOIN t_orderheader ON Result_OfficeT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
WHERE
|
|
Result_OfficeIsActive = 'Y' AND
|
|
Result_OfficeStatus = 'RECEIVED'
|
|
$sql_where
|
|
GROUP BY T_OrderHeaderID, T_OrderPromiseID
|
|
ORDER BY T_OrderHeaderLabNumber ASC
|
|
limit 0,20";
|
|
}
|
|
else{
|
|
|
|
}
|
|
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM (
|
|
$sqlx
|
|
) xs
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
$tot_count = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
} else {
|
|
$this->sys_error_db("t_samplestorageout count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = $sqlx;
|
|
|
|
$query = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
if($prm['filter_status'] = 'ready'){
|
|
$sqlx = "SELECT IF(Result_OfficeIsNonLab = '','LAB',Result_OfficeIsNonLab) as xgroup
|
|
FROM result_office
|
|
WHERE
|
|
Result_OfficeIsActive = 'Y' AND
|
|
Result_OfficeStatus = 'RECEIVED' AND
|
|
Result_OfficeT_OrderHeaderID = {$v['orderid']} AND
|
|
Result_OfficeT_OrderPromiseID = {$v['promiseid']}
|
|
GROUP BY Result_OfficeIsNonLab";
|
|
}
|
|
else{
|
|
|
|
}
|
|
|
|
$rows[$k]['xgroups'] = $this->db_onedev->query($sql)->result();
|
|
}
|
|
}
|
|
|
|
|
|
//$tot_count = 25;
|
|
//$this->_add_address($rows);
|
|
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getstaffs(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$rows = [];
|
|
$query =" SELECT M_StaffID as id, M_StaffName as name
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['staffs'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function searchstaff(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffName like ?
|
|
AND M_StaffIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_staff count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *
|
|
FROM m_staff
|
|
WHERE
|
|
M_StaffName like ?
|
|
AND M_StaffIsActive = 'Y'
|
|
ORDER BY M_StaffName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_staff rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
function doauthorization(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
if($prm['type'] == 'LAB'){
|
|
$prm['type'] = '';
|
|
}
|
|
|
|
$sql = "UPDATE result_office SET
|
|
Result_OfficeStatus = 'RECEIVED',
|
|
Result_OfficeUserID = {$userid}
|
|
WHERE
|
|
Result_OfficeT_OrderHeaderID = {$prm['orderid']} AND
|
|
Result_OfficeT_OrderPromiseID = {$prm['promiseid']} AND
|
|
Result_OfficeIsNonLab = '{$prm['type']}' AND
|
|
Result_OfficeStatus = 'NEW'
|
|
";
|
|
|
|
$this->db_onedev->query($sql);
|
|
|
|
$result = array(
|
|
"total" => 1,
|
|
"records" => $prm
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
} |