150 lines
4.2 KiB
PHP
150 lines
4.2 KiB
PHP
<?php
|
|
class Done extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "SampleStorage API";
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
$nolab = $prm["nolab"];
|
|
$groupid = $prm["groupid"];
|
|
//$subgroupid = $prm["subgroupid"];
|
|
$join_group = '';
|
|
if($groupid != '0'){
|
|
$join_group = "JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID AND Nat_GroupID = {$groupid}";
|
|
}
|
|
/*$join_subgroup = '';
|
|
if($subgroupid != 0){
|
|
$join_group = "JOIN nat_subgroup ON T_TestNat_SubgroupID = Nat_SubgroupID AND Nat_SubgroupID = {$subgroupid}";
|
|
}*/
|
|
|
|
if(!isset($prm['current_page']))
|
|
$prm['current_page'] = 1;
|
|
|
|
$sql_where = "WHERE Result_FrontOfficeStatus = 'S' AND JSON_CONTAINS(Result_FrontOfficeIds,T_OrderDetailID)";
|
|
$number_limit = 10;
|
|
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
|
//$sql_param = array();
|
|
if ($nolab != "" ) {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' OR M_PatientName like '%$nolab%' )";
|
|
}
|
|
|
|
/*if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " M_PatientName like '%$nama%' ";
|
|
}*/
|
|
|
|
$sql = "SELECT Result_FrontOfficeID as xid,
|
|
T_OrderHeaderID as orderid,
|
|
T_OrderHeaderLabNumber as ordernumber,
|
|
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
|
Result_FrontOfficeTestName as test_name,
|
|
'N' as chex
|
|
FROM result_frontoffice
|
|
join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND JSON_CONTAINS(Result_FrontOfficeIds, T_OrderDetailID)
|
|
$join_group
|
|
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
|
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
$sql_where
|
|
GROUP BY Result_FrontOfficeID
|
|
";
|
|
//echo $sql;
|
|
$query = $this->db_onedev->query($sql);
|
|
$rows = $query->result_array();
|
|
foreach($rows as $k => $v){
|
|
if($v['chex'] == 'N')
|
|
$rows[$k]['chex'] = false;
|
|
else
|
|
$rows[$k]['chex'] = true;
|
|
}
|
|
|
|
$result = array("total" => count($rst), "records" => $rows, "sql"=> '');
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function getkerajaan(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//$rst = array(array('id'=>0,'name'=>'Semua'));
|
|
|
|
$sql = "SELECT 0 as id, 'Semua' as name UNION SELECT Nat_GroupID as id, Nat_GroupName as name FROM nat_group WHERE Nat_GroupIsActive = 'Y'";
|
|
$rst_db = $this->db_onedev->query($sql)->result_array();
|
|
//$c = array_combine($rst,$rst_db);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => $rst_db
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function dosend(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$selected = $prm['selected'];
|
|
|
|
foreach($selected as $k => $v){
|
|
$sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'R' WHERE Result_FrontOfficeID = {$v['xid']}";
|
|
$this->db_onedev->query($sql);
|
|
|
|
$sql = "SELECT * FROM result_frontoffice WHERE Result_FrontOfficeID = {$v['xid']}";
|
|
$rst_log = $this->db_onedev->query($sql)->result_array();
|
|
$dt_log = json_encode($rst_log);
|
|
$sql = "INSERT INTO one_log.log_result_front_office(
|
|
Log_ResultFrontOfficeDateTime,
|
|
Log_ResultFrontOfficeJson,
|
|
Log_ResultFrontOfficeUserID
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$dt_log}',
|
|
{$userid}
|
|
)";
|
|
$this->db_onedev->query($sql);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
} |