Add MCU report template mapping flow
This commit is contained in:
@@ -1,7 +1,44 @@
|
||||
<?php
|
||||
class Setupmcucponev7 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
class Setupmcucponev7 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
private function resolve_report_template_id($prm)
|
||||
{
|
||||
if (isset($prm['Mcu_ReportUrlTemplateID'])) {
|
||||
if (is_array($prm['Mcu_ReportUrlTemplateID']) && isset($prm['Mcu_ReportUrlTemplateID']['id'])) {
|
||||
return intval($prm['Mcu_ReportUrlTemplateID']['id']);
|
||||
}
|
||||
return intval($prm['Mcu_ReportUrlTemplateID']);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function upsert_mgm_mcureport($mgmMcuID, $templateID, $userID)
|
||||
{
|
||||
$mgmMcuID = intval($mgmMcuID);
|
||||
$templateID = intval($templateID);
|
||||
$userID = intval($userID);
|
||||
|
||||
if ($mgmMcuID <= 0 || $templateID <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO mgm_mcureport (
|
||||
Mgm_McuReportMgm_McuID,
|
||||
Mgm_McuReportMcu_ReportUrlTemplateID,
|
||||
Mgm_McuReportIsActive,
|
||||
Mgm_McuReportCreated,
|
||||
Mgm_McuReportCreatedUserID,
|
||||
Mgm_McuReportLastUpdated,
|
||||
Mgm_McuReportLastUpdatedUserID
|
||||
) VALUES (?, ?, 'Y', NOW(), ?, NOW(), ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mgm_McuReportMcu_ReportUrlTemplateID = VALUES(Mgm_McuReportMcu_ReportUrlTemplateID),
|
||||
Mgm_McuReportIsActive = 'Y',
|
||||
Mgm_McuReportLastUpdated = NOW(),
|
||||
Mgm_McuReportLastUpdatedUserID = VALUES(Mgm_McuReportLastUpdatedUserID)";
|
||||
$this->db_onedev->query($sql, array($mgmMcuID, $templateID, $userID, $userID));
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
@@ -861,9 +898,10 @@ class Setupmcucponev7 extends MY_Controller
|
||||
// $Mgm_McuTotalParticipant = $prm['Mgm_McuTotalParticipant'];
|
||||
$Mgm_McuTotalParticipant = 0;
|
||||
$Mgm_McuT_PriceHeaderID = $prm['Mgm_McuT_PriceHeaderID'];
|
||||
$Mgm_McuM_BranchID = $prm['Mgm_McuM_BranchID'];
|
||||
$Mgm_McuReportHasil = $prm['Mgm_McuReportHasil'];
|
||||
$Mgm_McuGeneratePasswordBY = $prm['Mgm_McuGeneratePasswordBY'];
|
||||
$Mgm_McuM_BranchID = $prm['Mgm_McuM_BranchID'];
|
||||
$Mgm_McuReportHasil = $prm['Mgm_McuReportHasil'];
|
||||
$Mcu_ReportUrlTemplateID = $this->resolve_report_template_id($prm);
|
||||
$Mgm_McuGeneratePasswordBY = $prm['Mgm_McuGeneratePasswordBY'];
|
||||
$cover = isset($prm['cover']) ? $prm['cover'] : ['code' => 'DFLT', 'name' => 'Cover Default'];
|
||||
$background = isset($prm['background']) ? $prm['background'] : ['code' => 'DFLT', 'name' => 'Background Default', 'image' => 'one-ui/BackgroundWesterindo.png'];
|
||||
|
||||
@@ -958,7 +996,8 @@ class Setupmcucponev7 extends MY_Controller
|
||||
$this->sys_error_db("mgm_mcu insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$this->upsert_mgm_mcureport($last_id, $Mcu_ReportUrlTemplateID, $userid);
|
||||
|
||||
|
||||
|
||||
@@ -1090,7 +1129,8 @@ class Setupmcucponev7 extends MY_Controller
|
||||
// check data password for update
|
||||
// check paket exists or not
|
||||
|
||||
$last_id = $prm["xid"];
|
||||
$last_id = $prm["xid"];
|
||||
$this->upsert_mgm_mcureport($last_id, $Mcu_ReportUrlTemplateID, $userid);
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM mgm_mcu
|
||||
|
||||
@@ -54,7 +54,7 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
Published_McuDasboardLastUpdatedUserID = VALUES(Published_McuDasboardLastUpdatedUserID)";
|
||||
$this->db_onedev->query($sql, array($orderID, $userID, $userID));
|
||||
}
|
||||
public function getsetup()
|
||||
public function getsetup()
|
||||
{
|
||||
try {
|
||||
// if (!$this->isLogin) {
|
||||
@@ -78,8 +78,68 @@ class Resumeindividucponev7 extends MY_Controller
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function get_report_mcu()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$mgmMcuID = 0;
|
||||
if (isset($prm['Mgm_McuID'])) {
|
||||
$mgmMcuID = intval($prm['Mgm_McuID']);
|
||||
} else if (isset($prm['setupID'])) {
|
||||
$mgmMcuID = intval($prm['setupID']);
|
||||
}
|
||||
|
||||
if ($mgmMcuID <= 0) {
|
||||
$this->sys_error("Mgm_McuID is required");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
t.Mcu_ReportUrlTemplateID AS id,
|
||||
t.Mcu_ReportUrlTemplateName AS reportName,
|
||||
t.Mcu_ReportUrlTemplateType AS reportType,
|
||||
t.Mcu_ReportUrlTemplateUrl AS reportUrl,
|
||||
t.Mcu_ReportUrlTemplateParams AS reportParams,
|
||||
IF(mr.Mgm_McuReportMcu_ReportUrlTemplateID = t.Mcu_ReportUrlTemplateID, 'Y', 'N') AS selected
|
||||
FROM mcu_report_url_template t
|
||||
LEFT JOIN mgm_mcureport mr
|
||||
ON mr.Mgm_McuReportMcu_ReportUrlTemplateID = t.Mcu_ReportUrlTemplateID
|
||||
AND mr.Mgm_McuReportMgm_McuID = ?
|
||||
AND mr.Mgm_McuReportIsActive = 'Y'
|
||||
WHERE t.Mcu_ReportUrlTemplateIsActive = 'Y'
|
||||
ORDER BY t.Mcu_ReportUrlTemplateName ASC";
|
||||
$query = $this->db_onedev->query($sql, array($mgmMcuID));
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['qry'] = $this->db_onedev->last_query();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
$selected = null;
|
||||
foreach ($rows as $row) {
|
||||
if ($row['selected'] === 'Y') {
|
||||
$selected = $row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
"selected" => $selected
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function search()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
|
||||
52
scripts/sql/2026-04-29_create_mcu_report_url_template.sql
Normal file
52
scripts/sql/2026-04-29_create_mcu_report_url_template.sql
Normal file
@@ -0,0 +1,52 @@
|
||||
CREATE TABLE IF NOT EXISTS `mcu_report_url_template` (
|
||||
`Mcu_ReportUrlTemplateID` int NOT NULL AUTO_INCREMENT,
|
||||
`Mcu_ReportUrlTemplateName` varchar(100) NOT NULL,
|
||||
`Mcu_ReportUrlTemplateType` varchar(20) NOT NULL COMMENT 'BIRT/API',
|
||||
`Mcu_ReportUrlTemplateUrl` text NOT NULL COMMENT 'use placeholders like {{PResumeID}}',
|
||||
`Mcu_ReportUrlTemplateParams` varchar(500) DEFAULT NULL COMMENT 'comma-separated placeholders',
|
||||
`Mcu_ReportUrlTemplateIsActive` char(1) NOT NULL DEFAULT 'Y',
|
||||
`Mcu_ReportUrlTemplateCreated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`Mcu_ReportUrlTemplateCreatedUserID` int NOT NULL DEFAULT '0',
|
||||
`Mcu_ReportUrlTemplateLastUpdated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`Mcu_ReportUrlTemplateLastUpdatedUserID` int NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`Mcu_ReportUrlTemplateID`),
|
||||
UNIQUE KEY `uk_report_name` (`Mcu_ReportUrlTemplateName`),
|
||||
KEY `idx_active` (`Mcu_ReportUrlTemplateIsActive`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT INTO `mcu_report_url_template`
|
||||
(`Mcu_ReportUrlTemplateName`,`Mcu_ReportUrlTemplateType`,`Mcu_ReportUrlTemplateUrl`,`Mcu_ReportUrlTemplateParams`)
|
||||
VALUES
|
||||
('cover','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PTimestamp'),
|
||||
('coverprimaya','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_resume_cover_primaya.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PTimestamp'),
|
||||
('kesimpulandansaran','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_v2.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PTimestamp'),
|
||||
('kesimpulandansaran2logo','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan_portal.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PTimestamp'),
|
||||
('kesimpulandansaran2logobg','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan{{PBgSuffix}}_portal.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PBgSuffix,PTimestamp'),
|
||||
('kesimpulandansaran2','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_saran_kesimpulan.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PTimestamp'),
|
||||
('resume','BIRT','/birt/run?__report=report/one/mcu/rpt_mcu_resume.rptdesign&__format=pdf&username={{username}}&PID={{PResumeID}}&tm={{PTimestamp}}','username,PResumeID,PTimestamp'),
|
||||
('gabunganlogo','API','/one-api/tools/listrptpatienttahunanportal/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabunganlogobg','API','/one-api/tools/listrptpatienttahunanportalbg/get_list_patient_rpt/{{POrderID}}/{{PBg}}/{{PTimestamp}}','POrderID,PBg,PTimestamp'),
|
||||
('gabunganlogoeng','API','/one-api/tools/listrptpatienttahunanportaleng/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabunganlogoengbg','API','/one-api/tools/listrptpatienttahunanportalengbg/get_list_patient_rpt/{{POrderID}}/{{PBg}}/{{PTimestamp}}','POrderID,PBg,PTimestamp'),
|
||||
('gabunganlogoprimaya','API','/one-api/tools/listrptpatienttahunanportalprimaya/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabunganlogoprimayabg','API','/one-api/tools/listrptpatienttahunanportalprimayabg/get_list_patient_rpt/{{POrderID}}/{{PBg}}/{{PTimestamp}}','POrderID,PBg,PTimestamp'),
|
||||
('gabungan','API','/one-api/tools/listrptpatienttahunan/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabunganeng','API','/one-api/tools/listrptpatienttahunaneng/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabunganprimaya','API','/one-api/tools/listrptpatienttahunanprimaya/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabunganlogotanpakesimpulan','API','/one-api/tools/listrptpatienttahunanportal/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}/Y','POrderID,PTimestamp'),
|
||||
('gabunganlogotanpakesimpulanbg','API','/one-api/tools/listrptpatienttahunanportalbg/get_list_patient_rpt/{{POrderID}}/{{PBg}}/{{PTimestamp}}/Y','POrderID,PBg,PTimestamp'),
|
||||
('gabunganlogotanpakesimpulaneng','API','/one-api/tools/listrptpatienttahunanportaleng/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}/Y','POrderID,PTimestamp'),
|
||||
('gabungantanpakesimpulan','API','/one-api/tools/listrptpatienttahunan/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}/Y','POrderID,PTimestamp'),
|
||||
('gabungantanpakesimpulaneng','API','/one-api/tools/listrptpatienttahunaneng/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}/Y','POrderID,PTimestamp'),
|
||||
('gabungan2logo','API','/one-api/tools/listrptpatientportal/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('gabungan2logobg','API','/one-api/tools/listrptpatientportalbg/get_list_patient_rpt/{{POrderID}}/{{PBg}}/{{PTimestamp}}','POrderID,PBg,PTimestamp'),
|
||||
('gabungan2','API','/one-api/tools/listrptpatient/get_list_patient_rpt/{{POrderID}}/{{PTimestamp}}','POrderID,PTimestamp'),
|
||||
('haji','API','/one-api/tools/listrptpatienthaji/get_list_patient_rpt/{{PReIDHaji}}/{{PTimestamp}}','PReIDHaji,PTimestamp'),
|
||||
('hajiportal','API','/one-api/tools/listrptpatienthajiportal/get_list_patient_rpt/{{PReIDHaji}}/{{PTimestamp}}','PReIDHaji,PTimestamp'),
|
||||
('patientlabel','BIRT','/birt/run?__report=report/one/rekap/rpt_mcu_patient_label_lab.rptdesign&__format=pdf&username={{username}}&PNolab={{PLabNumber}}&PType={{PLabelType}}&tm={{PTimestamp}}&PStartDate={{PStartDate}}&PEndDate={{PEndDate}}&PMcuID={{PMcuID}}','username,PLabNumber,PLabelType,PTimestamp,PStartDate,PEndDate,PMcuID')
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Mcu_ReportUrlTemplateType = VALUES(Mcu_ReportUrlTemplateType),
|
||||
Mcu_ReportUrlTemplateUrl = VALUES(Mcu_ReportUrlTemplateUrl),
|
||||
Mcu_ReportUrlTemplateParams = VALUES(Mcu_ReportUrlTemplateParams),
|
||||
Mcu_ReportUrlTemplateIsActive = 'Y',
|
||||
Mcu_ReportUrlTemplateLastUpdated = NOW();
|
||||
14
scripts/sql/2026-04-29_create_mgm_mcureport.sql
Normal file
14
scripts/sql/2026-04-29_create_mgm_mcureport.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS `mgm_mcureport` (
|
||||
`Mgm_McuReportID` int NOT NULL AUTO_INCREMENT,
|
||||
`Mgm_McuReportMgm_McuID` int NOT NULL,
|
||||
`Mgm_McuReportMcu_ReportUrlTemplateID` int NOT NULL,
|
||||
`Mgm_McuReportIsActive` char(1) NOT NULL DEFAULT 'Y',
|
||||
`Mgm_McuReportCreated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`Mgm_McuReportCreatedUserID` int NOT NULL DEFAULT '0',
|
||||
`Mgm_McuReportLastUpdated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`Mgm_McuReportLastUpdatedUserID` int NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`Mgm_McuReportID`),
|
||||
UNIQUE KEY `uk_mcu_report` (`Mgm_McuReportMgm_McuID`),
|
||||
KEY `idx_template` (`Mgm_McuReportMcu_ReportUrlTemplateID`),
|
||||
KEY `idx_active` (`Mgm_McuReportIsActive`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
Reference in New Issue
Block a user