Sync resume status to MCU dashboard
This commit is contained in:
@@ -10,12 +10,50 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
echo "CPONE RESUME INDIVIDU API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
// $this->load->library("SsPriceMou");
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->library('Mcudashboard');
|
||||
// $this->load->library("SsPriceMou");
|
||||
}
|
||||
private function sync_resume_status_dashboard($resumeID)
|
||||
{
|
||||
$resumeID = intval($resumeID);
|
||||
if ($resumeID <= 0) {
|
||||
return;
|
||||
}
|
||||
$this->mcudashboard->upsert_patient_resume_status($resumeID);
|
||||
}
|
||||
|
||||
private function upsert_published_dashboard_on_new_to_val($orderID, $oldStatus, $newStatus, $userID)
|
||||
{
|
||||
$orderID = intval($orderID);
|
||||
$userID = intval($userID);
|
||||
$oldStatus = strtoupper(trim((string)$oldStatus));
|
||||
$newStatus = strtoupper(trim((string)$newStatus));
|
||||
|
||||
if ($orderID <= 0 || !($oldStatus === 'NEW' && $newStatus === 'VAL')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO published_mcu_dashboard (
|
||||
Published_McuDasboardT_OrderHeaderID,
|
||||
Published_McuDasboardStatus,
|
||||
Published_McuDasboardIsActive,
|
||||
Published_McuDasboardCreated,
|
||||
Published_McuDasboardCreatedUserID,
|
||||
Published_McuDasboardLastUpdated,
|
||||
Published_McuDasboardLastUpdatedUserID
|
||||
)
|
||||
VALUES (?, 'N', 'Y', NOW(), ?, NOW(), ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Published_McuDasboardStatus = 'N',
|
||||
Published_McuDasboardIsActive = 'Y',
|
||||
Published_McuDasboardLastUpdated = NOW(),
|
||||
Published_McuDasboardLastUpdatedUserID = VALUES(Published_McuDasboardLastUpdatedUserID)";
|
||||
$this->db_onedev->query($sql, array($orderID, $userID, $userID));
|
||||
}
|
||||
public function getsetup()
|
||||
{
|
||||
try {
|
||||
@@ -647,12 +685,13 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
}
|
||||
|
||||
$status = 'NEW';
|
||||
$statusLog = $act;
|
||||
$val = 'N';
|
||||
$dt = '0000-00-00 00:00:00';
|
||||
if ($act == 'VAL') {
|
||||
$status = 'VAL';
|
||||
$val = 'Y';
|
||||
$statusLog = $act;
|
||||
$val = 'N';
|
||||
$dt = '0000-00-00 00:00:00';
|
||||
$statusBefore = 'NEW';
|
||||
if ($act == 'VAL') {
|
||||
$status = 'VAL';
|
||||
$val = 'Y';
|
||||
$dt = date("Y-m-d h:i:s");
|
||||
} else if ($act == 'UNVAL') {
|
||||
$val = 'N';
|
||||
@@ -675,8 +714,11 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
exit;
|
||||
}
|
||||
|
||||
$dataCek = $query->result_array();
|
||||
if (count($dataCek) == 0) {
|
||||
$dataCek = $query->result_array();
|
||||
if (count($dataCek) > 0 && isset($dataCek[0]['Mcu_ResumeStatus'])) {
|
||||
$statusBefore = $dataCek[0]['Mcu_ResumeStatus'];
|
||||
}
|
||||
if (count($dataCek) == 0) {
|
||||
$sql = "INSERT INTO mcu_resume
|
||||
(Mcu_ResumeT_OrderHeaderID,
|
||||
Mcu_ResumeStatus,
|
||||
@@ -982,13 +1024,15 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
$statusLog,
|
||||
$userid
|
||||
]);
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$this->sys_ok('ok');
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$this->upsert_published_dashboard_on_new_to_val($data['orderID'], $statusBefore, $status, $userid);
|
||||
$this->sync_resume_status_dashboard($resumeID);
|
||||
$this->sys_ok('ok');
|
||||
}
|
||||
function getlab($id, $isApi)
|
||||
{
|
||||
@@ -1891,14 +1935,15 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
$status,
|
||||
$userid
|
||||
]);
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$this->sys_ok('OK');
|
||||
exit;
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$this->sync_resume_status_dashboard($resumeID);
|
||||
$this->sys_ok('OK');
|
||||
exit;
|
||||
}
|
||||
function cobaGenerate($orderID, $userID)
|
||||
{
|
||||
@@ -2352,15 +2397,16 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
$status,
|
||||
$userid
|
||||
]);
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
for ($i = 0; $i < count($rtn['data']); $i++) {
|
||||
$rtn['data'][$i]['Nat_TestName'] = str_replace("|", ", ", $rtn['data'][$i]['Nat_TestName']);
|
||||
}
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$this->sync_resume_status_dashboard($resumeID);
|
||||
for ($i = 0; $i < count($rtn['data']); $i++) {
|
||||
$rtn['data'][$i]['Nat_TestName'] = str_replace("|", ", ", $rtn['data'][$i]['Nat_TestName']);
|
||||
}
|
||||
$this->sys_ok($rtn);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user