Initial import
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rp_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RP 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;
|
||||
|
||||
$date = $prm["date"];
|
||||
$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_orderpromise
|
||||
join t_orderheader on t_orderpromiset_orderheaderid = t_orderheaderid
|
||||
join t_orderdetail on t_orderheaderid = t_orderdetailt_orderheaderid
|
||||
and t_orderdetailisactive = 'Y' and T_OrderDetailValidation = 'Y'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
where T_OrderPromiseIsActive = 'Y'
|
||||
and T_OrderPromiseDateTime LIKE '{$date}%'
|
||||
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,
|
||||
da.M_DoctorID doctor_pj_id, fn_global_doctor_name(da.M_DoctorID) doctor_pj_name,
|
||||
M_MouID, M_MouName, M_CompanyID, M_CompanyName,
|
||||
T_OrderHeaderFoNote, T_OrderHeaderSamplingNote, T_OrderHeaderResultNote,
|
||||
T_OrderPromiseDateTime
|
||||
from t_orderpromise
|
||||
join t_orderheader on t_orderpromiset_orderheaderid = t_orderheaderid
|
||||
join t_orderdetail on t_orderheaderid = t_orderdetailt_orderheaderid
|
||||
and t_orderdetailisactive = 'Y' and T_OrderDetailValidation = 'Y'
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_doctor da on T_OrderHeaderPJM_DoctorID = da.M_DoctorID
|
||||
JOIN m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
where T_OrderPromiseIsActive = 'Y'
|
||||
and T_OrderPromiseDateTime LIKE '{$date}%'
|
||||
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]['data'] = json_decode($v['data']);
|
||||
|
||||
$btn = $this->db_smartone->query("SELECT fn_process_rp_buttons('{$v['T_OrderHeaderID']}') x")
|
||||
->row();
|
||||
$rows[$k]['buttons'] = json_decode($btn->x);
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user