FHM17062601CPONE - Update store procedure trigger table terkait cpone_dashboard

This commit is contained in:
sas.fajri
2026-06-17 11:39:56 +07:00
parent bfff0267f6
commit a4252c6b50
3 changed files with 1010 additions and 0 deletions

View File

@@ -0,0 +1,248 @@
# Endpoint dan Controller yang Berhubungan dengan `cpone_dashboard`
Dokumen ini merangkum endpoint/controller di `BE_CPONE` yang memiliki hubungan dengan `cpone_dashboard`, baik secara langsung melalui koneksi database `cpone_dashboard`, maupun tidak langsung melalui library `Mcudashboard` atau stored procedure `cpone.sp_*`.
## Ringkasan Utama
Controller yang paling terkait dengan `cpone_dashboard`:
1. `summarydashboard/Generatedata`
2. `dashboard_mcu/User`
3. `cpone/SendEmailPreregister`
4. `mockup/mcuoffline/Preregisterappcponev8`
5. `mockup/mcuoffline/Preregisterappcponev3`
6. `mockup/mcuoffline/Resumeindividucponev7`
7. `mockup/sampling-lab-mobile-cpone-v14/Patient`
8. `v1/su/Test`
## Detail per Controller
### 1. `summarydashboard/Generatedata`
File: `application/controllers/summarydashboard/Generatedata.php`
Keterangan:
- Membuka koneksi database `cpone_dashboard` di constructor.
- Pusat sinkronisasi ada di method private `sync_to_dashboard($mgm_mcuid)`.
- Sync ini menulis snapshot hasil ke tabel dashboard seperti:
- `mcu_generate`
- `kelainan_details`
- `kelainan_summary`
- `mcu_result_all`
Method / endpoint yang memicu sinkronisasi:
| Method | Keterangan |
| --- | --- |
| `generate_kelainan_lab` | Generate kelainan lab lalu sync ke dashboard |
| `generate_kelainan_nonlab` | Generate kelainan nonlab lalu sync ke dashboard |
| `generate_kelainan_fisik` | Generate kelainan fisik lalu sync ke dashboard |
| `generate_all_results` | Generate hasil gabungan lalu sync ke dashboard |
| `summary_kelainan_sepuluh` | Generate summary kelainan lalu sync ke dashboard |
Catatan teknis:
- `sync_to_dashboard()` melakukan delete per `Mgm_McuID` lalu insert ulang snapshot terbaru.
- Sumber data diambil dari `cpone_corporate`, lalu dicopy ke `cpone_dashboard`.
### 2. `dashboard_mcu/User`
File: `application/controllers/dashboard_mcu/User.php`
Keterangan:
- Controller khusus user management untuk dashboard MCU.
- Direct query ke database `cpone_dashboard`.
- Menyentuh tabel seperti:
- `dashboard_user`
- `dashboard_user_project`
- Juga memakai stored procedure dashboard:
- `sp_insert_dashboard_user`
- `sp_reset_dashboard_user_password`
- `sp_assign_user_project`
- `sp_remove_user_project`
Method / endpoint terkait:
| Method | Keterangan |
| --- | --- |
| `save` | Insert user dashboard |
| `reset_password` | Reset password user dashboard |
| `assign_project` | Assign project MCU ke user dashboard |
| `remove_project` | Lepas project dari user dashboard |
| `remove_user` | Nonaktifkan user dashboard |
| `search_project` | Cari project untuk kebutuhan dashboard user |
| `search` | Cari/list user dashboard |
### 3. `cpone/SendEmailPreregister`
File: `application/controllers/cpone/SendEmailPreregister.php`
Keterangan:
- Tidak membuka koneksi `cpone_dashboard` secara khusus, tetapi query langsung tabel `cpone_dashboard` dan memanggil stored procedure sync.
- Dipakai untuk kebutuhan email notifikasi preregister berdasarkan schedule dashboard participant daily.
Method / endpoint terkait:
| Method | Keterangan |
| --- | --- |
| `RegisterEmailNotif` | Refresh participant daily dashboard lalu ambil pasien dari tabel dashboard untuk queue email |
| `RegisterEmailNotifManual` | Ambil pasien berdasarkan `mcu_id + date` atau `preregister_id`, termasuk mode ambil data dari tabel dashboard |
Objek dashboard yang disentuh:
- `CALL cpone.sp_refresh_mcu_participant_daily_by_mcu_date(?, ?)`
- `cpone_dashboard.mcu_participant_daily`
- `cpone_dashboard.mcu_participant_daily_details`
- `cpone_dashboard.mcu_patient`
### 4. `mockup/mcuoffline/Preregisterappcponev8`
File: `application/controllers/mockup/mcuoffline/Preregisterappcponev8.php`
Keterangan:
- Membuka koneksi `cpone_dashboard` di constructor.
- Lebih banyak memakai stored procedure / query terarah untuk sync preregister ke dashboard.
Method / endpoint terkait:
| Method | Keterangan |
| --- | --- |
| `syncSchedule` | Menjalankan sync participant daily berdasarkan preregister |
| `doReCheckin` | Insert data check-in ke `cpone_dashboard.mcu_checkinout` |
Objek dashboard yang disentuh:
- `CALL cpone.sp_refresh_mcu_participant_daily_by_preregister(?)`
- `cpone_dashboard.mcu_checkinout`
### 5. `mockup/mcuoffline/Preregisterappcponev3`
File: `application/controllers/mockup/mcuoffline/Preregisterappcponev3.php`
Keterangan:
- Membuka koneksi `cpone_dashboard` di constructor.
- Versi ini punya helper direct untuk sinkron patient dan participant schedule ke dashboard.
Helper penting:
| Method | Keterangan |
| --- | --- |
| `sync_schedule_and_daily` | Sinkron schedule pasien dan total participant harian |
| `sync_patient_dashboard` | Upsert data patient ke tabel dashboard |
Endpoint yang memicu helper tersebut:
| Method | Keterangan |
| --- | --- |
| `savenewform` | Setelah simpan preregister baru, sync patient ke dashboard |
| `savepreregisterpatient` | Setelah update/simpan patient preregister, sync patient ke dashboard |
Objek dashboard yang disentuh:
- `mcu_patient_schedule`
- `mcu_participant_daily`
- `mcu_patient`
### 6. `mockup/mcuoffline/Resumeindividucponev7`
File: `application/controllers/mockup/mcuoffline/Resumeindividucponev7.php`
Keterangan:
- Menggunakan library `Mcudashboard`.
- Relasi ke dashboard bersifat tidak langsung melalui:
- publish status resume
- generate file dashboard
- sync mirror `published_mcu_dashboard`
- update resume status ke dashboard
Method / endpoint terkait:
| Method | Keterangan |
| --- | --- |
| `save` | Saat validasi/unvalidasi resume, update publish dashboard, generate file dashboard, sync mirror dashboard, dan update status resume dashboard |
Helper terkait:
| Method | Keterangan |
| --- | --- |
| `sync_resume_status_dashboard` | Update status resume patient ke dashboard via library |
| `upsert_published_dashboard_on_new_to_val` | Buat/update row publish dashboard |
| `ensure_publish_dashboard_file` | Generate file dashboard dan sync mirror ke `cpone_dashboard` |
Objek dashboard yang disentuh:
- `Mcudashboard->generate_dashboard_files(...)`
- `Mcudashboard->upsert_patient_resume_status(...)`
- `CALL cpone.sp_sync_published_mcu_dashboard_by_orderheaderid(?)`
### 7. `mockup/sampling-lab-mobile-cpone-v14/Patient`
File: `application/controllers/mockup/sampling-lab-mobile-cpone-v14/Patient.php`
Keterangan:
- Menggunakan library `Mcudashboard`.
- Hubungan ke `cpone_dashboard` terjadi lewat update progress station/sample, bukan direct query tabel dashboard di controller ini.
Helper terkait:
| Method | Keterangan |
| --- | --- |
| `sync_station_progress` | Memanggil `Mcudashboard->upsert_station_progress(...)` |
Endpoint / flow yang memicu helper:
| Method | Keterangan |
| --- | --- |
| `scanbarcode` | Dalam alur proses/done bisa memicu sync station progress |
| `scanbarcode_nonlab` | Dalam alur nonlab bisa memicu sync station progress |
| `scanbarcode_additional_fisik` | Dalam alur additional fisik bisa memicu sync station progress |
Objek dashboard yang disentuh:
- `Mcudashboard->upsert_station_progress(orderSampleID, samplingSoID)`
### 8. `v1/su/Test`
File: `application/controllers/v1/su/Test.php`
Keterangan:
- Endpoint test/debug untuk generate dashboard file.
- Menggunakan library `Mcudashboard`.
Method / endpoint terkait:
| Method | Keterangan |
| --- | --- |
| `test_generate_dashboard_file` | Menjalankan `generate_dashboard_files()` untuk testing |
Objek dashboard yang disentuh:
- `Mcudashboard->generate_dashboard_files($mgmMcuID, $publishedID)`
## Klasifikasi Hubungan ke `cpone_dashboard`
### Direct database connection / direct query
- `summarydashboard/Generatedata`
- `dashboard_mcu/User`
- `mockup/mcuoffline/Preregisterappcponev8`
- `mockup/mcuoffline/Preregisterappcponev3`
- `cpone/SendEmailPreregister`
### Indirect via library `Mcudashboard`
- `mockup/mcuoffline/Resumeindividucponev7`
- `mockup/sampling-lab-mobile-cpone-v14/Patient`
- `v1/su/Test`
### Indirect via stored procedure `cpone.sp_*`
- `cpone/SendEmailPreregister`
- `mockup/mcuoffline/Preregisterappcponev8`
- `mockup/mcuoffline/Resumeindividucponev7`
## Kesimpulan
Kalau tujuan utamanya adalah audit endpoint yang benar-benar berhubungan dengan `cpone_dashboard`, fokus paling penting biasanya dimulai dari:
1. `summarydashboard/Generatedata`
2. `dashboard_mcu/User`
3. `cpone/SendEmailPreregister`
4. `mockup/mcuoffline/Preregisterappcponev8`
5. `mockup/mcuoffline/Preregisterappcponev3`
6. `mockup/mcuoffline/Resumeindividucponev7`
Sedangkan `sampling-lab-mobile-cpone-v14/Patient` dan `v1/su/Test` lebih tepat dianggap sebagai pintu masuk tidak langsung melalui library `Mcudashboard`.

View File

@@ -0,0 +1,340 @@
# SP `cpone_dashboard` dan Cek Trigger di `devcpone`
Dokumen ini mencatat stored procedure yang benar-benar berada di schema `cpone_dashboard` pada server `devcpone`, beserta hasil pengecekan apakah ada trigger yang memanggil SP-SP tersebut secara langsung.
Tanggal cek:
- `2026-06-17`
Server:
- `one@devcpone.aplikasi.web.id`
## Daftar SP di Schema `cpone_dashboard`
Stored procedure yang ditemukan:
1. `cpone_dashboard.sp_assign_user_project`
2. `cpone_dashboard.sp_generate_dashboard_data`
3. `cpone_dashboard.sp_generate_patient_required_stations`
4. `cpone_dashboard.sp_insert_dashboard_user`
5. `cpone_dashboard.sp_refresh_mcu_participant_daily_by_mcu`
6. `cpone_dashboard.sp_remove_user_project`
7. `cpone_dashboard.sp_reset_dashboard_user_password`
## Ringkasan Fungsi SP
| SP | Fungsi singkat |
| --- | --- |
| `sp_assign_user_project` | Assign project MCU ke user dashboard |
| `sp_generate_dashboard_data` | Generate data dashboard dasar seperti `mcu_patient`, `mcu_patient_schedule`, dan `mcu_patient_resume_status` |
| `sp_generate_patient_required_stations` | Generate kebutuhan station per patient ke `mcu_patient_required_station` |
| `sp_insert_dashboard_user` | Insert user dashboard baru |
| `sp_refresh_mcu_participant_daily_by_mcu` | Loop per tanggal checkin schedule lalu panggil refresh participant daily |
| `sp_remove_user_project` | Nonaktifkan hubungan user dengan project MCU |
| `sp_reset_dashboard_user_password` | Reset password user dashboard |
## Cek Trigger yang Memakai SP-SP Tersebut
Pengecekan dilakukan terhadap `information_schema.TRIGGERS` dengan mencari `ACTION_STATEMENT` yang mengandung nama SP berikut:
- `sp_assign_user_project`
- `sp_generate_dashboard_data`
- `sp_generate_patient_required_stations`
- `sp_insert_dashboard_user`
- `sp_refresh_mcu_participant_daily_by_mcu`
- `sp_remove_user_project`
- `sp_reset_dashboard_user_password`
Hasil:
- Tidak ditemukan trigger di `devcpone` yang memanggil salah satu dari 7 SP `cpone_dashboard` tersebut secara langsung.
Artinya:
- Saat ini 7 SP ini tampaknya dipakai lewat layer aplikasi atau dipanggil manual, bukan lewat trigger database.
## Dump Ringkas `SHOW CREATE PROCEDURE`
### 1. `cpone_dashboard.sp_assign_user_project`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_assign_user_project`(IN `p_username` varchar(50), IN `p_mcu_id` int)
BEGIN
DECLARE v_user_id INT;
SELECT User_ID INTO v_user_id
FROM dashboard_user
WHERE User_Username = p_username AND User_IsActive = 'Y'
LIMIT 1;
IF v_user_id IS NULL THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'User tidak ditemukan atau tidak aktif';
END IF;
IF NOT EXISTS (
SELECT 1 FROM mcu_project WHERE Mcu_ProjectMcuID = p_mcu_id
) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'mcu_id tidak ditemukan di mcu_project';
END IF;
INSERT INTO dashboard_user_project (UserProj_UserID, UserProj_McuID, UserProj_IsActive)
VALUES (v_user_id, p_mcu_id, 'Y')
ON DUPLICATE KEY UPDATE
UserProj_IsActive = 'Y',
UserProj_UpdatedAt = NOW();
END
```
### 2. `cpone_dashboard.sp_generate_dashboard_data`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_generate_dashboard_data`(IN `p_mcu_id` int)
BEGIN
INSERT INTO mcu_patient (
Mcu_PatientPreregisterID, Mcu_PatientMcuID, Mcu_PatientName,
Mcu_PatientNIP, Mcu_PatientGender, Mcu_PatientDOB, Mcu_PatientAge,
Mcu_PatientDepartment, Mcu_PatientDivision, Mcu_PatientPosisi,
Mcu_PatientIsRegistered, Mcu_PatientOrderID, Mcu_PatientIsActive,
Mcu_PatientSyncedAt
)
SELECT
p.Mcu_PreregisterPatientsID, p.Mcu_PreregisterPatientsMgm_McuID,
p.Mcu_PreregisterPatientsPatientName, p.Mcu_PreregisterPatientsNIP,
p.Mcu_PreregisterPatientsGender, p.Mcu_PreregisterPatientsDOB,
CAST(o.T_OrderHeaderM_PatientAge AS UNSIGNED),
p.Mcu_PreregisterPatientsDepartment, p.Mcu_PreregisterPatientsDivisi,
p.Mcu_PreregisterPatientsPosisi,
p.Mcu_PreregisterPatientsIsRegistered, p.Mcu_PreregisterPatientsT_OrderHeaderID,
p.Mcu_PreregisterPatientsIsActive, NOW()
FROM cpone.mcu_preregister_patients p
LEFT JOIN cpone.t_orderheader o ON o.T_OrderHeaderID = p.Mcu_PreregisterPatientsT_OrderHeaderID
WHERE p.Mcu_PreregisterPatientsMgm_McuID = p_mcu_id
AND p.Mcu_PreregisterPatientsIsActive = 'Y'
ON DUPLICATE KEY UPDATE
Mcu_PatientName = VALUES(Mcu_PatientName),
Mcu_PatientAge = VALUES(Mcu_PatientAge),
Mcu_PatientIsRegistered = VALUES(Mcu_PatientIsRegistered),
Mcu_PatientOrderID = VALUES(Mcu_PatientOrderID),
Mcu_PatientSyncedAt = NOW();
INSERT INTO mcu_patient_schedule (
Mcu_PatientSchedulePreregisterID, Mcu_PatientScheduleDate,
Mcu_PatientScheduleIsActive, Mcu_PatientScheduleSyncedAt
)
SELECT
p.Mcu_PreregisterPatientsID, DATE(o.T_OrderHeaderDate), 'Y', NOW()
FROM cpone.mcu_preregister_patients p
JOIN cpone.t_orderheader o ON o.T_OrderHeaderID = p.Mcu_PreregisterPatientsT_OrderHeaderID
WHERE p.Mcu_PreregisterPatientsMgm_McuID = p_mcu_id
AND p.Mcu_PreregisterPatientsT_OrderHeaderID > 0
AND p.Mcu_PreregisterPatientsIsActive = 'Y'
ON DUPLICATE KEY UPDATE
Mcu_PatientScheduleSyncedAt = NOW();
INSERT INTO mcu_patient_resume_status (
Mcu_PatientResumeStatusPreregisterID, Mcu_PatientResumeStatusMcuID,
Mcu_PatientResumeStatusStatus, Mcu_PatientResumeStatusValidated,
Mcu_PatientResumeStatusPublished, Mcu_PatientResumeSyncedAt
)
SELECT
p.Mcu_PreregisterPatientsID,
p_mcu_id,
r.Mcu_ResumeStatus,
r.Mcu_ResumeValidation,
'N',
NOW()
FROM cpone.mcu_preregister_patients p
JOIN cpone.t_orderheader o ON o.T_OrderHeaderID = p.Mcu_PreregisterPatientsT_OrderHeaderID
LEFT JOIN cpone.mcu_resume r ON r.Mcu_ResumeT_OrderHeaderID = o.T_OrderHeaderID AND r.Mcu_ResumeIsActive = 'Y'
WHERE p.Mcu_PreregisterPatientsMgm_McuID = p_mcu_id
AND p.Mcu_PreregisterPatientsT_OrderHeaderID > 0
AND p.Mcu_PreregisterPatientsIsActive = 'Y'
ON DUPLICATE KEY UPDATE
Mcu_PatientResumeStatusStatus = VALUES(Mcu_PatientResumeStatusStatus),
Mcu_PatientResumeStatusValidated = VALUES(Mcu_PatientResumeStatusValidated),
Mcu_PatientResumeSyncedAt = NOW();
END
```
### 3. `cpone_dashboard.sp_generate_patient_required_stations`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_generate_patient_required_stations`(IN `p_mcu_id` int)
BEGIN
DECLARE v_rows INT DEFAULT 0;
DELETE FROM mcu_patient_required_station WHERE mcu_id = p_mcu_id;
INSERT INTO mcu_patient_required_station
(mcu_id, preregister_id, order_header_id, location_id, sample_station_id, station_name)
SELECT
p_mcu_id,
preg.Mcu_PreregisterPatientsID,
preg.Mcu_PreregisterPatientsT_OrderHeaderID,
tol.T_OrderLocationM_LocationID,
tol.T_OrderLocationT_SampleStationID,
ss.T_SampleStationName
FROM cpone_dashboard.mcu_patient mp
JOIN cpone.mcu_preregister_patients preg
ON preg.Mcu_PreregisterPatientsID = mp.Mcu_PatientPreregisterID
JOIN cpone.t_order_location tol
ON tol.T_OrderLocationT_OrderHeaderID = preg.Mcu_PreregisterPatientsT_OrderHeaderID
AND tol.T_OrderLocationIsActive = 'Y'
JOIN cpone.t_samplestation ss
ON ss.T_SampleStationID = tol.T_OrderLocationT_SampleStationID
AND ss.T_SampleStationIsActive = 'Y'
WHERE mp.Mcu_PatientMcuID = p_mcu_id
AND mp.Mcu_PatientIsActive = 'Y'
ON DUPLICATE KEY UPDATE
order_header_id = VALUES(order_header_id),
sample_station_id = VALUES(sample_station_id),
station_name = VALUES(station_name),
updated_at = CURRENT_TIMESTAMP;
SET v_rows = ROW_COUNT();
SELECT v_rows AS rows_affected, p_mcu_id AS mcu_id;
END
```
### 4. `cpone_dashboard.sp_insert_dashboard_user`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_insert_dashboard_user`(IN `p_username` varchar(50), IN `p_password` varchar(255), IN `p_display_name` varchar(100))
BEGIN
DECLARE v_salt VARCHAR(36);
DECLARE v_hash VARCHAR(64);
IF p_username IS NULL OR TRIM(p_username) = '' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Username tidak boleh kosong';
END IF;
IF p_password IS NULL OR TRIM(p_password) = '' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Password tidak boleh kosong';
END IF;
IF LENGTH(p_password) < 6 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Password minimal 6 karakter';
END IF;
IF EXISTS (SELECT 1 FROM dashboard_user WHERE User_Username = TRIM(p_username)) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Username sudah terdaftar';
END IF;
SET v_salt = UUID();
SET v_hash = SHA2(CONCAT(v_salt, ':', p_password), 256);
INSERT INTO dashboard_user (User_Username, User_Password, User_Salt, User_DisplayName, User_IsActive)
VALUES (TRIM(p_username), v_hash, v_salt, p_display_name, 'Y');
END
```
### 5. `cpone_dashboard.sp_refresh_mcu_participant_daily_by_mcu`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_refresh_mcu_participant_daily_by_mcu`(IN `p_mgm_mcuid` int)
BEGIN
DECLARE v_done INT DEFAULT 0;
DECLARE v_schedule_date DATE;
DECLARE v_total_dates INT DEFAULT 0;
DECLARE cur_dates CURSOR FOR
SELECT DISTINCT pd.Mcu_PreregisterDateCheckinSchedule
FROM cpone.mcu_preregister_patients pp
INNER JOIN cpone.mcu_preregister_date pd
ON pd.Mcu_PreregisterDateMcu_PreregisterPatientsID = pp.Mcu_PreregisterPatientsID
AND pd.Mcu_PreregisterDateIsActive = 'Y'
WHERE pp.Mcu_PreregisterPatientsMgm_McuID = p_mgm_mcuid
AND pp.Mcu_PreregisterPatientsIsActive = 'Y'
AND pd.Mcu_PreregisterDateCheckinSchedule IS NOT NULL
AND pd.Mcu_PreregisterDateCheckinSchedule <> '0000-00-00'
ORDER BY pd.Mcu_PreregisterDateCheckinSchedule;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_done = 1;
OPEN cur_dates;
dates_loop: LOOP
FETCH cur_dates INTO v_schedule_date;
IF v_done = 1 THEN
LEAVE dates_loop;
END IF;
CALL cpone.sp_refresh_mcu_participant_daily_by_mcu_date(p_mgm_mcuid, v_schedule_date);
SET v_total_dates = v_total_dates + 1;
END LOOP;
CLOSE cur_dates;
SELECT v_total_dates AS processed_dates;
END
```
### 6. `cpone_dashboard.sp_remove_user_project`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_remove_user_project`(IN `p_username` varchar(50), IN `p_mcu_id` int)
BEGIN
DECLARE v_user_id INT;
SELECT User_ID INTO v_user_id
FROM dashboard_user
WHERE User_Username = p_username
LIMIT 1;
IF v_user_id IS NULL THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'User tidak ditemukan';
END IF;
UPDATE dashboard_user_project
SET UserProj_IsActive = 'N',
UserProj_UpdatedAt = NOW()
WHERE UserProj_UserID = v_user_id
AND UserProj_McuID = p_mcu_id;
END
```
### 7. `cpone_dashboard.sp_reset_dashboard_user_password`
```sql
CREATE DEFINER=`admin`@`localhost` PROCEDURE `sp_reset_dashboard_user_password`(IN `p_username` varchar(50), IN `p_new_password` varchar(255))
BEGIN
DECLARE v_salt VARCHAR(36);
DECLARE v_hash VARCHAR(64);
IF p_new_password IS NULL OR TRIM(p_new_password) = '' THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Password tidak boleh kosong';
END IF;
IF LENGTH(p_new_password) < 6 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Password minimal 6 karakter';
END IF;
IF NOT EXISTS (SELECT 1 FROM dashboard_user WHERE User_Username = TRIM(p_username)) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'User tidak ditemukan';
END IF;
SET v_salt = UUID();
SET v_hash = SHA2(CONCAT(v_salt, ':', p_new_password), 256);
UPDATE dashboard_user
SET User_Password = v_hash,
User_Salt = v_salt,
User_UpdatedAt = NOW()
WHERE User_Username = TRIM(p_username);
END
```
## Kesimpulan
- Schema `cpone_dashboard` pada `devcpone` memiliki 7 stored procedure.
- Dari hasil cek `information_schema.TRIGGERS`, tidak ada trigger yang memanggil 7 SP tersebut secara langsung.
- Jadi, jalur eksekusi SP-SP ini saat ini lebih masuk akal berasal dari layer aplikasi atau pemanggilan manual, bukan dari trigger database.

View File

@@ -0,0 +1,422 @@
# SP di DB `cpone` yang Berhubungan dengan `cpone_dashboard`
Dokumen ini hanya berisi stored procedure yang:
1. berada di database/schema `cpone`
2. memiliki relasi langsung ke database `cpone_dashboard`
Tanggal cek:
- `2026-06-17`
Server:
- `one@devcpone.aplikasi.web.id`
## Daftar SP
Stored procedure di schema `cpone` yang terdeteksi menyentuh `cpone_dashboard`:
1. `cpone.sp_generate_dummy_mcu_transactions`
2. `cpone.sp_refresh_mcu_participant_daily_by_mcu_date`
3. `cpone.sp_refresh_mcu_participant_daily_by_preregister`
4. `cpone.sp_sync_published_mcu_dashboard_by_mgm_mcuid`
5. `cpone.sp_sync_published_mcu_dashboard_by_orderheaderid`
6. `cpone.sp_upsert_mcu_patient_by_mgm_mcuid`
7. `cpone.sp_upsert_mcu_patient_by_preregister_id`
8. `cpone.sp_upsert_mcu_project_by_mgm_mcuid`
## Ringkasan Fungsi
| SP | Hubungan ke `cpone_dashboard` |
| --- | --- |
| `sp_generate_dummy_mcu_transactions` | Mengisi dummy transaksi lalu sync `mcu_patient`, `participant daily`, `mcu_station_progress`, dan `mcu_checkinout` |
| `sp_refresh_mcu_participant_daily_by_mcu_date` | Rebuild data `mcu_patient_schedule`, `mcu_participant_daily`, dan `mcu_participant_daily_details` per MCU + tanggal |
| `sp_refresh_mcu_participant_daily_by_preregister` | Refresh participant daily untuk satu preregister |
| `sp_sync_published_mcu_dashboard_by_mgm_mcuid` | Sync data `published_mcu_dashboard` ke `cpone_dashboard.published_mcu_dashboard_sync` berdasarkan `Mgm_McuID` |
| `sp_sync_published_mcu_dashboard_by_orderheaderid` | Sync data `published_mcu_dashboard` ke `cpone_dashboard.published_mcu_dashboard_sync` berdasarkan `T_OrderHeaderID` |
| `sp_upsert_mcu_patient_by_mgm_mcuid` | Upsert data patient dan packet ke `cpone_dashboard.mcu_patient` dan `mcu_patient_packet` |
| `sp_upsert_mcu_patient_by_preregister_id` | Upsert satu patient preregister ke `cpone_dashboard.mcu_patient` dan `mcu_patient_packet` |
| `sp_upsert_mcu_project_by_mgm_mcuid` | Upsert data project MCU ke `cpone_dashboard.mcu_project` |
## Tabel `cpone_dashboard` yang Disentuh
### `sp_generate_dummy_mcu_transactions`
Menyentuh:
- `cpone_dashboard.mcu_station_progress`
- `cpone_dashboard.mcu_checkinout`
Juga memanggil:
- `cpone.sp_upsert_mcu_patient_by_preregister_id`
- `cpone.sp_refresh_mcu_participant_daily_by_mcu_date`
### `sp_refresh_mcu_participant_daily_by_mcu_date`
Menyentuh:
- `cpone_dashboard.mcu_participant_daily_details`
- `cpone_dashboard.mcu_participant_daily`
- `cpone_dashboard.mcu_patient_schedule`
- `cpone_dashboard.mcu_patient`
- `cpone_dashboard.mcu_checkinout`
### `sp_refresh_mcu_participant_daily_by_preregister`
Menyentuh:
- `cpone_dashboard.mcu_patient`
- `cpone_dashboard.mcu_patient_schedule`
- `cpone_dashboard.mcu_participant_daily`
- `cpone_dashboard.mcu_participant_daily_details`
- `cpone_dashboard.mcu_checkinout`
### `sp_sync_published_mcu_dashboard_by_mgm_mcuid`
Menyentuh:
- `cpone_dashboard.published_mcu_dashboard_sync`
### `sp_sync_published_mcu_dashboard_by_orderheaderid`
Menyentuh:
- `cpone_dashboard.published_mcu_dashboard_sync`
### `sp_upsert_mcu_patient_by_mgm_mcuid`
Menyentuh:
- `cpone_dashboard.mcu_patient`
- `cpone_dashboard.mcu_patient_packet`
### `sp_upsert_mcu_patient_by_preregister_id`
Menyentuh:
- `cpone_dashboard.mcu_patient`
- `cpone_dashboard.mcu_patient_packet`
### `sp_upsert_mcu_project_by_mgm_mcuid`
Menyentuh:
- `cpone_dashboard.mcu_project`
## Catatan Penting
- Dokumen ini sengaja tidak memasukkan SP yang schema-nya `cpone_dashboard`.
- Fokusnya hanya SP yang berada di db `cpone` tetapi query atau write ke objek di `cpone_dashboard`.
- Dari sisi aplikasi, inilah kelompok SP yang paling relevan untuk flow sync antar db.
## Trigger di Schema `cpone` yang Terkait
Trigger `cpone` yang terdeteksi punya hubungan dengan `cpone_dashboard` atau memanggil SP di atas:
1. `cpone.trg_mgm_mcu_ai_sync_mcu_project`
2. `cpone.trg_mgm_mcu_au_sync_mcu_project`
3. `cpone.trg_published_mcu_dashboard_sync_ins`
4. `cpone.trg_published_mcu_dashboard_sync_upd`
### Ringkasan Trigger
| Trigger | Table | Relasi |
| --- | --- | --- |
| `trg_mgm_mcu_ai_sync_mcu_project` | `cpone.mgm_mcu` | `CALL cpone.sp_upsert_mcu_project_by_mgm_mcuid(NEW.Mgm_McuID)` |
| `trg_mgm_mcu_au_sync_mcu_project` | `cpone.mgm_mcu` | `CALL cpone.sp_upsert_mcu_project_by_mgm_mcuid(NEW.Mgm_McuID)` |
| `trg_published_mcu_dashboard_sync_ins` | `cpone.published_mcu_dashboard` | Direct insert/update ke `cpone_dashboard.published_mcu_dashboard_sync` |
| `trg_published_mcu_dashboard_sync_upd` | `cpone.published_mcu_dashboard` | Direct insert/update ke `cpone_dashboard.published_mcu_dashboard_sync` |
### Trigger `cpone` yang Memanggil SP dari Daftar Ini
Yang benar-benar memanggil SP dari daftar SP `cpone` di atas:
- `trg_mgm_mcu_ai_sync_mcu_project` -> `cpone.sp_upsert_mcu_project_by_mgm_mcuid`
- `trg_mgm_mcu_au_sync_mcu_project` -> `cpone.sp_upsert_mcu_project_by_mgm_mcuid`
### SP `cpone` yang Tidak Ditemukan Dipanggil Trigger `cpone`
SP berikut tidak ditemukan dipanggil langsung oleh trigger di schema `cpone`:
- `cpone.sp_generate_dummy_mcu_transactions`
- `cpone.sp_refresh_mcu_participant_daily_by_mcu_date`
- `cpone.sp_refresh_mcu_participant_daily_by_preregister`
- `cpone.sp_sync_published_mcu_dashboard_by_mgm_mcuid`
- `cpone.sp_sync_published_mcu_dashboard_by_orderheaderid`
- `cpone.sp_upsert_mcu_patient_by_mgm_mcuid`
- `cpone.sp_upsert_mcu_patient_by_preregister_id`
## Dump Ringkas SP
### 1. `cpone.sp_generate_dummy_mcu_transactions`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_generate_dummy_mcu_transactions`(
IN p_preregister_id INT,
IN p_mcu_id INT,
IN p_schedule_date DATE,
IN p_user_id INT
)
BEGIN
...
CALL cpone.sp_upsert_mcu_patient_by_preregister_id(v_preregister_id);
CALL cpone.sp_refresh_mcu_participant_daily_by_mcu_date(v_mcu_id, v_effective_date);
INSERT INTO cpone_dashboard.mcu_station_progress (...);
INSERT INTO cpone_dashboard.mcu_checkinout (...);
...
END$$
DELIMITER ;
```
### 2. `cpone.sp_refresh_mcu_participant_daily_by_mcu_date`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_refresh_mcu_participant_daily_by_mcu_date`(
IN p_mgm_mcuid INT,
IN p_schedule_date DATE
)
BEGIN
DELETE d
FROM cpone_dashboard.mcu_participant_daily_details d
INNER JOIN cpone_dashboard.mcu_participant_daily h
ON h.Mcu_ParticipantDailyID = d.Mcu_ParticipantDailyDetailsParticipantDailyID
WHERE h.Mcu_ParticipantDailyMcuID = p_mgm_mcuid
AND h.Mcu_ParticipantDailyDate = p_schedule_date;
DELETE FROM cpone_dashboard.mcu_participant_daily
WHERE Mcu_ParticipantDailyMcuID = p_mgm_mcuid
AND Mcu_ParticipantDailyDate = p_schedule_date;
DELETE s
FROM cpone_dashboard.mcu_patient_schedule s
...
INSERT INTO cpone_dashboard.mcu_patient_schedule (...);
INSERT INTO cpone_dashboard.mcu_participant_daily (...);
INSERT INTO cpone_dashboard.mcu_participant_daily_details (...);
...
END$$
DELIMITER ;
```
### 3. `cpone.sp_refresh_mcu_participant_daily_by_preregister`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_refresh_mcu_participant_daily_by_preregister`(
IN p_preregister_id INT
)
BEGIN
SELECT Mcu_PatientID
INTO v_mcu_patient_id
FROM cpone_dashboard.mcu_patient
WHERE Mcu_PatientPreregisterID = p_preregister_id
AND Mcu_PatientMcuID = v_mgm_mcuid
LIMIT 1;
INSERT INTO cpone_dashboard.mcu_patient_schedule (...);
INSERT INTO cpone_dashboard.mcu_participant_daily (...);
DELETE FROM cpone_dashboard.mcu_participant_daily_details ...;
INSERT INTO cpone_dashboard.mcu_participant_daily_details (...);
...
END$$
DELIMITER ;
```
### 4. `cpone.sp_sync_published_mcu_dashboard_by_mgm_mcuid`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_sync_published_mcu_dashboard_by_mgm_mcuid`(IN p_mgm_mcuid INT)
BEGIN
INSERT INTO cpone_dashboard.published_mcu_dashboard_sync (
Published_McuDasboardID,
Published_McuDasboardT_OrderHeaderID,
Published_McuDasboardStatus,
Published_McuDasboardFileUrl,
Published_McuDasboardIsActive,
Published_McuDasboardCreated,
Published_McuDasboardCreatedUserID,
Published_McuDasboardLastUpdated,
Published_McuDasboardLastUpdatedUserID
)
SELECT ...
FROM cpone.published_mcu_dashboard pmd
...
ON DUPLICATE KEY UPDATE ...;
END$$
DELIMITER ;
```
### 5. `cpone.sp_sync_published_mcu_dashboard_by_orderheaderid`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_sync_published_mcu_dashboard_by_orderheaderid`(IN p_t_orderheaderid INT)
BEGIN
INSERT INTO cpone_dashboard.published_mcu_dashboard_sync (
Published_McuDasboardID,
Published_McuDasboardT_OrderHeaderID,
Published_McuDasboardStatus,
Published_McuDasboardFileUrl,
Published_McuDasboardIsActive,
Published_McuDasboardCreated,
Published_McuDasboardCreatedUserID,
Published_McuDasboardLastUpdated,
Published_McuDasboardLastUpdatedUserID
)
SELECT ...
FROM cpone.published_mcu_dashboard pmd
WHERE pmd.Published_McuDasboardT_OrderHeaderID = p_t_orderheaderid
ON DUPLICATE KEY UPDATE ...;
END$$
DELIMITER ;
```
### 6. `cpone.sp_upsert_mcu_patient_by_mgm_mcuid`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_upsert_mcu_patient_by_mgm_mcuid`(IN `p_mgm_mcuid` int)
BEGIN
INSERT INTO cpone_dashboard.mcu_patient (
Mcu_PatientPreregisterID,
Mcu_PatientMcuID,
Mcu_PatientName,
Mcu_PatientNIP,
Mcu_PatientGender,
Mcu_PatientDOB,
Mcu_PatientDepartment,
Mcu_PatientDivision,
Mcu_PatientPosisi,
Mcu_PatientOrders,
Mcu_PatientPemeriksaan,
Mcu_PatientIsRegistered,
Mcu_PatientOrderID,
Mcu_PatientIsActive,
Mcu_PatientSyncedAt
)
SELECT ...
ON DUPLICATE KEY UPDATE ...;
DELETE ppk
FROM cpone_dashboard.mcu_patient_packet ppk
INNER JOIN cpone_dashboard.mcu_patient mp
ON mp.Mcu_PatientID = ppk.Mcu_PatientPacketMcu_PatientID
WHERE mp.Mcu_PatientMcuID = p_mgm_mcuid;
INSERT INTO cpone_dashboard.mcu_patient_packet (...);
END$$
DELIMITER ;
```
### 7. `cpone.sp_upsert_mcu_patient_by_preregister_id`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_upsert_mcu_patient_by_preregister_id`(IN `p_preregister_id` int)
BEGIN
INSERT INTO cpone_dashboard.mcu_patient (... )
SELECT ...
ON DUPLICATE KEY UPDATE ...;
DELETE FROM cpone_dashboard.mcu_patient_packet
WHERE Mcu_PatientPacketPreregisterID = p_preregister_id;
INSERT INTO cpone_dashboard.mcu_patient_packet (...);
END$$
DELIMITER ;
```
### 8. `cpone.sp_upsert_mcu_project_by_mgm_mcuid`
```sql
DELIMITER $$
CREATE PROCEDURE `sp_upsert_mcu_project_by_mgm_mcuid`(IN `p_mgm_mcuid` int)
BEGIN
INSERT INTO cpone_dashboard.mcu_project (
Mcu_ProjectMcuID,
Mcu_ProjectCorporateID,
Mcu_ProjectCorporateName,
Mcu_ProjectNumber,
Mcu_ProjectLabel,
Mcu_ProjectBranchID,
Mcu_ProjectStartDate,
Mcu_ProjectEndDate,
Mcu_ProjectIsActive,
Mcu_ProjectTotalParticipant,
Mcu_ProjectSyncedAt
)
SELECT ...
ON DUPLICATE KEY UPDATE ...;
END$$
DELIMITER ;
```
## Dump Ringkas Trigger `cpone`
### 1. `cpone.trg_mgm_mcu_ai_sync_mcu_project`
```sql
DELIMITER $$
CREATE TRIGGER `trg_mgm_mcu_ai_sync_mcu_project`
AFTER INSERT ON `mgm_mcu`
FOR EACH ROW
BEGIN
CALL cpone.sp_upsert_mcu_project_by_mgm_mcuid(NEW.Mgm_McuID);
END$$
DELIMITER ;
```
### 2. `cpone.trg_mgm_mcu_au_sync_mcu_project`
```sql
DELIMITER $$
CREATE TRIGGER `trg_mgm_mcu_au_sync_mcu_project`
AFTER UPDATE ON `mgm_mcu`
FOR EACH ROW
BEGIN
CALL cpone.sp_upsert_mcu_project_by_mgm_mcuid(NEW.Mgm_McuID);
END$$
DELIMITER ;
```
### 3. `cpone.trg_published_mcu_dashboard_sync_ins`
```sql
DELIMITER $$
CREATE TRIGGER `trg_published_mcu_dashboard_sync_ins`
AFTER INSERT ON `published_mcu_dashboard`
FOR EACH ROW
INSERT INTO cpone_dashboard.published_mcu_dashboard_sync (
Published_McuDasboardID,
Published_McuDasboardT_OrderHeaderID,
Published_McuDasboardStatus,
Published_McuDasboardFileUrl,
Published_McuDasboardIsActive,
Published_McuDasboardCreated,
Published_McuDasboardCreatedUserID,
Published_McuDasboardLastUpdated,
Published_McuDasboardLastUpdatedUserID
)
VALUES (...)
ON DUPLICATE KEY UPDATE ...$$
DELIMITER ;
```
### 4. `cpone.trg_published_mcu_dashboard_sync_upd`
```sql
DELIMITER $$
CREATE TRIGGER `trg_published_mcu_dashboard_sync_upd`
AFTER UPDATE ON `published_mcu_dashboard`
FOR EACH ROW
INSERT INTO cpone_dashboard.published_mcu_dashboard_sync (
Published_McuDasboardID,
Published_McuDasboardT_OrderHeaderID,
Published_McuDasboardStatus,
Published_McuDasboardFileUrl,
Published_McuDasboardIsActive,
Published_McuDasboardCreated,
Published_McuDasboardCreatedUserID,
Published_McuDasboardLastUpdated,
Published_McuDasboardLastUpdatedUserID
)
VALUES (...)
ON DUPLICATE KEY UPDATE ...$$
DELIMITER ;
```