From 9c396d1b36e1fc50f1c3e2f32b0aa3dc50bba01e Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Mon, 22 Jul 2024 10:54:39 +0700 Subject: [PATCH] improvement add/edit dialog --- .../Controllers/Api/RequestLogController.php | 18 +- .../Transformers/RequestLogShowResource.php | 2 +- .../Components/DialogConfirmation.tsx | 219 +++++++++--------- .../Components/DialogEditFinalLOG.tsx | 66 +++--- .../pages/CustomerService/FinalLog/Detail.tsx | 2 +- .../CustomerService/FinalLog/Model/Types.tsx | 4 +- 6 files changed, 162 insertions(+), 149 deletions(-) diff --git a/Modules/Internal/Http/Controllers/Api/RequestLogController.php b/Modules/Internal/Http/Controllers/Api/RequestLogController.php index c562d97e..ebb70b89 100755 --- a/Modules/Internal/Http/Controllers/Api/RequestLogController.php +++ b/Modules/Internal/Http/Controllers/Api/RequestLogController.php @@ -201,9 +201,13 @@ class RequestLogController extends Controller return Helper::responseJson(data: RequestLogShowResource::make($claimRequest)); } - public function diagnosis(){ + public function diagnosis(Request $request){ $icds = Icd::query() - ->get(); + ->when($request->search, function ($q, $search) { + $q->where('code', 'LIKE', "%".$search."%"); + $q->orWhere('name', 'LIKE', "%".$search."%"); + }) + ->paginate(); $manipulatedIcds = $icds->map(function ($icd) { // Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan @@ -445,9 +449,17 @@ class RequestLogController extends Controller $requestLog->discharge_date = $request->discharge_date; } if (!empty($request->icdCodes)) { - $diagnosis = implode(',', $request->icdCodes); + $data = []; + if (count($request->icdCodes)>0){ + foreach($request->icdCodes as $code){ + array_push($data, $code['value']); + } + } + $diagnosis = implode(',', $data); $requestLog->diagnosis = $diagnosis; + } else { + $requestLog->diagnosis = ''; } if (!empty($request->status)) { $requestLog->status_final_log = $status; diff --git a/Modules/Internal/Transformers/RequestLogShowResource.php b/Modules/Internal/Transformers/RequestLogShowResource.php index ca22d642..dc46b978 100755 --- a/Modules/Internal/Transformers/RequestLogShowResource.php +++ b/Modules/Internal/Transformers/RequestLogShowResource.php @@ -112,7 +112,7 @@ class RequestLogShowResource extends JsonResource $diagnosis = explode(',', $requestLog['diagnosis']); $icd = Icd::query() ->whereIn('code', $diagnosis) - ->select('code', 'name') + ->select('code as value', 'name as label') ->get(); } $memberUsage = Helper::getUsageMember($corporateId, $requestLog['member']['id'], $benefitData); diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogConfirmation.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogConfirmation.tsx index 4ff76dd6..feb71bc8 100755 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogConfirmation.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogConfirmation.tsx @@ -1,6 +1,5 @@ import MuiDialog from "@/components/MuiDialog"; -import { Autocomplete, Button, Card, Checkbox, DialogActions, Grid, TextField, Typography } from "@mui/material"; -import { Paper } from "@mui/material"; +import { Autocomplete, Button, Card, DialogActions, Grid, TextField, Typography } from "@mui/material"; import { Stack } from '@mui/material'; import React, { useEffect, useState } from 'react'; import { DetailFinalLogType } from "../Model/Types"; @@ -33,18 +32,8 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo { value: '-', label: '-' } ]); - useEffect(() => { - // Ambil data dari API dan atur opsi ICD - axios.get('diagnosis') - .then((response) => { - setIcdOptions(response.data.data); - }) - .catch((error) => { - console.error('Error fetching ICD options:', error); - }); - }, []); // useEffect dijalankan hanya sekali saat komponen dimount - - + const [searchIcd, setSearchIcd] = useState(''); + useEffect(() => { // Update formData setiap kali approve berubah setFormData(prevData => ({ @@ -58,7 +47,6 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo ...prevData, [field]: value, })); - }; const handleApprove = () => { @@ -68,7 +56,17 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo })); handleSubmit(); }; - + + const handleSearch = (search) => { + setSearchIcd(search); + axios.get('diagnosis?search=' + search) + .then((response) => { + setIcdOptions(response.data.data); + }) + .catch((error) => { + console.error('Error fetching ICD options:', error); + }); + } const handleSubmit = () => { axios @@ -76,7 +74,7 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo .then((response) => { enqueueSnackbar('Verification Request LOG Success', { variant: 'success' }); setOpenDialog(false); - if (requestLog?.service_type == 'Inpatient'){ + if (requestLog?.service_type === 'Inpatient') { navigate('/case_management/inpatient_monitoring'); } else { navigate('/custormer-service/final-log'); @@ -87,120 +85,117 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo }); } - const style1 = { color: '#919EAB', width: '30%' - } + }; const style2 = { width: '70%' - } + }; const marginBottom1 = { marginBottom: 1, - } + }; const marginBottom2 = { marginBottom: 2, - } + }; const handleCloseDialog = () => { setOpenDialog(false); - } - - + }; const getContent = () => ( - Are you sure to {approve == 'approved' ? 'approve' : 'deciline'} this final log ? + Are you sure to {approve === 'approved' ? 'approve' : 'decline'} this final log? - - - Member ID - {requestLog?.member_id} - - - Policy Number - {requestLog?.policy_number} - - - Name - {requestLog?.name} - - - Submission Date - {requestLog?.submission_date ? fDateTimesecond(requestLog?.submission_date) : '-'} - - - Claim Method - {requestLog?.claim_method ? toTitleCase(requestLog?.claim_method) : '-'} - - - Service Type - {requestLog?.service_type} - - + + + Member ID + {requestLog?.member_id} + + + Policy Number + {requestLog?.policy_number} + + + Name + {requestLog?.name} + + + Submission Date + {requestLog?.submission_date ? fDateTimesecond(requestLog?.submission_date) : '-'} + + + Claim Method + {requestLog?.claim_method ? toTitleCase(requestLog?.claim_method) : '-'} + + + Service Type + {requestLog?.service_type} + + - - - Discharge Date - handleChange('discharge_date', e.target.value)} - /> - - - Catatan - handleChange('catatan', e.target.value)} - /> - - - Diagnosis ICD - X - option.label} - fullWidth - value={icdOptions.filter((icd) => formData.icdCodes.includes(icd.value))} - onChange={(e, newValues) => handleChange('icdCodes', newValues.map((value) => value.value))} - renderInput={(params) => ( - - )} - /> - - - - - + + + Discharge Date + handleChange('discharge_date', e.target.value)} + /> + + + Catatan + handleChange('catatan', e.target.value)} + /> + + + Diagnosis ICD - X + option.label} + fullWidth + value={formData.icdCodes} + onChange={(e, newValues) => handleChange('icdCodes', newValues)} + inputValue={searchIcd} + onInputChange={(e, newInputValue) => handleSearch(newInputValue)} + renderInput={(params) => ( + + )} + /> + + + + + - {approve == 'approved' ? ( - - ) : ( - - ) } - - + {approve === 'approved' ? ( + + ) : ( + + )} + - ); - + ); return ( - ); -} \ No newline at end of file + ); +} diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogEditFinalLOG.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogEditFinalLOG.tsx index 88959ff9..3da8b4dc 100755 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogEditFinalLOG.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/Components/DialogEditFinalLOG.tsx @@ -26,9 +26,7 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo discharge_date: requestLog?.discharge_date, id: requestLog?.id, catatan: requestLog?.catatan, - icdCodes: requestLog?.diagnosis - ? requestLog?.diagnosis.map(diagnosis => diagnosis.code) - : [], + icdCodes: requestLog?.diagnosis, reason: requestLog?.reason }); @@ -36,8 +34,10 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo { value: '-', label: '-' } ]); + const [searchIcd, setSearchIcd] = useState(''); + useEffect(() => { - // Ambil data dari API dan atur opsi ICD + // Ambil data dari API dan atur opsi ICD axios.get('diagnosis') .then((response) => { setIcdOptions(response.data.data); @@ -45,23 +45,23 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo .catch((error) => { console.error('Error fetching ICD options:', error); }); + }, []); // useEffect dijalankan hanya sekali saat komponen dimount useEffect(() => { - if (requestLog) { - setFormData({ - discharge_date: requestLog.discharge_date, - billing_no: requestLog.billing_no, - invoice_no: requestLog.invoice_no, - id: requestLog.id, - catatan: requestLog.catatan, - icdCodes: requestLog.diagnosis - ? requestLog.diagnosis.map(diagnosis => diagnosis.code) - : [], - reason: requestLog.reason - }); - } - }, [requestLog]); + if (requestLog) { + setFormData({ + discharge_date: requestLog.discharge_date, + billing_no: requestLog.billing_no, + invoice_no: requestLog.invoice_no, + id: requestLog.id, + catatan: requestLog.catatan, + icdCodes: requestLog.diagnosis, + reason: requestLog.reason + }); + } + }, [requestLog]); + const handleChange = (field, value) => { setFormData((prevData) => ({ @@ -80,6 +80,17 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo })); handleSubmit(); }; + + const handleSearch = (search) => { + setSearchIcd(search); + axios.get('diagnosis?search=' + search) + .then((response) => { + setIcdOptions(response.data.data); + }) + .catch((error) => { + console.error('Error fetching ICD options:', error); + }); + } const handleSubmit = () => { @@ -100,8 +111,7 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo alert('Silakan pilih alasan sebelum mengirimkan data.'); } } - - + const style1 = { color: '#919EAB', width: '30%' @@ -123,13 +133,10 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo billing_no: requestLog?.billing_no, invoice_no: requestLog?.invoice_no, catatan: requestLog?.catatan, - icdCodes: requestLog?.diagnosis - ? requestLog?.diagnosis.map(diagnosis => diagnosis.code) - : [], + icdCodes: requestLog?.diagnosis, reason: requestLog?.reason }); }; - const [isReasonSelected, setIsReasonSelected] = useState(true); const handleCloseDialog = () => { @@ -227,11 +234,10 @@ export default function DialogEditFinalLOG({requestLog, setOpenDialog, openDialo options={icdOptions} getOptionLabel={(option) => option.label} fullWidth - value={icdOptions.filter((icd) => formData.icdCodes.includes(icd.value))} - onChange={(e, newValues) => { - const selectedCodes = newValues.map((value) => value.value); - setFormData({ ...formData, icdCodes: selectedCodes }); - }} + value={formData.icdCodes} + onChange={(e, newValues) => handleChange('icdCodes', newValues)} + inputValue={searchIcd} + onInputChange={(e, newInputValue) => handleSearch(newInputValue)} renderInput={(params) => ( option.label} fullWidth - value={reasons.find((r) => r.value === formData.reason) || null} // Use find to match the default value + value={reasons.find((r) => r.value == formData.reason) || null} // Use find to match the default value onChange={(e, newValue) => handleChange('reason', newValue?.value)} renderInput={(params) => ( 0 ? (
    {requestLog.diagnosis.map((diagnosisItem, index) => ( -
  • {diagnosisItem.code} - {diagnosisItem.name}
  • +
  • {diagnosisItem.value} - {diagnosisItem.label}
  • // Replace 'name' with the property you want to display ))}
diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/Model/Types.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/Model/Types.tsx index 4e245e17..5121f69b 100755 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/Model/Types.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/Model/Types.tsx @@ -65,8 +65,8 @@ export type DetailFinalLogType = { export type Diagnosis = { id : number, - name : string, - code : string + value : string, + label : string } export type BenefitData = {