Initial import
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
class Io_left extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"];
|
||||
$edate = $prm["end_date"];
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_orderdetailt_testid) total
|
||||
from t_orderdetail
|
||||
join t_orderheader on t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testisresult = 'Y'
|
||||
and (t_orderdetailt_testname like ? or t_orderdetailt_testcode like ?)";
|
||||
$query = $this->db_smartone->query($sql, [$search, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select t_orderdetailt_testid t_testid, t_orderdetailt_testcode t_testcode,
|
||||
t_orderdetailt_testname t_testname
|
||||
from t_orderdetail
|
||||
join t_orderheader on t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testisresult = 'Y'
|
||||
and (t_orderdetailt_testname like ? or t_orderdetailt_testcode like ?)
|
||||
group by t_orderdetailt_testid
|
||||
order by t_orderdetailt_testname asc
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$search, $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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_patient()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"];
|
||||
$edate = $prm["end_date"];
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_orderheader
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
|
||||
where t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
and (m_patientname like ? or T_OrderHeaderLabNumber like ?)";
|
||||
$query = $this->db_smartone->query($sql, [$search, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderLabNumber order_number, m_patientname patient_name,
|
||||
t_orderheaderid order_id
|
||||
from t_orderheader
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
|
||||
where t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
and (m_patientname like ? or T_OrderHeaderLabNumber like ?)
|
||||
order by T_OrderHeaderLabNumber desc
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$search, $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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_worklist()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"];
|
||||
$edate = $prm["end_date"];
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct t_worklistid) total
|
||||
from t_worklist
|
||||
join t_worklistdetail on t_worklistdetailt_worklistid = t_worklistid
|
||||
and t_worklistdetailisactive = 'Y'
|
||||
where t_worklistisactive = 'Y'
|
||||
and (t_worklistname like ?)";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select t_worklistid, t_worklistname
|
||||
from t_worklist
|
||||
join t_worklistdetail on t_worklistdetailt_worklistid = t_worklistid
|
||||
and t_worklistdetailisactive = 'Y'
|
||||
where t_worklistisactive = 'Y'
|
||||
and (t_worklistname like ?)
|
||||
group by t_worklistid
|
||||
order by t_worklistname 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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
class Io_right extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_patient()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 9999999999;
|
||||
|
||||
$sdate = $prm["start_date"];
|
||||
$edate = $prm["end_date"];
|
||||
$px_id = join(",", json_decode($prm["px_id"]));
|
||||
if ($px_id == "") $px_id = -1;
|
||||
// $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_orderdetail
|
||||
join t_orderheader on t_orderdetailt_orderheaderid = t_orderheaderid
|
||||
and t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testid IN ({$px_id})";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderLabNumber order_number, m_patientname patient_name,
|
||||
t_orderheaderid order_id, group_concat(t_orderdetailid separator ',') detail_id,
|
||||
t_orderdetailt_instrumentid instrument_id,
|
||||
group_concat(t_orderdetailt_testname separator ', ') test_name
|
||||
from t_orderdetail
|
||||
join t_orderheader on t_orderdetailt_orderheaderid = t_orderheaderid
|
||||
and t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testid IN ({$px_id})
|
||||
group by t_orderheaderid
|
||||
order by T_OrderHeaderLabNumber desc
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
// get instruments
|
||||
$inst = $this->db_smartone->select("T_InstrumentID, T_InstrumentName", false)
|
||||
->where("T_InstrumentIsActive", "Y")
|
||||
->get("t_instrument")
|
||||
->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['detail_id'] = explode(",", $v['detail_id']);
|
||||
$rows[$k]['instrument'] = $inst;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"];
|
||||
$edate = $prm["end_date"];
|
||||
$order_id = $prm["order_id"];
|
||||
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_orderdetail
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testisresult = 'Y'
|
||||
and t_orderdetailt_orderheaderid = ?";
|
||||
$query = $this->db_smartone->query($sql, [$order_id]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select t_orderdetailid detail_id, t_orderdetailt_testid t_testid,
|
||||
t_orderdetailt_testcode t_testcode, t_orderdetailt_testname t_testname,
|
||||
t_orderdetailt_instrumentid instrument_id
|
||||
from t_orderdetail
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testisresult = 'Y'
|
||||
and t_orderdetailt_orderheaderid = ?
|
||||
order by t_orderdetailt_testname asc
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$order_id]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
// get instruments
|
||||
$inst = $this->db_smartone->select("T_InstrumentID, T_InstrumentName", false)
|
||||
->where("T_InstrumentIsActive", "Y")
|
||||
->get("t_instrument")
|
||||
->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['instrument'] = $inst;
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_worklist_patient()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["start_date"];
|
||||
$edate = $prm["end_date"];
|
||||
$worklist_id = $prm["worklist_id"];
|
||||
// $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_orderdetail
|
||||
join t_orderheader on t_orderdetailt_orderheaderid = t_orderheaderid
|
||||
and t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
join t_worklistdetail on t_worklistdetailt_worklistid = ?
|
||||
and t_worklistdetailisactive = 'Y'
|
||||
and t_worklistdetailt_testid = t_orderdetailt_testid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testisresult = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, [$worklist_id]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OrderHeaderLabNumber order_number, m_patientname patient_name,
|
||||
t_orderheaderid order_id, t_orderdetailid detail_id,
|
||||
0 instrument_id,
|
||||
group_concat(t_orderdetailt_testname separator ', ') t_testnames
|
||||
from t_orderdetail
|
||||
join t_orderheader on t_orderdetailt_orderheaderid = t_orderheaderid
|
||||
and t_orderheaderisactive = 'Y'
|
||||
and t_orderheaderdate between '{$sdate} 00:00:00' and '{$edate} 23:59:59'
|
||||
join t_worklistdetail on t_worklistdetailt_worklistid = ?
|
||||
and t_worklistdetailisactive = 'Y'
|
||||
and t_worklistdetailt_testid = t_orderdetailt_testid
|
||||
join m_patient on t_orderheaderm_patientid = m_patientid
|
||||
where t_orderdetailisactive = 'Y'
|
||||
and t_orderdetailt_testisresult = 'Y'
|
||||
group by t_orderheaderid
|
||||
order by T_OrderHeaderLabNumber desc
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$worklist_id]);
|
||||
$lq = $this->db_smartone->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
// get instruments
|
||||
$inst = $this->db_smartone->select("T_InstrumentID, T_InstrumentName", false)
|
||||
->where("T_InstrumentIsActive", "Y")
|
||||
->get("t_instrument")
|
||||
->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['instrument'] = $inst;
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows), "q" => $lq);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function send_orders()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm['data']);
|
||||
$rst = [];
|
||||
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailT_InstrumentID', $v->instrument_id)
|
||||
->where('T_OrderDetailID', $v->detail_id)
|
||||
->update('t_orderdetail');
|
||||
|
||||
$this->db_smartone->query("
|
||||
INSERT INTO t_ordertx(T_OrderTxM_PatientName,
|
||||
T_OrderTxM_PatientNoReg,
|
||||
T_OrderTxT_OrderHeaderID,
|
||||
T_OrderTxT_OrderHeaderLabNumber,
|
||||
T_OrderTxM_PatientSexCode,
|
||||
T_OrderTxM_PatientDOB,
|
||||
T_OrderTxM_DoctorName,
|
||||
T_OrderTxT_InstrumentID,
|
||||
T_OrderTxT_InstrumentTestCode,
|
||||
T_OrderTxT_OrderDetailID,
|
||||
T_OrderTxFlagGluc)
|
||||
SELECT fn_global_patient_name(M_PatientID),
|
||||
M_PatientNoReg,
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber,
|
||||
M_SexCode,
|
||||
M_PatientDOB,
|
||||
fn_global_doctor_name(T_OrderHeaderSenderM_DoctorID),
|
||||
{$v->instrument_id},
|
||||
'',
|
||||
T_OrderDetailID,
|
||||
T_TestFlagGluc
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_sex on M_PatientM_SexID = M_SexID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE T_OrderDetailID = {$v->detail_id}
|
||||
");
|
||||
|
||||
$rst[] = $this->db_smartone->insert_id();
|
||||
}
|
||||
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user