211 lines
8.6 KiB
PHP
211 lines
8.6 KiB
PHP
<?php
|
|
class Getorder extends MY_Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function index()
|
|
{
|
|
echo "GET LIST PATIENT";
|
|
}
|
|
|
|
public function listpatient()
|
|
{
|
|
try {
|
|
|
|
$sql = "SELECT
|
|
T_OrderHeaderID,
|
|
T_OrderHeaderLabNumber as no_reg,
|
|
T_OrderHeaderDate,
|
|
T_OrderHeaderLabNumberExt,
|
|
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
|
M_PatientIDNumber,
|
|
M_PatientHP,
|
|
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
|
LogConfirmEformRetry,
|
|
So_TemplateName
|
|
FROM t_orderheader
|
|
join t_orderdetail
|
|
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
AND T_OrderDetailIsActive = 'Y'
|
|
AND T_OrderHeaderIsActive = 'Y'
|
|
join so_testtemplate
|
|
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
|
AND So_TestTemplateIsActive = 'Y'
|
|
join so_template
|
|
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
|
AND So_TemplateIsActive = 'Y'
|
|
AND So_TemplateID IN (6,8,9)
|
|
join m_mou
|
|
ON T_OrderHeaderM_MouID = M_MouID
|
|
AND M_MouIsActive = 'Y'
|
|
AND M_MouIsReleased = 'Y'
|
|
AND M_MouIsMcu = 'Y'
|
|
AND M_MouIsBill = 'Y'
|
|
join m_patient
|
|
ON T_OrderHeaderM_PatientID = M_PatientID
|
|
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
|
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
|
join m_title
|
|
on M_PatientM_TitleID = M_TitleID
|
|
left join log_confirm_eform
|
|
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
|
AND LogConfirmEformIsActive = 'Y'
|
|
WHERE (LogConfirmEformStatus = 'C' OR LogConfirmEformStatus = 'R' OR LogConfirmEformStatus = 'E') AND LogConfirmEformRetry <= 5
|
|
group by T_OrderHeaderID
|
|
|
|
UNION
|
|
|
|
SELECT
|
|
T_OrderHeaderID,
|
|
T_OrderHeaderLabNumber as no_reg,
|
|
T_OrderHeaderDate,
|
|
T_OrderHeaderLabNumberExt,
|
|
concat(M_TitleName, ' ', ifnull(M_PatientPrefix,' '), M_PatientName, ifnull(M_PatientSuffix,'')) as nama_pasien,
|
|
M_PatientIDNumber,
|
|
M_PatientHP,
|
|
IFNULL(LogConfirmEformStatus,'-') as LogConfirmEformStatus,
|
|
LogConfirmEformRetry,
|
|
So_TemplateName
|
|
from t_orderheader
|
|
join t_orderdetail
|
|
ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
|
AND T_OrderDetailIsActive = 'Y'
|
|
AND T_OrderHeaderIsActive = 'Y'
|
|
join so_testtemplate
|
|
ON T_OrderDetailT_TestID = So_TestTemplateT_TestID
|
|
AND So_TestTemplateIsActive = 'Y'
|
|
join so_template
|
|
ON So_TestTemplateSo_TemplateID = So_TemplateID
|
|
AND So_TemplateIsActive = 'Y'
|
|
AND So_TemplateID IN (6,8,9)
|
|
join m_mou
|
|
ON T_OrderHeaderM_MouID = M_MouID
|
|
AND M_MouIsActive = 'Y'
|
|
AND M_MouIsReleased = 'Y'
|
|
AND M_MouIsMcu = 'Y'
|
|
join m_patient
|
|
ON T_OrderHeaderM_PatientID = M_PatientID
|
|
AND (M_PatientIDNumber <> '' AND M_PatientIDNumber IS NOT NULL)
|
|
AND (M_PatientHP <> '' AND M_PatientHP IS NOT NULL AND M_PatientHP <> '-')
|
|
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'
|
|
left join log_confirm_eform
|
|
ON T_OrderHeaderID = LogConfirmEformT_OrderHeaderID
|
|
AND LogConfirmEformIsActive = 'Y'
|
|
WHERE (LogConfirmEformStatus = 'C' OR LogConfirmEformStatus = 'R' OR LogConfirmEformStatus = 'E') AND LogConfirmEformRetry <= 5
|
|
group by T_OrderHeaderID";
|
|
|
|
$qry = $this->db->query($sql);
|
|
$last_query = $this->db->last_query();
|
|
if (!$qry) {
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_query
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
$rows = $qry->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'];
|
|
}
|
|
|
|
if ($id == 0) {
|
|
$this->sys_error("ID mandatory !");
|
|
exit;
|
|
}
|
|
if ($status == "A") {
|
|
$this->sys_error("status mandatory !");
|
|
exit;
|
|
}
|
|
|
|
$sql_retry = "SELECT LogConfirmEformRetry
|
|
FROM log_confirm_eform
|
|
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
|
$qry_retry = $this->db->query($sql_retry, [$id]);
|
|
$last_qry = $this->db->last_query();
|
|
if (!$last_qry) {
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
$retry = intval($qry_retry->result_array()[0]["LogConfirmEformRetry"]) + 1;
|
|
|
|
if (count($qry_retry->result_array()) > 0) {
|
|
if ($status == "E") {
|
|
$sql = "UPDATE log_confirm_eform SET
|
|
LogConfirmEformStatus = 'E',
|
|
LogConfirmEformRetry = ?,
|
|
LogConfirmEformLastUpdated = ?
|
|
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
|
|
|
$qry = $this->db->query($sql, [$retry, date("Y-m-d H:i:s"), $id]);
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
} else if ($status == "S") {
|
|
$sql = "UPDATE log_confirm_eform SET
|
|
LogConfirmEformStatus = 'S',
|
|
LogConfirmEformLastUpdated = ?
|
|
WHERE LogConfirmEformT_OrderHeaderID = ?";
|
|
$qry = $this->db->query($sql, [date("Y-m-d H:i:s"), $id]);
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
$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);
|
|
}
|
|
}
|
|
}
|