Initial import
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ri_detail extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RI Detail API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$order_id = $prm["order_id"];
|
||||
$search = '%'.$prm["query"].'%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM t_orderrefintdetail
|
||||
JOIN t_orderheader ON T_OrderRefIntDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdetail ON T_OrderRefIntDetailT_OrderDetailID = T_OrderDetailID
|
||||
JOIN t_test ON T_OrderRefIntDetailT_TestID = T_TestID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_statusref ON T_OrderRefIntDetailM_StatusRefID = M_StatusRefID
|
||||
WHERE T_OrderRefIntDetailIsActive = 'Y'
|
||||
AND T_OrderRefIntDetailT_OrderRefIntID = ?
|
||||
AND (M_PatientName LIKE ? OR T_OrderHeaderLabNumber LIKE ?)";
|
||||
$query = $this->db_smartone->query($sql, [$order_id, $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, fn_global_patient_name(T_OrderHeaderM_PatientID) patient_name,
|
||||
T_TestName, T_OrderRefIntDetailResult, T_OrderRefIntDetailPromise,
|
||||
M_StatusRefName
|
||||
FROM t_orderrefintdetail
|
||||
JOIN t_orderheader ON T_OrderRefIntDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdetail ON T_OrderRefIntDetailT_OrderDetailID = T_OrderDetailID
|
||||
JOIN t_test ON T_OrderRefIntDetailT_TestID = T_TestID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_statusref ON T_OrderRefIntDetailM_StatusRefID = M_StatusRefID
|
||||
WHERE T_OrderRefIntDetailIsActive = 'Y'
|
||||
AND T_OrderRefIntDetailT_OrderRefIntID = ?
|
||||
AND (M_PatientName LIKE ? OR T_OrderHeaderLabNumber LIKE ?)
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$order_id, $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("RI Detail rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ri_header extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RI Header 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(*)
|
||||
FROM t_orderrefint
|
||||
JOIN m_branch ON T_OrderRefIntDestM_BranchID = M_BranchID
|
||||
JOIN m_statusref ON T_OrderRefIntM_StatusRefID = M_StatusRefID
|
||||
WHERE T_OrderRefIntIsActive = 'Y'
|
||||
AND T_OrderRefIntDate = ?";
|
||||
$query = $this->db_smartone->query($sql, [$sdate]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderRefIntID, T_OrderRefIntDate, T_OrderRefIntNumber, M_BranchID, M_BranchName,
|
||||
M_StatusRefName T_OrderRefIntStatus, M_StatusRefCode
|
||||
FROM t_orderrefint
|
||||
JOIN m_branch ON T_OrderRefIntDestM_BranchID = M_BranchID
|
||||
JOIN m_statusref ON T_OrderRefIntM_StatusRefID = M_StatusRefID
|
||||
WHERE T_OrderRefIntIsActive = 'Y'
|
||||
AND T_OrderRefIntDate = ?
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$sdate]);
|
||||
|
||||
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("RI Header rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$ref_id = $prm['ref_id'];
|
||||
|
||||
$sql = "CALL sp_process_refinternal_confirm(?)";
|
||||
$query = $this->db_smartone->query($sql, [$ref_id]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("REF INTERNAL CONFIRM", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ri_new extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RI New API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_branch()
|
||||
{
|
||||
$sql = "SELECT M_BranchID, M_BranchName, IFNULL(S_SystemsID, 0) `default`
|
||||
FROM m_branch
|
||||
LEFT JOIN conf_systems ON M_BranchID = S_SystemsM_BranchID
|
||||
WHERE M_BranchIsActive = 'Y'
|
||||
ORDER BY M_BranchName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows, "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Branch rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_worklist()
|
||||
{
|
||||
$sql = "SELECT T_WorklistID, T_WorklistName,
|
||||
CONCAT('[', GROUP_CONCAT(JSON_OBJECT('test_id', T_TestID, 'test_name', T_TestName) SEPARATOR ','), ']') tests
|
||||
FROM t_worklist
|
||||
JOIN t_worklistdetail ON T_WorklistDetailT_WorklistID = T_WorklistID
|
||||
AND T_WorklistDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_WorklistDetailT_TestID = T_TestID
|
||||
WHERE T_WorklistIsActive = 'Y'
|
||||
AND T_WorklistIsRujukan = 'Y'
|
||||
AND `fn_process_refinternal_hasorder`(T_TestID) > 0
|
||||
GROUP BY T_WorklistID
|
||||
ORDER BY T_WorklistName, T_TestName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v)
|
||||
$rows[$k]['tests'] = json_decode($v['tests']);
|
||||
|
||||
$result = array("records" => $rows, "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Branch rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_patient()
|
||||
{
|
||||
// print_r($this->sys_user);
|
||||
$prm = $this->sys_input;
|
||||
$ids = $prm['ids'];
|
||||
|
||||
$sql = "SELECT b.T_OrderDetailID, T_OrderHeaderID, T_OrderHeaderLabNumber, b.T_OrderDetailT_TestName,
|
||||
T_OrderHeaderDate, fn_global_patient_name(T_OrderHeaderM_PatientID) patient_name
|
||||
FROM t_ordersample
|
||||
JOIN t_test ON T_OrderSampleT_SampleTypeID = T_TestT_SampleTypeID
|
||||
AND FIND_IN_SET(T_TestID, ?)
|
||||
JOIN t_orderdetail a ON a.T_OrderDetailT_OrderHeaderID = T_OrderSampleT_OrderHeaderID
|
||||
AND a.T_OrderDetailT_TestID = T_TestID
|
||||
AND a.T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_orderdetail b ON a.T_OrderDetailT_OrderHeaderID = b.T_OrderDetailT_OrderHeaderID
|
||||
AND b.T_OrderdetailIsActive = 'Y'
|
||||
AND b.T_OrderDetailT_TestSasCode LIKE CONCAT(a.T_OrderDetailT_TestSasCode, '%')
|
||||
AND b.T_OrderDetailT_TestIsResult = 'Y'
|
||||
LEFT JOIN t_orderrefintdetail ON b.T_OrderDetailID = T_OrderRefIntDetailT_OrderDetailID
|
||||
AND T_ORderRefIntDetailIsActive = 'Y'
|
||||
JOIN t_orderheader ON a.T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
WHERE T_OrderSampleWorklistReceive = 'Y'
|
||||
AND T_OrderSampleIsActive = 'Y'
|
||||
AND T_OrderRefIntDetailID IS NULL";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$ids]);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows, "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Patient rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$ids = json_encode(explode(',', $prm['ids']));
|
||||
$branch_id = $prm['branch_id'];
|
||||
|
||||
$sql = "CALL sp_process_refinternal_save(?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$branch_id, $ids]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("Patient rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ri_samplereceive_header extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RI Sample Receive Header 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(*)
|
||||
FROM xfer_internal
|
||||
JOIN m_branch ON T_OrderRefIntSrcM_BranchID = M_BranchID
|
||||
JOIN m_statusref ON T_OrderRefIntM_StatusRefID = M_StatusRefID
|
||||
WHERE Xfer_InternalIsActive = 'Y'
|
||||
AND Xfer_InternalType = 'I'
|
||||
AND Xfer_InternalDataType = 'REF.ORDER'";
|
||||
$query = $this->db_smartone->query($sql, [$sdate]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Xfer_InternalID, Xfer_InternalDate, M_BranchID, , T_OrderRefIntNumber, M_BranchID, M_BranchName,
|
||||
M_StatusRefName T_OrderRefIntStatus, M_StatusRefCode
|
||||
FROM xfer_internal
|
||||
JOIN m_branch ON T_OrderRefIntSrcM_BranchID = M_BranchID
|
||||
JOIN m_statusref ON T_OrderRefIntM_StatusRefID = M_StatusRefID
|
||||
WHERE Xfer_InternalIsActive = 'Y'
|
||||
AND Xfer_InternalType = 'I'
|
||||
AND Xfer_InternalDataType = 'REF.ORDER'
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$sdate]);
|
||||
|
||||
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("RI Sample Receive Header rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user