update status benefit dan exlusion
This commit is contained in:
@@ -400,7 +400,8 @@ class DiagnosisExclusionController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
Exclusion::where('id', $request->id)->update([
|
Exclusion::where('id', $request->id)->update([
|
||||||
'active' => $request->active
|
'active' => $request->active == 1 ? 0 : 1,
|
||||||
|
'reason' => $request->reason
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
@@ -326,6 +326,7 @@ class MemberEnrollmentService
|
|||||||
|
|
||||||
public function __construct(Member $member)
|
public function __construct(Member $member)
|
||||||
{
|
{
|
||||||
|
app()->setLocale('en');
|
||||||
$this->member = $member;
|
$this->member = $member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class Exclusion extends Model
|
|||||||
'exclusionable_id',
|
'exclusionable_id',
|
||||||
'exclusionable_type',
|
'exclusionable_type',
|
||||||
'active',
|
'active',
|
||||||
|
'reason'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('exclusions', function (Blueprint $table) {
|
||||||
|
$table->string('reason')->after('active');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('exclusions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('reason');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -5,9 +5,12 @@ export type Icd = {
|
|||||||
version?: string;
|
version?: string;
|
||||||
code: string;
|
code: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
service_code: string;
|
||||||
|
active: number;
|
||||||
description?: any;
|
description?: any;
|
||||||
childs?: Icd[];
|
childs?: Icd[];
|
||||||
status: string;
|
status: string;
|
||||||
|
rules:any
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ import TableMoreMenu from '@/components/table/TableMoreMenu';
|
|||||||
import { Edit } from '@mui/icons-material';
|
import { Edit } from '@mui/icons-material';
|
||||||
import { fData, fNumber } from '@/utils/formatNumber';
|
import { fData, fNumber } from '@/utils/formatNumber';
|
||||||
import DialogUpdateStatus from '@/components/DialogUpdateStatus';
|
import DialogUpdateStatus from '@/components/DialogUpdateStatus';
|
||||||
|
|
||||||
import { ro } from 'date-fns/locale';
|
import { ro } from 'date-fns/locale';
|
||||||
|
|
||||||
export default function PlanList() {
|
export default function PlanList() {
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ export default function CorporateTabNavigations({ position }: Props) {
|
|||||||
path: 'formularium',
|
path: 'formularium',
|
||||||
label: 'Formularium',
|
label: 'Formularium',
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
path: 'claim-history',
|
// path: 'claim-history',
|
||||||
label: 'Claim History',
|
// label: 'Claim History',
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let currentIndex = mainTabItems.findIndex((item) => item.path === position);
|
let currentIndex = mainTabItems.findIndex((item) => item.path === position);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// @mui
|
// @mui
|
||||||
|
import * as Yup from 'yup';
|
||||||
import {
|
import {
|
||||||
Autocomplete,
|
Autocomplete,
|
||||||
Box,
|
Box,
|
||||||
@@ -46,6 +47,9 @@ import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'reac
|
|||||||
import useSettings from '../../../hooks/useSettings';
|
import useSettings from '../../../hooks/useSettings';
|
||||||
import { Link, useParams, useSearchParams, useNavigate } from 'react-router-dom';
|
import { Link, useParams, useSearchParams, useNavigate } from 'react-router-dom';
|
||||||
// components
|
// components
|
||||||
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
import axios from '../../../utils/axios';
|
import axios from '../../../utils/axios';
|
||||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||||
import { Icd } from '../../../@types/diagnosis';
|
import { Icd } from '../../../@types/diagnosis';
|
||||||
@@ -59,6 +63,8 @@ import TableMoreMenu from '@/components/table/TableMoreMenu';
|
|||||||
import { EditOutlined, FindInPageOutlined } from '@mui/icons-material';
|
import { EditOutlined, FindInPageOutlined } from '@mui/icons-material';
|
||||||
import Label from '@/components/Label';
|
import Label from '@/components/Label';
|
||||||
import { display } from '@mui/system';
|
import { display } from '@mui/system';
|
||||||
|
import DialogUpdateStatus from '@/components/DialogUpdateStatus'
|
||||||
|
import { FormProvider, RHFSelect } from '@/components/hook-form';
|
||||||
|
|
||||||
export default function List(props: any) {
|
export default function List(props: any) {
|
||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
@@ -272,6 +278,14 @@ export default function List(props: any) {
|
|||||||
...icd,
|
...icd,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
type DataContent = {
|
||||||
|
service: string;
|
||||||
|
id: number;
|
||||||
|
status: number;
|
||||||
|
code: string,
|
||||||
|
name: string,
|
||||||
|
rules: string,
|
||||||
|
};
|
||||||
const plans = props?.data.map((plan: any) => {
|
const plans = props?.data.map((plan: any) => {
|
||||||
return {
|
return {
|
||||||
value: plan.code,
|
value: plan.code,
|
||||||
@@ -305,6 +319,16 @@ export default function List(props: any) {
|
|||||||
const { row, index, data } = props;
|
const { row, index, data } = props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [isDialogOpen, setDialogOpen] = useState(false)
|
||||||
|
let titles = {
|
||||||
|
name: 'Update Status',
|
||||||
|
icon: '-'
|
||||||
|
}
|
||||||
|
const [dataValue, setDataValue] = useState('');
|
||||||
|
const [dataDescription, setDescriptionValue] = useState('');
|
||||||
|
const [url, setUrl] = useState('');
|
||||||
|
|
||||||
|
|
||||||
function Row(props: {
|
function Row(props: {
|
||||||
row: ReturnType<typeof createData>;
|
row: ReturnType<typeof createData>;
|
||||||
data: any;
|
data: any;
|
||||||
@@ -337,9 +361,6 @@ export default function List(props: any) {
|
|||||||
|
|
||||||
const [openEdit, setOpenEdit] = React.useState(false);
|
const [openEdit, setOpenEdit] = React.useState(false);
|
||||||
|
|
||||||
console.log('open', open);
|
|
||||||
console.log('openEdit', openEdit);
|
|
||||||
|
|
||||||
// const [plans, setPlans] = useState([]);
|
// const [plans, setPlans] = useState([]);
|
||||||
|
|
||||||
const plans = data;
|
const plans = data;
|
||||||
@@ -469,44 +490,53 @@ export default function List(props: any) {
|
|||||||
|
|
||||||
console.log('exclusions', exclusions);
|
console.log('exclusions', exclusions);
|
||||||
|
|
||||||
const handleActivate = (row: any) => {
|
// const handleActivate = (row: any) => {
|
||||||
axios
|
|
||||||
.put(`/corporates/diagnosis-exclusions/update_activation`, {
|
|
||||||
id: row.id,
|
|
||||||
active: row.active == 1 ? 0 : 1,
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
setDataTableData({
|
|
||||||
...dataTableData,
|
|
||||||
data: dataTableData.data.map((model) => {
|
|
||||||
let updatedModel = model;
|
|
||||||
|
|
||||||
if (model.id == row.id) {
|
// axios
|
||||||
updatedModel.active = row.active == 1 ? 0 : 1;
|
// .put(`/corporates/diagnosis-exclusions/update_activation`, {
|
||||||
}
|
// id: row.id,
|
||||||
|
// active: row.active == 1 ? 0 : 1,
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// setDataTableData({
|
||||||
|
// ...dataTableData,
|
||||||
|
// data: dataTableData.data.map((model) => {
|
||||||
|
// let updatedModel = model;
|
||||||
|
|
||||||
return updatedModel;
|
// if (model.id == row.id) {
|
||||||
}),
|
// updatedModel.active = row.active == 1 ? 0 : 1;
|
||||||
});
|
// }
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
if (error.response.status == 400) {
|
|
||||||
let data = error.response.data.messages;
|
|
||||||
|
|
||||||
for (const key in data) {
|
// return updatedModel;
|
||||||
enqueueSnackbar(
|
// }),
|
||||||
data[key][0],
|
// });
|
||||||
{ variant: 'error' }
|
// })
|
||||||
);
|
// .catch((error) => {
|
||||||
}
|
// if (error.response.status == 400) {
|
||||||
}
|
// let data = error.response.data.messages;
|
||||||
else {
|
|
||||||
enqueueSnackbar(
|
// for (const key in data) {
|
||||||
error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
// enqueueSnackbar(
|
||||||
{ variant: 'error' }
|
// data[key][0],
|
||||||
);
|
// { variant: 'error' }
|
||||||
}
|
// );
|
||||||
});
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// enqueueSnackbar(
|
||||||
|
// error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
||||||
|
// { variant: 'error' }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
const handleActivate = (isOpen: boolean, dataValue: DataContent) => {
|
||||||
|
console.log(dataValue)
|
||||||
|
setDialogOpen(isOpen)
|
||||||
|
setDataValue(dataValue)
|
||||||
|
setDescriptionValue('Are you sure to inactive this service ?')
|
||||||
|
setUrl(url)
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -557,7 +587,15 @@ export default function List(props: any) {
|
|||||||
<EditOutlined />
|
<EditOutlined />
|
||||||
Edit
|
Edit
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem onClick={() => handleActivate(row)}>
|
<MenuItem onClick={() => handleActivate(true, {
|
||||||
|
code: row.code,
|
||||||
|
name: row.name,
|
||||||
|
rules: Object.keys(row.rules).length ? 'With Rules' : 'All',
|
||||||
|
id:row.id,
|
||||||
|
status: row.active,
|
||||||
|
service: row.service_code
|
||||||
|
})
|
||||||
|
} >
|
||||||
<CachedIcon />
|
<CachedIcon />
|
||||||
Update Status
|
Update Status
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
@@ -585,16 +623,30 @@ export default function List(props: any) {
|
|||||||
MSC :
|
MSC :
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
|
<Grid item xs={9} sx={{ display: 'flex', gap: 1 }}>
|
||||||
{row?.rules?.msc && row?.rules?.msc[0] ? (
|
{row?.rules?.msc && row?.rules?.msc[0] ? (
|
||||||
row?.rules?.msc[0].split(',').map((text,i) => {
|
row?.rules?.msc[0].split(',').map((text, i) => {
|
||||||
return (
|
let labelMSC: string = text;
|
||||||
<Typography key={i} component="div">
|
switch (labelMSC) {
|
||||||
<Label>{text}</Label>
|
case 'm':
|
||||||
</Typography>
|
labelMSC = 'Member';
|
||||||
)
|
break;
|
||||||
})
|
case 'c':
|
||||||
) : '-'}
|
labelMSC = 'Child';
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
labelMSC = 'Spouse';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
labelMSC = 'Member';
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Typography key={i} component="div">
|
||||||
|
<Label>{labelMSC}</Label>
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : '-'}
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={3}>
|
<Grid item xs={3}>
|
||||||
<Typography variant="body1" component="div" color={'GrayText'}>
|
<Typography variant="body1" component="div" color={'GrayText'}>
|
||||||
@@ -603,9 +655,14 @@ export default function List(props: any) {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
|
<Grid item xs={9} sx={{display: 'flex', gap: 1}}>
|
||||||
{row?.rules?.gender && row?.rules?.gender[0] ? (
|
{row?.rules?.gender && row?.rules?.gender[0] ? (
|
||||||
<Typography component="div">
|
row?.rules?.gender[0].split(',').map((text,i) => {
|
||||||
<Label>{row?.rules?.gender[0]}</Label>
|
const capitalizedText = text.charAt(0).toUpperCase() + text.slice(1);
|
||||||
</Typography>
|
return (
|
||||||
|
<Typography key={i} component="div">
|
||||||
|
<Label>{capitalizedText}</Label>
|
||||||
|
</Typography>
|
||||||
|
)
|
||||||
|
})
|
||||||
) : '-'}
|
) : '-'}
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={3}>
|
<Grid item xs={3}>
|
||||||
@@ -742,6 +799,18 @@ export default function List(props: any) {
|
|||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onSubmit = async (row : any) => {
|
||||||
|
try {
|
||||||
|
handleUpdate(dataValue.status, dataValue.id, row.reason)
|
||||||
|
} catch (error: any) {
|
||||||
|
console.log('data gagal');
|
||||||
|
}
|
||||||
|
|
||||||
|
const ascent = document?.querySelector('ascent');
|
||||||
|
if (ascent != null) {
|
||||||
|
ascent.innerHTML = '';
|
||||||
|
}
|
||||||
|
};
|
||||||
const applyFilter = async (searchFilter: any) => {
|
const applyFilter = async (searchFilter: any) => {
|
||||||
await loadDataTableData({ search: searchFilter });
|
await loadDataTableData({ search: searchFilter });
|
||||||
setSearchParams({ search: searchFilter });
|
setSearchParams({ search: searchFilter });
|
||||||
@@ -759,6 +828,136 @@ export default function List(props: any) {
|
|||||||
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
|
const NewCorporateSchema = Yup.object().shape({
|
||||||
|
reason: Yup.string().required('Reason Edit is required'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const methods = useForm<FormValuesProps>({
|
||||||
|
resolver: yupResolver(NewCorporateSchema),
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const {
|
||||||
|
reset,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { isSubmitting },
|
||||||
|
} = methods;
|
||||||
|
|
||||||
|
const handleUpdate = (active: number, id: number, reason:string) => {
|
||||||
|
console.log(active)
|
||||||
|
axios
|
||||||
|
.put(`/corporates/diagnosis-exclusions/update_activation`, {
|
||||||
|
id: id,
|
||||||
|
active: active,
|
||||||
|
reason: reason
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const getContent = () => (
|
||||||
|
<>
|
||||||
|
<Stack paddingX={2} paddingY={2}>
|
||||||
|
<Typography variant='subtitle1'>Are you sure to {dataValue?.status == 1 ? 'inactive' : 'active'} this benefit ?</Typography>
|
||||||
|
</Stack>
|
||||||
|
<Card>
|
||||||
|
<Grid container paddingX={2} paddingY={2}>
|
||||||
|
<Grid item xs={5} md={5}>
|
||||||
|
<Typography variant='inherit'>Service</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={7}>
|
||||||
|
<Typography variant='subtitle1'>{dataValue?.service}</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={5} md={5} marginTop={2}>
|
||||||
|
<Typography variant='inherit'>Code</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={7} marginTop={2}>
|
||||||
|
<Typography variant='subtitle1'>{dataValue?.code}</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={5} md={5} marginTop={2}>
|
||||||
|
<Typography variant='inherit'>Name</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={7} marginTop={2}>
|
||||||
|
<Typography variant='subtitle1'>{dataValue?.name}</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={5} md={5} marginTop={2}>
|
||||||
|
<Typography variant='inherit'>Rules</Typography>
|
||||||
|
</Grid>
|
||||||
|
<Grid item xs={7} marginTop={2}>
|
||||||
|
<Typography variant='subtitle1'>{dataValue?.rules}</Typography>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Typography marginTop={5} marginBottom={3} variant='subtitle1'>
|
||||||
|
Reason for update*
|
||||||
|
</Typography>
|
||||||
|
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<RHFSelect
|
||||||
|
name="reason"
|
||||||
|
label="Reason for update"
|
||||||
|
>
|
||||||
|
<option value=""></option>
|
||||||
|
<option value="Agreement changed">Agreement changed</option>
|
||||||
|
<option value="Endorsement">Endorsement</option>
|
||||||
|
<option value="Renewal">Renewal</option>
|
||||||
|
<option value="Worng Setting">Worng Setting</option>
|
||||||
|
</RHFSelect>
|
||||||
|
<Stack
|
||||||
|
alignItems="center"
|
||||||
|
justifyContent="flex-end"
|
||||||
|
direction={{ xs: 'column', md: 'row' }}
|
||||||
|
spacing={2}
|
||||||
|
marginTop={5}
|
||||||
|
>
|
||||||
|
<Stack direction="row" spacing={1}>
|
||||||
|
<Button
|
||||||
|
sx={{
|
||||||
|
boxShadow: 'none',
|
||||||
|
}}
|
||||||
|
variant="outlined"
|
||||||
|
size="medium"
|
||||||
|
fullWidth={true}
|
||||||
|
onClick={() => setDialogOpen(false)}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{dataValue?.status == 1?
|
||||||
|
<LoadingButton
|
||||||
|
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)'}}
|
||||||
|
type="submit"
|
||||||
|
variant="contained"
|
||||||
|
size="medium"
|
||||||
|
fullWidth={true}
|
||||||
|
loading={isSubmitting}
|
||||||
|
color='error'
|
||||||
|
>
|
||||||
|
Inactive
|
||||||
|
</LoadingButton>
|
||||||
|
:
|
||||||
|
<LoadingButton
|
||||||
|
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)'}}
|
||||||
|
type="submit"
|
||||||
|
variant="contained"
|
||||||
|
size="medium"
|
||||||
|
fullWidth={true}
|
||||||
|
loading={isSubmitting}
|
||||||
|
color='success'
|
||||||
|
>
|
||||||
|
Active
|
||||||
|
</LoadingButton>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
</FormProvider>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
<ImportForm />
|
<ImportForm />
|
||||||
@@ -831,6 +1030,16 @@ export default function List(props: any) {
|
|||||||
|
|
||||||
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
|
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<DialogUpdateStatus
|
||||||
|
openDialog={isDialogOpen}
|
||||||
|
setOpenDialog={setDialogOpen}
|
||||||
|
title={titles}
|
||||||
|
data={dataValue}
|
||||||
|
description={dataDescription}
|
||||||
|
content={getContent()}
|
||||||
|
// maxWidth='50px'
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user