This commit is contained in:
2022-07-12 13:23:27 +07:00
parent b5f892641d
commit 4e99ba5109
29 changed files with 1826 additions and 228 deletions

View File

@@ -0,0 +1,147 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
use App\Models\Benefit;
use App\Models\MemberBenefit;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
use Illuminate\Support\Facades\Storage;
class BenefitController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request, $corporate_id)
{
$benefits = MemberBenefit::query()
->filter($request->all())
->where('corporate_id', $corporate_id)
->paginate(0)
->appends($request->all());
return $benefits;
}
/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('internal::create');
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Renderable
*/
public function store(Request $request)
{
//
}
/**
* Show the specified resource.
* @param int $id
* @return Renderable
*/
public function show($id)
{
return view('internal::show');
}
/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('internal::edit');
}
/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
public function memberBenefitImport(Request $request, $corporate_id)
{
$request->validate([
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
]);
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
$file = $request->file('file')->storeAs('temp', $file_name);
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
$reader->open(Storage::path('temp/'.$file_name));
$headers_map_to_table_fields = MemberBenefit::$doc_headers_to_field_map;
$imported_benefit_data = 0;
$failed_benefit_data = [];
foreach ($reader->getSheetIterator() as $sheet) {
$doc_headers_indexes = [];
foreach ($sheet->getRowIterator() as $index => $row) {
if ($index == 1) { // First Row Must be Header
foreach ($row->getCells() as $index => $cell) {
$doc_headers_indexes[$index] = rtrim($cell->getValue());
}
} else { // Next Row Should be Data
$new_benefit_data = [];
foreach ($row->getCells() as $index => $cell) {
$new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
}
// $imported_plan_data[] = $new_row; // Insert to Array
// Create Directly
$new_benefit_data['corporate_id'] = $corporate_id;
try {
MemberBenefit::updateOrCreate([
'corporate_id' => $corporate_id,
'code' => $new_benefit_data['code']
], $new_benefit_data);
$imported_benefit_data++;
} catch(\Exception $e) {
$new_benefit_data['error'] = $e->getMessage();
$failed_benefit_data[] = $new_benefit_data;
}
}
}
break; //only read first sheet
}
$reader->close();
Storage::delete('temp/'.$file_name);
// throw(404);
return [
'total_successed_row' => $imported_benefit_data,
'total_failed_row' => count($failed_benefit_data),
'failed_row' => $failed_benefit_data
];
}
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
use App\Models\Benefit;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class CorporateBenefitController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request, $corporate_id)
{
$benefits = Benefit::query()
->filter($request->all())
->where('corporate_id', $corporate_id)
->paginate(0)
->appends($request->all());
return $benefits;
}
/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('internal::create');
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Renderable
*/
public function store(Request $request)
{
//
}
/**
* Show the specified resource.
* @param int $id
* @return Renderable
*/
public function show($id)
{
return view('internal::show');
}
/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('internal::edit');
}
/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
use App\Models\CorporatePlan;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class CorporatePlanController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request, $corporate_id)
{
$benefits = CorporatePlan::query()
->filter($request->all())
->where('corporate_id', $corporate_id)
->paginate(0)
->appends($request->all());
return $benefits;
}
/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('internal::create');
}
/**
* Store a newly created resource in storage.
* @param Request $request
* @return Renderable
*/
public function store(Request $request)
{
//
}
/**
* Show the specified resource.
* @param int $id
* @return Renderable
*/
public function show($id)
{
return view('internal::show');
}
/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('internal::edit');
}
/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
}

View File

@@ -89,7 +89,7 @@ class PlanController extends Controller
//
}
public function plansImport(Request $request, $corporate_id)
public function planImport(Request $request, $corporate_id)
{
$request->validate([
'file' => 'required|file|mimes:xls,xlsx,csv,txt',

View File

@@ -2,7 +2,10 @@
use Modules\Internal\Http\Controllers\Api\AuthController;
use Illuminate\Http\Request;
use Modules\Internal\Http\Controllers\Api\BenefitController;
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
use Modules\Internal\Http\Controllers\Api\CorporateController;
use Modules\Internal\Http\Controllers\Api\CorporatePlanController;
use Modules\Internal\Http\Controllers\Api\PlanController;
/*
@@ -32,9 +35,14 @@ Route::prefix('internal')->group(function () {
});
Route::resource('corporates', CorporateController::class);
// Route::post('corporates/{id}/plans', [CorporateController::class, 'planImport']);
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
Route::post('corporates/{corporate_id}/plans/import', [PlanController::class, 'planImport']);
Route::get('corporates/{corporate_id}/benefits', [BenefitController::class, 'index']);
Route::post('corporates/{corporate_id}/benefits/import', [BenefitController::class, 'memberBenefitImport']);
Route::get('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'index']);
Route::get('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'index']);
});
});
// Route::resource('corporates', CorporateController::class);

View File

@@ -8,4 +8,21 @@ use Illuminate\Database\Eloquent\Model;
class Benefit extends Model
{
use HasFactory;
protected $fillable = [
"corporate_id",
"code",
"name",
"description"
];
public function scopeFilter($query, array $filters)
{
$query->when($filters['search'] ?? false, function ($query, $search) {
return $query
->where('code', 'like', "%" . $search . "%")
->orWhere('name', 'like', "%" . $search . "%")
->orWhere('description', 'like', "%" . $search . "%");
});
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CorporateBenefit extends Model
{
use HasFactory;
}

View File

@@ -19,4 +19,13 @@ class CorporatePlan extends Model
{
return $this->belongsTo(Corporate::class);
}
public function scopeFilter($query, array $filters)
{
$query->when($filters['search'] ?? false, function ($query, $search) {
return $query
->where('code', 'like', "%" . $search . "%")
->orWhere('name', 'like', "%" . $search . "%");
});
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class CorporatePolicy extends Model
{
@@ -28,4 +29,9 @@ class CorporatePolicy extends Model
{
return $this->belongsTo(Corporate::class);
}
public function setCodeAttribute($value)
{
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
}
}

View File

@@ -10,14 +10,17 @@ class MemberBenefit extends Model
use HasFactory;
protected $fillable = [
'corporate_id',
'service_code',
'plan_code',
'benefit_code',
'code',
'description',
'budget',
'budget_conditions',
'budget_code',
'primary_benefit_code',
'benefit_mode',
'room_class_coverage',
'max_bed_coverage',
'tolerance_parameter',
@@ -25,6 +28,7 @@ class MemberBenefit extends Model
'limit_amount',
'area_limit',
'shared_benefit',
'shared_benefit_type',
'msc',
'genders',
'min_age',
@@ -33,6 +37,7 @@ class MemberBenefit extends Model
'daily_frequency',
'weekly_frequency',
'monthly_frequency',
'yearly_frequency',
'custom_frequency_days',
'custom_duration_value',
'allowed_transaction_types',
@@ -52,6 +57,7 @@ class MemberBenefit extends Model
'co_share_c_percentage',
'cashless_deductible',
'reimbursement_deductible',
'digital_deductible',
'co_share_m_deductible',
'co_share_s_deductible',
'co_share_c_deductible',
@@ -63,4 +69,96 @@ class MemberBenefit extends Model
'show_benefit_item',
'show_benefit_value',
];
public static $doc_headers_to_field_map = [
"Service" => 'service_code',
"Plan" => 'plan_code',
"Benefit Code" => 'benefit_code',
"Customer Benefit Code" => 'code',
"Detail Benefit" => 'description',
"ASO/Budget" => 'budget',
"Budget Condition" => 'budget_conditions',
"Budget Code" => 'budget_code',
"Primary benefit" => 'primary_benefit_code',
"Benefit Mode" => 'benefit_mode',
"Room Class" => 'room_class_coverage',
"Max Bed" => 'max_bed_coverage',
"Tolerance Paramater" => 'tolerance_parameter',
"Max. Room Class" => 'max_room_class',
"Limit Value" => 'limit_amount',
"Area" => 'area_limit',
"Shared Benefit With" => 'shared_benefit',
"Shared Benefit Type" => 'shared_benefit_type',
"MSC" => 'msc',
"Gender" => 'genders',
"Min Age" => 'min_age',
"Max Age" => 'max_age',
"Freq. Period" => 'max_frequency_period',
"Daily Frequency" => 'daily_frequency',
"Weekly Frequency" => 'weekly_frequency',
"Monthly Frequency" => 'monthly_frequency',
"Yearly Frequency" => 'yearly_frequency',
"Custom Duration" => 'custom_frequency_days',
"Custom Duration Value" => 'custom_duration_value',
"Cashless, Reimbursement" => 'allowed_transaction_types',
"High Plan Factor" => 'high_plan_factor',
"Pre Post Treatment" => 'pre_post_treatment',
"Pre Treatment" => 'pre_treatment_days',
"Post Treatment" => 'post_treatment_days',
"Layer Type 1" => 'layer_type_1',
"Layer Value 1" => 'layer_value_1',
"Layer Type 2" => 'layer_type_2',
"Layer Value 2" => 'layer_value_2',
"Cashless (%)" => 'cashless_percentage',
"Reimburse (%)" => 'reimbursement_percentage',
"Digital (%)" => 'digital_percentage',
"CoShareM (%)" => 'co_share_m_percentage',
"CoShareS (%)" => 'co_share_s_percentage',
"CoShareC (%)" => 'co_share_c_percentage',
"Cashless Deductible" => 'cashless_deductible',
"Reimbursement Deductible" => 'reimbursement_deductible',
"Digital Deductible" => 'digital_deductible',
"DeductibleM" => 'co_share_m_deductible',
"DeductibleS" => 'co_share_s_deductible',
"DeductibleC" => 'co_share_c_deductible',
"Prorate Type" => 'prorate_type',
"Prorate Lookup" => 'prorate_lookup',
"Max Days for Disability" => 'max_days_for_disability',
"Max Periode of Disability" => 'max_period_for_disability',
"Currency" => 'currency',
"Show Benefit Item" => 'show_benefit_item',
"Show Benefit Value" => 'show_benefit_value',
];
public function setPrePostTreatmentAttribute($value)
{
return empty($value) ? null : ($value == 'Y');
}
public function getPrePostTreatmentAttribute($value)
{
return empty($value) ? null : ($value ? 'Y' : 'N');
}
public function scopeFilter($query, array $filters)
{
$query->when($filters['search'] ?? false, function ($query, $search) {
return $query
->where('service_code', 'like', "%" . $search . "%")
->orWhere('code', 'like', "%" . $search . "%")
->orWhereHas('plan', function ($query) use ($search) {
$query->where('code', 'like', "%" . $search . "%");
});
});
}
public function benefit()
{
return $this->belongsTo(Benefit::class, 'benefit_code', 'code');
}
public function plan()
{
return $this->belongsTo(Plan::class, 'plan_code', 'code');
}
}

View File

@@ -15,10 +15,65 @@ return new class extends Migration
{
Schema::create('benefits', function (Blueprint $table) {
$table->id();
$table->string('code')->unique();
$table->string('name');
$table->foreignId('corporate_id')->index()->nullable();
$table->string('service_code')->index()->nullable();
$table->string('plan_code')->index()->nullable();
$table->string('benefit_code')->index()->nullable();
$table->string('code')->index()->nullable();
$table->text('description')->nullable();
$table->string('budget')->nullable();
$table->string('budget_conditions')->nullable();
$table->string('budget_code')->nullable();
$table->string('primary_benefit_code')->index()->nullable();
$table->string('benefit_mode')->nullable();
$table->string('room_class_coverage')->nullable();
$table->string('max_bed_coverage')->nullable();
$table->string('tolerance_parameter')->nullable();
$table->string('max_room_class')->nullable();
$table->decimal('limit_amount', 15, 2)->nullable();
$table->boolean('area_limit')->default(false)->nullable();
$table->string('shared_benefit')->nullable();
$table->string('shared_benefit_type')->nullable();
$table->string('msc')->nullable();
$table->string('genders')->nullable();
$table->string('min_age')->nullable();
$table->string('max_age')->nullable();
$table->string('max_frequency_period')->nullable();
$table->string('daily_frequency')->nullable();
$table->string('weekly_frequency')->nullable();
$table->string('monthly_frequency')->nullable();
$table->string('yearly_frequency')->nullable();
$table->string('custom_frequency_days')->nullable();
$table->string('custom_duration_value')->nullable();
$table->string('allowed_transaction_types')->nullable();
$table->string('high_plan_factor')->nullable();
$table->boolean('pre_post_treatment')->nullable();
$table->string('pre_treatment_days')->nullable();
$table->string('post_treatment_days')->nullable();
$table->string('layer_type_1')->nullable();
$table->string('layer_value_1')->nullable();
$table->string('layer_type_2')->nullable();
$table->string('layer_value_2')->nullable();
$table->tinyInteger('cashless_percentage')->default(100)->nullable();
$table->tinyInteger('reimbursement_percentage')->default(100)->nullable();
$table->tinyInteger('digital_percentage')->default(100)->nullable();
$table->tinyInteger('co_share_m_percentage')->default(100)->nullable();
$table->tinyInteger('co_share_s_percentage')->default(100)->nullable();
$table->tinyInteger('co_share_c_percentage')->default(100)->nullable();
$table->decimal('cashless_deductible', 15, 2)->nullable();
$table->decimal('reimbursement_deductible', 15, 2)->nullable();
$table->decimal('digital_deductible', 15, 2)->nullable();
$table->decimal('co_share_m_deductible', 15, 2)->nullable();
$table->decimal('co_share_s_deductible', 15, 2)->nullable();
$table->decimal('co_share_c_deductible', 15, 2)->nullable();
$table->string('prorate_type')->nullable();
$table->string('prorate_lookup')->nullable();
$table->string('max_days_for_disability')->nullable();
$table->string('max_period_for_disability')->nullable();
$table->string('currency')->nullable();
$table->string('show_benefit_item')->nullable();
$table->string('show_benefit_value')->nullable();
$table->timestamps();
$table->softDeletes();

View File

@@ -1,89 +0,0 @@
<?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::create('member_benefits', function (Blueprint $table) {
$table->id();
$table->string('service_code')->index()->nullable();
$table->string('plan_code')->index()->nullable();
$table->string('benefit_code')->index()->nullable();
$table->text('description')->nullable();
$table->string('budget')->nullable();
$table->string('budget_conditions')->nullable();
$table->string('budget_code')->nullable();
$table->string('primary_benefit_code')->index()->nullable();
$table->string('room_class_coverage')->nullable();
$table->string('max_bed_coverage')->nullable();
$table->string('tolerance_parameter')->nullable();
$table->string('max_room_class')->nullable();
$table->decimal('limit_amount', 15, 2)->nullable();
$table->boolean('area_limit')->default(false)->nullable();
$table->string('shared_benefit')->nullable();
$table->string('msc')->nullable();
$table->string('genders')->nullable();
$table->string('min_age')->nullable();
$table->string('max_age')->nullable();
$table->string('max_frequency_period')->nullable();
$table->string('daily_frequency')->nullable();
$table->string('weekly_frequency')->nullable();
$table->string('monthly_frequency')->nullable();
$table->string('custom_frequency_days')->nullable();
$table->string('custom_duration_value')->nullable();
$table->string('allowed_transaction_types')->nullable();
$table->string('high_plan_factor')->nullable();
$table->boolean('pre_post_treatment')->nullable();
$table->string('pre_treatment_days')->nullable();
$table->string('post_treatment_days')->nullable();
$table->string('layer_type_1')->nullable();
$table->string('layer_value_1')->nullable();
$table->string('layer_type_2')->nullable();
$table->string('layer_value_2')->nullable();
$table->tinyInteger('cashless_percentage')->default(100)->nullable();
$table->tinyInteger('reimbursement_percentage')->default(100)->nullable();
$table->tinyInteger('digital_percentage')->default(100)->nullable();
$table->tinyInteger('co_share_m_percentage')->default(100)->nullable();
$table->tinyInteger('co_share_s_percentage')->default(100)->nullable();
$table->tinyInteger('co_share_c_percentage')->default(100)->nullable();
$table->decimal('cashless_deductible', 15, 2)->nullable();
$table->decimal('reimbursement_deductible', 15, 2)->nullable();
$table->decimal('co_share_m_deductible', 15, 2)->nullable();
$table->decimal('co_share_s_deductible', 15, 2)->nullable();
$table->decimal('co_share_c_deductible', 15, 2)->nullable();
$table->string('prorate_type')->nullable();
$table->string('prorate_lookup')->nullable();
$table->string('max_days_for_disability')->nullable();
$table->string('max_period_for_disability')->nullable();
$table->string('currency')->nullable();
$table->string('show_benefit_item')->nullable();
$table->string('show_benefit_value')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreignId('created_by')->nullable()->index();
$table->foreignId('updated_by')->nullable()->index();
$table->foreignId('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('member_benefits');
}
};

View File

@@ -0,0 +1,43 @@
<?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::create('corporate_benefits', function (Blueprint $table) {
$table->id();
$table->foreignId('corporate_id')->index();
$table->string('code')->index();
$table->string('name')->nullable();
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreignId('created_by')->nullable()->index();
$table->foreignId('updated_by')->nullable()->index();
$table->foreignId('deleted_by')->nullable()->index();
$table->unique(['corporate_id', 'code']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('corporate_benefits');
}
};

View File

@@ -2,6 +2,8 @@
namespace Database\Seeders;
use App\Models\Benefit;
use App\Models\MemberBenefit;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@@ -14,37 +16,14 @@ class BenefitSeeder extends Seeder
*/
public function run()
{
$listOfBenefit = [
[
"service_code" => 'OP',
"code" => "GP",
"name" => "General Practitioner",
"description" => "Consultation With General Practitioner"
],
[
"service_code" => 'OP',
"code" => "GP",
"name" => "General Practitioner",
"description" => "Consultation With General Practitioner"
],
[
"service_code" => 'OP',
"code" => "GP",
"name" => "General Practitioner",
"description" => "Consultation With General Practitioner"
],
[
"service_code" => 'OP',
"code" => "GP",
"name" => "General Practitioner",
"description" => "Consultation With General Practitioner"
],
[
"service_code" => 'OP',
"code" => "GP",
"name" => "General Practitioner",
"description" => "Consultation With General Practitioner"
],
];
$member_benefits = MemberBenefit::pluck('benefit_code')->unique();
foreach ($member_benefits as $benefit_code) {
Benefit::create([
'code' => $benefit_code,
'name' => "Benefit ". $benefit_code,
'corporate_id' => 3,
]);
}
}
}

View File

@@ -41,16 +41,16 @@ export type Policy = {
end: string | Date;
}
export type CorporatePlan = {
export type Plan = {
id: number;
corporate_id: number;
code: string;
name: string;
}
export type Plan = {
export type PlanConfig = {
id: number;
corporate_plan: CorporatePlan | null;
corporate_plan: Plan | null;
service_code: string;
corporate_plan_id: string;
code: string;
@@ -100,3 +100,63 @@ export type Plan = {
max_surgery_reinstatement_days: string;
max_surgery_periode_days: string;
}
export type MemberBenefit = {
service_code : string;
plan_code : string;
benefit_code : string;
code : string;
description : string;
budget : string;
budget_conditions : string;
budget_code : string;
primary_benefit_code : string;
benefit_mode : string;
room_class_coverage : string;
max_bed_coverage : string;
tolerance_parameter : string;
max_room_class : string;
limit_amount : string;
area_limit : string;
shared_benefit : string;
shared_benefit_type : string;
msc : string;
genders : string;
min_age : string;
max_age : string;
max_frequency_period : string;
daily_frequency : string;
weekly_frequency : string;
monthly_frequency : string;
yearly_frequency : string;
custom_frequency_days : string;
custom_duration_value : string;
allowed_transaction_types : string;
high_plan_factor : string;
pre_post_treatment : string;
pre_treatment_days : string;
post_treatment_days : string;
layer_type_1 : string;
layer_value_1 : string;
layer_type_2 : string;
layer_value_2 : string;
cashless_percentage : string;
reimbursement_percentage : string;
digital_percentage : string;
co_share_m_percentage : string;
co_share_s_percentage : string;
co_share_c_percentage : string;
cashless_deductible : string;
reimbursement_deductible : string;
digital_deductible : string;
co_share_m_deductible : string;
co_share_s_deductible : string;
co_share_c_deductible : string;
prorate_type : string;
prorate_lookup : string;
max_days_for_disability : string;
max_period_for_disability : string;
currency : string;
show_benefit_item : string;
show_benefit_value : string;
}

View File

@@ -13,14 +13,13 @@ export default function Divisions() {
const { id } = useParams();
const pageTitle = 'Benefit List';
const pageTitle = 'Benefit';
return (
<Page title={ pageTitle }>
<HeaderBreadcrumbs
heading={ pageTitle }
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Corporates',
href: '/corporates',
@@ -30,7 +29,7 @@ export default function Divisions() {
href: '/corporates/'+id,
},
{
name: 'Benefits',
name: 'Benefit',
href: '/corporates/'+id+'/benefits',
},
]}

View File

@@ -11,7 +11,7 @@ import useSettings from '../../../hooks/useSettings';
import { useParams, useSearchParams } from 'react-router-dom';
// components
import axios from '../../../utils/axios';
import { Plan } from '../../../@types/corporates';
import { MemberBenefit } from '../../../@types/corporates';
import { LaravelPaginatedData } from '../../../@types/paginated-data';
export default function PlanList() {
@@ -35,7 +35,7 @@ export default function PlanList() {
}
useEffect(() => {
console.log('Search Input: useEffect')
// console.log('Search Input: useEffect')
setSearchText(searchParams.get('search') ?? '');
}, [searchParams])
@@ -88,7 +88,7 @@ export default function PlanList() {
if (importPlan.current?.files.length) {
const formData = new FormData();
formData.append("file", importPlan.current?.files[0])
axios.post(`corporates/${id}/plans/import`, formData )
axios.post(`corporates/${id}/benefits/import`, formData )
.then(response => {
handleCancelImportButton();
loadDataTableData();
@@ -155,9 +155,9 @@ export default function PlanList() {
}
// Called on every row to map the data to the columns
function createData( plan: Plan ): Plan {
function createData( memberBenefit: MemberBenefit ): MemberBenefit {
return {
...plan,
...memberBenefit,
}
}
@@ -179,29 +179,43 @@ export default function PlanList() {
</IconButton>
</TableCell>
<TableCell align="left">{row.service_code}</TableCell>
<TableCell align="left">{row.corporate_plan?.code}</TableCell>
<TableCell align="left">{row.plan_code}</TableCell>
<TableCell align="left">{row.benefit_code}</TableCell>
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.type}</TableCell>
<TableCell align="left">{row.start}</TableCell>
<TableCell align="left">{row.end}</TableCell>
<TableCell align="left">{row.require_referral}</TableCell>
<TableCell align="left">{row.referral_source}</TableCell>
<TableCell align="left">{row.referral_duration}</TableCell>
<TableCell align="left">{row.family_plan}</TableCell>
<TableCell align="left">{row.family_plan_share_rules}</TableCell>
<TableCell align="left">{row.limit_rules}</TableCell>
<TableCell align="left">{row.layer}</TableCell>
<TableCell align="left">{row.layer_conditions}</TableCell>
<TableCell align="left">{row.budget_type}</TableCell>
<TableCell align="left">{row.budget_code}</TableCell>
<TableCell align="left">{row.description}</TableCell>
<TableCell align="left">{row.budget}</TableCell>
<TableCell align="left">{row.budget_conditions}</TableCell>
<TableCell align="left">{row.surgery_limit}</TableCell>
<TableCell align="left">{row.non_surgery_limit}</TableCell>
<TableCell align="left">{row.max_claim_limit}</TableCell>
<TableCell align="left">{row.max_claim_count}</TableCell>
<TableCell align="left">{row.budget_code}</TableCell>
<TableCell align="left">{row.primary_benefit_code}</TableCell>
<TableCell align="left">{row.benefit_mode}</TableCell>
<TableCell align="left">{row.room_class_coverage}</TableCell>
<TableCell align="left">{row.max_bed_coverage}</TableCell>
<TableCell align="left">{row.tolerance_parameter}</TableCell>
<TableCell align="left">{row.max_room_class}</TableCell>
<TableCell align="left">{row.limit_amount}</TableCell>
<TableCell align="left">{row.area_limit}</TableCell>
<TableCell align="left">{row.limit_shared_plans}</TableCell>
<TableCell align="left">{row.limit_shared_plan_type}</TableCell>
<TableCell align="left">{row.shared_benefit}</TableCell>
<TableCell align="left">{row.shared_benefit_type}</TableCell>
<TableCell align="left">{row.msc}</TableCell>
<TableCell align="left">{row.genders}</TableCell>
<TableCell align="left">{row.min_age}</TableCell>
<TableCell align="left">{row.max_age}</TableCell>
<TableCell align="left">{row.max_frequency_period}</TableCell>
<TableCell align="left">{row.daily_frequency}</TableCell>
<TableCell align="left">{row.weekly_frequency}</TableCell>
<TableCell align="left">{row.monthly_frequency}</TableCell>
<TableCell align="left">{row.yearly_frequency}</TableCell>
<TableCell align="left">{row.custom_frequency_days}</TableCell>
<TableCell align="left">{row.custom_duration_value}</TableCell>
<TableCell align="left">{row.allowed_transaction_types}</TableCell>
<TableCell align="left">{row.high_plan_factor}</TableCell>
<TableCell align="left">{row.pre_post_treatment}</TableCell>
<TableCell align="left">{row.pre_treatment_days}</TableCell>
<TableCell align="left">{row.post_treatment_days}</TableCell>
<TableCell align="left">{row.layer_type_1}</TableCell>
<TableCell align="left">{row.layer_value_1}</TableCell>
<TableCell align="left">{row.layer_type_2}</TableCell>
<TableCell align="left">{row.layer_value_2}</TableCell>
<TableCell align="left">{row.cashless_percentage}</TableCell>
<TableCell align="left">{row.reimbursement_percentage}</TableCell>
<TableCell align="left">{row.digital_percentage}</TableCell>
@@ -214,18 +228,14 @@ export default function PlanList() {
<TableCell align="left">{row.co_share_m_deductible}</TableCell>
<TableCell align="left">{row.co_share_s_deductible}</TableCell>
<TableCell align="left">{row.co_share_c_deductible}</TableCell>
<TableCell align="left">{row.co_share_deductible_condition}</TableCell>
<TableCell align="left">{row.msc}</TableCell>
<TableCell align="left">{row.genders}</TableCell>
<TableCell align="left">{row.min_age}</TableCell>
<TableCell align="left">{row.max_age}</TableCell>
<TableCell align="left">{row.rule_of_excess}</TableCell>
<TableCell align="left">{row.max_excess_covered}</TableCell>
<TableCell align="left">{row.prorate_type}</TableCell>
<TableCell align="left">{row.prorate_lookup}</TableCell>
<TableCell align="left">{row.max_days_for_disability}</TableCell>
<TableCell align="left">{row.max_period_for_disability}</TableCell>
<TableCell align="left">{row.currency}</TableCell>
<TableCell align="left">{row.max_surgery_reinstatement_days}</TableCell>
<TableCell align="left">{row.max_surgery_periode_days}</TableCell>
<TableCell align="left">{row.show_benefit_item}</TableCell>
<TableCell align="left">{row.show_benefit_value}</TableCell>
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
<TableCell align="right"><Button variant="outlined" color="success" size="small">Edit</Button></TableCell>
</TableRow>
@@ -296,7 +306,7 @@ export default function PlanList() {
const loadDataTableData = async (appliedFilter = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/corporates/'+id+'/plans', { params: filter });
const response = await axios.get('/corporates/'+id+'/benefits', { params: filter });
// console.log(response.data);
setDataTableLoading(false);
@@ -329,52 +339,61 @@ export default function PlanList() {
<TableCell style={headStyle} align="left" />
<TableCell style={headStyle} align="left">Service</TableCell>
<TableCell style={headStyle} align="left">Plan</TableCell>
<TableCell style={headStyle} align="left">Code</TableCell>
<TableCell style={headStyle} align="left">Type</TableCell>
<TableCell style={headStyle} align="left">Start</TableCell>
<TableCell style={headStyle} align="left">End</TableCell>
<TableCell style={headStyle} align="left">Referral</TableCell>
<TableCell style={headStyle} align="left">Referral Source</TableCell>
<TableCell style={headStyle} align="left">Referral Duration</TableCell>
<TableCell style={headStyle} align="left">Family Plan</TableCell>
<TableCell style={headStyle} align="left">Family Sharing Overflow</TableCell>
<TableCell style={headStyle} align="left">Plan Limit</TableCell>
<TableCell style={headStyle} align="left">Layer ID</TableCell>
<TableCell style={headStyle} align="left">Layer Condition</TableCell>
<TableCell style={headStyle} align="left">Budget Type</TableCell>
<TableCell style={headStyle} align="left">Budget Code</TableCell>
<TableCell style={headStyle} align="left">Benefit Code</TableCell>
<TableCell style={headStyle} align="left">Customer Benefit Code</TableCell>
<TableCell style={headStyle} align="left">Detail Benefit</TableCell>
<TableCell style={headStyle} align="left">ASO/Budget</TableCell>
<TableCell style={headStyle} align="left">Budget Condition</TableCell>
<TableCell style={headStyle} align="left">Surgery</TableCell>
<TableCell style={headStyle} align="left">Non Surgery</TableCell>
<TableCell style={headStyle} align="left">Max/Claim</TableCell>
<TableCell style={headStyle} align="left">Max Count of Claim</TableCell>
<TableCell style={headStyle} align="left">Budget Code</TableCell>
<TableCell style={headStyle} align="left">Primary benefit</TableCell>
<TableCell style={headStyle} align="left">Benefit Mode</TableCell>
<TableCell style={headStyle} align="left">Room Class</TableCell>
<TableCell style={headStyle} align="left">Max Bed</TableCell>
<TableCell style={headStyle} align="left">Tolerance Paramater</TableCell>
<TableCell style={headStyle} align="left">Max. Room Class</TableCell>
<TableCell style={headStyle} align="left">Limit Value</TableCell>
<TableCell style={headStyle} align="left">Area</TableCell>
<TableCell style={headStyle} align="left">Shared Plan</TableCell>
<TableCell style={headStyle} align="left">Limit Shared Type</TableCell>
<TableCell style={headStyle} align="left">Cashless(%)</TableCell>
<TableCell style={headStyle} align="left">Reimbursement(%)</TableCell>
<TableCell style={headStyle} align="left">Digital(%)</TableCell>
<TableCell style={headStyle} align="left">CoShare M(%)</TableCell>
<TableCell style={headStyle} align="left">CoShare S(%)</TableCell>
<TableCell style={headStyle} align="left">CoShare C(%)</TableCell>
<TableCell style={headStyle} align="left">Shared Benefit With</TableCell>
<TableCell style={headStyle} align="left">Shared Benefit Type</TableCell>
<TableCell style={headStyle} align="left">MSC</TableCell>
<TableCell style={headStyle} align="left">Gender</TableCell>
<TableCell style={headStyle} align="left">Min Age</TableCell>
<TableCell style={headStyle} align="left">Max Age</TableCell>
<TableCell style={headStyle} align="left">Freq. Period</TableCell>
<TableCell style={headStyle} align="left">Daily Frequency</TableCell>
<TableCell style={headStyle} align="left">Weekly Frequency</TableCell>
<TableCell style={headStyle} align="left">Monthly Frequency</TableCell>
<TableCell style={headStyle} align="left">Yearly Frequency</TableCell>
<TableCell style={headStyle} align="left">Custom Duration</TableCell>
<TableCell style={headStyle} align="left">Custom Duration Value</TableCell>
<TableCell style={headStyle} align="left">Cashless, Reimbursement</TableCell>
<TableCell style={headStyle} align="left">High Plan Factor</TableCell>
<TableCell style={headStyle} align="left">Pre Post Treatment</TableCell>
<TableCell style={headStyle} align="left">Pre Treatment</TableCell>
<TableCell style={headStyle} align="left">Post Treatment</TableCell>
<TableCell style={headStyle} align="left">Layer Type 1</TableCell>
<TableCell style={headStyle} align="left">Layer Value 1</TableCell>
<TableCell style={headStyle} align="left">Layer Type 2</TableCell>
<TableCell style={headStyle} align="left">Layer Value 2</TableCell>
<TableCell style={headStyle} align="left">Cashless (%)</TableCell>
<TableCell style={headStyle} align="left">Reimburse (%)</TableCell>
<TableCell style={headStyle} align="left">Digital (%)</TableCell>
<TableCell style={headStyle} align="left">CoShareM (%)</TableCell>
<TableCell style={headStyle} align="left">CoShareS (%)</TableCell>
<TableCell style={headStyle} align="left">CoShareC (%)</TableCell>
<TableCell style={headStyle} align="left">Cashless Deductible</TableCell>
<TableCell style={headStyle} align="left">Reimbursement Deductible</TableCell>
<TableCell style={headStyle} align="left">Digital Deductible</TableCell>
<TableCell style={headStyle} align="left">DeductibleM</TableCell>
<TableCell style={headStyle} align="left">DeductibleS</TableCell>
<TableCell style={headStyle} align="left">DeductibleC</TableCell>
<TableCell style={headStyle} align="left">CoShare & Deductible Condition</TableCell>
<TableCell style={headStyle} align="left">MSC</TableCell>
<TableCell style={headStyle} align="left">Gender</TableCell>
<TableCell style={headStyle} align="left">Min Age</TableCell>
<TableCell style={headStyle} align="left">Max Age</TableCell>
<TableCell style={headStyle} align="left">Rule of Excess</TableCell>
<TableCell style={headStyle} align="left">Max Excess Covered</TableCell>
<TableCell style={headStyle} align="left">Prorate Type</TableCell>
<TableCell style={headStyle} align="left">Prorate Lookup</TableCell>
<TableCell style={headStyle} align="left">Max Days for Disability</TableCell>
<TableCell style={headStyle} align="left">Max Periode of Disability</TableCell>
<TableCell style={headStyle} align="left">Currency</TableCell>
<TableCell style={headStyle} align="left">Reinstatement Surgery</TableCell>
<TableCell style={headStyle} align="left">Period of Surgery</TableCell>
<TableCell style={headStyle} align="left">Show Benefit Item</TableCell>
<TableCell style={headStyle} align="left">Show Benefit Value</TableCell>
<TableCell style={headStyle} align="right">Status</TableCell>
<TableCell style={headStyle} align="right">Action</TableCell>
</TableRow>

View File

@@ -0,0 +1,241 @@
import * as Yup from 'yup';
import { yupResolver } from "@hookform/resolvers/yup";
import { Card, Collapse, Divider, Grid, Stack, Typography } from "@mui/material";
import { useForm } from "react-hook-form";
import { useParams } from "react-router-dom";
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
import { FormProvider, RHFCheckbox, RHFSelect, RHFTextField } from "../../../components/hook-form";
import Page from "../../../components/Page";
import useSettings from "../../../hooks/useSettings";
import CorporateTabNavigations from "../CorporateTabNavigations";
import DivisionsList from "./List";
import { useMemo, useState } from 'react';
export default function Divisions() {
const { themeStretch } = useSettings();
const { id } = useParams();
const NewDivisionSchema = Yup.object().shape({
name: Yup.string().required('Name is required'),
code: Yup.string().required('Corporate Code is required'),
active: Yup.boolean().required('Corporate Status is required'),
});
const defaultValues = useMemo(
() => ({
code: '',
}),
[]
);
const methods = useForm({
resolver: yupResolver(NewDivisionSchema),
defaultValues,
});
const {
reset,
watch,
control,
setValue,
getValues,
setError,
handleSubmit,
formState: { isSubmitting },
} = methods;
const onSubmit = async (data: any) => {
console.log(data);
};
const [open, setOpen] = useState(false);
const benefits = [
{
'category' : 'General Practitioner',
'childs' : [
{
'name' : 'External Doctor Online',
'code' : 'gp-external-doctor-online'
},
{
'name' : 'External Doctor Offline',
'code' : 'gp-external-doctor-offline'
},
{
'name' : 'Internal Doctor Online',
'code' : 'gp-internal-doctor-online'
},
{
'name' : 'Internal Doctor Offline',
'code' : 'gp-internal-doctor-offline'
},
]
},
{
'category' : 'Specialist',
'childs' : [
{
'name' : 'External Doctor Online',
'code' : 'sp-external-doctor-online'
},
{
'name' : 'External Doctor Offline',
'code' : 'sp-external-doctor-offline'
},
{
'name' : 'Internal Doctor Online',
'code' : 'sp-internal-doctor-online'
},
{
'name' : 'Internal Doctor Offline',
'code' : 'sp-internal-doctor-offline'
},
]
},
{
'category' : 'Medicines',
'childs' : [
{
'name' : 'Vitamins',
'code' : 'medicines-vitamins'
},
{
'name' : 'Delivery Fee',
'code' : 'medicines-delivery-fee'
},
]
},
];
const products = [
{
'name' : 'Inpatient',
'code' : 'IP',
},
{
'name' : 'Outpatient',
'code' : 'OP',
},
{
'name' : 'Dental',
'code' : 'DT',
},
{
'name' : 'Dental',
'code' : 'DTL',
},
{
'name' : 'Matternity',
'code' : 'MT',
},
{
'name' : 'Special Benefit',
'code' : 'SB',
},
];
return (
<Page title="Create Benefit">
<HeaderBreadcrumbs
heading={'Create Benefit'}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Corporates',
href: '/corporates',
},
{
name: 'Corporate Name',
href: '/corporates/'+id,
},
{
name: 'Benefits',
href: '/corporates/'+id+'/benefits',
},
{
name: 'Create',
href: '/corporates/'+id+'/benefits/create',
},
]}
/>
<Grid container spacing={2}>
<Grid item xs={12}>
<Card sx={{ p: 2 }}>
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Stack spacing={3}>
<Typography variant="h6">Benefit Detail</Typography>
<RHFTextField name="name" label="Benefit Name" />
<RHFTextField name="code" label="Benefit Code" />
<Typography variant="h6">Benefit Configuration</Typography>
<Divider orientation="horizontal" flexItem />
<Stack spacing={3} divider={<Divider orientation="horizontal" flexItem />}>
<Stack spacing={2}>
<RHFCheckbox name="a" label='Outpatient'/>
{benefits.map(row => (
<Collapse in={true} timeout="auto" unmountOnExit >
<Typography>{row.category}</Typography>
<Grid container>
{row.childs.map(benefit => (
<Grid item xs={6}>
<RHFCheckbox name={benefit.code} label={benefit.name}/>
</Grid>
))}
</Grid>
</Collapse>
))}
<Typography>Admin Fee</Typography>
<Grid container>
{benefits.map(row => (
<Grid item xs={4}>
<RHFCheckbox name="cat" label={row.category}/>
</Grid>
))}
</Grid>
</Stack>
<Stack spacing={2}>
<RHFCheckbox name="a" label='Inpatient'/>
{benefits.map(row => (
<Collapse in={true} timeout="auto" unmountOnExit >
<Typography>{row.category}</Typography>
<Grid container>
{row.childs.map(benefit => (
<Grid item xs={6}>
<RHFCheckbox name={benefit.code} label={benefit.name}/>
</Grid>
))}
</Grid>
</Collapse>
))}
<Typography>Admin Fee</Typography>
<Grid container>
{benefits.map(row => (
<Grid item xs={4}>
<RHFCheckbox name="cat" label={row.category}/>
</Grid>
))}
</Grid>
</Stack>
</Stack>
</Stack>
</FormProvider>
</Card>
</Grid>
</Grid>
</Page>
);
}

View File

@@ -0,0 +1,54 @@
import { Card, Grid } from "@mui/material";
import { useParams } from "react-router-dom";
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
import Page from "../../../components/Page";
import useSettings from "../../../hooks/useSettings";
import CorporateTabNavigations from "../CorporateTabNavigations";
import DivisionsList from "./List";
export default function Divisions() {
const { themeStretch } = useSettings();
const { id } = useParams();
const pageTitle = 'Corporate Benefit';
return (
<Page title={ pageTitle }>
<HeaderBreadcrumbs
heading={ pageTitle }
links={[
{
name: 'Corporates',
href: '/corporates',
},
{
name: 'Corporate Name',
href: '/corporates/'+id,
},
{
name: 'Corporate Benefit',
href: '/corporates/'+id+'/benefits',
},
]}
/>
<Grid container spacing={2}>
<Grid item xs={8}>
<Card>
<CorporateTabNavigations position={'corporate-benefits'} />
<DivisionsList />
</Card>
</Grid>
<Grid item xs={4}>
<Card sx={{ p: 2 }}>
Corporate Detail Goes Here
&nbsp;
</Card>
</Grid>
</Grid>
</Page>
);
}

View File

@@ -0,0 +1,220 @@
// @mui
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup } from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel';
// hooks
import React, { Component, useEffect, useRef, useState } from 'react';
import useSettings from '../../../hooks/useSettings';
import { useParams, useSearchParams } from 'react-router-dom';
// components
import axios from '../../../utils/axios';
import { MemberBenefit } from '../../../@types/corporates';
import { LaravelPaginatedData } from '../../../@types/paginated-data';
export default function PlanList() {
const { themeStretch } = useSettings();
const { id } = useParams();
const [searchParams, setSearchParams] = useSearchParams();
function SearchInput(props: any) {
// SEARCH
const searchInput = useRef<HTMLInputElement>(null);
const [searchText, setSearchText] = useState("");
const handleSearchChange = (event: any) => {
const newSearchText = event.target.value ?? ''
setSearchText(newSearchText);
}
const handleSubmit = (event: any) => {
event.preventDefault();
props.onSearch(searchText); // Trigger to Parent
}
useEffect(() => {
// console.log('Search Input: useEffect')
setSearchText(searchParams.get('search') ?? '');
}, [searchParams])
return (
<form onSubmit={handleSubmit} style={{ width: '100%' }}>
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/>
</form>
);
}
// Called on every row to map the data to the columns
function createData( benefit: Benefit ): Benefit {
return {
...benefit,
}
}
// Generate the every row of the table
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell>
<IconButton
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton>
</TableCell>
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.name}</TableCell>
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
<TableCell align="right"><Button variant="outlined" color="success" size="small">Edit</Button></TableCell>
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={10}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
<Typography variant="body2" gutterBottom component="div">
No Extra Data
</Typography>
</Box>
{false && <Box sx={{ margin: 1 }}>
<Typography variant="h6" gutterBottom component="div">
Rules
</Typography>
<Table size="small" aria-label="purchases">
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Customer</TableCell>
<TableCell align="right">Amount</TableCell>
<TableCell align="right">Total price ($)</TableCell>
</TableRow>
</TableHead>
<TableBody>
{/* {row.history ? row.history.map((historyRow) => ( */}
<TableRow key={row.id}>
<TableCell component="th" scope="row">{row.start} - {row.end}</TableCell>
<TableCell>{row.start}</TableCell>
<TableCell align="right">{row.start}</TableCell>
<TableCell align="right">{row.start}</TableCell>
</TableRow>
{/* ))
: (
<TableRow>
<TableCell colSpan={8}>No Data</TableCell>
</TableRow>
)
} */}
</TableBody>
</Table>
</Box>}
</Collapse>
</TableCell>
</TableRow>
</React.Fragment>
);
}
// Dummy Default Data
const [dataTableIsLoading, setDataTableLoading] = React.useState(true);
const [dataTableData, setDataTableData] = React.useState<LaravelPaginatedData>({
current_page: 1,
data: [],
path: "",
first_page_url: "",
last_page: 1,
last_page_url: "",
next_page_url: "",
prev_page_url: "",
per_page: 10,
from: 0,
to: 0,
total: 0
});
const loadDataTableData = async (appliedFilter = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/corporates/'+id+'/corporate-benefits', { params: filter });
// console.log(response.data);
setDataTableLoading(false);
setDataTableData(response.data);
}
const headStyle = {
fontWeight: 'bold',
};
const applyFilter = async (searchFilter) => {
await loadDataTableData({ "search" : searchFilter });
setSearchParams({ "search" : searchFilter });
}
useEffect(() => {
loadDataTableData();
}, [])
return (
<Stack>
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter}/>
<Button
id="upload-button"
variant='outlined'
startIcon={<AddIcon />} sx={{ p: 1.8 }}
>
Create
</Button>
</Stack>
<Card>
{/* The Main Table */}
<TableContainer component={Paper}>
<Table aria-label="collapsible table">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left" />
<TableCell style={headStyle} align="left">Code</TableCell>
<TableCell style={headStyle} align="left">Name</TableCell>
<TableCell style={headStyle} align="right">Status</TableCell>
<TableCell style={headStyle} align="right">Action</TableCell>
</TableRow>
</TableBody>
{dataTableIsLoading ?
(
<TableBody>
<TableRow>
<TableCell colSpan={8} align="center">Loading</TableCell>
</TableRow>
</TableBody>
) : (
dataTableData.data.length == 0 ?
(
<TableBody>
<TableRow>
<TableCell colSpan={8} align="center">No Data</TableCell>
</TableRow>
</TableBody>
) : (
<TableBody>
{dataTableData.data.map(row => (
<Row key={row.code} row={row} />
))}
</TableBody>
)
)}
</Table>
</TableContainer>
</Card>
</Stack>
);
}

View File

@@ -0,0 +1,247 @@
import * as Yup from 'yup';
import { yupResolver } from "@hookform/resolvers/yup";
import { Card, Collapse, Divider, Grid, Stack, Typography } from "@mui/material";
import { useForm } from "react-hook-form";
import { useParams } from "react-router-dom";
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
import { FormProvider, RHFCheckbox, RHFSelect, RHFTextField } from "../../../components/hook-form";
import Page from "../../../components/Page";
import useSettings from "../../../hooks/useSettings";
import CorporateTabNavigations from "../CorporateTabNavigations";
import DivisionsList from "./List";
import { useMemo, useState } from 'react';
export default function PlanCreate() {
const { themeStretch } = useSettings();
const { id } = useParams();
const NewDivisionSchema = Yup.object().shape({
name: Yup.string().required('Name is required'),
code: Yup.string().required('Corporate Code is required'),
active: Yup.boolean().required('Corporate Status is required'),
});
const defaultValues = useMemo(
() => ({
code: '',
}),
[]
);
const methods = useForm({
resolver: yupResolver(NewDivisionSchema),
defaultValues,
});
const {
reset,
watch,
control,
setValue,
getValues,
setError,
handleSubmit,
formState: { isSubmitting },
} = methods;
const onSubmit = async (data: any) => {
console.log(data);
};
const [open, setOpen] = useState(false);
const benefits = [
{
'category' : 'General Practitioner',
'childs' : [
{
'name' : 'External Doctor Online',
'code' : 'gp-external-doctor-online'
},
{
'name' : 'External Doctor Offline',
'code' : 'gp-external-doctor-offline'
},
{
'name' : 'Internal Doctor Online',
'code' : 'gp-internal-doctor-online'
},
{
'name' : 'Internal Doctor Offline',
'code' : 'gp-internal-doctor-offline'
},
]
},
{
'category' : 'Specialist',
'childs' : [
{
'name' : 'External Doctor Online',
'code' : 'sp-external-doctor-online'
},
{
'name' : 'External Doctor Offline',
'code' : 'sp-external-doctor-offline'
},
{
'name' : 'Internal Doctor Online',
'code' : 'sp-internal-doctor-online'
},
{
'name' : 'Internal Doctor Offline',
'code' : 'sp-internal-doctor-offline'
},
]
},
{
'category' : 'Medicines',
'childs' : [
{
'name' : 'Vitamins',
'code' : 'medicines-vitamins'
},
{
'name' : 'Delivery Fee',
'code' : 'medicines-delivery-fee'
},
]
},
];
const products = [
{
'name' : 'Inpatient',
'code' : 'IP',
},
{
'name' : 'Outpatient',
'code' : 'OP',
},
{
'name' : 'Dental',
'code' : 'DT',
},
{
'name' : 'Dental',
'code' : 'DTL',
},
{
'name' : 'Matternity',
'code' : 'MT',
},
{
'name' : 'Special Benefit',
'code' : 'SB',
},
];
return (
<Page title="Create Plan">
<HeaderBreadcrumbs
heading={'Create Plan'}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Corporates',
href: '/corporates',
},
{
name: 'Corporate Name',
href: '/corporates/'+id,
},
{
name: 'Plans',
href: '/corporates/'+id+'/plans',
},
{
name: 'Create',
href: '/corporates/'+id+'/plans/create',
},
]}
/>
<Grid container spacing={2}>
<Grid item xs={12}>
<Card sx={{ p: 2 }}>
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Stack spacing={3}>
<Typography variant="h6">Plan Detail</Typography>
<RHFTextField name="name" label="Name" />
<RHFTextField name="code" label="Code" />
<RHFTextField name="limit" label="Limit" />
<RHFTextField name="start" label="Start (YYYY-MM-DD)" />
<RHFTextField name="end" label="End (YYYY-MM-DD)" />
<Typography variant="h6">Benefit Configuration</Typography>
<Divider orientation="horizontal" flexItem />
<Stack spacing={3} divider={<Divider orientation="horizontal" flexItem />}>
<Stack spacing={2}>
<RHFCheckbox name="a" label='Outpatient'/>
{benefits.map(row => (
<Collapse in={true} timeout="auto" unmountOnExit >
<Typography>{row.category}</Typography>
<Grid container>
{row.childs.map(benefit => (
<Grid item xs={6}>
<RHFCheckbox name={benefit.code} label={benefit.name}/>
</Grid>
))}
</Grid>
</Collapse>
))}
<Typography>Admin Fee</Typography>
<Grid container>
{benefits.map(row => (
<Grid item xs={4}>
<RHFCheckbox name="cat" label={row.category}/>
</Grid>
))}
</Grid>
</Stack>
<Stack spacing={2}>
<RHFCheckbox name="a" label='Inpatient'/>
{benefits.map(row => (
<Collapse in={true} timeout="auto" unmountOnExit >
<Typography>{row.category}</Typography>
<Grid container>
{row.childs.map(benefit => (
<Grid item xs={6}>
<RHFCheckbox name={benefit.code} label={benefit.name}/>
</Grid>
))}
</Grid>
</Collapse>
))}
<Typography>Admin Fee</Typography>
<Grid container>
{benefits.map(row => (
<Grid item xs={4}>
<RHFCheckbox name="cat" label={row.category}/>
</Grid>
))}
</Grid>
</Stack>
</Stack>
</Stack>
</FormProvider>
</Card>
</Grid>
</Grid>
</Page>
);
}

View File

@@ -0,0 +1,53 @@
import { Card, Grid } from "@mui/material";
import { useParams } from "react-router-dom";
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
import Page from "../../../components/Page";
import useSettings from "../../../hooks/useSettings";
import CorporateTabNavigations from "../CorporateTabNavigations";
import DivisionsList from "./List";
export default function Divisions() {
const { themeStretch } = useSettings();
const { id } = useParams();
return (
<Page title="Corporate Plan">
<HeaderBreadcrumbs
heading={'Corporate Plan'}
links={[
{
name: 'Corporates',
href: '/corporates',
},
{
name: 'Corporate Name',
href: '/corporates/'+id,
},
{
name: 'Corporate Plan',
href: '/corporates/'+id+'/divisions',
},
]}
/>
<Grid container spacing={2}>
<Grid item xs={8}>
<Card>
<CorporateTabNavigations position={'corporate-plans'} />
<DivisionsList />
</Card>
</Grid>
<Grid item xs={4}>
<Card sx={{ p: 2 }}>
Corporate Detail Goes Here
&nbsp;
</Card>
</Grid>
</Grid>
</Page>
);
}

View File

@@ -0,0 +1,221 @@
// @mui
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup } from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel';
// hooks
import React, { Component, useEffect, useRef, useState } from 'react';
import useSettings from '../../../hooks/useSettings';
import { useParams, useSearchParams } from 'react-router-dom';
// components
import axios from '../../../utils/axios';
import { Plan } from '../../../@types/corporates';
import { LaravelPaginatedData } from '../../../@types/paginated-data';
export default function PlanList() {
const { themeStretch } = useSettings();
const { id } = useParams();
const [searchParams, setSearchParams] = useSearchParams();
function SearchInput(props: any) {
// SEARCH
const searchInput = useRef<HTMLInputElement>(null);
const [searchText, setSearchText] = useState("");
const handleSearchChange = (event: any) => {
const newSearchText = event.target.value ?? ''
setSearchText(newSearchText);
}
const handleSubmit = (event: any) => {
event.preventDefault();
props.onSearch(searchText); // Trigger to Parent
}
useEffect(() => {
// console.log('Search Input: useEffect')
setSearchText(searchParams.get('search') ?? '');
}, [searchParams])
return (
<form onSubmit={handleSubmit} style={{ width: '100%' }}>
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/>
</form>
);
}
// Called on every row to map the data to the columns
function createData( plan: Plan ): Plan {
return {
...plan,
}
}
// Generate the every row of the table
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell>
<IconButton
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton>
</TableCell>
<TableCell align="left">{row.id}</TableCell>
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.name}</TableCell>
<TableCell align="left">{row.description}</TableCell>
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
<TableCell align="right"><Button variant="outlined" color="success" size="small">Edit</Button></TableCell>
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={10}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
<Typography variant="body2" gutterBottom component="div">
No Extra Data
</Typography>
</Box>
{false && <Box sx={{ margin: 1 }}>
<Typography variant="h6" gutterBottom component="div">
Rules
</Typography>
<Table size="small" aria-label="purchases">
<TableHead>
<TableRow>
<TableCell>Date</TableCell>
<TableCell>Customer</TableCell>
<TableCell align="right">Amount</TableCell>
<TableCell align="right">Total price ($)</TableCell>
</TableRow>
</TableHead>
<TableBody>
{/* {row.history ? row.history.map((historyRow) => ( */}
<TableRow key={row.id}>
<TableCell component="th" scope="row">{row.start} - {row.end}</TableCell>
<TableCell>{row.start}</TableCell>
<TableCell align="right">{row.start}</TableCell>
<TableCell align="right">{row.start}</TableCell>
</TableRow>
{/* ))
: (
<TableRow>
<TableCell colSpan={8}>No Data</TableCell>
</TableRow>
)
} */}
</TableBody>
</Table>
</Box>}
</Collapse>
</TableCell>
</TableRow>
</React.Fragment>
);
}
// Dummy Default Data
const [dataTableIsLoading, setDataTableLoading] = React.useState(true);
const [dataTableData, setDataTableData] = React.useState<LaravelPaginatedData>({
current_page: 1,
data: [],
path: "",
first_page_url: "",
last_page: 1,
last_page_url: "",
next_page_url: "",
prev_page_url: "",
per_page: 10,
from: 0,
to: 0,
total: 0
});
const loadDataTableData = async (appliedFilter = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/corporates/'+id+'/corporate-plans', { params: filter });
// console.log(response.data);
setDataTableLoading(false);
setDataTableData(response.data);
}
const headStyle = {
fontWeight: 'bold',
};
const applyFilter = async (searchFilter) => {
await loadDataTableData({ "search" : searchFilter });
setSearchParams({ "search" : searchFilter });
}
useEffect(() => {
loadDataTableData();
}, [])
return (
<Stack>
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter}/>
<Button
id="upload-button"
variant='outlined'
startIcon={<AddIcon />} sx={{ p: 1.8 }}
>
Create
</Button>
</Stack>
<Card>
{/* The Main Table */}
<TableContainer component={Paper}>
<Table aria-label="collapsible table">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left" />
<TableCell style={headStyle} align="left">ID</TableCell>
<TableCell style={headStyle} align="left">Code</TableCell>
<TableCell style={headStyle} align="left">Name</TableCell>
<TableCell style={headStyle} align="left">Description</TableCell>
</TableRow>
</TableBody>
{dataTableIsLoading ?
(
<TableBody>
<TableRow>
<TableCell colSpan={8} align="center">Loading</TableCell>
</TableRow>
</TableBody>
) : (
dataTableData.data.length == 0 ?
(
<TableBody>
<TableRow>
<TableCell colSpan={8} align="center">No Data</TableCell>
</TableRow>
</TableBody>
) : (
<TableBody>
{dataTableData.data.map(row => (
<Row key={row.code} row={row} />
))}
</TableBody>
)
)}
</Table>
</TableContainer>
</Card>
</Stack>
);
}

View File

@@ -16,24 +16,32 @@ export default function CorporateTabNavigations({ position }: Props) {
const mainTabItems = [
{
'path' : 'members',
'label': 'Member List',
'path' : '',
'label': 'Dashboard',
},
{
'path' : 'claim-history',
'label': 'Claim History',
},
{
'path' : 'divisions',
'label': 'Divisions',
'path' : 'corporate-plans',
'label': 'Corporate Plan',
},
{
'path' : 'plans',
'label': 'Plans',
},
{
'path' : 'corporate-benefits',
'label': 'Corporate Benefit',
},
{
'path' : 'benefits',
'label': 'Benefit & Exclusion',
'label': 'Benefit',
},
{
'path' : 'divisions',
'label': 'Divisions',
},
{
'path' : 'members',
'label': 'Member List',
},
{
'path' : 'hospitals',
@@ -43,6 +51,10 @@ export default function CorporateTabNavigations({ position }: Props) {
'path' : 'formularium',
'label': 'Formularium',
},
{
'path' : 'claim-history',
'label': 'Claim History',
},
];
useEffect(() => {
let currentIndex = mainTabItems.findIndex(item => item.path === position);

View File

@@ -224,7 +224,7 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
</Grid>
</Grid>
<RHFTextField name="policy_total_premi" label="Total Premi" />
<RHFTextField name="policy_total_premi" label="Deposit Intial Fund" />
<Stack spacing={1}>
<Typography>Minimal Deposit Policy Level</Typography>

View File

@@ -19,7 +19,6 @@ export default function Divisions() {
<HeaderBreadcrumbs
heading={'Corporate Plan'}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Corporates',
href: '/corporates',
@@ -29,8 +28,8 @@ export default function Divisions() {
href: '/corporates/'+id,
},
{
name: 'Plans',
href: '/corporates/'+id+'/divisions',
name: 'Plan',
href: '/corporates/'+id+'/plans',
},
]}
/>

View File

@@ -14,7 +14,7 @@ import axios from '../../../utils/axios';
import { Plan } from '../../../@types/corporates';
import { LaravelPaginatedData } from '../../../@types/paginated-data';
export default function PlanList() {
export default function CorporatePlanList() {
const { themeStretch } = useSettings();
const { id } = useParams();
const [searchParams, setSearchParams] = useSearchParams();
@@ -35,7 +35,7 @@ export default function PlanList() {
}
useEffect(() => {
console.log('Search Input: useEffect')
// console.log('Search Input: useEffect')
setSearchText(searchParams.get('search') ?? '');
}, [searchParams])

View File

@@ -194,12 +194,11 @@ export default function Corporates() {
const { id } = useParams();
return (
<Page title="Corporate Detail">
<Page title="Dashboard">
<HeaderBreadcrumbs
heading={'Corporate Detail'}
heading={'Corporate Dashboard'}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Corporates',
href: '/corporates',
@@ -215,7 +214,7 @@ export default function Corporates() {
{/* <Container maxWidth={themeStretch ? false : 'xl'}> */}
<Card>
<Stack spacing="3">
<CorporateTabNavigations position="any"/>
<CorporateTabNavigations position=""/>
<Grid container spacing={3}>
<Grid item xs={12} sx={{ p:2 }}>

View File

@@ -109,18 +109,26 @@ export default function Router() {
},
{
path: 'corporates/:id/plans/create',
element: <CorporatePlansCreate />,
element: <PlanCreate />,
},
{
path: 'corporates/:id/plans',
element: <Plans />,
},
{
path: 'corporates/:id/corporate-plans',
element: <CorporatePlans />,
},
{
path: 'corporates/:id/benefits/create',
element: <CorporateBenefitsCreate />,
element: <BenefitCreate />,
},
{
path: 'corporates/:id/benefits',
element: <Benefits />,
},
{
path: 'corporates/:id/corporate-benefits',
element: <CorporateBenefits />,
},
]
@@ -171,10 +179,20 @@ const MedicinesCreate = Loadable(lazy(() => import('../pages/Medicines/Create'))
const Corporate = Loadable(lazy(() => import('../pages/Corporates/Index')));
const CorporateCreate = Loadable(lazy(() => import('../pages/Corporates/Create')));
const CorporateShow = Loadable(lazy(() => import('../pages/Corporates/Show')));
const CorporateDivisions = Loadable(lazy(() => import('../pages/Corporates/Division/Index')));
const CorporateDivisionsCreate = Loadable(lazy(() => import('../pages/Corporates/Division/Create')));
const CorporateMembers = Loadable(lazy(() => import('../pages/Corporates/Member/Index')));
const CorporateBenefitsCreate = Loadable(lazy(() => import('../pages/Corporates/Benefit/Create')));
const CorporateBenefits = Loadable(lazy(() => import('../pages/Corporates/Benefit/Index')));
const CorporatePlansCreate = Loadable(lazy(() => import('../pages/Corporates/Plan/Create')));
const CorporatePlans = Loadable(lazy(() => import('../pages/Corporates/Plan/Index')));
const BenefitCreate = Loadable(lazy(() => import('../pages/Corporates/Benefit/Create')));
const Benefits = Loadable(lazy(() => import('../pages/Corporates/Benefit/Index')));
const CorporateBenefitsCreate = Loadable(lazy(() => import('../pages/Corporates/CorporateBenefit/Create')));
const CorporateBenefits = Loadable(lazy(() => import('../pages/Corporates/CorporateBenefit/Index')));
// const PlanCreate = Loadable(lazy(() => import('../pages/Corporates/CorporatePlan/Create')));
const CorporatePlans = Loadable(lazy(() => import('../pages/Corporates/CorporatePlan/Index')));
const PlanCreate = Loadable(lazy(() => import('../pages/Corporates/Plan/Create')));
const Plans = Loadable(lazy(() => import('../pages/Corporates/Plan/Index')));