Initial import
This commit is contained in:
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ro_master extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RO Master Reference API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT t_orderrefmasterID) total
|
||||
from t_orderrefmaster
|
||||
join t_test on t_orderrefmastert_testid = t_testid
|
||||
join m_company on t_orderrefmastertom_companyid = m_companyid
|
||||
|
||||
where T_OrderRefMasterIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RO Master Reference API Count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderRefMasterID, T_TestID, T_TestName, T_TestCode,
|
||||
IFNULL(M_CompanyID, 0) M_CompanyID, IFNULL(M_CompanyName, '') M_CompanyName,
|
||||
IFNULL(M_BranchID, 0) M_BranchID, IFNULL(M_BranchName, '') M_BranchName,
|
||||
t_orderrefmasterisinternal is_internal,
|
||||
IFNULL(S_RegionalID, 0) S_RegionalID, IFNULL(S_RegionalName, '') S_RegionalName
|
||||
from t_orderrefmaster
|
||||
join t_test on t_orderrefmastert_testid = t_testid
|
||||
left join m_company on t_orderrefmastertom_companyid = m_companyid
|
||||
left join m_branch on t_orderrefmastertom_branchid = m_branchid
|
||||
left join s_regional on t_orderrefmastertos_regionalid = s_regionalid
|
||||
|
||||
where T_OrderRefMasterIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RO Master Reference API", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyIsLabTo = 'Y'
|
||||
and M_CompanyName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyIsLabTo = 'Y'
|
||||
and M_CompanyName like ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_company rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$exclude = join(",", json_decode($prm["exclude"]));
|
||||
|
||||
$sql_param = array("%$search%", $exclude);
|
||||
$sql = "select count(distinct T_TestID) total
|
||||
from t_test
|
||||
where T_TestName like ?
|
||||
and T_TestIsResult = 'Y'
|
||||
and NOT FIND_IN_SET(T_TestID, ?)";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select distinct T_TestID, T_TestName, 'N' IsFromPanel, T_TestRequirement
|
||||
from t_test
|
||||
where T_TestName like ?
|
||||
and T_TestIsResult = 'Y'
|
||||
and NOT FIND_IN_SET(T_TestID, ?)
|
||||
order by T_TestName ASC
|
||||
limit 0, 20";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "query" => $this->db_smartone->last_query() );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = $prm['data'];
|
||||
|
||||
$sql = "CALL sp_process_ref_master_save('{$data}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save master", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_regional()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select count(*) total
|
||||
from s_regional
|
||||
where S_RegionalIsActive = 'Y'";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("Regional count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select S_RegionalID, S_RegionalName,
|
||||
CONCAT('[', GROUP_CONCAT(JSON_OBJECT('M_BranchID', M_BranchID, 'M_BranchName', M_BranchName) SEPARATOR ','), ']') branches
|
||||
from s_regional
|
||||
left join m_branch on m_branchs_regionalid = s_regionalid and m_branchisactive = 'Y'
|
||||
where S_RegionalIsActive = 'Y'
|
||||
group by S_RegionalID
|
||||
order by S_RegionalName ASC";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['branches'] = json_decode($v['branches']);
|
||||
}
|
||||
$result = array("total" => $tot_count, "records" => $rows, "query" => $this->db_smartone->last_query() );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ro_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RO Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["sdate"];
|
||||
$edate = $prm["edate"];
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(DISTINCT T_OrderHeaderID) total
|
||||
from t_orderheader
|
||||
join t_orderdetail on t_orderheaderid = t_orderdetailt_orderheaderid
|
||||
and t_orderdetailisactive = 'Y' and T_OrderDetailVerification <> 'Y'
|
||||
join t_orderrefmaster on t_orderrefmastert_testid = t_orderdetailt_testid
|
||||
and t_orderrefmasterisactive = 'Y'
|
||||
|
||||
left join t_orderrefout ON T_OrderRefOutT_OrderHeaderID = t_orderheaderid
|
||||
AND T_OrderRefOutT_TestID = t_orderdetailt_testid
|
||||
AND T_OrderRefOutIsActive = 'Y'
|
||||
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_company on T_OrderRefMasterToM_CompanyID = M_CompanyID
|
||||
where T_OrderheaderIsActive = 'Y'
|
||||
and T_OrderheaderDate BETWEEN '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
and T_OrderHeaderLabNumber LIKE ?
|
||||
and M_PatientName LIKE ?
|
||||
order by T_OrderHeaderLabNumber DESC";
|
||||
$query = $this->db_smartone->query($sql, [$nolab, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
|
||||
concat('[',
|
||||
group_concat(JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName,
|
||||
'M_CompanyID', M_CompanyID, 'M_CompanyName', M_CompanyName,
|
||||
'M_BranchID', T_OrderRefMasterToM_BranchID, 'is_internal', T_OrderRefMasterIsInternal,
|
||||
'sent', IFNULL(T_OrderRefOutIsSent, 'N'))
|
||||
order by T_TestName SEPARATOR ','),
|
||||
']') T_TestName
|
||||
|
||||
from t_orderheader
|
||||
join t_orderdetail on t_orderheaderid = t_orderdetailt_orderheaderid
|
||||
and t_orderdetailisactive = 'Y' and T_OrderDetailVerification <> 'Y'
|
||||
join t_orderrefmaster on t_orderrefmastert_testid = t_orderdetailt_testid
|
||||
and t_orderrefmasterisactive = 'Y'
|
||||
join t_test on t_orderdetailt_testid = t_testid
|
||||
|
||||
left join t_orderrefout ON T_OrderRefOutT_OrderHeaderID = t_orderheaderid
|
||||
AND T_OrderRefOutT_TestID = t_orderdetailt_testid
|
||||
AND T_OrderRefOutIsActive = 'Y'
|
||||
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_company on T_OrderRefMasterToM_CompanyID = M_CompanyID
|
||||
where T_OrderheaderIsActive = 'Y'
|
||||
and T_OrderheaderDate BETWEEN '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
and T_OrderHeaderLabNumber LIKE ?
|
||||
and M_PatientName LIKE ?
|
||||
group by T_OrderHeaderID
|
||||
order by T_OrderHeaderLabNumber DESC
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$nolab, $search]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['T_TestName'] = json_decode($v['T_TestName']);
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function send()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$data = $prm['data'];
|
||||
$sql = "CALL sp_process_ref_send('{$data}', '{$this->sys_input['M_UserID']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$r = $query->row();
|
||||
if ($r->status == "OK")
|
||||
$this->sys_ok($r);
|
||||
|
||||
else
|
||||
{
|
||||
$this->sys_error($r->message);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->sys_error("ERROR");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user