1032 lines
41 KiB
PHP
1032 lines
41 KiB
PHP
<?php
|
|
class Uploadnational extends MY_Controller
|
|
{
|
|
var $db;
|
|
var $hostname;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->hostname = '192.168.250.42';
|
|
// $this->hostname = 'devbandungraya.aplikasi.web.id';
|
|
}
|
|
public function index()
|
|
{
|
|
echo "ETL MCU Top 3 Kelainan";
|
|
}
|
|
|
|
function reply($resp)
|
|
{
|
|
echo json_encode($resp);
|
|
}
|
|
|
|
function reply_gz($resp, $debug = "")
|
|
{
|
|
if ($debug != "") {
|
|
echo json_encode($resp);
|
|
} else {
|
|
echo gzcompress(json_encode($resp));
|
|
}
|
|
}
|
|
|
|
function get_param()
|
|
{
|
|
|
|
$body = file_get_contents("php://input");
|
|
return json_decode($body, true);
|
|
}
|
|
|
|
function get_param_z($debug = 'N')
|
|
{
|
|
$body_z = file_get_contents("php://input");
|
|
$body = '';
|
|
if ($debug == 'Y') {
|
|
$body = $body_z;
|
|
} else {
|
|
$body = gzuncompress($body_z);
|
|
}
|
|
return json_decode($body, true);
|
|
}
|
|
public function post($url, $data)
|
|
{
|
|
$ch = curl_init($url);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"Content-Type: application/text",
|
|
"Content-Length: " . strlen($data),
|
|
]);
|
|
$result = curl_exec($ch);
|
|
if (curl_error($ch) != "") {
|
|
echo json_encode([
|
|
"status" => "ERR",
|
|
"message" => "Http Error : " . curl_error($ch),
|
|
]);
|
|
curl_close($ch);
|
|
exit();
|
|
}
|
|
curl_close($ch);
|
|
return $result;
|
|
}
|
|
public function getBranch()
|
|
{
|
|
$sql = "SELECT * FROM `m_branch` WHERE `M_BranchIsDefault` = 'Y'";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get branch");
|
|
exit;
|
|
}
|
|
$result = $qry->row_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
|
|
public function getMgmMcu()
|
|
{
|
|
$sql = "SELECT
|
|
one_etl.mgm_mcu.*,
|
|
MAX(LogUploadMgmHeaderUploadDate) AS LatestUploadDate
|
|
FROM
|
|
one_etl.mgm_mcu
|
|
JOIN
|
|
one_etl.mgm_header ON Mgm_HeaderMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuNumberNational IS NOT NULL
|
|
AND Mgm_McuNumberNational <> ''
|
|
AND Mgm_McuStartDate <= CURDATE()
|
|
AND CURDATE() <= DATE_ADD(Mgm_McuEndDate, INTERVAL 6 MONTH)
|
|
-- AND Mgm_HeaderIsActive = 'Y'
|
|
-- AND Mgm_McuIsActive = 'Y'
|
|
-- AND Mgm_McuID = 2
|
|
LEFT JOIN
|
|
one_etl.log_upload_mgm_header AS log ON LogUploadMgmHeaderMgm_HeaderID = Mgm_HeaderID
|
|
GROUP BY
|
|
Mgm_McuID ;";
|
|
|
|
// $sql = "SELECT
|
|
// one_etl.mgm_mcu.*
|
|
// FROM one_etl.mgm_mcu
|
|
// LEFT JOIN one_etl.log_upload_mgm_mcu
|
|
// ON Mgm_McuID = LogUploadMgmMcuMgm_McuID
|
|
// AND Mgm_McuIsActive = 'Y'
|
|
// AND Mgm_McuNumberNational IS NOT NULL
|
|
// AND Mgm_McuNumberNational <> ''
|
|
// AND (LogUploadMgmMcuID IS NULL OR LogUploadMgmMcuID IN ('E','N','R'))";
|
|
$sql = "SELECT
|
|
one_etl.mgm_mcu.*,
|
|
MAX(LogUploadMgmHeaderUploadDate) AS LatestUploadDate
|
|
FROM
|
|
one_etl.mgm_mcu
|
|
JOIN
|
|
one_etl.mgm_header ON Mgm_HeaderMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuNumberNational IS NOT NULL
|
|
AND Mgm_McuNumberNational <> ''
|
|
AND Mgm_McuStartDate <= CURDATE()
|
|
AND CURDATE() <= DATE_ADD(Mgm_McuEndDate, INTERVAL 6 MONTH)
|
|
-- AND Mgm_HeaderIsActive = 'Y'
|
|
-- AND Mgm_McuIsActive = 'Y'
|
|
-- AND Mgm_McuID = 2
|
|
LEFT JOIN
|
|
one_etl.log_upload_mgm_header AS log ON LogUploadMgmHeaderMgm_HeaderID = Mgm_HeaderID
|
|
GROUP BY
|
|
Mgm_McuID;";
|
|
// AND Mgm_McuID= 17
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM MCU");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
|
|
public function getCompany($mgmMcuID, $branchCode)
|
|
{
|
|
$sql = "SELECT
|
|
M_CompanyID,
|
|
M_CompanyName,
|
|
M_CompanyAddress,
|
|
M_CompanyIsActive,
|
|
{$mgmMcuID} as mcuID
|
|
FROM m_company
|
|
JOIN one_etl.mgm_mcu
|
|
ON M_CompanyID = Mgm_McuM_CompanyID
|
|
WHERE Mgm_McuID = {$mgmMcuID}";
|
|
// AND Mgm_McuID= 17
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM COMPANY");
|
|
exit;
|
|
}
|
|
// echo $sql;
|
|
$result = $qry->row_array();
|
|
// "branch": {
|
|
// "M_BranchCode": "DA"
|
|
// },
|
|
// "data":{
|
|
// "Mgm_McuID": "16",
|
|
// "Mgm_McuM_CompanyID": "3323",
|
|
// "Mgm_McuNumber": "PMCU240800005",
|
|
// "Mgm_McuNumberNational": "0123512",
|
|
// "Mgm_McuStartDate": "2024-07-17",
|
|
// "Mgm_McuEndDate": "2024-07-24",
|
|
// "Mgm_McuIsActive": "Y",
|
|
// "Mgm_McuCreated": "2024-08-05 10:37:56",
|
|
// "Mgm_McuLastUpdated": "2024-08-05 10:37:56",
|
|
// "Mgm_McuUserID": "286",
|
|
// "Mgm_McuTotalParticipant": "136",
|
|
// "LatestUploadDate": null
|
|
// }
|
|
$param = gzcompress(json_encode(array(
|
|
'branch' => array(
|
|
"M_BranchCode" => $branchCode
|
|
),
|
|
"data" => $result
|
|
)));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMgmCompany/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->sys_error($rst);
|
|
}
|
|
// $this->sys_ok(
|
|
// $result
|
|
// );
|
|
}
|
|
|
|
public function getMgmHeaderCount($mgmMcuID, $rowPerPage = 500, $page = 1)
|
|
{
|
|
$sql = "SELECT
|
|
count(Mgm_HeaderID) as total
|
|
FROM mgm_header
|
|
LEFT JOIN log_upload_mgm_header
|
|
ON Mgm_HeaderID= LogUploadMgmHeaderMgm_HeaderID
|
|
AND (LogUploadMgmHeaderID IS NULL OR LogUploadMgmHeaderStatus IN ('E','N','R'))
|
|
WHERE Mgm_HeaderMgm_McuID = $mgmMcuID
|
|
-- AND Mgm_HeaderIsActive= 'Y'
|
|
";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM Header");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getMgmHeader($mgmMcuID, $date = '')
|
|
{
|
|
$sqlDate = '';
|
|
if ($date != '' and $date != null) {
|
|
$sqlDate = "OR (LogUploadMgmHeaderStatus = 'Y' AND Mgm_HeaderLastUpdated > $date)";
|
|
}
|
|
// $sql = "SELECT
|
|
// one_etl.mgm_header.*
|
|
// FROM one_etl.mgm_header
|
|
// LEFT JOIN one_etl.log_upload_mgm_header
|
|
// ON Mgm_HeaderID = LogUploadMgmHeaderMgm_HeaderID
|
|
// WHERE Mgm_HeaderMgm_McuID = $mgmMcuID
|
|
// AND (LogUploadMgmHeaderStatus IN ('E','N','R')
|
|
// OR LogUploadMgmHeaderID IS NULL
|
|
// OR (LogUploadMgmHeaderStatus = 'Y' AND Mgm_HeaderLastUpdated > LogUploadMgmHeaderUploadDate)
|
|
// OR Mgm_HeaderID IN ( SELECT Mgm_DetailMgm_HeaderID
|
|
// FROM one_etl.mgm_detail
|
|
// LEFT JOIN one_etl.log_upload_mgm_detail
|
|
// ON Mgm_DetailID = LogUploadMgmDetailMgm_DetailID
|
|
|
|
// WHERE (LogUploadMgmDetailStatus IS NULL -- Belum ada log
|
|
// OR LogUploadMgmDetailStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
// OR (LogUploadMgmDetailStatus = 'Y' AND Mgm_DetailLastUpdated > LogUploadMgmDetailUploadDate))
|
|
// AND Mgm_DetailMgm_HeaderID IN (SELECT Mgm_HeaderID FROM one_etl.mgm_header WHERE Mgm_HeaderMgm_McuID = $mgmMcuID)
|
|
// )
|
|
// OR Mgm_HeaderID IN (SELECT Mgm_RiwayatMgm_HeaderID
|
|
// FROM one_etl.mgm_riwayat
|
|
// LEFT JOIN one_etl.log_upload_mgm_riwayat
|
|
// ON Mgm_RiwayatID = LogUploadMgmRiwayatMgm_RiwayatID
|
|
// WHERE (LogUploadMgmRiwayatStatus IS NULL -- Belum ada log
|
|
// OR LogUploadMgmRiwayatStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
// OR (LogUploadMgmRiwayatStatus = 'Y' AND Mgm_RiwayatLastUpdated > LogUploadMgmRiwayatUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
// AND Mgm_RiwayatMgm_HeaderID IN (SELECT Mgm_HeaderID FROM one_etl.mgm_header WHERE Mgm_HeaderMgm_McuID = $mgmMcuID)
|
|
// ))
|
|
// -- AND Mgm_HeaderCreated BETWEEN '2024-11-26 00:00:00' AND '2024-11-28 12:00:07'
|
|
// -- AND Mgm_HeaderIsActive= 'Y'
|
|
// ";
|
|
$sql = "SELECT
|
|
m_patient.M_PatientLocation as Mgm_HeaderM_PatientLocation2,
|
|
one_etl.mgm_header.*
|
|
FROM one_etl.mgm_header
|
|
join one_etl.mgm_mcu
|
|
ON Mgm_HeaderMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuID = $mgmMcuID
|
|
AND Mgm_McuIsActive = 'Y'
|
|
JOIN t_orderheader ON
|
|
Mgm_HeaderT_OrderHeaderID = T_OrderHeaderID
|
|
JOIN m_patient
|
|
ON T_OrderHeaderM_PatientID = M_PatientID
|
|
LEFT JOIN one_etl.log_upload_mgm_header
|
|
ON Mgm_HeaderID = LogUploadMgmHeaderMgm_HeaderID
|
|
WHERE Mgm_HeaderMgm_McuID = $mgmMcuID
|
|
AND (LogUploadMgmHeaderStatus IN ('E','N','R')
|
|
OR LogUploadMgmHeaderID IS NULL
|
|
OR (LogUploadMgmHeaderStatus = 'Y' AND Mgm_HeaderLastUpdated > LogUploadMgmHeaderUploadDate))
|
|
-- AND Mgm_HeaderCreated BETWEEN '2024-11-26 00:00:00' AND '2024-11-28 12:00:07'
|
|
AND Mgm_HeaderIsActive= 'Y'
|
|
";
|
|
$qry = $this->db->query($sql, array());
|
|
// echo $sql;
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM Header");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getMgmDetail($mghHeaderID)
|
|
{
|
|
// $sql = "SELECT
|
|
// one_etl.mgm_detail.*
|
|
// FROM one_etl.mgm_detail
|
|
// LEFT JOIN one_etl.log_upload_mgm_detail
|
|
// ON Mgm_DetailID = LogUploadMgmDetailMgm_DetailID
|
|
// AND (LogUploadMgmDetailID IS NULL
|
|
// OR LogUploadMgmDetailStatus IN ('E','N','R')
|
|
// )
|
|
// WHERE Mgm_DetailMgm_HeaderID = $mghHeaderID
|
|
// AND Mgm_DetailIsActive= 'Y'";
|
|
|
|
$sql = "SELECT one_etl.mgm_detail.*
|
|
FROM one_etl.mgm_detail
|
|
LEFT JOIN one_etl.log_upload_mgm_detail
|
|
ON Mgm_DetailID = LogUploadMgmDetailMgm_DetailID
|
|
WHERE Mgm_DetailMgm_HeaderID = $mghHeaderID
|
|
AND (LogUploadMgmDetailStatus IS NULL -- Belum ada log
|
|
OR LogUploadMgmDetailStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (LogUploadMgmDetailStatus = 'Y' AND Mgm_DetailLastUpdated > LogUploadMgmDetailUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
-- AND Mgm_DetailIsActive = 'Y';
|
|
";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM detail");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getMgmRiwayat($mghHeaderID)
|
|
{
|
|
$sql = "SELECT one_etl.mgm_riwayat.*
|
|
FROM one_etl.mgm_riwayat
|
|
LEFT JOIN one_etl.log_upload_mgm_riwayat
|
|
ON Mgm_RiwayatID = LogUploadMgmRiwayatMgm_RiwayatID
|
|
WHERE Mgm_RiwayatMgm_HeaderID = $mghHeaderID
|
|
AND (LogUploadMgmRiwayatStatus IS NULL -- Belum ada log
|
|
OR LogUploadMgmRiwayatStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (LogUploadMgmRiwayatStatus = 'Y' AND Mgm_RiwayatLastUpdated > LogUploadMgmRiwayatUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
-- AND Mgm_RiwayatIsActive = 'Y'
|
|
;";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM detail");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getMgmMou()
|
|
{
|
|
|
|
// WHERE Mgm_MouMgm_McuID = $mgmMcuID
|
|
$sql = "SELECT one_etl.mgm_mou.*
|
|
FROM one_etl.mgm_mou
|
|
LEFT JOIN one_etl.log_upload_mgm_mou
|
|
ON Mgm_MouID = LogUploadMgmMouMgm_MouID
|
|
WHERE (LogUploadMgmMouStatus IS NULL -- Belum ada log
|
|
OR LogUploadMgmMouStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (LogUploadMgmMouStatus = 'Y' AND Mgm_MouLastUpdated > LogUploadMgmMouUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
-- AND Mgm_MouIsActive = 'Y'
|
|
; ";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM MOU");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getTop3Kelainan($mgmMcuID)
|
|
{
|
|
|
|
$sql = "SELECT one_etl.mcu_top3_kelainan.*
|
|
FROM one_etl.mcu_top3_kelainan
|
|
join one_etl.mgm_mcu
|
|
ON Mcu_Top3KelainanMgm_McuID = Mgm_McuID
|
|
-- AND Mgm_McuID = 17
|
|
AND Mgm_McuIsActive = 'Y'
|
|
LEFT JOIN one_etl.log_upload_mcu_top3_kelainan
|
|
ON Mcu_Top3KelainanID= LogUploadMcuTop3KelainanMcu_Top3KelainanID
|
|
|
|
WHERE Mcu_Top3KelainanMgm_McuID = $mgmMcuID
|
|
AND (LogUploadMcuTop3KelainanStatus IS NULL -- Belum ada log
|
|
OR LogUploadMcuTop3KelainanStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (LogUploadMcuTop3KelainanStatus = 'Y' AND Mcu_Top3KelainanUpdated > LogUploadMcuTop3KelainanUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
-- AND Mcu_Top3KelainanIsActive= 'Y'
|
|
; ";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM get top 3 kelainan");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getMcuOrder($mgmMcuID)
|
|
{
|
|
|
|
$sql = "SELECT one_etl.mcu_order.*
|
|
FROM one_etl.mcu_order
|
|
join one_etl.mgm_mcu
|
|
ON Mcu_OrderMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuID = $mgmMcuID
|
|
AND Mgm_McuIsActive = 'Y'
|
|
LEFT JOIN one_etl.log_upload_mcu_order
|
|
ON Mcu_OrderID = LogUploadMcuOrderMcu_OrderID
|
|
WHERE Mcu_OrderMgm_McuID = $mgmMcuID
|
|
AND (LogUploadMcuOrderStatus IS NULL -- Belum ada log
|
|
OR LogUploadMcuOrderStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (Mcu_OrderLastUpdated > LogUploadMcuOrderUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get MGM order");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getAntropometri($mgmMcuID)
|
|
{
|
|
|
|
$sql = "SELECT one_etl.antropometri.*
|
|
FROM one_etl.antropometri
|
|
join one_etl.mgm_mcu
|
|
ON AntropometriMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuID = $mgmMcuID
|
|
AND Mgm_McuIsActive = 'Y'
|
|
LEFT JOIN one_etl.log_upload_antropometri
|
|
ON AntropometriID = LogUploadAntropometriAntropometriID
|
|
WHERE AntropometriMgm_McuID = $mgmMcuID
|
|
AND (LogUploadAntropometriStatus IS NULL -- Belum ada log
|
|
OR LogUploadAntropometriStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
)";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get Antropometri");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getExeSumTpl($mgmMcuID)
|
|
{
|
|
|
|
$sql = "SELECT one_etl.exe_sum_tpl.*
|
|
FROM one_etl.exe_sum_tpl
|
|
join one_etl.mgm_mcu
|
|
ON exeSumTplMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuID = $mgmMcuID
|
|
AND Mgm_McuIsActive = 'Y'
|
|
LEFT JOIN one_etl.log_upload_exe_sum_tpl
|
|
ON exeSumTplID = LogUploadExeSumTplExeSumTplID
|
|
|
|
WHERE exeSumTplMgm_McuID = $mgmMcuID
|
|
AND (LogUploadExeSumTplStatus IS NULL -- Belum ada log
|
|
OR LogUploadExeSumTplStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (LogUploadExeSumTplStatus = 'Y' AND exeSumTplCreated > LogUploadExeSumTplUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
-- AND exeSumTplIsActive = 'Y'
|
|
;";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get Antropometri");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function getMcuSnapshotNote($mgmMcuID)
|
|
{
|
|
|
|
$sql = "SELECT one_etl.mcu_snapshot_note.*
|
|
FROM one_etl.mcu_snapshot_note
|
|
join one_etl.mgm_mcu
|
|
ON Mcu_Snapshot_NoteMgm_McuID = Mgm_McuID
|
|
AND Mgm_McuID = $mgmMcuID
|
|
AND Mgm_McuIsActive = 'Y'
|
|
LEFT JOIN one_etl.log_upload_mcu_snapshot_note
|
|
ON Mcu_Snapshot_NoteID = LogUploadMcuSnapshotNoteMcu_Snapshot_NoteID
|
|
|
|
WHERE Mcu_Snapshot_NoteMgm_McuID = $mgmMcuID
|
|
AND (LogUploadMcuSnapshotNoteStatus IS NULL -- Belum ada log
|
|
OR LogUploadMcuSnapshotNoteStatus IN ('N', 'R', 'E') -- Status N, R, E
|
|
OR (LogUploadMcuSnapshotNoteStatus = 'Y' AND Mcu_Snapshot_NoteLastUpdated > LogUploadMcuSnapshotNoteUploadDate)) -- Status Y dan LastUpdated lebih besar dari UploadDate
|
|
-- AND Mcu_Snapshot_NoteIsActive = 'Y'
|
|
;";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get Antropometri");
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->sys_ok(
|
|
$result
|
|
);
|
|
}
|
|
public function updateLogMgmMcu($mgmMcuID, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mgm_mcu (
|
|
LogUploadMgmMcuMgm_McuID,
|
|
LogUploadMgmMcuStatus,
|
|
LogUploadMgmMcuUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMgmMcuStatus = VALUES(LogUploadMgmMcuStatus),
|
|
LogUploadMgmMcuUploadDate = VALUES(LogUploadMgmMcuUploadDate);";
|
|
$qry = $this->db->query($sql, array($mgmMcuID, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mgm mcu log");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
return;
|
|
}
|
|
public function updateLogMgmHeader($mgmHeaderID, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mgm_header (
|
|
LogUploadMgmHeaderMgm_HeaderID,
|
|
LogUploadMgmHeaderStatus,
|
|
LogUploadMgmHeaderUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMgmHeaderStatus = VALUES(LogUploadMgmHeaderStatus),
|
|
LogUploadMgmHeaderUploadDate = VALUES(LogUploadMgmHeaderUploadDate);";
|
|
$qry = $this->db->query($sql, array($mgmHeaderID, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mgm header log");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateLogMgmDetail($mgmDetailID, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mgm_detail (
|
|
LogUploadMgmDetailMgm_DetailID,
|
|
LogUploadMgmDetailStatus,
|
|
LogUploadMgmDetailUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMgmDetailStatus = VALUES(LogUploadMgmDetailStatus),
|
|
LogUploadMgmDetailUploadDate = VALUES(LogUploadMgmDetailUploadDate);";
|
|
$qry = $this->db->query($sql, array($mgmDetailID, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mgm detail log");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateLogMgmMou($mgmMouID, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mgm_mou (
|
|
LogUploadMgmMouMgm_MouID,
|
|
LogUploadMgmMouStatus,
|
|
LogUploadMgmMouUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMgmMouStatus = VALUES(LogUploadMgmMouStatus),
|
|
LogUploadMgmMouUploadDate = VALUES(LogUploadMgmMouUploadDate);";
|
|
$qry = $this->db->query($sql, array($mgmMouID, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mgm mou log");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateLogMcuOrder($mcuorderID, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mcu_order (
|
|
LogUploadMcuOrderMcu_OrderID,
|
|
LogUploadMcuOrderStatus,
|
|
LogUploadMcuOrderUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMcuOrderStatus = VALUES(LogUploadMcuOrderStatus),
|
|
LogUploadMcuOrderUploadDate = VALUES(LogUploadMcuOrderUploadDate);";
|
|
$qry = $this->db->query($sql, array($mcuorderID, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mgm order");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateLogAntropometri($id, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_antropometri (
|
|
LogUploadAntropometriAntropometriID,
|
|
LogUploadAntropometriStatus,
|
|
LogUploadAntropometriUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadAntropometriStatus = VALUES(LogUploadAntropometriStatus),
|
|
LogUploadAntropometriUploadDate = VALUES(LogUploadAntropometriUploadDate);";
|
|
$qry = $this->db->query($sql, array($id, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update antropometri");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateMgmRiwayat($id, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mgm_riwayat (
|
|
LogUploadMgmRiwayatMgm_RiwayatID,
|
|
LogUploadMgmRiwayatStatus,
|
|
LogUploadMgmRiwayatUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMgmRiwayatStatus = VALUES(LogUploadMgmRiwayatStatus),
|
|
LogUploadMgmRiwayatUploadDate = VALUES(LogUploadMgmRiwayatUploadDate);";
|
|
$qry = $this->db->query($sql, array($id, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mgm riwayat");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateLogExeSumTpl($id, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_exe_sum_tpl (
|
|
LogUploadExeSumTplExeSumTplID,
|
|
LogUploadExeSumTplStatus,
|
|
LogUploadExeSumTplUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadExeSumTplStatus = VALUES(LogUploadExeSumTplStatus),
|
|
LogUploadExeSumTplUploadDate = VALUES(LogUploadExeSumTplUploadDate);";
|
|
$qry = $this->db->query($sql, array($id, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update exe sum tpl");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateLogTop3Kelainan($id, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mcu_top3_kelainan (
|
|
LogUploadMcuTop3KelainanMcu_Top3KelainanID,
|
|
LogUploadMcuTop3KelainanStatus,
|
|
LogUploadMcuTop3KelainanUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMcuTop3KelainanStatus = VALUES(LogUploadMcuTop3KelainanStatus),
|
|
LogUploadMcuTop3KelainanUploadDate = VALUES(LogUploadMcuTop3KelainanUploadDate);";
|
|
$qry = $this->db->query($sql, array($id, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update top 3 kelainan");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
public function updateMcuSnapshotNote($id, $status)
|
|
{
|
|
$sql = "INSERT INTO one_etl.log_upload_mcu_snapshot_note (
|
|
LogUploadMcuSnapshotNoteMcu_Snapshot_NoteID,
|
|
LogUploadMcuSnapshotNoteStatus,
|
|
LogUploadMcuSnapshotNoteUploadDate
|
|
) VALUES
|
|
(?, ?, NOW())
|
|
ON DUPLICATE KEY UPDATE
|
|
LogUploadMcuSnapshotNoteStatus = VALUES(LogUploadMcuSnapshotNoteStatus),
|
|
LogUploadMcuSnapshotNoteUploadDate = VALUES(LogUploadMcuSnapshotNoteUploadDate);";
|
|
$qry = $this->db->query($sql, array($id, $status));
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mcu snapshot note");
|
|
exit;
|
|
}
|
|
// $result = $qry->result_array();
|
|
// $this->sys_ok(
|
|
// "Success"
|
|
// );
|
|
return;
|
|
}
|
|
|
|
public function uploadMgmMcu()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMgmMcu/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogMgmMcu($prm['data']['Mgm_McuID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogMgmMcu($prm['data']['Mgm_McuID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadMgmHeader()
|
|
{
|
|
$prm = $this->sys_input;
|
|
// Mgm_HeaderNat_TestName
|
|
$natTestCode = $prm['data']['Mgm_HeaderNat_TestCode'];
|
|
$sql = "SELECT Nat_TestName
|
|
FROM nat_test
|
|
WHERE Nat_TestCode = '{$natTestCode}'
|
|
AND Nat_TestIsActive = 'Y'";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error insert/update mcu snapshot note");
|
|
exit;
|
|
}
|
|
$test = $qry->result_array();
|
|
if (count($test) == 0) {
|
|
$prm['data']['Mgm_HeaderNat_TestName'] = 'Pemeriksaan Fisik';
|
|
# code...
|
|
} else {
|
|
$prm['data']['Mgm_HeaderNat_TestName'] = $test[0]['Nat_TestName'];
|
|
}
|
|
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMgmHeader/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogMgmHeader($prm['data']['Mgm_HeaderID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogMgmHeader($prm['data']['Mgm_HeaderID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadMgmDetail()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMgmDetail/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogMgmDetail($prm['data']['Mgm_DetailID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogMgmDetail($prm['data']['Mgm_DetailID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadMgmRiwayat()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMgmRiwayat/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateMgmRiwayat($prm['data']['Mgm_RiwayatID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateMgmRiwayat($prm['data']['Mgm_RiwayatID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadMgmMou()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMgmMou/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogMgmMou($prm['data']['Mgm_MouID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogMgmMou($prm['data']['Mgm_MouID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadTop3Kelainan()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertTop3Kelainan/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogTop3Kelainan($prm['data']['Mcu_Top3KelainanID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogTop3Kelainan($prm['data']['Mcu_Top3KelainanID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadMcuOrder()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMcuorder/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogMcuOrder($prm['data']['Mcu_OrderID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogMcuOrder($prm['data']['Mcu_OrderID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadAntropometri()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertAntropometri/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateLogAntropometri($prm['data']['AntropometriID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateLogAntropometri($prm['data']['AntropometriID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadMcuSnapshotNote()
|
|
{
|
|
$prm = $this->sys_input;
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMcuSnapshotNote/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
$this->updateMcuSnapshotNote($prm['data']['Mcu_Snapshot_NoteID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
$this->updateMcuSnapshotNote($prm['data']['Mcu_Snapshot_NoteID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
public function uploadExecutiveTest($mgmMcuID)
|
|
{
|
|
|
|
$sql = "SELECT
|
|
one_etl.mgm_mcu.*
|
|
FROM
|
|
one_etl.mgm_mcu
|
|
WHERE Mgm_McuID = ?;";
|
|
$qry = $this->db->query($sql, array($mgmMcuID));
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
$dataMgmMcu = $qry->row_array();
|
|
|
|
if ($dataMgmMcu['Mgm_McuIsActive'] == 'N') {
|
|
$this->sys_ok("Mgm Mcu sudah di hapus");
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
|
|
$sql = "call sp_rpt_executive_test({$mgmMcuID});";
|
|
$qry = $this->db->query($sql, array());
|
|
$last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$error = array(
|
|
"message" => $this->db->error()["message"],
|
|
"sql" => $last_qry
|
|
);
|
|
$this->sys_error_db($error, $this->db);
|
|
exit;
|
|
}
|
|
$result = $qry->result_array();
|
|
$this->clean_mysqli_connection($this->db->conn_id);
|
|
|
|
$sql = "SELECT * FROM `m_branch` WHERE `M_BranchIsDefault` = 'Y'";
|
|
$qry = $this->db->query($sql, array());
|
|
// $last_qry = $this->db->last_query();
|
|
if (!$qry) {
|
|
// $this->db->trans_rollback();
|
|
$this->sys_error_db("Error get branch");
|
|
exit;
|
|
}
|
|
$branch = $qry->row_array();
|
|
|
|
$arrRst = array();
|
|
|
|
foreach ($result as $key => $value) {
|
|
$value['Mgm_McuID'] = $mgmMcuID;
|
|
$value['M_BranchCode'] = $branch['M_BranchCode'];
|
|
$arrRst[] = $value;
|
|
}
|
|
|
|
$prm = array(
|
|
"branch" => $branch,
|
|
"mgmMcuID" => $mgmMcuID,
|
|
"data" => $arrRst
|
|
);
|
|
|
|
// echo json_encode($arrRst);
|
|
// exit;
|
|
|
|
$param = gzcompress(json_encode($prm));
|
|
$url = "http://" . $this->hostname . "/one-api/etl/etlreceiver/insertMcuExecutiveTest/";
|
|
// echo "to $url \n param : $param\n";
|
|
$post_rst = $this->post($url, $param);
|
|
$rst = json_decode($post_rst, true);
|
|
|
|
if ($rst["status"] == "OK") {
|
|
// $this->updateMcuSnapshotNote($prm['data']['Mcu_Snapshot_NoteID'], 'Y');
|
|
$this->sys_ok("Success");
|
|
} else {
|
|
// $this->updateMcuSnapshotNote($prm['data']['Mcu_Snapshot_NoteID'], 'E');
|
|
$this->sys_error($rst);
|
|
}
|
|
}
|
|
}
|