Flatten mockup repo
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Process_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Handling.Process'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, '' status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and m_statussamplecode = 'SAMPLING.Handling.Process'
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_sent()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and (m_statussamplecode = 'SAMPLING.Handling.To.Process')
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderID, T_OrderHeaderLabNumber lab, T_OrderHeaderDate `date`,
|
||||
M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) name,
|
||||
T_OrderSampleBarcode sid, m_statussamplecode status, last_statussampleid id
|
||||
from t_ordersample
|
||||
join t_orderheader on t_ordersamplet_orderheaderid = t_orderheaderid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join last_statussample on t_ordersamplet_orderheaderid = last_statussamplet_orderheaderid
|
||||
and t_ordersamplet_sampletypeid = last_statussamplet_sampletypeid
|
||||
and t_ordersamplebarcode = last_statussamplebarcode
|
||||
join m_statussample on last_statussamplem_statussampleid = m_statussampleid
|
||||
and (m_statussamplecode = 'SAMPLING.Handling.To.Process')
|
||||
where T_OrderHeaderLabNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($nolab, $search));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function send()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_sampling_handling_03_send_remove('SND', '{$prm['ids']}', '0')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("handling send process", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function remove()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_sampling_handling_03_send_remove('RMV', '', '{$prm['id']}')";
|
||||
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->row();
|
||||
$this->sys_ok($row);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("handling remove process", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user