Initial import
This commit is contained in:
218
application/controllers/confirm-result/Getorder.php
Normal file
218
application/controllers/confirm-result/Getorder.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
class Getorder extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// db wilayah contoh surabaya
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
|
||||
// string database
|
||||
$this->db_str_doctor = 'one_doctor';
|
||||
$this->M_MouM_CompanyID = "1235";
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "GET RESULT";
|
||||
}
|
||||
|
||||
public function getdata()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$limit = 10;
|
||||
if (isset($prm['limit'])) {
|
||||
$limit = trim($prm["limit"]);
|
||||
$limit = $prm['limit'];
|
||||
}
|
||||
$sql = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
AND M_MouIsBill = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
WHERE (OneResultConfirmStatus = 'C' OR OneResultConfirmStatus = 'R' OR OneResultConfirmStatus = 'E') AND OneResultConfirmRetry <= 5
|
||||
group by T_OrderHeaderID
|
||||
|
||||
UNION
|
||||
|
||||
select
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderLabNumber as no_reg,
|
||||
T_OrderHeaderDate,
|
||||
concat(M_TitleName, ' ',
|
||||
ifnull(M_PatientPrefix,' '),
|
||||
M_PatientName,
|
||||
ifnull(M_PatientSuffix,'')
|
||||
) as nama_pasien,
|
||||
'' as test,
|
||||
IFNULL(OneResultConfirmStatus,'-') as OneResultConfirmStatus,
|
||||
OneResultConfirmRetry
|
||||
from t_orderheader
|
||||
join t_orderdetail
|
||||
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
join m_mou
|
||||
ON T_OrderHeaderM_MouID = M_MouID
|
||||
AND M_MouIsActive = 'Y'
|
||||
AND M_MouIsReleased = 'Y'
|
||||
left join one_result_confirm
|
||||
ON T_OrderHeaderID = OneResultConfirmT_OrderHeaderID
|
||||
AND OneResultConfirmIsActive = 'Y'
|
||||
join m_patient
|
||||
ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_title
|
||||
on M_PatientM_TitleID = M_TitleID
|
||||
join f_payment
|
||||
ON t_orderheader.T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
AND F_PaymentIsActive = 'Y'
|
||||
join f_payment_orderheader
|
||||
ON F_PaymentID = F_Payment_OrderHeaderF_PaymentID
|
||||
AND F_Payment_OrderHeaderIsLunas = 'Y'
|
||||
WHERE (OneResultConfirmStatus = 'C' OR OneResultConfirmStatus = 'R' OR OneResultConfirmStatus = 'E') AND OneResultConfirmRetry <= 5
|
||||
group by T_OrderHeaderID
|
||||
limit $limit";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok($rows);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function update_status()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
$id = 0;
|
||||
if (isset($prm['id'])) {
|
||||
$id = trim($prm["id"]);
|
||||
$id = $prm['id'];
|
||||
}
|
||||
$status = "A";
|
||||
if (isset($prm['status'])) {
|
||||
$status = trim($prm["status"]);
|
||||
$status = $prm['status'];
|
||||
}
|
||||
|
||||
// print_r("$status & $id");
|
||||
// exit;
|
||||
|
||||
if ($id == 0) {
|
||||
$this->sys_error("ID mandatory !");
|
||||
exit;
|
||||
}
|
||||
if ($status == "A") {
|
||||
$this->sys_error("status mandatory !");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_retry = "SELECT OneResultConfirmRetry
|
||||
FROM one_result_confirm
|
||||
WHERE OneResultConfirmT_OrderHeaderID = ?";
|
||||
$query_retry = $this->db->query($sql_retry, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query_retry) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
$retry = intval($query_retry->result_array()[0]['OneResultConfirmRetry']) + 1;
|
||||
// print_r(
|
||||
// array(
|
||||
// "retrydb" => $query_retry->result_array()[0]['OneResultConfirmRetry'],
|
||||
// "retry + 1" => $query_retry->result_array()[0]['OneResultConfirmRetry'] + 1,
|
||||
// "resp" => $query_retry->result_array(),
|
||||
// "last_qry" => $this->db->last_query(),
|
||||
// "retry_var" => $retry
|
||||
// )
|
||||
|
||||
// );
|
||||
// exit;
|
||||
|
||||
if (count($query_retry->result_array()) > 0) {
|
||||
if ($status == "E") {
|
||||
|
||||
$sql = "UPDATE one_result_confirm SET
|
||||
OneResultConfirmStatus = 'E'
|
||||
,OneResultConfirmRetry = ?
|
||||
,OneResultConfirmLastUpdated = ?
|
||||
WHERE OneResultConfirmT_OrderHeaderID = ?";
|
||||
$query = $this->db->query($sql, [$retry, date("Y-m-d H:i:s"), $id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
} else if ($status == "S") {
|
||||
$sql = "UPDATE one_result_confirm SET
|
||||
OneResultConfirmStatus = 'S'
|
||||
WHERE OneResultConfirmT_OrderHeaderID = ?";
|
||||
$query = $this->db->query($sql, [$id]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$query) {
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = array(
|
||||
"message" => "ID not found",
|
||||
);
|
||||
$this->sys_error($error);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok("OK");
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user