Initial import
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE 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;
|
||||
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$nolab = "%{$prm['nolab']}%";
|
||||
|
||||
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
|
||||
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
|
||||
JOIN helper_order ON Helper_OrderT_OrderHeaderID = T_OrderHeaderID
|
||||
AND Helper_OrderIsLAB = 'Y'
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber like ?
|
||||
and
|
||||
( M_PatientName LIKE ?
|
||||
or ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL))
|
||||
or ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL))
|
||||
)
|
||||
order by T_OrderHeaderLabNumber DESC";
|
||||
$query = $this->db_smartone->query($sql, [$nolab, $search, $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_OrderHeaderID, T_OrderHeaderLabNumber, T_OrderHeaderDate,
|
||||
M_PatientID, M_PatientNoReg, fn_global_patient_name(M_PatientID) M_PatientName,
|
||||
M_PatientDOB, T_OrderHeaderM_PatientAge, M_PatientHP, M_SexName,
|
||||
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, M_LangCode,
|
||||
T_OrderHeaderLangIsSI is_si
|
||||
from t_orderheader
|
||||
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
|
||||
JOIN m_sex on M_PatientM_SexID = M_SexID
|
||||
JOIN helper_order ON Helper_OrderT_OrderHeaderID = T_OrderHeaderID
|
||||
AND Helper_OrderIsLAB = 'Y'
|
||||
JOIN m_lang ON T_OrderHeaderM_LangID = M_LangID
|
||||
where T_OrderHeaderIsActive = 'Y'
|
||||
and T_OrderHeaderLabNumber like ?
|
||||
and
|
||||
( M_PatientName LIKE ?
|
||||
or ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL))
|
||||
or ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL))
|
||||
)
|
||||
order by T_OrderHeaderLabNumber DESC
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$nolab, $search, $search, $search ]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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,178 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RE Px API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 99;
|
||||
|
||||
$id = $prm["order_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
// $sql = "";
|
||||
// $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;
|
||||
// }
|
||||
$tot_count = 0;
|
||||
$sql = "SELECT T_TestID
|
||||
FROM t_orderdetail JOIN t_test ON T_OrderDetailT_TEstID = T_TestID
|
||||
WHERE T_OrderDetailT_OrderHeaderID = ?
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_TestParentT_TestID = 0";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query) {
|
||||
$rst = [];
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$sql = "WITH RECURSIVE ancestors AS
|
||||
(
|
||||
SELECT t_testid, t_testname,
|
||||
T_OrderDetailResult result, T_OrderDetailNote note, T_OrderDetailID id,
|
||||
T_OrderDetailT_TestIsResult is_result, 1 level,
|
||||
T_OrderDetailValMRState mr_state,
|
||||
T_OrderDetailValidation validation,
|
||||
T_OrderDetailValidation validation_old,
|
||||
'N' unvalidation
|
||||
FROM t_orderdetail
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
WHERE T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND t_testid = ?
|
||||
|
||||
UNION
|
||||
|
||||
SELECT g.t_testid, g.t_testname,
|
||||
T_OrderDetailResult result, T_OrderDetailNote note, T_OrderDetailID id,
|
||||
T_OrderDetailT_TestIsResult is_result, level+1 level,
|
||||
T_OrderDetailValMRState mr_state,
|
||||
T_OrderDetailValidation validation,
|
||||
T_OrderDetailValidation validation_old,
|
||||
'N' unvalidation
|
||||
FROM ancestors a, t_orderdetail f
|
||||
JOIN t_test g ON f.T_OrderDetailT_TestID = g.T_TestID
|
||||
|
||||
WHERE T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_OrderHeaderID = ?
|
||||
AND g.t_testparentt_testid = a.t_testid and g.t_testisactive = 'Y' )
|
||||
SELECT * FROM ancestors;";
|
||||
$query = $this->db_smartone->query($sql, [$id, $v['T_TestID'], $id]);
|
||||
|
||||
$r = $query->result_array();
|
||||
foreach($r as $k => $v) {
|
||||
if ($v['mr_state'] == "X")
|
||||
{
|
||||
$tmp = $this->db_smartone->query("SELECT fn_process_rv_mrstate('{$v['id']}') x")
|
||||
->row();
|
||||
$v['mr_state'] = $tmp->x;
|
||||
}
|
||||
|
||||
// Sample Handling & Verification Perfect
|
||||
$y = $this->db_smartone->query("SELECT fn_process_sample_handling_perfect('{$id}', '{$v['t_testid']}') c")
|
||||
->row();
|
||||
$v['sample_handling_perfect'] = $y->c;
|
||||
$rst[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rst, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RE Px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["id"]);
|
||||
|
||||
if (sizeof($data) < 1)
|
||||
{
|
||||
$this->sys_error_db("RE Verification Confirmation", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailVerDeltaCheck', $v->delta)
|
||||
->set('T_OrderDetailVerTrendAnalysis', $v->trend)
|
||||
->set('T_OrderDetailVerification', $v->verification)
|
||||
->set('T_OrderDetailVerDate', date('Y-m-d H:i:s'))
|
||||
->set('T_OrderDetailVerUserID', $this->sys_user->M_UserID)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
|
||||
public function search_group()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("worklist count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_WorklistID group_id, T_WorklistName group_name
|
||||
from t_worklist
|
||||
where T_WorklistIsActive = 'Y'
|
||||
order by T_WorklistName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['data'] = json_decode($v['data']);
|
||||
$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("worklist rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Rv_validation extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Result Validation API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function mr_state()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["order_id"];
|
||||
|
||||
$data = ["image"=>"http://blog.aylien.com/wp-content/uploads/2016/07/Screen-Shot-2016-07-21-at-18.46.42.png",
|
||||
"note"=>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"title"=>"Multi Rule"];
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
|
||||
public function unvalidate()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$data = json_decode($prm["data"]);
|
||||
|
||||
if (sizeof($data) < 1)
|
||||
{
|
||||
$this->sys_error_db("RE UnValidation", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($data as $k => $v)
|
||||
{
|
||||
$this->db_smartone->set('T_OrderDetailValidation', "N")
|
||||
->set('T_OrderDetailValDate', null)
|
||||
->set('T_OrderDetailValUserID', 0)
|
||||
->where('T_OrderDetailID', $v->id)
|
||||
->update('t_orderdetail');
|
||||
$ids[] = $v->id;
|
||||
}
|
||||
|
||||
// LOG Process
|
||||
$order = $this->db_smartone->select('T_OrderDetailT_OrderHeaderID id, T_OrderHeaderLabNumber lab_number', false)
|
||||
->join('t_orderheader', 'T_OrderHeaderID = T_OrderDetailT_OrderHeaderID')
|
||||
->where('T_OrderDetailID', $data[0]->id)
|
||||
->get('t_orderdetail')
|
||||
->row();
|
||||
|
||||
$dblog = $this->load->database("onelog", true);
|
||||
$dblog->set('Log_ProcessCode', 'PROCESS.Result.Unvalidation')
|
||||
->set('Log_ProcessOrderID', $order->id)
|
||||
->set('Log_ProcessOrderNumber', $order->lab_number)
|
||||
->set('Log_ProcessJson', json_encode($data))
|
||||
->set('Log_ProcessUserID', $this->sys_user['M_UserID'])
|
||||
->insert('log_process');
|
||||
// END OF Log Process
|
||||
|
||||
$this->sys_ok($ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user