107 lines
3.4 KiB
PHP
107 lines
3.4 KiB
PHP
<?php
|
|
|
|
|
|
class Helper extends MY_Controller
|
|
{
|
|
var $db_smartone;
|
|
|
|
public function index()
|
|
{
|
|
echo "RE Helper API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_smartone = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function calc_age()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$orderID = $prm["orderID"];
|
|
|
|
$sql = "call sp_recount_age(?)";
|
|
$query = $this->db_smartone->query($sql, array($orderID));
|
|
|
|
if ($query) {
|
|
$sql = "select T_OrderHeaderM_PatientAge, M_PatientDOB
|
|
from t_orderheader
|
|
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
|
and T_OrderHeaderID = ?";
|
|
$qry = $this->db_smartone->query($sql, array($orderID));
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
$rst = $rows;
|
|
if (count($rows) > 0)
|
|
$rst = $rows[0];
|
|
$this->sys_ok($rst);
|
|
} else {
|
|
$this->sys_error_db("", $this->db_smartone);
|
|
}
|
|
} else {
|
|
$this->sys_error_db("", $this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
public function check_status_print()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$orderID = $prm["orderID"];
|
|
|
|
$sql = "SELECT GROUP_CONCAT(T_TestName SEPARATOR ',') as testname, concat( '[', group_concat( json_object('T_TestID', T_TestID, 'T_TestName',T_TestName) separator ',' ), ']' ) testall
|
|
FROM t_orderdetail
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
|
JOIN group_resultdetail ON Group_ResultDetailT_TestID = T_TestID AND Group_ResultDetailIsActive = 'Y'
|
|
JOIN group_result ON Group_ResultDetailGroup_ResultID = Group_ResultID AND Group_ResultFlagNonLab = 'N'
|
|
WHERE T_OrderDetailIsActive = 'Y' AND T_OrderDetailT_OrderHeaderID = ?
|
|
AND T_OrderDetailT_TestIsResult = 'Y'
|
|
AND (T_OrderDetailResult IS NULL OR T_OrderDetailResult = '')";
|
|
$query = $this->db_smartone->query($sql, array($orderID));
|
|
|
|
if ($query) {
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$rows[$k]['testall'] = json_decode($v['testall']);
|
|
}
|
|
}
|
|
$tot_count = count( $rows );
|
|
$rst = array("total" => $tot_count,
|
|
"records" => $rows);
|
|
if (count($rows) > 0)
|
|
$this->sys_ok($rst);
|
|
}
|
|
} else {
|
|
$this->sys_error_db("", $this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
function insertlogprint()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$tests = json_encode($prm['tests']);
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$sql = "INSERT INTO log_printresultpartial(
|
|
Log_PrintResultPartialT_OrderHeaderID,
|
|
Log_PrintResultPartialTests,
|
|
Log_PrintResultPartialUserID)
|
|
VALUES ('{$prm['orderid']}','{$tests}','{$userid}')";
|
|
$qry = $this->db_smartone->query($sql);
|
|
if ($qry) {
|
|
$result = array(
|
|
"total" => 1,
|
|
"records" => array()
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
} else {
|
|
$this->db_smartone->trans_rollback();
|
|
$this->sys_error_db(["status" => "ERR", "message" => "insert log_printresultpartial end| " .
|
|
$this->db_smartone->error()["message"], "debug" => $this->db_smartone->last_query()]);
|
|
exit;
|
|
}
|
|
}
|
|
}
|