diff --git a/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php b/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php
index b77e34da..5709ec4a 100644
--- a/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php
+++ b/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php
@@ -205,6 +205,7 @@ class RequestLogController extends Controller
'members.name as full_name',
'members.member_id as no_polis',
'members.birth_date',
+ 'request_logs.service_code',
DB::raw('
CASE
WHEN request_logs.status = "requested" THEN "requested"
diff --git a/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx b/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx
index 51b55087..061c81fe 100644
--- a/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx
+++ b/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx
@@ -38,19 +38,38 @@ export default function TableListFinalLog() {
const [data, setData] = useState([]);
// Download LOG
- async function handleDownloadLog(request_log_id:any) {
+ async function handleDownloadLog(request_log_id: any, service_code:any, no_polis:any, full_name:any) {
return axios
.get(`download-final-log/${request_log_id}`, {
responseType: 'blob',
})
.then((response) => {
- window.open(URL.createObjectURL(response.data), '_blank');
+ console.log(response);
+ // GL Akhir-010124-OP-00001234 Ratih-LinkSehat
+ const namaFile = 'GL Akhir-'+getFormattedToday()+'-'+service_code+'-'+no_polis+'-'+full_name+'-LinkSehat.pdf';
+ const url = URL.createObjectURL(response.data);
+ const link = document.createElement('a');
+ link.href = url;
+ link.setAttribute('download', namaFile);
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
})
- .catch((response) => {
- enqueueSnackbar(response.message, { variant: 'error' });
+ .catch((error) => {
+ enqueueSnackbar(error.message, { variant: 'error' });
});
}
+ function getFormattedToday() {
+ const today = new Date();
+
+ const day = String(today.getDate()).padStart(2, '0');
+ const month = String(today.getMonth() + 1).padStart(2, '0'); // Bulan dimulai dari 0 (Januari = 0)
+ const year = String(today.getFullYear()).substring(2, 4);
+
+ return `${day}${month}${year}`;
+ }
+
/* -------------------------------------------------------------------------- */
/* setting up for the table */
/* -------------------------------------------------------------------------- */
@@ -350,7 +369,7 @@ export default function TableListFinalLog() {
View
{obj.status === 'approved' ? (
-
{obj.status === 'approved' ? (
- handleDownloadLog(obj.id)}>
+ handleDownloadLog(obj.id, obj.service_code, obj.no_polis, obj.full_name)}>
Download LOG