diff --git a/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php b/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php index b84a5b5c..df17793e 100644 --- a/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php +++ b/Modules/HospitalPortal/Http/Controllers/Api/RequestLogController.php @@ -234,7 +234,8 @@ class RequestLogController extends Controller $query->orWhere('request_logs.code', 'like', "%" . $search . "%") ->orWhere('members.name', 'like', "%" . $search . "%") ->orWhere('request_logs.submission_date', 'like', "%" . $search . "%") - ->orWhere('request_logs.service_code', 'like', "%" . ($search == 'outpatient' || $search == 'Outpatient' ? 'OP' : 'IP') . "%"); + ->orWhere('request_logs.service_code', 'like', "%" . ($search == 'outpatient' || $search == 'Outpatient' ? 'OP' : $search) . "%") + ->orWhere('request_logs.service_code', 'like', "%" . ($search == 'inpatient' || $search == 'Inpatient' ? 'IP' : $search) . "%"); }); }) ->when($request->has('orderBy'), function ($query) use ($request) { diff --git a/frontend/hospital-portal/index.html b/frontend/hospital-portal/index.html index 7c476007..3d1db293 100644 --- a/frontend/hospital-portal/index.html +++ b/frontend/hospital-portal/index.html @@ -34,6 +34,6 @@
- + diff --git a/frontend/hospital-portal/src/sections/dashboard/TableList.tsx b/frontend/hospital-portal/src/sections/dashboard/TableList.tsx index f9a6b51a..20ab4ce9 100644 --- a/frontend/hospital-portal/src/sections/dashboard/TableList.tsx +++ b/frontend/hospital-portal/src/sections/dashboard/TableList.tsx @@ -31,6 +31,7 @@ import DialogMember from './DialogMember'; import DialogFinalLog from './DialogFinalLog'; import { fPostFormat } from '@/utils/formatTime'; import TableListFinalLog from './TableListFinalLog'; +import TableListReqLog from './TableListReqLog'; export default function TableList() { const navigate = useNavigate(); @@ -39,364 +40,13 @@ export default function TableList() { useEffect(() => { setCurrentTab('request_log') -}, []) + }, []) -function handleChangeTab(event: React.SyntheticEvent, newValue: string) { - setCurrentTab(newValue) -} - - //const { corporateValue } = useContext(UserCurrentCorporateContext); - //const { corporateValue } = useContext(null); - - const [data, setData] = useState([]); - - // Download LOG - async function handleDownloadLog(request_log_id:any) { - return axios - .get(`download-log/${request_log_id}`, { - responseType: 'blob', - }) - .then((response) => { - window.open(URL.createObjectURL(response.data), '_blank'); - }) - .catch((response) => { - enqueueSnackbar(response.message, { variant: 'error' }); - }); + function handleChangeTab(event: React.SyntheticEvent, newValue: string) { + setCurrentTab(newValue) } - - /* -------------------------------------------------------------------------- */ - /* setting up for the table */ - /* -------------------------------------------------------------------------- */ - const [isLoading, setIsLoading] = useState(true); - - const loadings = { - isLoading: isLoading, - setIsLoading: setIsLoading, - }; - - /* ------------------------------ handle params ----------------------------- */ - const [searchParams, setSearchParams] = useSearchParams(); - const [appliedParams, setAppliedParams] = useState({}); - - const params = { - searchParams: searchParams, - setSearchParams: setSearchParams, - appliedParams: appliedParams, - setAppliedParams: setAppliedParams, - }; - /* -------------------------------------------------------------------------- */ - - /* ------------------------------ handle order ------------------------------ */ - const [order, setOrder] = useState('desc'); - const [orderBy, setOrderBy] = useState('submission_date'); - - const orders = { - order: order, - setOrder: setOrder, - orderBy: orderBy, - setOrderBy: setOrderBy, - }; - /* -------------------------------------------------------------------------- */ - - /* ---------------------------- handle pagination --------------------------- */ - const [page, setPage] = useState(0); - const [rowsPerPage, setRowsPerPage] = useState(10); - - const [paginationTable, setPaginationTable] = useState({ - current_page: 0, - from: 0, - last_page: 0, - links: [], - path: '', - per_page: 0, - to: 0, - total: 0, - }); - - const paginations = { - page: page, - setPage: setPage, - rowsPerPage: rowsPerPage, - setRowsPerPage: setRowsPerPage, - paginationTable: paginationTable, - setPaginationTable: setPaginationTable, - }; - - /* -------------------------------------------------------------------------- */ - - /* ------------------------------ handle search ----------------------------- */ - const [searchText, setSearchText] = useState(''); - - const handleSearchSubmit = async (event: React.FormEvent) => { - event.preventDefault(); - - if (searchText === '') { - searchParams.delete('search'); - const params = Object.fromEntries([...searchParams.entries()]); - setAppliedParams(params); - } else { - const params = Object.fromEntries([...searchParams.entries(), ['search', searchText]]); - setAppliedParams(params); - } - }; - - const searchs = { - useSearchs: true, - searchText: searchText, - setSearchText: setSearchText, - handleSearchSubmit: handleSearchSubmit, - }; - - /* ------------------------------ handle filter ----------------------------- */ - const [statusValue, setStatusValue] = useState('all'); - const [filterData, setStatusData] = useState([]); - - // handle status - const handleStatusChanges = (event: SelectChangeEvent) => { - setStatusValue(event.target.value as string); - - if (event.target.value === 'all') { - searchParams.delete('status'); - const params = Object.fromEntries([...searchParams.entries()]); - setAppliedParams(params); - } else { - const params = Object.fromEntries([ - ...searchParams.entries(), - ['status', event.target.value as string], - ]); - setAppliedParams(params); - } - }; - - const filterStatus = { - useFilter: true, - config: { - label: 'Status', - statusValue: statusValue, - filterData: filterData, - handleStatusChange: handleStatusChanges, - }, - }; - - // handle start date - const [startDateValue, setStartDateValue] = useState(''); - - const handleStartDateChanges = async (event: React.FormEvent) => { - event.preventDefault(); - const newStartDateValue = event.currentTarget.elements['date-input'].value; - setStartDateValue(newStartDateValue); - if (newStartDateValue === '') { - searchParams.delete('start_date'); - const params = Object.fromEntries([...searchParams.entries()]); - setAppliedParams(params); - } else { - const params = Object.fromEntries([...searchParams.entries(), ['start_date', newStartDateValue]]); - setAppliedParams(params); - } - }; - - const filterStartDate = { - useFilter: true, - startDate: startDateValue, - setStartDate: setStartDateValue, - handleStartDateChange: handleStartDateChanges, - }; - - // handle end date - const [endDateValue, setEndDateValue] = useState(''); - - const handleEndDateChanges = async (event: React.FormEvent) => { - event.preventDefault(); - const newEndDateValue = event.currentTarget.elements['date-input'].value; - setEndDateValue(newEndDateValue); - if (newEndDateValue === '') { - searchParams.delete('end_date'); - const params = Object.fromEntries([...searchParams.entries()]); - setAppliedParams(params); - } else { - const params = Object.fromEntries([...searchParams.entries(), ['end_date', newEndDateValue]]); - setAppliedParams(params); - } - }; - - const filterEndDate = { - useFilter: true, - endDate: endDateValue, - setEndDate: setEndDateValue, - handleEndDateChange: handleEndDateChanges, - }; - - /* -------------------------------- headCell Request LOG -------------------------------- */ - const headCells: HeadCell[] = [ - { - id: 'code', - align: 'left', - label: localeData.txtRequestCode, - isSort: true, - }, - { - id: 'provider', - align: 'left', - label: localeData.txtProvider, - isSort: true, - }, - { - id: 'full_name', - align: 'left', - label: localeData.txtName, - isSort: true, - }, - { - id: 'submission_date', - align: 'center', - label: localeData.txtSubmissionDate, - isSort: true, - }, - { - id: 'status', - align: 'center', - label: localeData.txtStatus, - isSort: true, - }, - { - id: 'action', - align: 'right', - label: '', - isSort: false, - }, - ]; - function handleSearchMember(noPolis:any, birthDate:any) { - setLoadingClaim(false) - axios.post('/search-member', { - no_polis: noPolis, - birth_date: birthDate ? fPostFormat(birthDate, 'yyyy-MM-dd') : null, - type: 'view' - }) - .then((response) => { - setOpenDialogBenefit(true) - setCurrentMember(response.data.data) - setNameMember(response.data.data.members.name); - }) - .catch(({response}) => { - enqueueSnackbar(response.data.errors ? response.data.errors[0] : (response.data ? response.data.meta.message : 'Opps, Something went Wrong!'), {variant : "error"}) - }) - .then(() => { - }); - } - - - - function handleRequestFinalLog(id:any, full_name:any, no_polis:any, submission_date:any) - { - setOpenDialogFinalLog(true); - const datas_view = { - 'id' : id, - 'full_name' : full_name, - 'no_polis' : no_polis, - 'submission_date' : submission_date - }; - setDataViewFinalDialog(datas_view); - } - - useEffect(() => { - getData(); - }, [appliedParams, searchParams, order, orderBy, setSearchParams]); - - function getData() - { - (async () => { - setIsLoading(true); - - await new Promise((resolve) => setTimeout(resolve, 250)); - - const parameters = - Object.keys(appliedParams).length !== 0 - ? appliedParams - : Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]); - - const response = await axios.get(`/get-request-log`, { - params: { ...parameters, order: order, - orderBy: orderBy, type: 'request-log' }, - }); - setData( - response.data.data.map((obj: any) => ({ - ...obj, - status: - obj.status === 'requested' ? ( - - ) : obj.status === 'approved' ? ( - - ) : obj.status === 'declined' ? ( - - ) : obj.status === 'reviewed' ? ( - - ) : ( - - ), - submission_date: - - , - action: - - handleSearchMember(obj.no_polis, obj.birth_date) }> - - View - - {obj.status === 'approved' ? ( - handleDownloadLog(obj.id)}> - - Download LOG - - ):''} - {obj.final_log === 0 && obj.status === 'approved' ? ( - handleRequestFinalLog(obj.id, obj.full_name, obj.no_polis, obj.submission_date) }> - - Request Final LOG - - ):''} - - } /> - })) - ); - - setPaginationTable(response.data); - setRowsPerPage(response.data.per_page); - - if (searchParams.get('page')) { - //@ts-ignore - const currentPage = parseInt(searchParams.get('page')) - 1; - - paginationTable.current_page = currentPage; - setPage(currentPage); - } - - const status:any = [ - {"id": "requested", "name": "Request" }, - {"id": "reviewed", "name": "Review" }, - {"id": "approved", "name": "Approval" }, - {"id": "declined", "name": "Decline" }, - ]; - setStatusData(status) - - setIsLoading(false); - })(); - } - const RootNotificationStyle = styled(Card)(({ theme }) => ({ boxShadow: 'none', padding: '1rem 0.5rem', @@ -425,18 +75,6 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { ); } - // const [noPolis, setNoPolis] = useState('AW001-01'); - //const [birthDate, setBirthDate] = useState('1991-01-10'); - const [loadingBenefit, setLoadingBenefit] = useState(false); - const [loadingClaim, setLoadingClaim] = useState(false); - const [openDialogBenefit, setOpenDialogBenefit] = useState(false); - const [openDialogFinalLog, setOpenDialogFinalLog] = useState(false); - const [openDialogClaim, setOpenDialogClaim] = useState(false); - const [currentMember, setCurrentMember] = useState(null); - const [nameMember, setNameMember] = useState(''); - const [setIsRequestFinalLog, isRequestFinalLog] = useState(false); - const [dataViewFinalDialog, setDataViewFinalDialog] = useState(null); - return ( @@ -450,51 +88,12 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { - + - setOpenDialogBenefit(false)) - } - maxWidth="sm" - /> - - { - console.log('Data returned:', data); - getData(); - setOpenDialogFinalLog(false); - }} - handleSubmitSuccess={() => { - }} - /> - } - maxWidth="sm" - /> + ); } diff --git a/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx b/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx index 4792858f..51b55087 100644 --- a/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx +++ b/frontend/hospital-portal/src/sections/dashboard/TableListFinalLog.tsx @@ -309,7 +309,7 @@ export default function TableListFinalLog() { : Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]); const response = await axios.get(`/get-final-log`, { - params: { ...parameters, order: order, + params: { ...parameters, search:searchText, order: order, orderBy: orderBy, type: 'final-log' }, }); setData( diff --git a/frontend/hospital-portal/src/sections/dashboard/TableListReqLog.tsx b/frontend/hospital-portal/src/sections/dashboard/TableListReqLog.tsx index 1e5b224f..5fc1755a 100644 --- a/frontend/hospital-portal/src/sections/dashboard/TableListReqLog.tsx +++ b/frontend/hospital-portal/src/sections/dashboard/TableListReqLog.tsx @@ -26,19 +26,15 @@ import Label from '../../components/Label'; import { enqueueSnackbar } from 'notistack'; import { LoadingButton, TabPanel } from "@mui/lab"; import { LanguageContext } from '@/contexts/LanguageContext'; +import MuiDialog from '@/components/MuiDialog'; +import DialogMember from './DialogMember'; +import DialogFinalLog from './DialogFinalLog'; +import { fPostFormat } from '@/utils/formatTime'; +import TableListFinalLog from './TableListFinalLog'; export default function TableList() { const navigate = useNavigate(); const { localeData }: any = useContext(LanguageContext); - const [currentTab, setCurrentTab] = useState('request_log'); - - useEffect(() => { - setCurrentTab('request_log') -}, []) - -function handleChangeTab(event: React.SyntheticEvent, newValue: string) { - setCurrentTab(newValue) -} //const { corporateValue } = useContext(UserCurrentCorporateContext); //const { corporateValue } = useContext(null); @@ -46,23 +42,16 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { const [data, setData] = useState([]); // Download LOG - async function handleDownloadLog(claimRequest) { + async function handleDownloadLog(request_log_id:any) { return axios - .get(`claim-requests/${claimRequest}/log`, { + .get(`download-log/${request_log_id}`, { responseType: 'blob', }) .then((response) => { - window.open(URL.createObjectURL(response.data)); - // setLoadingLog(false); + window.open(URL.createObjectURL(response.data), '_blank'); }) - // .then((blobFile) => { - // new File([blobFile], 'asdads.pdf', { type: blobFile.type }) - // setLoadingLog(false); - // }) .catch((response) => { - console.log(response); enqueueSnackbar(response.message, { variant: 'error' }); - // setLoadingLog(false); }); } @@ -228,24 +217,18 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { handleEndDateChange: handleEndDateChanges, }; - /* -------------------------------- headCell -------------------------------- */ + /* -------------------------------- headCell Request LOG -------------------------------- */ const headCells: HeadCell[] = [ - { - id: 'submission_date', - align: 'center', - label: localeData.txtRequestDate, - isSort: true, - }, - { - id: 'member_id', - align: 'left', - label: localeData.txtMemberID, - isSort: true, - }, { id: 'code', align: 'left', - label: localeData.txtClaimCode, + label: localeData.txtRequestCode, + isSort: true, + }, + { + id: 'provider', + align: 'left', + label: localeData.txtProvider, isSort: true, }, { @@ -254,6 +237,12 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { label: localeData.txtName, isSort: true, }, + { + id: 'submission_date', + align: 'center', + label: localeData.txtSubmissionDate, + isSort: true, + }, { id: 'status', align: 'center', @@ -267,8 +256,47 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { isSort: false, }, ]; + + + function handleSearchMember(noPolis:any, birthDate:any) { + setLoadingClaim(false) + axios.post('/search-member', { + no_polis: noPolis, + birth_date: birthDate ? fPostFormat(birthDate, 'yyyy-MM-dd') : null, + type: 'view' + }) + .then((response) => { + setOpenDialogBenefit(true) + setCurrentMember(response.data.data) + setNameMember(response.data.data.members.name); + }) + .catch(({response}) => { + enqueueSnackbar(response.data.errors ? response.data.errors[0] : (response.data ? response.data.meta.message : 'Opps, Something went Wrong!'), {variant : "error"}) + }) + .then(() => { + }); + } + + + + function handleRequestFinalLog(id:any, full_name:any, no_polis:any, submission_date:any) + { + setOpenDialogFinalLog(true); + const datas_view = { + 'id' : id, + 'full_name' : full_name, + 'no_polis' : no_polis, + 'submission_date' : submission_date + }; + setDataViewFinalDialog(datas_view); + } useEffect(() => { + getData(); + }, [appliedParams, searchParams, order, orderBy, setSearchParams]); + + function getData() + { (async () => { setIsLoading(true); @@ -279,10 +307,10 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { ? appliedParams : Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]); - const response = await axios.get(`/get-claim-requests`, { - params: { ...parameters, type: 'claim-request' }, + const response = await axios.get(`/get-request-log`, { + params: { ...parameters, search:searchText, order: order, + orderBy: orderBy, type: 'request-log' }, }); - setData( response.data.data.map((obj: any) => ({ ...obj, @@ -316,14 +344,22 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { action: - navigate ('/detail/'+obj.claim_request_id)}> + handleSearchMember(obj.no_polis, obj.birth_date) }> View - handleDownloadLog(obj.claim_request_id)}> + {obj.status === 'approved' ? ( + handleDownloadLog(obj.id)}> Download LOG + ):''} + {obj.final_log === 0 && obj.status === 'approved' ? ( + handleRequestFinalLog(obj.id, obj.full_name, obj.no_polis, obj.submission_date) }> + + Request Final LOG + + ):''} } /> })) @@ -340,60 +376,37 @@ function handleChangeTab(event: React.SyntheticEvent, newValue: string) { setPage(currentPage); } - const status = [ + const status:any = [ {"id": "requested", "name": "Request" }, {"id": "reviewed", "name": "Review" }, {"id": "approved", "name": "Approval" }, {"id": "declined", "name": "Decline" }, - ] + ]; setStatusData(status) setIsLoading(false); })(); - }, [appliedParams, searchParams, order, orderBy, setSearchParams]); - - const RootNotificationStyle = styled(Card)(({ theme }) => ({ - boxShadow: 'none', - padding: '1rem 0.5rem', - color: 'black', - borderRadius: 0, - backgroundColor: theme.palette.grey[200], - // maxHeight: '240px', - })); - - function TabPanel(props:any) { - const { children, value, index, ...other } = props; - return ( - - ); } + + + + + // const [noPolis, setNoPolis] = useState('AW001-01'); + //const [birthDate, setBirthDate] = useState('1991-01-10'); + const [loadingBenefit, setLoadingBenefit] = useState(false); + const [loadingClaim, setLoadingClaim] = useState(false); + const [openDialogBenefit, setOpenDialogBenefit] = useState(false); + const [openDialogFinalLog, setOpenDialogFinalLog] = useState(false); + const [openDialogClaim, setOpenDialogClaim] = useState(false); + const [currentMember, setCurrentMember] = useState(null); + const [nameMember, setNameMember] = useState(''); + const [setIsRequestFinalLog, isRequestFinalLog] = useState(false); + const [dataViewFinalDialog, setDataViewFinalDialog] = useState(null); + return ( - - - - - - - - - + - - - - - + setOpenDialogBenefit(false)) + } + maxWidth="sm" + /> + + { + console.log('Data returned:', data); + getData(); + setOpenDialogFinalLog(false); + }} + handleSubmitSuccess={() => { + }} + /> + } + maxWidth="sm" + /> + ); -} +} \ No newline at end of file