sort di final log dan menampilkan admission

This commit is contained in:
2024-02-13 11:40:35 +07:00
parent ccb374da85
commit 814eb014f7
7 changed files with 153 additions and 33 deletions

View File

@@ -24,7 +24,8 @@ class RequestLogResource extends JsonResource
$data = [ $data = [
'id' => $this->id, 'id' => $this->id,
'code' => $this->code, 'code' => $this->code,
'submission_date' => $this->submission_date, 'submission_date' => $this->created_at, // submsion_date diambil dari kolom created_at
'admission_date' => $this->submission_date, // admission_date diambil dari kolom submission
'submission_date_fgl' => $this->approved_final_log_at, 'submission_date_fgl' => $this->approved_final_log_at,
'member_name' => $this->member->name, 'member_name' => $this->member->name,
'status' => $this->status ?? 'unknown', 'status' => $this->status ?? 'unknown',

View File

@@ -106,7 +106,8 @@ class RequestLogShowResource extends JsonResource
'principal_id' => $requestLog['member']['principal_id'] ? $requestLog['member']['principal_id'] : '-', 'principal_id' => $requestLog['member']['principal_id'] ? $requestLog['member']['principal_id'] : '-',
'principal_name' => $requestLog['member']['principal_id'] ? Helper::principalName($requestLog['member']['principal_id']) : '-', 'principal_name' => $requestLog['member']['principal_id'] ? Helper::principalName($requestLog['member']['principal_id']) : '-',
'relation_with_principal' => Helper::relationWithPrincipal($requestLog['member']['relation_with_principal']), 'relation_with_principal' => Helper::relationWithPrincipal($requestLog['member']['relation_with_principal']),
'submission_date' => $requestLog['submission_date'], 'submission_date' => $requestLog['created_at'],
'admission_date' => $requestLog['submission_date'],
'approved_final_log_at' => $requestLog['approved_final_log_at'], // submission final log 'approved_final_log_at' => $requestLog['approved_final_log_at'], // submission final log
'discharge_date' => $requestLog['discharge_date'], 'discharge_date' => $requestLog['discharge_date'],
'service_type' => Helper::serviceName($requestLog['service_code']), 'service_type' => Helper::serviceName($requestLog['service_code']),

View File

@@ -202,6 +202,10 @@ export default function Detail() {
<Typography variant='subtitle2' sx={style1} gutterBottom>Submission Date</Typography> <Typography variant='subtitle2' sx={style1} gutterBottom>Submission Date</Typography>
<Typography variant='subtitle2' sx={style2} gutterBottom>{requestLog?.submission_date ? fDateTimesecond(requestLog?.submission_date) : '-'}</Typography> <Typography variant='subtitle2' sx={style2} gutterBottom>{requestLog?.submission_date ? fDateTimesecond(requestLog?.submission_date) : '-'}</Typography>
</Stack> </Stack>
<Stack direction='row' spacing={2} sx={marginBottom1}>
<Typography variant='subtitle2' sx={style1} gutterBottom>Admission Date</Typography>
<Typography variant='subtitle2' sx={style2} gutterBottom>{requestLog?.admission_date ? fDateTimesecond(requestLog?.admission_date) : '-'}</Typography>
</Stack>
<Stack direction='row' spacing={2} sx={marginBottom1}> <Stack direction='row' spacing={2} sx={marginBottom1}>
<Typography variant='subtitle2' sx={style1} gutterBottom>Discharge Date</Typography> <Typography variant='subtitle2' sx={style1} gutterBottom>Discharge Date</Typography>

View File

@@ -8,6 +8,7 @@ import {
MenuItem, MenuItem,
Table, Table,
TableBody, TableBody,
TableSortLabel,
TableCell, TableCell,
TableRow, TableRow,
TextField, TextField,
@@ -48,10 +49,12 @@ import { capitalizeFirstLetter } from '@/utils/formatString';
import Label from '@/components/Label'; import Label from '@/components/Label';
import TableMoreMenu from '@/components/table/TableMoreMenu'; import TableMoreMenu from '@/components/table/TableMoreMenu';
import { Import } from '@/@types/claims'; import { Import } from '@/@types/claims';
import { visuallyHidden } from '@mui/utils';
import { FinalLogType } from '../FinalLog/Model/Types'; import { FinalLogType } from '../FinalLog/Model/Types';
import DialogDeleteFinalLOG from './Components/DialogDeleteFinalLOG'; import DialogDeleteFinalLOG from './Components/DialogDeleteFinalLOG';
import { Delete } from '@mui/icons-material'; import { Delete } from '@mui/icons-material';
import { HeadCell, Order } from '@/@types/table';
// import LoadingButton from '@/theme/overrides/LoadingButton'; // import LoadingButton from '@/theme/overrides/LoadingButton';
export default function List() { export default function List() {
@@ -284,8 +287,14 @@ export default function List() {
const loadDataTableData = async (appliedFilter: any | null = null) => { const loadDataTableData = async (appliedFilter: any | null = null) => {
setDataTableLoading(true); setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]); const parameters =
const response = await axios.get('/customer-service/request?final_log=1&service_code=OP', { params: filter }); Object.keys(appliedParams).length !== 0
? appliedParams
: Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]);
const response = await axios.get('/customer-service/request?final_log=1&service_code=OP', {
params: { ...parameters },
});
// console.log(response.data); // console.log(response.data);
setDataTableLoading(false); setDataTableLoading(false);
@@ -472,38 +481,139 @@ export default function List() {
/* ------------------ END TABLE ROW ------------------ */ /* ------------------ END TABLE ROW ------------------ */
} }
/* -------------------------------- headCell -------------------------------- */
const headCells: HeadCell<never>[] = [
{
id: 'code',
align: 'left',
label: 'Code',
isSort: true,
},
{
id: 'provider',
align: 'left',
label: 'Provider',
isSort: false,
},
{
id: 'name',
align: 'left',
label: 'Name',
isSort: false,
},
{
id: 'submission_date',
align: 'left',
label: 'Admission Date',
isSort: true,
},
{
id: 'service_code',
align: 'left',
label: 'Service Type',
isSort: true,
},
{
id: 'claim_method',
align: 'left',
label: 'Claim Method',
isSort: false,
},
{
id: 'status',
align: 'left',
label: 'Status',
isSort: true,
},
{
id: '',
align: 'left',
label: 'Action',
isSort: false,
},
];
/* -------------------------------------------------------------------------- */
const createSortHandler = (property: string) => (event: React.MouseEvent<unknown>) => {
handleRequestSort(event, property);
};
/* ------------------------------ handle params ----------------------------- */
const [appliedParams, setAppliedParams] = useState({});
const params = {
searchParams: searchParams,
setSearchParams: setSearchParams,
appliedParams: appliedParams,
setAppliedParams: setAppliedParams,
};
/* ------------------------------ handle order ------------------------------ */
const [order, setOrder] = useState<Order>('desc');
const [orderBy, setOrderBy] = useState('submission_date');
const orders = {
order: order,
setOrder: setOrder,
orderBy: orderBy,
setOrderBy: setOrderBy,
};
/* ------------------------------- handle sort ------------------------------ */
const handleRequestSort = async (event: React.MouseEvent<unknown>, property: string) => {
const isAsc = orders?.orderBy === property && orders?.order === 'asc';
orders?.setOrder(isAsc ? 'desc' : 'asc');
orders?.setOrderBy(property);
const parameters = Object.fromEntries([
...(params?.searchParams.entries() as IterableIterator<[string, string]>),
['order', isAsc ? 'desc' : 'asc'],
['orderBy', property],
]);
console.log(parameters)
params?.setAppliedParams(parameters);
};
useEffect(() => {
loadDataTableData();
}, [appliedParams, searchParams, order, orderBy, setSearchParams]);
function TableContent() { function TableContent() {
return ( return (
<Table aria-label="collapsible table"> <Table aria-label="collapsible table">
{/* ------------------ TABLE HEADER ------------------ */} {/* ------------------ TABLE HEADER ------------------ */}
<TableHead> <TableHead>
<TableRow> <TableRow>
{/* <TableCell style={headStyle} align="left" /> */} {headCells &&
{/* <TableCell style={headStyle} align="left"> headCells.map((headCell, index) => (
ID Request LOG <TableCell
</TableCell> */} key={index}
<TableCell style={headStyle} align="left"> sortDirection={orders?.orderBy === headCell.id ? orders.order : false}
Code // @ts-ignore
</TableCell> align={headCell.align}
<TableCell style={headStyle} align="left"> sx={{ padding: 2 }}
Provider width={headCell.width ? headCell.width : 'auto'}
</TableCell> >
<TableCell style={headStyle} align="left"> {headCell.isSort ? (
Name <TableSortLabel
</TableCell> active={orders?.orderBy === headCell.id}
<TableCell style={headStyle} align="left"> direction={orders?.orderBy === headCell.id ? orders.order : 'asc'}
Date of Submission onClick={createSortHandler(headCell.id)}
</TableCell> >
<TableCell style={headStyle} align="left"> {headCell.label}
Service Type {orders?.orderBy === headCell.id ? (
</TableCell> <Box component="span" sx={visuallyHidden}>
<TableCell style={headStyle} align="left"> {orders.order === 'desc' ? 'sorted descending' : 'sorted ascending'}
Claim Method </Box>
</TableCell> ) : null}
<TableCell style={headStyle} align="left"> </TableSortLabel>
Status ) : (
</TableCell> headCell.label
<TableCell style={headStyle} align="right"></TableCell> )}
</TableCell>
))}
</TableRow> </TableRow>
</TableHead> </TableHead>
{/* ------------------ END TABLE HEADER ------------------ */} {/* ------------------ END TABLE HEADER ------------------ */}

View File

@@ -36,6 +36,7 @@ export type DetailFinalLogType = {
gender : string, gender : string,
marital_status : string, marital_status : string,
submission_date : string, submission_date : string,
admission_date : string,
approved_final_log_at : string, approved_final_log_at : string,
service_type : string, service_type : string,
claim_method : string, claim_method : string,

View File

@@ -334,7 +334,7 @@ export default function List() {
}; };
// Called on every row to map the data to the columns // Called on every row to map the data to the columns
function createData(data: RequestLogType): any { function createData(data: RequestLogType) {
return { return {
...data, ...data,
}; };
@@ -368,7 +368,7 @@ export default function List() {
<TableCell align="left">{row.code}</TableCell> <TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.provider}</TableCell> <TableCell align="left">{row.provider}</TableCell>
<TableCell align="left">{row.member_name}</TableCell> <TableCell align="left">{row.member_name}</TableCell>
<TableCell align="left"><Label>{fDateTimesecond(row.submission_date)}</Label></TableCell> <TableCell align="left"><Label>{fDateTimesecond(row.admission_date)}</Label></TableCell>
<TableCell align="left">{row.service_name}</TableCell> <TableCell align="left">{row.service_name}</TableCell>
<TableCell align="left">{row.payment_type_name}</TableCell> <TableCell align="left">{row.payment_type_name}</TableCell>
<TableCell align="left"> <TableCell align="left">
@@ -514,7 +514,7 @@ export default function List() {
{ {
id: 'submission_date', id: 'submission_date',
align: 'left', align: 'left',
label: 'Submision Date', label: 'Admission Date',
isSort: true, isSort: true,
}, },
{ {

View File

@@ -15,7 +15,10 @@ export type RequestLogType = {
code : string, code : string,
member : Member, member : Member,
submission_date : string, submission_date : string,
admission_date : string,
service_name : string, service_name : string,
provider : string,
member_name : string,
payment_type_name : string, payment_type_name : string,
status_final_log : string, status_final_log : string,
status : string, status : string,