Update Approve Claim
This commit is contained in:
@@ -322,29 +322,72 @@ class ClaimController extends Controller
|
||||
|
||||
public function decline($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
$claim->status = 'declined';
|
||||
$claim->save();
|
||||
DB::table('claims')
|
||||
->where('claim_request_id', $id)
|
||||
->update(
|
||||
[
|
||||
'status' => 'declined'
|
||||
]
|
||||
);
|
||||
|
||||
return Helper::responseJson($claim, message: "Claim berhasil di decline");
|
||||
// Claim Log
|
||||
DB::table('claim_logs')
|
||||
->insert([
|
||||
'claim_request_id' => $id,
|
||||
'status' => 'declined',
|
||||
'date' => date('Y-m-d H:i:s'),
|
||||
'description' => "Claim Requested Declined",
|
||||
'system_origin' => 'prime-center',
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at'=> date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
return Helper::responseJson([], message: "Claim berhasil di decline");
|
||||
}
|
||||
|
||||
public function approve($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
$claim->status = 'approved';
|
||||
$claim->save();
|
||||
DB::table('claims')
|
||||
->where('claim_request_id', $id)
|
||||
->update(
|
||||
[
|
||||
'status' => 'approved'
|
||||
]
|
||||
);
|
||||
|
||||
return Helper::responseJson($claim, message: "Claim berhasil di approve");
|
||||
// Claim Log
|
||||
DB::table('claim_logs')
|
||||
->insert([
|
||||
'claim_request_id' => $id,
|
||||
'status' => 'approved',
|
||||
'date' => date('Y-m-d H:i:s'),
|
||||
'description' => "Claim Requested Successfully Approved",
|
||||
'system_origin' => 'prime-center',
|
||||
'created_by' => auth()->user()->id,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at'=> date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
return Helper::responseJson([], message: "Claim berhasil di approve");
|
||||
}
|
||||
|
||||
public function reOpen($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
$claim->status = 'received';
|
||||
$claim->save();
|
||||
DB::table('claims')
|
||||
->where('claim_request_id', $id)
|
||||
->update(
|
||||
[
|
||||
'status' => 'received'
|
||||
]
|
||||
);
|
||||
|
||||
return Helper::responseJson($claim, message: "Claim berhasil di approve");
|
||||
// Claim Log
|
||||
DB::table('claim_logs')
|
||||
->where('claim_request_id', $id)
|
||||
->delete();
|
||||
|
||||
return Helper::responseJson([], message: "Claim berhasil di re-open");
|
||||
}
|
||||
|
||||
public function downloadFinalLog($id)
|
||||
@@ -614,6 +657,13 @@ class ClaimController extends Controller
|
||||
$results['claim_service_benefits'] = null;
|
||||
}
|
||||
|
||||
$dialog_submits = DB::table('claim_requests')
|
||||
->leftJoin('members', 'claim_requests.member_id','=', 'members.id')
|
||||
->where('claim_requests.id', $claim_id)
|
||||
->select('claim_requests.code', 'members.name', 'claim_requests.submission_date', 'claim_requests.service_code','claim_requests.status')
|
||||
->first();
|
||||
$results['dialog_submits'] = $dialog_submits;
|
||||
|
||||
|
||||
return Helper::responseJson($results);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ export default function Detail() {
|
||||
<Stack direction="row" padding={4}>
|
||||
{dataDialog && dataDialog.status === 'requested' ? (
|
||||
<>
|
||||
<Button variant="outlined" sx={{color: '#212B36', marginLeft: 'auto'}} >Cancel</Button>
|
||||
<Button variant="outlined" sx={{color: '#212B36', marginLeft: 'auto', borderColor: '#919EAB52'}} >Cancel</Button>
|
||||
<Button sx={{backgroundColor: '#19BBBB', marginLeft: 1}} variant="contained" onClick={()=> setOpenDialogSubmit(true)}>Submit</Button>
|
||||
</>
|
||||
) : ''}
|
||||
@@ -288,7 +288,7 @@ export default function Detail() {
|
||||
) : ''}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" sx={{color: '#212B36'}} onClick={handleCloseDialogSubmit}>Cancel</Button>
|
||||
<Button variant="outlined" sx={{color: '#212B36', borderColor: '#919EAB52'}} onClick={handleCloseDialogSubmit}>Cancel</Button>
|
||||
<Button sx={{backgroundColor: '#19BBBB'}} onClick={handleSubmitData} variant="contained">Submit</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
@@ -61,6 +61,7 @@ export default function Detail() {
|
||||
const [requestDocumentData, setRequestDocumentData] = useState(null);
|
||||
const [serviceData, setServiceData] = useState(null);
|
||||
const [serviceBenefitData, setServiceBenefitData] = useState(null);
|
||||
const [dataDialog, setDataDialog] = useState(null);
|
||||
|
||||
const { id } = useParams();
|
||||
|
||||
@@ -73,6 +74,7 @@ export default function Detail() {
|
||||
setRequestDocumentData(response.data.data.request_documents);
|
||||
setServiceData(response.data.data.claim_services);
|
||||
setServiceBenefitData(response.data.data.claim_service_benefits);
|
||||
setDataDialog(response.data.data.dialog_submits);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
@@ -258,6 +260,45 @@ export default function Detail() {
|
||||
})
|
||||
}
|
||||
|
||||
const [openDialogSubmit, setOpenDialogSubmit] = useState(false);
|
||||
const handleCloseDialogSubmit = () => {
|
||||
setOpenDialogSubmit(false);
|
||||
}
|
||||
|
||||
const [decline, setDeclaine] = useState('');
|
||||
|
||||
const handleSubmitData = () => {
|
||||
//approve or decline
|
||||
axios
|
||||
.post('claims/'+id+'/'+decline)
|
||||
.then((response) => {
|
||||
enqueueSnackbar('Success '+toTitleCase(decline)+' Claim Request', { variant: 'success' });
|
||||
setOpenDialogSubmit(false);
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
|
||||
});
|
||||
|
||||
setTimeout(() =>
|
||||
{
|
||||
window.location.reload();
|
||||
}, 5000);
|
||||
|
||||
};
|
||||
|
||||
const handelDownloadLog = () => {
|
||||
axios
|
||||
.get(`final-log/${id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then((response) => {
|
||||
window.open(URL.createObjectURL(response.data));
|
||||
})
|
||||
.catch((response) => {
|
||||
enqueueSnackbar(response.message, { variant: 'error' });
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<Page title='Detail'>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
@@ -679,9 +720,100 @@ export default function Detail() {
|
||||
<Grid item xs={12} md={12}>
|
||||
<Stack direction="row" padding={4}>
|
||||
<>
|
||||
<Button variant="outlined" sx={{color: '#FF4842', borderColor: '#FF4842', marginLeft: 'auto'}} >Decline</Button>
|
||||
<Button sx={{backgroundColor: '#19BBBB', marginLeft: 1}} variant="contained" onClick={()=> setOpenDialogSubmit(true)}>Submit</Button>
|
||||
{(customerData && customerData.status === 'received') ? (
|
||||
<>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{color: '#FF4842', borderColor: '#FF4842', marginLeft: 'auto'}}
|
||||
onClick={() => {
|
||||
setOpenDialogSubmit(true);
|
||||
setDeclaine('decline');
|
||||
}}
|
||||
>
|
||||
Decline
|
||||
</Button>
|
||||
<Button
|
||||
sx={{backgroundColor: '#19BBBB', marginLeft: 1}}
|
||||
variant="contained"
|
||||
onClick={()=> {
|
||||
setOpenDialogSubmit(true);
|
||||
setDeclaine('approve');
|
||||
}}
|
||||
>
|
||||
Approve
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{color: '#212B36', borderColor: '#919EAB52', marginLeft: 'auto'}}
|
||||
onClick={handelDownloadLog}
|
||||
>
|
||||
Download Final LOG
|
||||
</Button>
|
||||
<Button
|
||||
sx={{backgroundColor: '#19BBBB', marginLeft: 1}}
|
||||
variant="contained"
|
||||
onClick={()=> {
|
||||
setOpenDialogSubmit(true);
|
||||
setDeclaine('re-open');
|
||||
}}
|
||||
>
|
||||
Re-Open
|
||||
</Button>
|
||||
</>
|
||||
) }
|
||||
|
||||
</>
|
||||
{/* Dialog Submits */}
|
||||
<Dialog open={openDialogSubmit} onClose={handleCloseDialogSubmit} fullWidth={true}>
|
||||
<DialogTitle sx={{ backgroundColor: '#19BBBB', color: '#FFF', padding: 2 }}>
|
||||
<Stack direction="row" alignItems="center" justifyContent="space-between">
|
||||
<Stack direction="row" alignItems='center' spacing={1}>
|
||||
<Typography variant="h6">Confirmation</Typography>
|
||||
</Stack>
|
||||
<IconButton sx={{ color: '#FFF' }} onClick={handleCloseDialogSubmit}>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</Stack>
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
{dataDialog ? (
|
||||
<Stack spacing={2} padding={2}>
|
||||
<Typography variant='body1'>Are you sure to {toTitleCase(decline)} this claim ?</Typography>
|
||||
<Card sx={{padding:2}} >
|
||||
<Stack direction='row' spacing={2}>
|
||||
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '30%'}}>Code</Typography>
|
||||
<Typography variant='subtitle2' sx={{width: '70%'}}>{dataDialog.code}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2}>
|
||||
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '30%'}}>Name</Typography>
|
||||
<Typography variant='subtitle2' sx={{width: '70%'}}>{dataDialog.name}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2}>
|
||||
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '30%'}}>Date Submission</Typography>
|
||||
<Typography variant='subtitle2' sx={{width: '70%'}}>{fDateTime(dataDialog.submission_date)}</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2}>
|
||||
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '30%'}}>Claim Method</Typography>
|
||||
<Typography variant='subtitle2' sx={{width: '70%'}}>Service Type</Typography>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2}>
|
||||
<Typography variant='subtitle2' sx={{color: '#919EAB', width: '30%'}}>Service Type</Typography>
|
||||
<Typography variant='subtitle2' sx={{width: '70%'}}>
|
||||
{dataDialog.service_code === 'IP' ? 'Inpatient' : 'Outpatient'}
|
||||
</Typography>
|
||||
</Stack>
|
||||
</Card>
|
||||
</Stack>
|
||||
) : ''}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" sx={{color: '#212B36', borderColor: '#919EAB52'}} onClick={handleCloseDialogSubmit}>Cancel</Button>
|
||||
<Button sx={{backgroundColor: (decline === 'decline' ? '' : '#19BBBB'), color: (decline === 'decline' ? '#FF4842' : ''), borderColor: '#FF4842'}} onClick={handleSubmitData} variant={(decline === 'decline' ? 'outlined' : 'contained')}>{(decline === "decline" ? 'Decline' : (decline === "approve" ? 'Approve' : 'Re-Open'))}</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user