[WIP] Update

This commit is contained in:
R
2023-03-03 08:44:08 +07:00
parent 9e322c4ee5
commit 91ba718a50
17 changed files with 197 additions and 78 deletions

View File

@@ -62,10 +62,11 @@ class ClaimRequestController extends Controller
{
$request->validate([
'member_id' => 'required',
'service_code' => 'required|in:OP,IP'
]);
$member = Member::find($request->member_id);
$newClaimRequest = ClaimRequestService::storeClaimRequest(member: $member);
$newClaimRequest = ClaimRequestService::storeClaimRequest(member: $member, paymentType: 'reimbursement', serviceCode: $request->service_code);
ClaimRequested::dispatch($newClaimRequest);

View File

@@ -36,7 +36,7 @@ class ClaimRequestController extends Controller
->when($request->status, function($q, $status) {
$q->where('status', $status);
})
->with(['member', 'files'])
->with(['member', 'files', 'service'])
->paginate();
return Helper::paginateResources(ClaimRequestResource::collection($claimRequests));

View File

@@ -1,11 +0,0 @@
<?php
namespace Modules\Internal\Services;
use App\Models\Claim;
use Illuminate\Support\Facades\DB;
class ClaimService
{
}

View File

@@ -24,7 +24,9 @@ class ClaimRequestResource extends JsonResource
'submission_date' => $this->submission_date,
'member' => $this->member,
'status' => $this->status ?? 'unknown',
'service_type' => $this->service_type,
'service_name' => $this->service->name,
'payment_type' => $this->payment_type,
'payment_type_name' => $this->payment_type_name,
'files_by_type' => $filesGroupByType
];

View File

@@ -57,6 +57,8 @@ class GeneratedDocumentController extends Controller
// $pdf = PDF::loadFile(route('generated-document.show', $id));
// return $pdf->inline();
// $pdf = PDF::loadHtml('<h1>Motherfucker</h1>');
// $snappy = App::make('snappy.pdf');
// $html = '<h1>Bill</h1><p>You owe me money, dude.</p>';
// // $snappy->generateFromHtml($html, '/tmp/bill-123.pdf');

View File

@@ -122,6 +122,17 @@ class Claim extends Model
return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
}
// Current ClaimRequest that refer to the claim
public function claimRequest()
{
return $this->belongsTo(ClaimRequest::class, 'claim_request_id');
}
// Possibilities of ClaimRequest that refer to the claim
public function claimRequests()
{
return $this->hasMany(ClaimRequest::class, 'claim_id');
}
public function files()
{

View File

@@ -17,8 +17,12 @@ class ClaimRequest extends Model
protected static $code_prefix = 'CRQ';
public $fillable = [
'uuid',
'submission_date',
'member_id',
'payment_type',
'service_code',
'policy_id',
'status',
'claim_id'
];
@@ -35,13 +39,19 @@ class ClaimRequest extends Model
public static $status = [
'draft' => 'Draft',
'requested' => 'Requested',
'received' => 'Received',
'approved' => 'Approved',
'postpone' => 'Postpone',
'paid' => 'Paid',
'declined' => 'Declined'
];
public static $payment_types = [
'cashless' => 'Cashless',
'reimbursement' => 'Reimbursement'
];
public $appends = [
'payment_type_name'
];
protected static function boot()
{
parent::boot();
@@ -116,6 +126,11 @@ class ClaimRequest extends Model
return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
}
public function claim()
{
return $this->belongsTo(Claim::class, 'claim_id');
}
public function claims()
{
return $this->hasMany(Claim::class, 'claim_request_id');
@@ -140,4 +155,19 @@ class ClaimRequest extends Model
{
return $this->belongsTo(Member::class, 'member_id', 'id');
}
public function service()
{
return $this->belongsTo(Service::class, 'service_code', 'code');
}
public function getPaymentTypeNameAttribute()
{
return self::$payment_types[$this->payment_type] ?? $this->payment_type;
}
public function getStatusAttribute($value)
{
return self::$payment_types[$value] ?? $value;
}
}

View File

@@ -151,13 +151,20 @@ class Member extends Model
}
public function currentPolicy()
{
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
->where('status', 'active')
->orderBy('end', 'DESC');
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
}
public function currentActivePolicy()
{
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
->where('corporate_policies.start', '<', now())
->where('corporate_policies.end', '>', now())
->where('member_policies.start', '<', now())
->where('member_policies.end', '>', now());
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
}
public function getAgeAttribute()

View File

@@ -14,7 +14,7 @@ use Str;
class ClaimRequestService{
public static function storeClaimRequest($member, $submissionDate = null, $status = 'requested')
public static function storeClaimRequest($member, $paymentType, $serviceCode, $submissionDate = null, $status = 'requested')
{
try {
DB::beginTransaction();
@@ -22,7 +22,10 @@ class ClaimRequestService{
$claimRequestData = [
'member_id' => $member->id,
'submission_date' => $submissionDate ?? now(),
'status' => $status
'status' => $status,
'payment_type' => $paymentType,
'service_code' => $serviceCode,
'policy_id' => $member->currentPolicy->id ?? null,
];
$claimRequest = ClaimRequest::create($claimRequestData);

View File

@@ -19,6 +19,9 @@ return new class extends Migration
$table->string('code')->index();
$table->dateTime('submission_date')->nullable();
$table->foreignId('member_id');
$table->string('payment_type');
$table->string('service_code');
$table->foreignId('policy_id');
$table->string('status')->nullable();
$table->foreignId('claim_id')->nullable()->comment('After Claim is Created');

View File

@@ -135,6 +135,34 @@ const DialogDetailClaim = ({ title, openDialog, setOpenDialog, data }: MuiDialog
</Stack>
)} */}
<Stack direction="row" spacing={2} sx={{ marginTop: 2 }}>
<Divider orientation="vertical" flexItem sx={{ borderStyle: 'dashed' }} />
<Stack spacing={2} sx={{ flex: 1, maxWidth: '100%' }}>
{/* ---------------------------------TYPE INFO------------------------------------ */}
<Card sx={{ paddingY: 2, paddingX: 3 }}>
<Stack direction="row" justifyContent="space-between" alignItems="center">
<Typography variant="body1" fontWeight={600}>
<Iconify icon="eva:file-text-fill"></Iconify> Pengajuan Penjaminan
</Typography>
</Stack>
<Divider sx={{ marginY: 2 }} />
<Stack>
<LoadingButton loading={false}
variant="contained"
startIcon={<Add />}
fullWidth
// sx={{ typography: 'subtitle2', borderColor: '#F5F5F5' }}
onClick={() => {}}
>
Upload Invoice
</LoadingButton>
</Stack>
</Card>
</Stack>
</Stack>
{claim.histories_by_date &&
claim.histories_by_date.map((historiesByDate) => (
<Stack key={historiesByDate.date}>

View File

@@ -59,7 +59,7 @@ const navConfig = [
],
},
{
title: 'LOG REQUEST',
title: 'CLAIM REQUEST',
path: '/claim-requests',
// children: [
// { title: 'Request', path: '/case-request' },

View File

@@ -26,6 +26,7 @@ import CancelIcon from '@mui/icons-material/Cancel';
// hooks
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
import { Navigate, useNavigate, useSearchParams } from 'react-router-dom';
import useSettings from '@/hooks/useSettings';
// components
import axios from '../../utils/axios';
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
@@ -40,6 +41,7 @@ import DialogDetailClaim from '@/components/dialogs/DialogDetailClaim';
// import LoadingButton from '@/theme/overrides/LoadingButton';
export default function List() {
const { themeColorPresets } = useSettings();
const [searchParams, setSearchParams] = useSearchParams();
const [importResult, setImportResult] = useState(null);
@@ -137,15 +139,16 @@ export default function List() {
};
const handleApprove = (claimRequest) => {
axios.post(`claim-requests/${claimRequest.id}/approve`)
axios
.post(`claim-requests/${claimRequest.id}/approve`)
.then((response) => {
enqueueSnackbar('Success Approve', {variant: 'success'})
loadDataTableData()
enqueueSnackbar('Success Approve', { variant: 'success' });
loadDataTableData();
})
.catch(({response}) => {
enqueueSnackbar(response.data.message ?? 'Something went wrong!', {variant : "error"})
})
}
.catch(({ response }) => {
enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
});
};
useEffect(() => {
loadDataTableData();
@@ -178,13 +181,39 @@ export default function List() {
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton>
</TableCell>
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">
<Typography
onClick={() => {
handleShowClaim(row);
}}
color={themeColorPresets}
>
{row.code}
</Typography>
</TableCell>
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left">{row.submission_date}</TableCell>
<TableCell align="left">{row.service_type}</TableCell>
<TableCell align="right"><Chip label={row.status}/></TableCell>
<TableCell align="right">{ row.status == 'requested' && (<LoadingButton loading={loadingApprove} variant="outlined" onClick={() => {handleApprove(row)}}>Approve</LoadingButton> )}</TableCell>
<TableCell>
<TableCell align="left">{row.service_name}</TableCell>
<TableCell align="left">{row.payment_type_name}</TableCell>
<TableCell align="right">
<Chip label={row.status} />
</TableCell>
<TableCell align="right">
{row.status == 'requested' && (
<LoadingButton
loading={loadingApprove}
variant="outlined"
size="small"
onClick={() => {
handleApprove(row);
}}
>
Ajukan Claim <Iconify icon="eva:arrow-forward-outline"></Iconify>
</LoadingButton>
)}
</TableCell>
{/* <TableCell>
<IconButton
onClick={() => {
@@ -193,32 +222,33 @@ export default function List() {
>
<Iconify icon="eva:eye-fill" />
</IconButton>
</TableCell>
</TableCell> */}
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
<Stack
divider={<Divider orientation="horizontal" flexItem />}
spacing={1}
sx={{ marginY: 2 }}
>
<Box>
<Typography fontWeight={600}>Berkas Hasil Penunjang</Typography>
{row.files_by_type?.result &&
row.files_by_type?.result.map((file, index) => (
<Stack direction="row" key={index}>
<Typography sx={{marginRight: 2}}>-</Typography> <a href={file.url} target="_blank">{file.name}</a>
</Stack>
))}
{ !row.files_by_type?.result && (
<Typography>Tidak ada berkas</Typography>
)}
<Stack
divider={<Divider orientation="horizontal" flexItem />}
spacing={1}
sx={{ marginY: 2 }}
>
<Box>
<Typography fontWeight={600}>Berkas Hasil Penunjang</Typography>
{row.files_by_type?.result &&
row.files_by_type?.result.map((file, index) => (
<Stack direction="row" key={index}>
<Typography sx={{ marginRight: 2 }}>-</Typography>{' '}
<a href={file.url} target="_blank">
{file.name}
</a>
</Stack>
))}
{!row.files_by_type?.result && <Typography>Tidak ada berkas</Typography>}
</Box>
</Stack>
</Stack>
</Box>
</Collapse>
</TableCell>
@@ -241,20 +271,24 @@ export default function List() {
Code
</TableCell>
<TableCell style={headStyle} align="left">
Member Name
Name
</TableCell>
<TableCell style={headStyle} align="left">
Submission Date
Nomor Polis
</TableCell>
<TableCell style={headStyle} align="left">
Jenis Layanan
Tanggal Pengajuan
</TableCell>
<TableCell style={headStyle} align="left">
Service Type
</TableCell>
<TableCell style={headStyle} align="left">
Claim Type
</TableCell>
<TableCell style={headStyle} align="left">
Status
</TableCell>
<TableCell style={headStyle} align="right">
Action
</TableCell>
<TableCell style={headStyle} align="right"></TableCell>
</TableRow>
</TableBody>
{/* ------------------ END TABLE HEADER ------------------ */}
@@ -288,8 +322,6 @@ export default function List() {
);
}
// ---------------------------------------------------------
// Dialog Detail Claim Request
const [openDialogDetailClaim, setOpenDialogDetailClaim] = useState(false);
@@ -300,20 +332,18 @@ export default function List() {
setLoadingClaimDetail(true);
setOpenDialogDetailClaim(true);
axios.get(`/claim-requests/${claimRequest.id}`)
.then(({data}) => {
axios
.get(`/claim-requests/${claimRequest.id}`)
.then(({ data }) => {
setCurrentClaim(data.data);
setLoadingClaimDetail(false);
})
.catch((err) => {
enqueueSnackbar(err.message, {variant: 'error'})
})
}
function handleDownloadLog() {
enqueueSnackbar(err.message, { variant: 'error' });
});
}
function handleDownloadLog() {}
return (
<Card>
@@ -327,7 +357,6 @@ export default function List() {
TableContent={<TableContent />}
/>
<DialogDetailClaim
openDialog={openDialogDetailClaim}
setOpenDialog={setOpenDialogDetailClaim}

View File

@@ -36,8 +36,8 @@ export const colorPresets = [
name: 'blue',
lighter: '#D1E9FC',
light: '#76B0F1',
main: '#006a35',
dark: '#004422',
main: '#2065D1',
dark: '#103996',
darker: '#061B64',
contrastText: '#fff',
},
@@ -63,7 +63,7 @@ export const colorPresets = [
},
];
export const defaultPreset = colorPresets[3];
export const defaultPreset = colorPresets[0];
export const purplePreset = colorPresets[1];
export const cyanPreset = colorPresets[2];
export const bluePreset = colorPresets[3];

View File

@@ -1,7 +1,7 @@
// mui
import { styled } from '@mui/material/styles';
import { LoadingButton, TabPanel } from "@mui/lab";
import { Card, Divider, Grid, LinearProgress, linearProgressClasses, Typography } from "@mui/material";
import { Button, Card, Divider, Grid, LinearProgress, linearProgressClasses, Typography } from "@mui/material";
import { Tab, Tabs } from "@mui/material";
import { Box, Stack } from "@mui/material";
import { useEffect, useState } from "react";
@@ -80,7 +80,7 @@ export default function DialogMember(member, handleSubmitSuccess) {
<Grid item sm={6} key={index}>
<Card sx={{p: 2}}>
<Typography variant="body1" sx={{fontWeight: 500}}>{corporateBenefit.benefit.description}</Typography>
<Typography variant="body2">{corporateBenefit.benefit.code}</Typography>
<Typography variant="body2">Member ID : {corporateBenefit.benefit.code}</Typography>
<Typography variant="body2" sx={{ marginTop: 2 }}>Yearly Limits</Typography>
<BorderLinearProgress variant="determinate" value={100 - (corporateBenefit.limit_amount ? ((corporateBenefit.usage ?? 0) / corporateBenefit.limit_amount) : 0)} sx={{ mb: 1 }} />
<Typography sx={{ textAlign: 'right'}}>{corporateBenefit.usage ?? 0} /

View File

@@ -2,7 +2,7 @@ import { styled } from '@mui/material/styles';
import Iconify from '@/components/Iconify';
import { fCurrency } from '@/utils/formatNumber';
import { LoadingButton } from '@mui/lab';
import { Avatar, Divider, LinearProgress, linearProgressClasses } from '@mui/material';
import { Avatar, Button, Divider, LinearProgress, linearProgressClasses } from '@mui/material';
import { Card } from '@mui/material';
import { Stack, Typography } from '@mui/material';
import { fPostFormat } from '@/utils/formatTime';
@@ -25,6 +25,8 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
},
}));
const [serviceCode, setServiceCode] = useState('IP');
// ----------------------------------------------------------------------
// Files Diagnosa
@@ -98,7 +100,8 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
member_id: member.id,
result_files: fileHasilPenunjangs,
diagnosa_files: fileDiagnosas,
kondisi_files: fileKondisis
kondisi_files: fileKondisis,
service_code: serviceCode
});
axios
.post('/claim-requests', formData)
@@ -117,10 +120,21 @@ export default function FormRequestClaim({ member, handleSubmitSuccess }) {
return (
<Stack>
<Stack direction="row" justifyContent={'end'} sx={{ marginBottom: 2 }}>
<Typography textAlign={'right'}>
<Typography textAlign={'right'} variant='body2'>
Submission Date : <br /> {fPostFormat(new Date(), 'dd/MM/yyyy')}
</Typography>
</Stack>
<Card sx={{ p: 1, background: '#f4f6f8', marginBottom: 2 }}>
<Stack direction="row" spacing={2}>
<Button sx={{padding: 2, width: '100%'}} variant={serviceCode == 'IP' ? 'contained' : ''} onClick={() => {setServiceCode('IP')}}>Rawat Inap</Button>
<Button sx={{padding: 2, width: '100%'}} variant={serviceCode == 'OP' ? 'contained' : ''} onClick={() => {setServiceCode('OP')}}>Rawat Jalan</Button>
</Stack>
</Card>
<Card sx={{ p: 1, background: '#f4f6f8', marginBottom: 2 }}>
<Stack direction="row">
<Avatar

View File

@@ -79,7 +79,7 @@
<table style="width: 100%;">
<tr>
<td rowspan="4" style="width: 110px;">
<img src="{{ public_path('images/logo-linksehat-vertical-default.png') }}" width="100px">
{{-- <img src="{{ assets('images/logo-linksehat-vertical-default.png') }}" width="100px"> --}}
</td>
</tr>