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";
|
echo "CPONE RESUME INDIVIDU API";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->db_onedev = $this->load->database("onedev", true);
|
$this->db_onedev = $this->load->database("onedev", true);
|
||||||
// $this->load->library("SsPriceMou");
|
$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()
|
public function getsetup()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -647,12 +685,13 @@ class Resumeindividucponev7 extends MY_Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$status = 'NEW';
|
$status = 'NEW';
|
||||||
$statusLog = $act;
|
$statusLog = $act;
|
||||||
$val = 'N';
|
$val = 'N';
|
||||||
$dt = '0000-00-00 00:00:00';
|
$dt = '0000-00-00 00:00:00';
|
||||||
if ($act == 'VAL') {
|
$statusBefore = 'NEW';
|
||||||
$status = 'VAL';
|
if ($act == 'VAL') {
|
||||||
$val = 'Y';
|
$status = 'VAL';
|
||||||
|
$val = 'Y';
|
||||||
$dt = date("Y-m-d h:i:s");
|
$dt = date("Y-m-d h:i:s");
|
||||||
} else if ($act == 'UNVAL') {
|
} else if ($act == 'UNVAL') {
|
||||||
$val = 'N';
|
$val = 'N';
|
||||||
@@ -675,8 +714,11 @@ class Resumeindividucponev7 extends MY_Controller
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dataCek = $query->result_array();
|
$dataCek = $query->result_array();
|
||||||
if (count($dataCek) == 0) {
|
if (count($dataCek) > 0 && isset($dataCek[0]['Mcu_ResumeStatus'])) {
|
||||||
|
$statusBefore = $dataCek[0]['Mcu_ResumeStatus'];
|
||||||
|
}
|
||||||
|
if (count($dataCek) == 0) {
|
||||||
$sql = "INSERT INTO mcu_resume
|
$sql = "INSERT INTO mcu_resume
|
||||||
(Mcu_ResumeT_OrderHeaderID,
|
(Mcu_ResumeT_OrderHeaderID,
|
||||||
Mcu_ResumeStatus,
|
Mcu_ResumeStatus,
|
||||||
@@ -982,13 +1024,15 @@ class Resumeindividucponev7 extends MY_Controller
|
|||||||
$statusLog,
|
$statusLog,
|
||||||
$userid
|
$userid
|
||||||
]);
|
]);
|
||||||
if (!$query) {
|
if (!$query) {
|
||||||
$message = $this->db_onedev->error();
|
$message = $this->db_onedev->error();
|
||||||
$message['qry'] = $this->db_onedev->last_query();
|
$message['qry'] = $this->db_onedev->last_query();
|
||||||
$this->sys_error($message);
|
$this->sys_error($message);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$this->sys_ok('ok');
|
$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)
|
function getlab($id, $isApi)
|
||||||
{
|
{
|
||||||
@@ -1891,14 +1935,15 @@ class Resumeindividucponev7 extends MY_Controller
|
|||||||
$status,
|
$status,
|
||||||
$userid
|
$userid
|
||||||
]);
|
]);
|
||||||
if (!$query) {
|
if (!$query) {
|
||||||
$message = $this->db_onedev->error();
|
$message = $this->db_onedev->error();
|
||||||
$message['qry'] = $this->db_onedev->last_query();
|
$message['qry'] = $this->db_onedev->last_query();
|
||||||
$this->sys_error($message);
|
$this->sys_error($message);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$this->sys_ok('OK');
|
$this->sync_resume_status_dashboard($resumeID);
|
||||||
exit;
|
$this->sys_ok('OK');
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
function cobaGenerate($orderID, $userID)
|
function cobaGenerate($orderID, $userID)
|
||||||
{
|
{
|
||||||
@@ -2352,15 +2397,16 @@ class Resumeindividucponev7 extends MY_Controller
|
|||||||
$status,
|
$status,
|
||||||
$userid
|
$userid
|
||||||
]);
|
]);
|
||||||
if (!$query) {
|
if (!$query) {
|
||||||
$message = $this->db_onedev->error();
|
$message = $this->db_onedev->error();
|
||||||
$message['qry'] = $this->db_onedev->last_query();
|
$message['qry'] = $this->db_onedev->last_query();
|
||||||
$this->sys_error($message);
|
$this->sys_error($message);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < count($rtn['data']); $i++) {
|
$this->sync_resume_status_dashboard($resumeID);
|
||||||
$rtn['data'][$i]['Nat_TestName'] = str_replace("|", ", ", $rtn['data'][$i]['Nat_TestName']);
|
for ($i = 0; $i < count($rtn['data']); $i++) {
|
||||||
}
|
$rtn['data'][$i]['Nat_TestName'] = str_replace("|", ", ", $rtn['data'][$i]['Nat_TestName']);
|
||||||
|
}
|
||||||
$this->sys_ok($rtn);
|
$this->sys_ok($rtn);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user