backend filter plan
This commit is contained in:
@@ -25,6 +25,31 @@ class CorporatePlanController extends Controller
|
|||||||
return $benefits;
|
return $benefits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function filter(Request $request, $corporate_id){
|
||||||
|
|
||||||
|
$benefits = CorporatePlan::query()
|
||||||
|
->filter($request->all())
|
||||||
|
->where('corporate_id', $corporate_id);
|
||||||
|
// ->where('type', $request->type)
|
||||||
|
// ->where('code', $request->code);
|
||||||
|
|
||||||
|
if ($request->has('service_code') && is_array($request->service_code) && count($request->service_code) > 0) {
|
||||||
|
$benefits->whereIn('service_code', $request->service_code);
|
||||||
|
}
|
||||||
|
if ($request->has('type') && is_array($request->type) && count($request->type) > 0) {
|
||||||
|
$benefits->whereIn('type', $request->type);
|
||||||
|
}
|
||||||
|
if ($request->has('code') && is_array($request->code) && count($request->code) > 0) {
|
||||||
|
$benefits->whereIn('code', $request->code);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$benefits = $benefits->paginate(0)->appends($request->all());
|
||||||
|
|
||||||
|
return $benefits;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function activation(Request $request, $plan_id)
|
public function activation(Request $request, $plan_id)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
||||||
Route::get('corporates/{corporate_id}/corporate-plans/{id}/edit', [CorporatePlanController::class, 'edit']);
|
Route::get('corporates/{corporate_id}/corporate-plans/{id}/edit', [CorporatePlanController::class, 'edit']);
|
||||||
Route::put('corporates/{corporate_id}/corporate-plans/{id}', [CorporatePlanController::class, 'update']);
|
Route::put('corporates/{corporate_id}/corporate-plans/{id}', [CorporatePlanController::class, 'update']);
|
||||||
|
Route::post('corporates/{corporate_id}/corporate-plans/filter', [CorporatePlanController::class, 'filter']);
|
||||||
Route::put('plans/{plan_id}/activation', [CorporatePlanController::class, 'activation']);
|
Route::put('plans/{plan_id}/activation', [CorporatePlanController::class, 'activation']);
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
||||||
|
|||||||
@@ -382,27 +382,35 @@ export default function PlanList() {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
let frequency_period_name: string
|
let frequency_period_name: string
|
||||||
|
let limit_frequency: string
|
||||||
switch (row.max_frequency_period) {
|
switch (row.max_frequency_period) {
|
||||||
case '1' :
|
case '1' :
|
||||||
frequency_period_name = 'Daily Visit';
|
frequency_period_name = 'Daily Visit';
|
||||||
|
limit_frequency = row.daily_frequency ? row.daily_frequency : '1';
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
frequency_period_name = 'Weekly';
|
frequency_period_name = 'Weekly';
|
||||||
|
limit_frequency = row.weekly_frequency ? row.weekly_frequency : '7';
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
frequency_period_name = 'Monthly';
|
frequency_period_name = 'Monthly';
|
||||||
|
limit_frequency = row.monthly_frequency ? row.monthly_frequency : '30';
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
frequency_period_name = 'Yearly';
|
frequency_period_name = 'Yearly';
|
||||||
|
limit_frequency = row.yearly_frequency ? row.yearly_frequency : '365';
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
frequency_period_name = 'Disability';
|
frequency_period_name = 'Disability';
|
||||||
|
limit_frequency = row.max_days_for_disability ? row.max_days_for_disability : '-';
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
frequency_period_name = 'Visit';
|
frequency_period_name = 'Visit';
|
||||||
|
limit_frequency = row.daily_frequency ? row.daily_frequency : '-';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
frequency_period_name = 'Policy Period';
|
frequency_period_name = 'Policy Period';
|
||||||
|
limit_frequency = row.daily_frequency ? row.daily_frequency : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -419,7 +427,8 @@ export default function PlanList() {
|
|||||||
<TableCell align="left">{row.corporate_benefit_code}</TableCell>
|
<TableCell align="left">{row.corporate_benefit_code}</TableCell>
|
||||||
<TableCell align="left">{row.benefit?.description}</TableCell>
|
<TableCell align="left">{row.benefit?.description}</TableCell>
|
||||||
<TableCell align="left">{ fNumber(row.limit_amount)}</TableCell>
|
<TableCell align="left">{ fNumber(row.limit_amount)}</TableCell>
|
||||||
<TableCell align="left">{ row.max_frequency_period}</TableCell>
|
<TableCell align="left">{ frequency_period_name}</TableCell>
|
||||||
|
<TableCell align="left">{ limit_frequency}</TableCell>
|
||||||
|
|
||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
{row.active == 1 && (
|
{row.active == 1 && (
|
||||||
@@ -1086,6 +1095,9 @@ export default function PlanList() {
|
|||||||
<TableCell style={headStyle} align="left">
|
<TableCell style={headStyle} align="left">
|
||||||
Limit Benefit
|
Limit Benefit
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">
|
||||||
|
Freq. Period
|
||||||
|
</TableCell>
|
||||||
<TableCell style={headStyle} align="left">
|
<TableCell style={headStyle} align="left">
|
||||||
Limit Frequency
|
Limit Frequency
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -81,6 +81,19 @@ export default function CorporatePlanList() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// filter
|
||||||
|
const defaultValue = [
|
||||||
|
{
|
||||||
|
value: '-',
|
||||||
|
label: '-'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const [serviceCode, setServiceCode] = useState(defaultValue);
|
||||||
|
const [type, setType] = useState(defaultValue);
|
||||||
|
const [code, setCode] = useState(defaultValue);
|
||||||
|
const [codePlan, setCodePlan] = useState(defaultValue);
|
||||||
|
|
||||||
function SearchInput(props: any) {
|
function SearchInput(props: any) {
|
||||||
// SEARCH
|
// SEARCH
|
||||||
const searchInput = useRef<HTMLInputElement>(null);
|
const searchInput = useRef<HTMLInputElement>(null);
|
||||||
@@ -227,16 +240,7 @@ export default function CorporatePlanList() {
|
|||||||
<Grid item xs={2}>
|
<Grid item xs={2}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
id="combo-box-demo"
|
id="combo-box-demo"
|
||||||
options={[
|
options={serviceCode}
|
||||||
{
|
|
||||||
value: 'IP',
|
|
||||||
label: 'Inpatient'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'OP',
|
|
||||||
label: 'Outpatient'
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
multiple
|
multiple
|
||||||
limitTags={1}
|
limitTags={1}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -252,16 +256,7 @@ export default function CorporatePlanList() {
|
|||||||
<Grid item xs={1.5}>
|
<Grid item xs={1.5}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
id="combo-box-demo"
|
id="combo-box-demo"
|
||||||
options={[
|
options={codePlan}
|
||||||
{
|
|
||||||
value: 'IP',
|
|
||||||
label: 'IP-001'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'OP',
|
|
||||||
label: 'OP-001'
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
multiple
|
multiple
|
||||||
limitTags={1}
|
limitTags={1}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -277,16 +272,7 @@ export default function CorporatePlanList() {
|
|||||||
<Grid item xs={1.5}>
|
<Grid item xs={1.5}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
id="combo-box-demo"
|
id="combo-box-demo"
|
||||||
options={[
|
options={code}
|
||||||
{
|
|
||||||
value: 'IP',
|
|
||||||
label: 'IP-001'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'OP',
|
|
||||||
label: 'OP-001'
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
multiple
|
multiple
|
||||||
limitTags={1}
|
limitTags={1}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -302,16 +288,7 @@ export default function CorporatePlanList() {
|
|||||||
<Grid item xs={1.5}>
|
<Grid item xs={1.5}>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
id="combo-box-demo"
|
id="combo-box-demo"
|
||||||
options={[
|
options={type}
|
||||||
{
|
|
||||||
value: 'IP',
|
|
||||||
label: 'IP-001'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'OP',
|
|
||||||
label: 'OP-001'
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
multiple
|
multiple
|
||||||
limitTags={1}
|
limitTags={1}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -790,10 +767,68 @@ export default function CorporatePlanList() {
|
|||||||
setDataTableLoading(true);
|
setDataTableLoading(true);
|
||||||
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||||
const response = await axios.get('/corporates/' + corporate_id + '/plans', { params: filter });
|
const response = await axios.get('/corporates/' + corporate_id + '/plans', { params: filter });
|
||||||
// console.log(response.data);
|
|
||||||
setDataTableLoading(false);
|
setDataTableLoading(false);
|
||||||
|
|
||||||
setDataTableData(response.data);
|
setDataTableData(response.data);
|
||||||
|
|
||||||
|
const data = response.data.data;
|
||||||
|
const serviceCodeArray :string[] = [];
|
||||||
|
const codeArray :string[] = [];
|
||||||
|
const typeArray :string[] = [];
|
||||||
|
const planArray :string[] = [];
|
||||||
|
|
||||||
|
data.forEach((row: any) => {
|
||||||
|
if (!serviceCodeArray.includes(row.service_code)) {
|
||||||
|
serviceCodeArray.push(row.service_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!codeArray.includes(row.code)) {
|
||||||
|
codeArray.push(row.code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!typeArray.includes(row.type)) {
|
||||||
|
typeArray.push(row.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!planArray.includes(row.corporate_plan_id)) {
|
||||||
|
planArray.push(row.corporate_plan_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const optionServiceCode = serviceCodeArray.map((value) => {
|
||||||
|
return {
|
||||||
|
value: value,
|
||||||
|
label: value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const optionCode = codeArray.map((value) => {
|
||||||
|
return {
|
||||||
|
value: value,
|
||||||
|
label: value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const optionType = typeArray.map((value) => {
|
||||||
|
return {
|
||||||
|
value: value,
|
||||||
|
label: value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const optionPlan = planArray.map((value) => {
|
||||||
|
return {
|
||||||
|
value: value,
|
||||||
|
label: value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
console.log(optionCode)
|
||||||
|
setServiceCode(optionServiceCode)
|
||||||
|
setType(optionType)
|
||||||
|
setCode(optionCode)
|
||||||
|
setCodePlan(optionPlan)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const headStyle = {
|
const headStyle = {
|
||||||
|
|||||||
Reference in New Issue
Block a user