3 Commits

Author SHA1 Message Date
R
32efc28043 [WIP] Claim 2022-12-08 12:26:29 +07:00
R
7d8a60f207 [WIP] Claims 2022-12-07 17:29:48 +07:00
R
aac9fcf58b [WIP] Claims 2022-12-07 12:00:58 +07:00
49 changed files with 2146 additions and 1707 deletions

View File

@@ -81,7 +81,7 @@ class AuthController extends Controller
);
}
return Helper::responseJson(status: 'error', message: 'OTP yang anda masukan salah!');
return Helper::responseJson(message: 'OTP yang anda masukan salah!');
}
public function logout(Request $request)

View File

@@ -1,75 +0,0 @@
<?php
namespace Modules\Client\Http\Controllers\Api;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
class CorporateController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request)
{
$userLogin = Auth::user();
$corporate = $userLogin->managedCorporates()->select(['corporates.id', 'corporates.name'])->get();
// corporate policy, all member list, notification
return response()->json($corporate);
}
/**
* 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($corporate_id)
{
//
}
/**
* Show the form for editing the specified resource.
* @param int $id
* @return Renderable
*/
public function edit($id)
{
return view('client::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

@@ -5,8 +5,6 @@ namespace Modules\Client\Http\Controllers\Api;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Modules\Client\Transformers\DashboardResources;
class DashboardController extends Controller
{
@@ -14,16 +12,18 @@ class DashboardController extends Controller
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request, $corporate_id)
public function index()
{
$user = Auth::user();
$currentCorporate = $user->managedCorporates()
->with(['currentPolicy', 'employees'])
->find($corporate_id);
$data = DashboardResources::make($currentCorporate);
$user = auth()->user();
return response()->json($data);
$corporate = $user->managedCorporates()
->withCount('employees')
->with(['policies' => function ($policy) {
$policy->limit(1)->latest();
}])
->first();
return response()->json(compact('corporate'));
}
/**

View File

@@ -1,120 +0,0 @@
<?php
namespace Modules\Client\Http\Controllers\Api;
use App\Models\CorporateDivision;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class DivisionController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request)
{
$user = Auth::user();
$corporate = $user->managedCorporates()->where('active', 1)->first();
$benefits = CorporateDivision::query()
->where('corporate_id', $corporate->id)
->get(['id', 'name']);
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, $corporate_id)
{
$request->validate([
'code' => [
'required',
],
'name' => 'required'
]);
$newCorporatePlan = CorporateDivision::create([
'corporate_id' => $corporate_id,
'code' => $request->code,
'name' => $request->name,
]);
return $newCorporatePlan;
}
/**
* 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($corporate_id, $id)
{
$corporatePlan = CorporateDivision::findOrFail($id);
return $corporatePlan;
}
/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Renderable
*/
public function update(Request $request, $corporate_id, $id)
{
$corporatePlan = CorporateDivision::findOrFail($id);
$request->validate([
'code' => [
'required',
Rule::unique('corporate_plans')->where('corporate_id', $corporate_id)->ignore($corporatePlan->id)
],
'name' => 'required'
]);
$corporatePlan->fill([
'code' => $request->code,
'name' => $request->name,
'active' => $request->active,
])->save();
return $corporatePlan;
}
/**
* Remove the specified resource from storage.
* @param int $id
* @return Renderable
*/
public function destroy($id)
{
//
}
}

View File

@@ -5,7 +5,6 @@ namespace Modules\Client\Http\Controllers\Api;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
class UserController extends Controller
{
@@ -15,10 +14,7 @@ class UserController extends Controller
*/
public function index()
{
$userLogin = Auth::user();
$corporateSelected = $userLogin->managedCorporates()->select('corporates.id')->where('active', 1)->first();
return response()->json(['user' => $userLogin, 'corporate' => $corporateSelected]);
return response()->json(auth()->user());
}
/**

View File

@@ -1,9 +1,7 @@
<?php
use Modules\Client\Http\Controllers\Api\AuthController;
use Modules\Client\Http\Controllers\Api\CorporateController;
use Modules\Client\Http\Controllers\Api\DashboardController;
use Modules\Client\Http\Controllers\Api\DivisionController;
use Modules\Client\Http\Controllers\Api\MemberController;
use Modules\Client\Http\Controllers\Api\UserController;
@@ -28,19 +26,9 @@ Route::prefix('client')->group(function () {
Route::middleware('auth:sanctum')->group(function () {
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
Route::get('user', [UserController::class, 'index']);
Route::get('/user', [UserController::class, 'index']);
Route::prefix('{corporate_id}')->group(function() {
Route::get('asd', function ($corporate_id) {
return $corporate_id;
});
Route::get('dashboard', [DashboardController::class, 'index']);
Route::get('corporate', [CorporateController::class, 'index']);
Route::get('corporate/{corporate_id}', [CorporateController::class, 'show']);
Route::get('division', [DivisionController::class, 'index']);
Route::get('members', [MemberController::class, 'index']);
});
});
});

View File

@@ -1,38 +0,0 @@
<?php
namespace Modules\Client\Transformers;
use App\Helpers\Helper;
use Illuminate\Http\Resources\Json\JsonResource;
class DashboardResources extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
$myLimitBalance = (int)$this->currentPolicy->limit_balance;
$myLimitTotal = (int)$this->currentPolicy->total_premi;
$lockBalance = (int)$this->currentPolicy->minimal_stop_service_net;
$lockPercentage = (int)$this->currentPolicy->minimal_stop_service_percentage;
return [
'policy' => [
'myLimit' => [
'balance' => $myLimitBalance,
'total' => $myLimitTotal,
'percentage' => ($myLimitBalance / $myLimitTotal) * 100,
],
'lockLimit' => [
'balance' => $lockBalance,
'percentage' => $lockPercentage
]
],
];
}
}

View File

@@ -1,25 +0,0 @@
<?php
namespace Modules\Client\Transformers;
use Illuminate\Http\Resources\Json\JsonResource;
class MemberResources extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return [
'memberId' => $this->member_id,
'full_name' => $this->full_name,
'division' => $this->division->name,
'employeeLimit' => '',
'status' => $this->active
];
}
}

View File

@@ -6,10 +6,10 @@ use App\Models\Benefit;
use App\Models\Claim;
use App\Models\Icd;
use App\Models\Member;
use App\Services\ClaimService;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\Internal\Services\ClaimService;
class ClaimController extends Controller
{
@@ -65,7 +65,7 @@ class ClaimController extends Controller
// Store Claim
if ($validation['isEligible']) {
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit);
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit, 'requested');
} else {
return response()->json([
'data' => $validation,
@@ -83,7 +83,17 @@ class ClaimController extends Controller
*/
public function show($id)
{
return view('internal::show');
$claim = Claim::query()
->with([
'member',
'member.currentPlan',
'diagnosis',
'benefit',
'files'
])
->findOrFail($id);
return response()->json($claim);
}
/**

View File

@@ -26,17 +26,18 @@ class CorporateController extends Controller
public function index(Request $request)
{
$corporates = Corporate::query()
->when($request->search, function ($query, $search) {
return $query->where('name', 'LIKE', '%' . $search . '%')
->orWhere('code', 'LIKE', '%' . $search . '%');
})
->with('currentPolicy', 'subCorporates')
->withCount([
'employees',
'corporateBenefits',
])
->where('type', 'corporate')
->paginate(10);
->when($request->search, function ($query, $search) {
return $query->where('name', 'LIKE', '%'.$search.'%')
->orWhere('code', 'LIKE', '%'.$search.'%');
})
->with('currentPolicy', 'subCorporates')
->withCount([
'employees',
'corporatePlans',
'corporateBenefits',
])
->where('type', 'corporate')
->paginate(10);
return $corporates;
}
@@ -47,10 +48,10 @@ class CorporateController extends Controller
*/
public function create()
{
$corporateGroups = Corporate::whereNull('parent_id')->get()->map(function ($corporate) {
$corporateGroups = Corporate::whereNull('parent_id')->get()->map(function($corporate) {
return [
'value' => $corporate->id,
'label' => $corporate->name . ' (' . $corporate->code . ')',
'label' => $corporate->name.' ('.$corporate->code.')',
];
});
@@ -79,7 +80,7 @@ class CorporateController extends Controller
'policy_stop_service_percentage' => 'required_with:policy_code',
'policy_stop_service_net' => 'required_with:policy_code',
]);
try {
DB::beginTransaction();
$corporate_data = $request->all();
@@ -119,7 +120,14 @@ class CorporateController extends Controller
*/
public function show($id)
{
return view('internal::show');
$corporate = Corporate::query()
->with(['currentPolicy'])
->withCount('corporatePlans')
->withCount('employees')
// ->withCount('employees.claims')
->findOrFail($id);
return response()->json($corporate);
}
/**
@@ -154,7 +162,7 @@ class CorporateController extends Controller
'policy_stop_service_percentage' => 'required_with:policy_code',
'policy_stop_service_net' => 'required_with:policy_code',
]);
try {
DB::beginTransaction();
@@ -198,8 +206,7 @@ class CorporateController extends Controller
//
}
public function activation(Request $request, $corporate_id)
{
public function activation(Request $request, $corporate_id) {
$request->validate([
'active' => 'required'
]);
@@ -223,16 +230,16 @@ class CorporateController extends Controller
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
]);
// dd($request->toArray());
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
$file = $request->file('file')->storeAs('temp', $file_name);
$corporate = Corporate::findOrFail($corporate_id);
$import = new ImportService();
$import->read(Storage::path('temp/' . $file_name));
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
$import->read(Storage::path('temp/'.$file_name));
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
if (!in_array($sheet->getName(), ['Plan', 'Benefit'])) {
if ( !in_array($sheet->getName(), ['Plan', 'Benefit']) ) {
continue;
} else {
if ($sheetIndex == 1) { // Rename First Sheet to Writer
@@ -243,9 +250,9 @@ class CorporateController extends Controller
$nextWriterSheet->setName($sheet->getName());
}
if ($sheet->getName() == 'Plan') {
if ( $sheet->getName() == 'Plan' ) {
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
} else if ($sheet->getName() == 'Benefit') {
} else if ( $sheet->getName() == 'Benefit' ) {
$headers_map_to_table_fields = Benefit::$doc_headers_to_field_map;
}
@@ -253,6 +260,7 @@ class CorporateController extends Controller
$result_headers = array_keys($headers_map_to_table_fields);
$result_headers = array_merge($result_headers, ['Ingest Code', 'Ingest Note']);
$import->addArrayToRow($result_headers);
}
$doc_headers_indexes = [];
@@ -260,8 +268,8 @@ class CorporateController extends Controller
if ($index == 1) { // First Row Must be Header
foreach ($row->getCells() as $index => $cell) {
$title = $cell->getValue();
$title = preg_replace("/\r|\n/", " ", $title);
$title = preg_replace('/\xc2\xa0/', " ", $title);
$title = preg_replace( "/\r|\n/", " ", $title );
$title = preg_replace('/\xc2\xa0/', " ", $title );
$title = rtrim($title);
$title = ltrim($title);
$doc_headers_indexes[$index] = $title;
@@ -277,9 +285,9 @@ class CorporateController extends Controller
try { // Process the Row Data
$corporateService = new CorporateService();
if ($sheet->getName() == 'Plan') {
if ( $sheet->getName() == 'Plan' ) {
$corporateService->handlePlanRow($corporate, $row_data);
} else if ($sheet->getName() == 'Benefit') {
} else if ( $sheet->getName() == 'Benefit' ) {
$corporateService->handleBenefitRow($corporate, $row_data);
}
@@ -288,6 +296,7 @@ class CorporateController extends Controller
'Ingest Code' => 200,
'Ingest Note' => 'Success',
]), $sheet->getName());
} catch (ImportRowException $e) {
// Write Data Validation Error to File
$import->addArrayToRow(array_merge($row_data, [
@@ -306,7 +315,7 @@ class CorporateController extends Controller
}
}
$import->reader->close();
Storage::delete('temp/' . $file_name);
Storage::delete('temp/'.$file_name);
$import->writer->close();
return [
@@ -314,8 +323,8 @@ class CorporateController extends Controller
// 'total_failed_row' => count($failed_plan_data),
// 'failed_row' => $failed_plan_data,
'result_file' => [
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
'name' => 'result-' . $file_name,
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
'name' => 'result-'.$file_name,
]
];
}

View File

@@ -3,6 +3,8 @@
namespace Modules\Internal\Http\Controllers\Api;
use App\Exceptions\ImportRowException;
use App\Helpers\Helper;
use App\Http\Resources\MemberDataTableResource;
use App\Models\Corporate;
use App\Models\Member;
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
@@ -27,23 +29,26 @@ class CorporateMemberController extends Controller
public function index(Request $request, $corporate_id)
{
$members = Member::query()
->filter($request->all())
// ->where('corporate_id', $corporate_id)
->whereHas('employeds', function ($employeds) use ($corporate_id) {
$employeds->where('corporate_id', $corporate_id);
})
->with([
'employeds',
'currentPolicy',
// 'claims' => function ($claim) {
// return $claim->used();
// }
])
->with('currentPlan')
->paginate()
->appends($request->all());
return $members;
->filter($request->all())
// ->where('corporate_id', $corporate_id)
->whereHas('employeds', function ($employeds) use ($corporate_id) {
$employeds->where('corporate_id', $corporate_id);
})
->with([
'employeds',
'currentPolicy',
// 'claims',
'claims' => function ($claim) {
return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
// return $claim->used(now()->startOfYear(), now()->endOfYear());
}
])
->with('currentPlan')
// ->with
->paginate()
->appends($request->all());
return Helper::paginateResources(MemberDataTableResource::collection($members));
}
/**
@@ -111,17 +116,17 @@ class CorporateMemberController extends Controller
{
$request->validate([
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
]);
]);
$corporate = Corporate::findOrFail($corporate_id)->load('currentPolicy');
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
$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));
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
$reader->open(Storage::path('temp/'.$file_name));
$writer = WriterEntityFactory::createXLSXWriter();
$writer->openToFile(Storage::disk('public')->path('temp/result-' . $file_name));
$writer->openToFile(Storage::disk('public')->path('temp/result-'.$file_name));
$headers_map_to_table_fields = $this->memberEnrollmentService->doc_headers_to_field_map;
@@ -139,8 +144,8 @@ class CorporateMemberController extends Controller
foreach ($row->getCells() as $index => $cell) {
// Clear up the string and remove all spaces
$title = $cell->getValue();
$title = preg_replace("/\r|\n/", " ", $title);
$title = preg_replace('/\xc2\xa0/', " ", $title);
$title = preg_replace( "/\r|\n/", " ", $title );
$title = preg_replace('/\xc2\xa0/', " ", $title );
$title = rtrim($title);
$title = ltrim($title);
$doc_headers_indexes[$index] = $title;
@@ -157,7 +162,7 @@ class CorporateMemberController extends Controller
try {
// dd($new_member_data);
$rowResponse = $this->memberEnrollmentService->handleImportRow($corporate, $new_member_data);
// Write Success Result to File
$singleRow = WriterEntityFactory::createRow($this->memberEnrollmentService->makeResultRowWithResultFormat($rowResponse));
$writer->addRow($singleRow);
@@ -182,13 +187,14 @@ class CorporateMemberController extends Controller
$failed_member_data[] = ['row_number' => $index, 'error' => $e->getMessage()];
}
}
}
}
break; //only read first sheet
}
$reader->close();
$writer->close();
Storage::delete('temp/' . $file_name);
Storage::delete('temp/'.$file_name);
// throw(404);
return [
@@ -196,8 +202,8 @@ class CorporateMemberController extends Controller
'total_failed_row' => count($failed_member_data),
'failed_row' => $failed_member_data,
'result_file' => [
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
'name' => 'result-' . $file_name,
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
'name' => 'result-'.$file_name,
]
];
}

View File

@@ -17,11 +17,11 @@ class DivisionController extends Controller
public function index(Request $request, $corporate_id)
{
$benefits = CorporateDivision::query()
->filter($request->all())
->where('corporate_id', $corporate_id)
->paginate(0)
->appends($request->all());
->filter($request->all())
->where('corporate_id', $corporate_id)
->paginate(0)
->appends($request->all());
return $benefits;
}
@@ -44,6 +44,7 @@ class DivisionController extends Controller
$request->validate([
'code' => [
'required',
Rule::unique('corporate_plans')->where('corporate_id', $corporate_id)
],
'name' => 'required'
]);

View File

@@ -100,6 +100,7 @@ Route::prefix('internal')->group(function () {
Route::get('claims', [ClaimController::class, 'index']);
Route::post('claims', [ClaimController::class, 'store']);
Route::get('claims/{id}', [ClaimController::class, 'show']);
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
});

View File

@@ -7,109 +7,5 @@ use Illuminate\Support\Facades\DB;
class ClaimService
{
public static function checkMemberEligibility($member, $benefit, $diagnosis, $totalClaim = 0)
{
$currentPlan = $member->currentPlan;
$policy = $member->currentPolicy;
$corporate = $policy->corporate;
$isEligible = true;
$validationErrors = [];
// Eligibility Validation
if (!in_array($member->marital_status, explode(',', $benefit->msc))) {
$validationErrors[] = [
'error' => 'msc',
'message' => 'Only '.$benefit->msc
];
$isEligible = false;
}
if (!in_array($member->gender_code, explode(',', $benefit->genders))) {
$validationErrors[] = [
'error' => 'genders',
'message' => 'Only '.$benefit->genders
];
$isEligible = false;
}
if (!empty($benefit->min_age) && $member->age < $benefit->min_age) {
$validationErrors[] = [
'error' => 'min_age',
'message' => 'Minimum Age is '.$benefit->min_age
];
$isEligible = false;
}
if (!empty($benefit->max_age) && $member->age > $benefit->max_age) {
$validationErrors[] = [
'error' => 'max_age',
'message' => 'Maximum Age is '.$benefit->min_age
];
$isEligible = false;
}
// TODO complete validations
// Limit Validation
if ($totalClaim > 0) {
if (bcsub($corporate->limit_balance, $totalClaim) < 0) {
$validationErrors[] = [
'error' => 'corporate_limit',
'message' => 'Corporate Limit cannot cover this'
];
$isEligible = false;
}
if (bcsub($benefit->limit_amount, $totalClaim) < 0) {
$validationErrors[] = [
'error' => 'benefit_limit',
'message' => 'Benefit Limit cannot cover this'
];
$isEligible = false;
}
// TODO complete validations
}
return [
'isEligible' => $isEligible,
'errors' => $validationErrors
];
}
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit)
{
try {
DB::beginTransaction();
$claim = Claim::create([
'member_id' => $member->id,
'diagnosis_id' => $diagnosis->id,
'total_claim' => $totalClaim,
'currency' => 'IDR',
'plan_id' => $member->currentPlan->id,
'benefit_id' => $benefit->id,
]);
$policy = $member->currentPolicy;
$policy->limitJournals()->create([
'previous_balance' => $policy->limit_balance,
'total_credit' => $totalClaim,
'type' => 'credit',
'balance' => bcsub($policy->limit_balance, $totalClaim),
'description' => 'Log for Claim #'. $claim->code,
]);
DB::commit();
return $claim;
} catch (\Exception $error) {
DB::rollBack();
return false;
}
}
}

View File

@@ -27,7 +27,7 @@ class MemberEnrollmentService
"Halodoc Member ID" => "halodoc_member_id",
"Corporate ID" => "corporate_id",
"NIK" => "nik",
"Division" => "division_name",
"Division" => "division_code",
"Branch Code" => "branch_code",
"Bank Info" => "banks_info",
"Language" => "language",
@@ -89,7 +89,7 @@ class MemberEnrollmentService
"Internal Use" => "internal_use_6",
"StartNoClaim" => "start_no_claim",
"EndNoClaim" => "end_no_claim",
"Option Mode" => "option_mode",
"Option Mode" => "option_mode",
"Policy Inforce" => "policy_in_force",
"Renewal activation date" => "renewal_activation_date",
"Renewal Activation Date" => "renewal_activation_date",
@@ -106,7 +106,7 @@ class MemberEnrollmentService
"halodoc_member_id" => "Halodoc Member ID",
"corporate_id" => "Corporate ID",
"nik" => "NIK",
"division_name" => "Division",
"division_code" => "Division",
"branch_code" => "Branch Code",
"banks_info" => "Bank Info",
"language" => "Language",
@@ -264,7 +264,7 @@ class MemberEnrollmentService
if (!empty($row['principal_id'])) {
throw new ImportRowException(__('enrollment.PRINCIPAL_ID_NOT_REQUIRED'), 0, null, $row);
}
if (empty($row['corporate_id'])) {
throw new ImportRowException(__('enrollment.CORPORATE_ID_REQUIRED'), 0, null, $row);
}
@@ -306,38 +306,34 @@ class MemberEnrollmentService
throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
}
if (empty($row['member_effective_date'])) {
if (empty($row['member_effective_date']) ) {
throw new ImportRowException(__('enrollment.MEMBER_EFFECTIVE_REQUIRED'), 0, null, $row);
}
// TODO EFFECTIVE DATE VALIDATION
if (empty($row['member_expiry_date'])) {
if (empty($row['member_expiry_date']) ) {
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_REQUIRED'), 0, null, $row);
}
// TODO EFFECTIVE DATE VALIDATION
// TODO FKTP VALIDATION
// TODO FKRTL VALIDATION
if (!empty($row['marital_status']) && !in_array($row['marital_status'], ['S', 'M', 'D'])) {
throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
}
if (empty($row['name'])) {
throw new ImportRowException(__('enrollment.NAME_REQUIRED'), 0, null, $row);
}
if (
!empty($row['telephone_mobile'])
&& !(substr($row['telephone_mobile'], 0, 4) == '+628' || substr($row['telephone_mobile'], 0, 3) == '628')
) {
if (!empty($row['telephone_mobile'])
&& !(substr($row['telephone_mobile'], 0, 4) == '+628' || substr($row['telephone_mobile'], 0, 3) == '628')) {
throw new ImportRowException(__('enrollment.PHONE_INVALID'), 0, null, $row);
}
if (
!empty($row['email'])
&& !filter_var($row['email'], FILTER_VALIDATE_EMAIL)
) {
if (!empty($row['email'])
&& !filter_var($row['email'], FILTER_VALIDATE_EMAIL)) {
throw new ImportRowException(__('enrollment.EMAIL_INVALID'), 0, null, $row);
}
@@ -400,16 +396,16 @@ class MemberEnrollmentService
switch ($row['record_mode']) {
case "1": // New Member
$member = Member::query()
->where('member_id', $row['member_id'])
// ->whereHas('employeds', function ($query) use ($corporate) {
// $query->where('corporate_id', $corporate->id);
// })
->first();
->where('member_id', $row['member_id'])
// ->whereHas('employeds', function ($query) use ($corporate) {
// $query->where('corporate_id', $corporate->id);
// })
->first();
// Validate If Exist Member
if ($member) {
throw new ImportRowException(__('enrollment.MEMBER_UNIQUE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
} else {
@@ -422,7 +418,7 @@ class MemberEnrollmentService
if ($memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -453,28 +449,8 @@ class MemberEnrollmentService
]);
$memberPolicy->save();
if (!empty($row['division_name'])) {
$division_id = CorporateDivision::query()->where('code', $row['division_name'])->pluck('id')->first();
if (empty($division_id)) {
$corporateCodeArray = explode(' ', $row['division_name']);
if (!empty($corporateCodeArray[1])) {
$corporateCode = substr($corporateCodeArray[0], 0, 1) . substr($corporateCodeArray[1], 0, 1);
} elseif (!empty($corporateCodeArray[2])) {
$corporateCode = substr($corporateCodeArray[0], 0, 1) . substr($corporateCodeArray[1], 0, 1);
} else {
$corporateCode = substr($row['division_name'], 0, 1);
}
$division = CorporateDivision::query()->create([
'corporate_id' => $corporate->id,
'name' => $row['division_name'],
'code' => $corporateCode,
]);
$division_id = $division->id;
}
if (!empty($row['division'])) {
$division_id = CorporateDivision::where('code', $row['division_code'])->where('')->pluck('id');
}
$member->employeds()->create([
@@ -500,13 +476,13 @@ class MemberEnrollmentService
break;
case "2": // Member Information Update (Without Replacement Card)
$member = Member::query()
->where('member_id', $row['member_id'])
->first();
->where('member_id', $row['member_id'])
->first();
// Validate If Exist Member
if (!$member) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_FOUND', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -520,23 +496,23 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
$memberPolicy->member->fill($member_data);
if (!$memberPolicy->member->isDirty()) {
throw new ImportRowException(__('enrollment.MEMBER_NO_CHANGE'), 0, null, $row);
}
$memberPolicy->member->save();
DB::commit();
} catch (\Exception $e) {
@@ -547,13 +523,13 @@ class MemberEnrollmentService
break;
case "3": // Member Deletion
$member = Member::query()
->where('member_id', $row['member_id'])
->first();
->where('member_id', $row['member_id'])
->first();
// Validate If Exist Member
if (!$member) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_FOUND', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -565,21 +541,21 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
$member = $memberPolicy->member;
$member->active = false;
$member->save();
break;
case "5": // Member Renewal Policy (without card)
@@ -590,14 +566,14 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -607,10 +583,9 @@ class MemberEnrollmentService
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
}
if (
Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
) {
if (Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
) {
throw new ImportRowException(__('enrollment.MEMBER_RENEWAL_STILL_ACTIVE'), 0, null, $row);
}
@@ -634,14 +609,14 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -650,10 +625,9 @@ class MemberEnrollmentService
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
}
if (
Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
) {
if (Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
) {
throw new ImportRowException(__('enrollment.MEMBER_RENEWAL_STILL_ACTIVE'), 0, null, $row);
}
@@ -677,7 +651,7 @@ class MemberEnrollmentService
// 'policy_id' => $row['policy_number']
// ]), 0, null, $row);
// }
// // Read Option Mode
// $option_mode = explode('!', $row['option_mode']);
// $corp_code = $option_mode[1] ?? null;
@@ -703,7 +677,7 @@ class MemberEnrollmentService
$member_id_old = $member_id[0] ?? null;
$member_id_new = $member_id[1] ?? null;
$memberPolicy = MemberPolicy::query()
->where('policy_id', $policy_number_old)
->where('member_id', $member_id_old)
@@ -712,14 +686,14 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $member_id_old,
'member_id' => $member_id_old,
'policy_id' => $policy_number_old
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $member_id_old,
'member_id' => $member_id_old,
'policy_id' => $policy_number_old
]), 0, null, $row);
}
@@ -728,12 +702,12 @@ class MemberEnrollmentService
if (!empty($row['principal_id'])) {
throw new ImportRowException(__('enrollment.PRINCIPAL_ID_NOT_REQUIRED'), 0, null, $row);
}
if (empty($row['corporate_id'])) {
throw new ImportRowException(__('enrollment.CORPORATE_ID_REQUIRED'), 0, null, $row);
}
}
if ($record_type_new == 'D') {
if (empty($row['principal_id'])) {
throw new ImportRowException(__('enrollment.PRINCIPAL_ID_REQUIRED'), 0, null, $row);
@@ -765,19 +739,19 @@ class MemberEnrollmentService
// 'policy_id' => $row['policy_number']
// ]), 0, null, $row);
// }
try {
DB::beginTransaction();
if (!empty($record_type_new)) {
if ( !empty($record_type_new) ) {
$member = $memberPolicy->member;
$member->record_type = $record_type_new;
$member->principal_id = $row['principal_id'];
$member->save();
}
if (!empty($corp_code_new)) {
if ( !empty($corp_code_new) ) {
$oldCorporate = Corporate::where('code', $corp_code_old)->first();
$newCorporate = Corporate::where('code', $corp_code_new)->first();
@@ -785,26 +759,24 @@ class MemberEnrollmentService
throw new ImportRowException(__('enrollment.CORPORATE_NOT_FOUND'), 0, null, $row);
}
$corporateEmployee = CorporateEmployee::where('corporate_id', $oldCorporate->id)
->where('member_id', $memberPolicy->member->id)
->first();
$newCorporateEmployee = CorporateEmployee::updateOrCreate(
[
'corporate_id' => $oldCorporate->id,
'member_id' => $memberPolicy->member->id
],
[
'corporate_id' => $newCorporate->id,
'member_id' => $memberPolicy->member->id
]
);
->where('member_id', $memberPolicy->member->id)
->first();
$newCorporateEmployee = CorporateEmployee::updateOrCreate([
'corporate_id' => $oldCorporate->id,
'member_id' => $memberPolicy->member->id
],
[
'corporate_id' => $newCorporate->id,
'member_id' => $memberPolicy->member->id
]);
}
if (!empty($policy_number_new)) {
if ( !empty($policy_number_new) ) {
$memberPolicy->policy_id = $policy_number_new;
$memberPolicy->save();
}
if (!empty($member_id_new)) {
if ( !empty($member_id_new) ) {
$memberPolicy->member_id = $member_id_new;
$memberPolicy->save();
@@ -828,7 +800,7 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -836,7 +808,7 @@ class MemberEnrollmentService
if (Carbon::parse(strtotime($row['member_effective_date'])) < now() || Carbon::parse(strtotime($row['member_expiry_date'])) < now()) {
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_MUST_BE_AFTER_TODAY'), 0, null, $row);
}
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse(strtotime($row['member_expiry_date']))) {
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
}
@@ -856,14 +828,14 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -879,10 +851,10 @@ class MemberEnrollmentService
$newMemberPolicy->save();
break;
// THESE MODES BELOW ARE DISABLED
// THESE MODES BELOW ARE DISABLED
case "4": // Member Update Start and End Date
throw new ImportRowException(__('MODE 4 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
break;
@@ -893,14 +865,14 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -924,9 +896,9 @@ class MemberEnrollmentService
case "8": // Member Information Update (With Replacement Card)
throw new ImportRowException(__('MODE 8 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
break;
// case "10": // No Information Available
// case "10": // No Information Available
// break;
// break;
case "11": // Advance Renewal with OLD Card No. (PRINT)
throw new ImportRowException(__('MODE 11 NOT HANDLED PROPERLY, TRY TO USE MODE 13'), 0, null, $row);
@@ -935,9 +907,9 @@ class MemberEnrollmentService
throw new ImportRowException(__('MODE 12 NOT HANDLED PROPERLY, TRY TO USE MODE 13'), 0, null, $row);
break;
// case "14": // No Information Available
// case "14": // No Information Available
// break;
// break;
case "15": // Lost Card / Change Card with new card number (Print) (Rarely Used)
throw new ImportRowException(__('MODE 15 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
@@ -946,10 +918,10 @@ class MemberEnrollmentService
throw new ImportRowException(__('MODE 16 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
break;
$plan = CorporatePlan::query()
->where('corporate_id', $corporate->id)
->where('code', $row['plan_id'])
->where('active', true)
->first();
->where('corporate_id', $corporate->id)
->where('code', $row['plan_id'])
->where('active', true)
->first();
if (!$plan) {
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
}
@@ -961,14 +933,14 @@ class MemberEnrollmentService
if (!$memberPolicy) {
throw new ImportRowException(__('enrollment.MEMBER_NOT_EXISTS', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
if ($memberPolicy->status != 'active') {
throw new ImportRowException(__('enrollment.MEMBER_INACTIVE', [
'member_id' => $row['member_id'],
'member_id' => $row['member_id'],
'policy_id' => $row['policy_number']
]), 0, null, $row);
}
@@ -1006,7 +978,7 @@ class MemberEnrollmentService
}
// This returning row with format or order as it is
public function makeResultRow($row_data)
public function makeResultRow($row_data)
{
$cells = [];
foreach ($row_data as $cellValue) {

View File

@@ -0,0 +1,22 @@
<?php
namespace Modules\Internal\Transformers;
use Illuminate\Http\Resources\Json\JsonResource;
class ClaimResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$claimData = parent::toArray($request);
$claimData['uploaded_files'] = $this->files->groupBy('type');
return $claimData;
}
}

View File

@@ -158,10 +158,10 @@ class Helper
* @param string $message
* @return JsonResponse
*/
public static function responseJson(array|object $data = [], string $status = 'success', int $statusCode = Response::HTTP_OK, string $message = 'Data berhasil di ambil'): JsonResponse
public static function responseJson(array|object $data = [], int $statusCode = Response::HTTP_OK, string $message = 'Data berhasil di ambil'): JsonResponse
{
return response()->json([
'status' => $status,
'status' => in_array($statusCode, [200, 201, 204]) ? 'success' : 'error',
'statusCode' => $statusCode,
'message' => $message,
'data' => $data,

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Api;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Models\Member;
use App\Services\ClaimService;
use Illuminate\Http\Request;
class MembershipController extends Controller
{
//
public function check(Request $request)
{
$request->validate([
'member_id' => 'required',
'birth_date' => 'required',
]);
$member = Member::where('member_id', $request->member_id)->first();
if (!$member) {
return Helper::responseJson(statusCode: 404, message: 'Member not found.');
}
if (!$member->active) {
return Helper::responseJson(statusCode: 406, message: 'The Member '.$request->member_id.' is Inactive.');
}
return Helper::responseJson(data: $member, message: 'Member Found');
}
public function checkLimit(Request $request)
{
$request->validate([
'member_id' => 'required',
'type' => 'required|in:consultation-gp,consultation-specialist,medicine'
]);
if ($request->type == 'consultation-gp') {
$benefitCode = 'OPCONS1';
}
if ($request->type == 'consultation-specialist') {
$benefitCode = 'OPCONS2';
}
if ($request->type == 'medicine') {
$benefitCode = 'OPMEDI1';
}
$member = Member::where('member_id', $request->member_id)->with(['currentCorporate', 'currentPolicy', 'currentPlan'])->first();
$limits = ClaimService::showMemberBenefitLimit($member, $benefitCode);
return Helper::responseJson(data: $limits);
}
}

View File

@@ -64,5 +64,6 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'linksehat.old.auth' => \App\Http\Middleware\LinksehatOldAuthMiddleware::class,
];
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class LinksehatOldAuthMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
if ($request->header('authorization') == 'Bearer LpMbGm0NQvFC3lUBiy1Ch3NzS0CIPSmanR12FcdP') {
return $next($request);
}
return abort(401, "Unauthenticated");
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class MemberDataTableResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
$data = parent::toArray($request);
$data['claim_grouped_by_status'] = $this->claims->groupBy('status');
$data['total_claims'] = [
'draft' => count($data['claim_grouped_by_status']['draft'] ?? []),
'requested' => count($data['claim_grouped_by_status']['requested'] ?? []),
'received' => count($data['claim_grouped_by_status']['received'] ?? []),
'approved' => count($data['claim_grouped_by_status']['approved'] ?? []),
'paid' => count($data['claim_grouped_by_status']['paid'] ?? []),
'declined' => count($data['claim_grouped_by_status']['declined'] ?? [])
];
// $data = ['fuck' => 'you'];
return $data;
}
}

View File

@@ -132,6 +132,21 @@ class Benefit extends Model
"Show Benefit Value" => 'show_benefit_value',
];
public static $max_frequency_periods = [
0 => 'Policy Period',
1 => 'Daily Visit',
2 => 'Weekly',
3 => 'Monthly',
4 => 'Yearly',
5 => 'Disability',
6 => 'Visit',
];
protected $appends = [
'max_frequency_period_name',
'max_frequency'
];
public function setAreaLimitAttribute($value)
{
$this->attributes['area_limit'] = empty($value) ? null : $value;
@@ -168,4 +183,42 @@ class Benefit extends Model
{
return $this->belongsTo(Plan::class, 'plan_code', 'code');
}
public function getMaxFrequencyPeriodNameAttribute()
{
return self::$max_frequency_periods[$this->max_frequency_period] ?? null;
}
public function getMaxFrequencyAttribute()
{
switch ($this->max_frequency_period) {
// case(0) :
// // TODO Fix This
// return null;
// break;
case(1) :
return empty($this->daily_frequency) ? 1 : $this->daily_frequency;
break;
case(2) :
return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency;
break;
case(3) :
return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency;
break;
case(4) :
return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency;
break;
case(5) :
// TODO Fix This
return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability;
break;
case(6) :
// TODO Fix This
return 1;
break;
default :
return null;
break;
}
}
}

View File

@@ -18,6 +18,17 @@ class Claim extends Model
'currency',
'plan_id',
'benefit_id',
'status',
'requested_at',
'requested_by',
'received_at',
'received_by',
'approved_at',
'approved_by',
'declined',
'declined_by',
'paid_at',
'paid_by',
];
protected $hidden = [
@@ -51,6 +62,11 @@ class Claim extends Model
});
}
public function files()
{
return $this->morphMany(File::class, 'fileable');
}
public function member()
{
return $this->belongsTo(Member::class, 'member_id');
@@ -75,7 +91,7 @@ class Claim extends Model
{
return $query
->whereIn('status', ['approved', 'paid'])
->whereBetween('requested_at', $startDate, $endDate);
->whereBetween('requested_at', [$startDate, $endDate]);
}
}

View File

@@ -44,10 +44,10 @@ class Corporate extends Model
public function currentPolicy()
{
return $this->hasOne(CorporatePolicy::class)
// ->where('start', '<=', now())
// ->where('end', '>=', now())
->where('active', true)
->latestOfMany();
// ->where('start', '<=', now())
// ->where('end', '>=', now())
->where('active', true)
->latestOfMany();
}
public function corporatePlans()
@@ -77,6 +77,8 @@ class Corporate extends Model
]);
}
// public function
public function importLogs()
{
return $this->morphMany(ImportLog::class, 'importable');

View File

@@ -19,9 +19,4 @@ class CorporateEmployee extends Model
'nik',
'status'
];
public function division()
{
return $this->belongsTo(CorporateDivision::class, 'division_id');
}
}

View File

@@ -63,7 +63,7 @@ class Member extends Model
'gender_code',
''
];
protected $hidden = [
'created_at',
'updated_at',
@@ -86,30 +86,37 @@ class Member extends Model
public function corporates()
{
return $this
->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
->withPivot([
'branch_code',
'division_id',
'nik',
'status',
'start',
'end'
]);
->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
->withPivot([
'branch_code',
'divison_id',
'nik',
'status',
'start',
'end'
]);
}
public function currentCorporate()
{
return $this->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
// ->withPivot([
// 'branch_code',
// 'divison_id',
// 'nik',
// 'status',
// 'start',
// 'end'
// ])
->where('start', '<', now())
->where('end', '>', now());
// return $this->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
// // ->withPivot([
// // 'branch_code',
// // 'divison_id',
// // 'nik',
// // 'status',
// // 'start',
// // 'end'
// // ])
// ->where('start', '<', now())
// ->where('end', '>', now());
return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id');
// ->where('corporate_policies.start', '<', now())
// ->where('corporate_policies.end', '>', now())
// ->where('member_policies.start', '<', now())
// ->where('member_policies.end', '>', now());
}
public function memberPlans()
@@ -126,7 +133,7 @@ class Member extends Model
{
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')->latest();
}
public function policies()
{
return $this->hasMany(MemberPolicy::class, 'member_id', 'member_id');
@@ -135,10 +142,10 @@ class Member extends Model
public function currentPolicy()
{
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());
->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();
}
@@ -174,22 +181,13 @@ class Member extends Model
{
$query->when($filters['search'] ?? false, function ($query, $search) {
return $query
->where('member_id', 'like', "%" . $search . "%")
->orWhere('payor_id', 'like', "%" . $search . "%")
->orWhere('name', 'like', "%" . $search . "%");
// ->orWhereHas('corporatePlan', function ($query) use ($search) {
// $query->where('code', 'like', "%" . $search . "%");
// });
->where('member_id', 'like', "%" . $search . "%")
->orWhere('payor_id', 'like', "%" . $search . "%")
->orWhere('name', 'like', "%" . $search . "%")
;
// ->orWhereHas('corporatePlan', function ($query) use ($search) {
// $query->where('code', 'like', "%" . $search . "%");
// });
});
}
// public function corporateEmployee()
// {
// return $this->hasOne(CorporateEmployee::class, 'member_id');
// }
public function division()
{
return $this->hasOneThrough(CorporateDivision::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'division_id');
}
}

View File

@@ -10,23 +10,6 @@ use Str;
class ClaimService{
public function storeClaim($member, $icd, $benefit, $totalClaim)
{
$claim = Claim::create([
'code' => Str::random('16'),
'member_id' => $member->id,
'diagnosis_id' => $icd,
'total_claim' => $totalClaim,
'currency' => 'IDR',
'plan_id' => $member->currentPlan->id,
'benefit_id' => $benefit->id,
]);
$corporate = $member->asd;
return $claim;
}
public static function getMemberTotalUsage(Member $member, $startDate = null, $endDate = null)
{
$startDate = empty($startDate) ? Carbon::now()->startOfMonth() : $startDate;
@@ -41,4 +24,171 @@ class ClaimService{
return $total;
}
public static function checkMemberEligibility($member, $benefit, $diagnosis, $totalClaim = 0)
{
$currentPlan = $member->currentPlan;
$policy = $member->currentPolicy;
$corporate = $policy->corporate;
$isEligible = true;
$validationErrors = [];
// Eligibility Validation
if (!in_array($member->marital_status, explode(',', $benefit->msc))) {
$validationErrors[] = [
'error' => 'msc',
'message' => 'Only '.$benefit->msc
];
$isEligible = false;
}
if (!in_array($member->gender_code, explode(',', $benefit->genders))) {
$validationErrors[] = [
'error' => 'genders',
'message' => 'Only '.$benefit->genders
];
$isEligible = false;
}
if (!empty($benefit->min_age) && $member->age < $benefit->min_age) {
$validationErrors[] = [
'error' => 'min_age',
'message' => 'Minimum Age is '.$benefit->min_age
];
$isEligible = false;
}
if (!empty($benefit->max_age) && $member->age > $benefit->max_age) {
$validationErrors[] = [
'error' => 'max_age',
'message' => 'Maximum Age is '.$benefit->min_age
];
$isEligible = false;
}
// TODO complete validations
// Limit Validation
if ($totalClaim > 0) {
if (bcsub($corporate->limit_balance, $totalClaim) < 0) {
$validationErrors[] = [
'error' => 'corporate_limit',
'message' => 'Corporate Limit cannot cover this'
];
$isEligible = false;
}
if (bcsub($benefit->limit_amount, $totalClaim) < 0) {
$validationErrors[] = [
'error' => 'benefit_limit',
'message' => 'Benefit Limit cannot cover this'
];
$isEligible = false;
}
// TODO complete validations
}
return [
'isEligible' => $isEligible,
'errors' => $validationErrors
];
}
public static function getMemberUsageByBenefitLimit($member, $benefit)
{
}
public static function showMemberBenefitLimit($member, $benefit_code)
{
// $plan = $member->currentPlan;
// $policy = $member->currentPolicy;
// $corporate = $member->currentCorporate;
$benefit = $member->currentPlan->benefits()->where('code', $benefit_code)->first();
// dd($benefit->toArray());
// dd(compact(['plan', 'policy', 'corporate', 'benefit']));
$limits = [
'total_limit' => $benefit->limit_amount,
'frequency_limit_name' => $benefit->max_frequency_period_name,
'frequency_limit' => $benefit->max_frequency,
'total_claim' => 0,
'remaining_limit' => $benefit->limit_amount,
'usage_daily' => null,
'usage_weekly' => null,
'usage_monthly' => null,
'usage_yearly' => null
];
switch ($benefit->max_frequency_period) {
case(0) :
$limits['usage_yearly'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->count();
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->sum('total_claim');
break;
case(1) :
$limits['usage_daily'] = $member->claims()->used(now()->format('Y-m-d'), now()->addDay(1)->format('Y-m-d'))->count();
$limits['total_claim'] = $member->claims()->used(now()->format('Y-m-d'), now()->addDay(1)->format('Y-m-d'))->sum('total_claim');
break;
case(2) :
$limits['usage_weekly'] = $member->claims()->used(Carbon::parse('Previous Sunday'), now())->count();
$limits['total_claim'] = $member->claims()->used(Carbon::parse('Previous Sunday'), now())->sum('total_claim');
break;
case(3) :
$limits['usage_monthly'] = $member->claims()->used(Carbon::now()->firstOfMonth(), now())->count();
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfMonth(), now())->sum('total_claim');
break;
case(4) :
$limits['usage_yearly'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->count();
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->sum('total_claim');
break;
default :
// return null;
break;
}
$limits['remaining_limit'] = $benefit->limit_amount - $limits['total_claim'];
return $limits;
}
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit, $status)
{
try {
DB::beginTransaction();
$claimData = [
'member_id' => $member->id,
'diagnosis_id' => $diagnosis->id,
'total_claim' => $totalClaim,
'currency' => 'IDR',
'plan_id' => $member->currentPlan->id,
'benefit_id' => $benefit->id,
'status' => $status
];
$claimData[$status.'_at'] = now();
$claimData[$status.'_by'] = auth()->user()->id ?? null;
$claim = Claim::create($claimData);
$policy = $member->currentPolicy;
$policy->limitJournals()->create([
'previous_balance' => $policy->limit_balance,
'total_credit' => $totalClaim,
'type' => 'credit',
'balance' => bcsub($policy->limit_balance, $totalClaim),
'description' => 'Log for Claim #'. $claim->code,
]);
DB::commit();
return $claim;
} catch (\Exception $error) {
DB::rollBack();
throw new \Exception($error);
}
}
}

View File

@@ -22,12 +22,16 @@ return new class extends Migration
$table->string('currency');
$table->foreignId('plan_id')->index();
$table->foreignId('benefit_id')->index();
$table->string('status');
$table->dateTime('requested_at')->nullable();
$table->unsignedBigInteger('requested_by')->nullable()->index();
$table->dateTime('received_at')->nullable();
$table->unsignedBigInteger('received_by')->nullable()->index();
$table->dateTime('approved_at')->nullable();
$table->unsignedBigInteger('approved_by')->nullable()->index();
$table->dateTime('declined')->nullable();
$table->unsignedBigInteger('declined_by')->nullable()->index();

View File

@@ -28,7 +28,7 @@ export type JWTContextType = {
method: 'jwt';
login: (phoneOrEmail: string) => Promise<void>;
validateOtp: (phoneOrEmail: string, otp: string) => Promise<void>
logout: () => void;
logout: () => Promise<void>;
};
// export type FirebaseContextType = {

View File

@@ -132,9 +132,16 @@ function AuthProvider({ children }: AuthProviderProps) {
axios
.post('/verify-code', { phoneOrEmail: phoneOrEmail, otp })
.then((response) => {
const { token } = response.data.data;
const { user, token } = response.data.data;
setSession(token);
dispatch({
type: Types.ValidateOtp,
payload: {
user,
},
});
return response.data;
})
.catch((error) => {
@@ -142,7 +149,8 @@ function AuthProvider({ children }: AuthProviderProps) {
if (error.response.status !== 422) throw error.response;
});
const logout = () => {
const logout = async () => {
await axios.post('/logout');
setSession(null);
dispatch({ type: Types.Logout });
};

View File

@@ -8,7 +8,6 @@ import { IconButtonAnimate } from '../../../components/animate';
import { useNavigate } from 'react-router-dom';
import useAuth from '../../../hooks/useAuth';
import useLocalStorage from '../../../hooks/useLocalStorage';
import { enqueueSnackbar } from 'notistack';
// ----------------------------------------------------------------------
@@ -34,6 +33,10 @@ export default function AccountPopover() {
const navigate = useNavigate();
const { logout } = useAuth();
const [emailOrPhone, setEmailOrPhone] = useLocalStorage('emailOrPhone', '');
const [emailOrPhoneForm, setEmailOrPhoneForm] = useLocalStorage('emailOrPhoneForm', false);
const [loginOrVerifyCode, setLoginOrVerifyCode] = useLocalStorage('loginOrVerifyCode', false);
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
setOpen(event.currentTarget);
};
@@ -43,9 +46,11 @@ export default function AccountPopover() {
};
const handleLogout = () => {
setEmailOrPhone('');
setEmailOrPhoneForm(false);
setLoginOrVerifyCode(false);
logout();
navigate('/auth/login');
enqueueSnackbar('Logout Berhasil!', { variant: 'success' });
};
return (

View File

@@ -1,13 +1,5 @@
// @mui
import {
Typography,
Container,
Grid,
FormControl,
InputLabel,
MenuItem,
Select,
} from '@mui/material';
import { Typography, Container, Grid } from '@mui/material';
// hooks
import useSettings from '../../hooks/useSettings';
// components
@@ -16,11 +8,7 @@ import Page from '../../components/Page';
import CardNotification from '../../sections/dashboard/CardNotification';
import CardBalance from '../../sections/dashboard/CardBalance';
import TableList from '../../sections/dashboard/TableList';
import { useEffect, useState } from 'react';
import axios from '../../utils/axios';
import { Stack } from '@mui/system';
import { SelectChangeEvent } from '@mui/material/Select';
import useAuth from '../../hooks/useAuth';
import List from './List';
// ----------------------------------------------------------------------
@@ -33,100 +21,43 @@ const itemList = [
// ----------------------------------------------------------------------
/* ---------------------------------- types --------------------------------- */
type CorporateDataProps = {
id: number;
name: string;
};
type CardBalanceProps = {
myLimit: {
balance: number;
total: number;
percentage: number;
};
lockLimit: {
balance: number;
percentage: number;
};
};
/* -------------------------------------------------------------------------- */
export default function Dashboard() {
const { themeStretch } = useSettings();
const { user } = useAuth();
const [currentCorporate, setCurrentCorporate] = useState({id: 1});
// @ts-ignore
const [corporateValue, setCorporateValue] = useState(`${user.corporate.id}`);
const [corporateData, setCorporateData] = useState([]);
const [tableData, setTableData] = useState([]);
const [policyData, setPolicyData] = useState<CardBalanceProps>({
myLimit: {
balance: 0,
total: 0,
percentage: 0,
},
lockLimit: {
balance: 0,
percentage: 0,
},
});
// const [corporate, setCorporate] = useState({});
const handleCorporateChange = (event: SelectChangeEvent) => {
setCorporateValue(event.target.value as string);
};
// const loadSomething = () => {
// axios
// .get('dashboard')
// .then((res) => {
// setCorporate(res.data.corporate);
// })
// .catch((err) => {
// alert('Opps, Something Went Wrong when collecting dashboard data');
// });
// };
useEffect(() => {
(async () => {
const corporates = await axios.get(`${currentCorporate.id}/dashboard`);
const dashboard = await axios.get(`${currentCorporate.id}/dashboard`);
console.log(dashboard);
setCorporateData(corporates.data);
setPolicyData(dashboard.data.policy);
})();
}, [user, corporateValue]);
// useEffect(() => {
// loadSomething();
// }, []);
return (
<Page title="Dashboard">
<Container maxWidth={themeStretch ? false : 'xl'}>
<Stack direction="row" justifyContent="space-between">
<Typography variant="h3" component="h1" paragraph>
Dashboard
</Typography>
<FormControl>
<InputLabel id="simple-corporate-select-lable">Corporate</InputLabel>
<Select
labelId="simple-corporate-select-lable"
id="corporate-select-lable"
value={corporateValue}
label="Corporate"
defaultValue={corporateValue}
onChange={handleCorporateChange}
>
{corporateData.map((row: CorporateDataProps, index) => (
<MenuItem key={index} value={row.id}>
{row.name}
</MenuItem>
))}
</Select>
</FormControl>
</Stack>
<Typography variant="h3" component="h1" paragraph>
Dashboard
</Typography>
<Grid container spacing={2}>
<Grid item xs={12} lg={6} md={12}>
<Grid item xs={6} lg={6} md={12}>
<CardNotification data={itemList} />
</Grid>
<Grid item xs={12} lg={6} md={12}>
<CardBalance data={policyData} />
<Grid item xs={6} lg={6} md={12}>
<CardBalance />
</Grid>
<Grid item xs={12} lg={12} md={12}>
<TableList />
{/* <List /> */}
</Grid>
</Grid>
</Container>

View File

@@ -0,0 +1,373 @@
// @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,
Pagination,
Grid,
Autocomplete,
} 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, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
import useSettings from '../../hooks/useSettings';
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
// components
import axios from '../../utils/axios';
import { LaravelPaginatedData } from '../../@types/paginated-data';
import { Icd } from '../../@types/diagnosis';
import BasePagination from '../../components/BasePagination';
import { Member } from '../../@types/member';
import Iconify from '../../components/Iconify';
const options = [
{ label: 'The Shawshank Redemption', value: 1994 },
{ label: 'The Godfather', year: 1972 },
{ label: 'The Godfather: Part II', year: 1974 },
{ label: 'The Dark Knight', year: 2008 },
{ label: '12 Angry Men', year: 1957 },
{ label: "Schindler's List", year: 1993 },
{ label: 'Pulp Fiction', year: 1994 },
];
export default function List() {
const navigate = useNavigate();
const { themeStretch } = useSettings();
const { corporate_id } = useParams();
const [searchParams, setSearchParams] = useSearchParams();
const [importResult, setImportResult] = useState(null);
function SearchInput(props: any) {
// SEARCH
const searchInput = useRef<HTMLInputElement>(null);
const [searchText, setSearchText] = useState('');
const [value, setValue] = useState<string | null>(options[0]);
const [inputValue, setInputValue] = useState('');
const handleSearchChange = (event: any) => {
const newSearchText = event.target.value ?? '';
setSearchText(newSearchText);
};
const handleSearchSubmit = (event: any) => {
event.preventDefault();
props.onSearch(searchText); // Trigger to Parent
};
useEffect(() => {
// Trigger First Search
setSearchText(searchParams.get('search') ?? '');
console.log(value, inputValue);
}, [searchParams, value, inputValue]);
return (
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}>
<Stack direction="row" spacing={2}>
<Autocomplete
value={value}
onChange={(event: any, newValue: string | null) => {
setValue(newValue);
}}
inputValue={inputValue}
onInputChange={(event, newInputValue) => {
setInputValue(newInputValue);
}}
id="controllable-states-demo"
options={options}
sx={{ width: 300 }}
renderInput={(params) => <TextField {...params} label="Division" />}
/>
<TextField
id="search-input"
ref={searchInput}
label="Search"
variant="outlined"
fullWidth
onChange={handleSearchChange}
value={searchText}
/>
</Stack>
</form>
);
}
function ImportForm(props: any) {
// IMPORT
// Create Button Menu
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const createMenu = Boolean(anchorEl);
const importForm = useRef<HTMLInputElement>(null);
const [currentImportFileName, setCurrentImportFileName] = useState(null);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const handleImportButton = () => {
if (importForm?.current) {
handleClose();
importForm.current ? importForm.current.click() : console.log('No File selected');
} else {
alert('No file selected');
}
};
const handleCancelImportButton = () => {
importForm.current.value = '';
importForm.current.dispatchEvent(new Event('change', { bubbles: true }));
};
const handleImportChange = (event: any) => {
if (event.target.files[0]) {
setCurrentImportFileName(event.target.files[0].name);
} else {
setCurrentImportFileName(null);
}
};
const handleUpload = () => {
if (importForm.current?.files.length) {
const formData = new FormData();
formData.append('file', importForm.current?.files[0]);
axios
.post(`master/formularium/import`, formData)
.then((response) => {
handleCancelImportButton();
loadDataTableData();
setImportResult(response.data);
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
})
.catch((response) => {
alert(
'Looks like something went wrong. Please check your data and try again. ' +
response.message
);
});
} else {
alert('No File Selected');
}
};
return (
<Stack direction="row" spacing={2} padding={2}>
<SearchInput onSearch={applyFilter} />
<Button
id="import-button"
variant="outlined"
startIcon={<Iconify icon="material-symbols:download-rounded" />}
sx={{ paddingY: '15px', paddingX: '22px', flex: '10%' }}
component="label"
>
Import
<input
type="file"
id="file"
ref={importForm}
style={{ display: 'none' }}
onChange={handleImportChange}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
/>
</Button>
<Button
id="import-button"
variant="contained"
startIcon={<AddIcon />}
sx={{ paddingY: '15px', paddingX: '22px', flex: '15%' }}
onClick={handleClick}
>
Add Data
</Button>
</Stack>
);
}
// Called on every row to map the data to the columns
function createData(member: Member): Member {
return {
...member,
};
}
// Generate the every row of the table
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(true);
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.member_id}</TableCell>
<TableCell align="left">{row.payor_id}</TableCell>
<TableCell align="left">{row.name}</TableCell>
<TableCell align="left">{row.nik}</TableCell>
<TableCell align="left">{row.nric}</TableCell>
<TableCell align="right">
<Button variant="outlined" color="success" size="small">
Active
</Button>
</TableCell>
{/* <TableCell align="right"><Button variant="outlined" color="error" size="small">Disable</Button></TableCell> */}
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
<Typography variant="body2" gutterBottom component="div">
<Grid></Grid>
</Typography>
</Box>
</Collapse>
</TableCell>
</TableRow>
</React.Fragment>
);
}
// Dummy Default Data
const [dataTableIsLoading, setDataTableLoading] = useState(true);
const [dataTableLastRequest, setDataTableLastRequest] = useState(0);
const [dataTableResponseState, setDataTableResponseState] = useState('idle');
const [dataTableData, setDataTableData] = 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 [dataTablePage, setDataTablePage] = useState(5);
const loadDataTableData = async (appliedFilter: any | null = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/members', { params: filter });
setDataTableData(response.data.members);
setDataTableLoading(false);
};
const headStyle = {
fontWeight: 'bold',
};
const applyFilter = async (searchFilter: string) => {
await loadDataTableData({ search: searchFilter });
setSearchParams({ search: searchFilter });
};
const handlePageChange = (event: ChangeEvent, value: number) => {
const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
loadDataTableData(filter);
setSearchParams(filter);
};
useEffect(() => {
loadDataTableData();
}, []);
return (
<Stack>
<Card>
<ImportForm />
{/* The Main Table */}
<TableContainer component={Paper} sx={{ paddingX: 1, borderRadius: 2 }}>
<Table aria-label="collapsible table">
<TableBody>
<TableRow sx={{ backgroundColor: '#F4F6F8' }}>
<TableCell style={headStyle} align="left">
Member ID
</TableCell>
<TableCell style={headStyle} align="center">
Name
</TableCell>
<TableCell style={headStyle} align="center">
Divisi
</TableCell>
<TableCell style={headStyle} align="center">
Limit
</TableCell>
<TableCell style={headStyle} align="center">
Status
</TableCell>
<TableCell style={headStyle} align="right">
{' '}
</TableCell>
</TableRow>
</TableBody>
{dataTableIsLoading ? (
<TableBody>
<TableRow>
<TableCell colSpan={6} align="center">
Loading
</TableCell>
</TableRow>
</TableBody>
) : dataTableData.data.length === 0 ? (
<TableBody>
<TableRow>
<TableCell colSpan={6} align="center">
No Data
</TableCell>
</TableRow>
</TableBody>
) : (
<TableBody>
{dataTableData.data.map((row) => (
<Row key={row.id} row={row} />
))}
</TableBody>
)}
</Table>
</TableContainer>
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange} />
</Card>
</Stack>
);
}

View File

@@ -11,7 +11,6 @@ import useAuth from '../../../hooks/useAuth';
import useIsMountedRef from '../../../hooks/useIsMountedRef';
/* ------------------------------- components ------------------------------- */
import { FormProvider, RHFTextField } from '../../../components/hook-form';
import { enqueueSnackbar } from 'notistack';
/* ---------------------------------- types --------------------------------- */
@@ -57,10 +56,6 @@ export default function LoginForm({ setEmailOrPhone, setLoginOrVerifyCode }: Log
setEmailOrPhone(data.email);
setLoginOrVerifyCode(true);
reset();
enqueueSnackbar('Kode OTP telah dikirim, silahkan cek email yang login', {
variant: 'success',
autoHideDuration: 2000,
});
} catch (error: any) {
reset();

View File

@@ -11,7 +11,6 @@ import { FormProvider, RHFTextField } from '../../../components/hook-form';
/* ---------------------------------- hooks --------------------------------- */
import useAuth from '../../../hooks/useAuth';
import useIsMountedRef from '../../../hooks/useIsMountedRef';
import { enqueueSnackbar } from 'notistack';
/* ---------------------------------- types --------------------------------- */
@@ -57,10 +56,6 @@ export default function LoginPhoneForm({ setEmailOrPhone, setLoginOrVerifyCode }
setEmailOrPhone(0 + data.phone);
setLoginOrVerifyCode(true);
reset();
enqueueSnackbar('Kode OTP telah dikirim, silahkan cek pada nomor yang telah login', {
variant: 'success',
autoHideDuration: 2000,
});
} catch (error: any) {
reset();

View File

@@ -87,25 +87,24 @@ export default function VerifyCodeForm({
}, [setValue]);
const onSubmit = async (data: FormValuesProps) => {
// @ts-ignore
const response: responseProps = await validateOtp(emailOrPhone, Object.values(data).join(''));
try {
await new Promise((resolve) => setTimeout(resolve, 1000));
// @ts-ignore
const response: responseProps = await validateOtp(emailOrPhone, Object.values(data).join(''));
if (response.data.length === 0) {
return enqueueSnackbar(response.message, {
variant: 'error',
autoHideDuration: 4000,
preventDuplicate: true,
});
} else {
enqueueSnackbar('Verify success!', { variant: 'success', autoHideDuration: 1000 });
await new Promise((resolve) => setTimeout(resolve, 2000));
if (response.data.length === 0) {
return enqueueSnackbar(response.message, {
variant: 'error',
autoHideDuration: 4000,
preventDuplicate: true,
});
}
navigate('/dashboard');
enqueueSnackbar('Verify success!', { variant: 'success' });
} catch (error) {
console.error(error);
}
navigate('/dashboard');
enqueueSnackbar('Login Berhasil!', { variant: 'success' });
localStorage.removeItem('loginOrVerifyCode');
localStorage.removeItem('emailOrPhone');
localStorage.removeItem('emailOrPhoneForm');
};
const handleChangeWithNextField = (

View File

@@ -14,29 +14,23 @@ import Iconify from '../../components/Iconify';
import { useState } from 'react';
// utils
import { fCurrency } from '../../utils/formatNumber';
/* -------------------------------- sections -------------------------------- */
// <sections></sections>
import DialogTopUpLimit from './DialogTopUpLimit';
import DialogClaimSubmitMember from './DialogClaimSubmitMember';
/* ---------------------------------- types --------------------------------- */
// ----------------------------------------------------------------------
type CardBalanceProps = {
data: {
myLimit: {
balance: number;
total: number;
percentage: number;
};
lockLimit: {
balance: number;
percentage: number;
};
};
type DataMembers = {
name: string;
memberId: string;
saldo: string;
};
/* -------------------------------------------------------------------------- */
type NotificationProps = {
data?: { members: DataMembers[] };
};
/* --------------------------------- styled --------------------------------- */
// ----------------------------------------------------------------------
const RootBalanceStyle = styled(Card)(({ theme }) => ({
boxShadow: 'none',
@@ -58,15 +52,19 @@ const BorderLinearProgress = styled(LinearProgress)(({ theme }) => ({
},
}));
/* -------------------------------------------------------------------------- */
// ----------------------------------------------------------------------
export default function CardBalance(props: CardBalanceProps) {
const INITIAL = '500.000.000';
const TOTAL = 375000000;
const PERCENT = 75;
// ----------------------------------------------------------------------
export default function CardBalance({ data }: NotificationProps) {
const [openDialog, setOpenDialog] = useState(false);
const [dialogTitle, setDialogTitle] = useState('');
const [isDialog, setIsDialog] = useState('');
const { myLimit, lockLimit } = props.data;
const clickHandler = (isDialog: string) => {
switch (isDialog) {
case 'submitClaim':
@@ -93,26 +91,18 @@ export default function CardBalance(props: CardBalanceProps) {
<Typography variant="body2" component="span" sx={{ opacity: 0.72 }}>
Total Limit
</Typography>
<Typography sx={{ typography: 'body2' }}>
{fCurrency(myLimit ? myLimit.balance : 0)}
</Typography>
<Typography sx={{ typography: 'caption', color: '#919EAB' }}>
/ {myLimit ? myLimit.total : 0}
</Typography>
<Typography sx={{ typography: 'body2' }}>{fCurrency(TOTAL)}</Typography>
<Typography sx={{ typography: 'caption', color: '#919EAB' }}>/ {INITIAL}</Typography>
</div>
<Stack direction="row" alignItems="center" justifyContent="center">
<Typography variant="h5" sx={{ ml: 0.5 }}>
{myLimit ? myLimit.percentage : 0}%
{PERCENT}%
</Typography>
</Stack>
</Stack>
<BorderLinearProgress
variant="determinate"
value={myLimit ? myLimit.percentage : 0}
sx={{ mb: 1 }}
/>
<BorderLinearProgress variant="determinate" value={PERCENT} sx={{ mb: 1 }} />
<Stack sx={{ backgroundColor: '#B2E8E8', paddingY: 1, paddingX: 1.5, mb: 2 }}>
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
@@ -123,11 +113,11 @@ export default function CardBalance(props: CardBalanceProps) {
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Lock Fund ( {lockLimit ? lockLimit.percentage : 0}% )
Lock Fund ( 25% )
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
{lockLimit ? lockLimit.balance : 0} / {myLimit ? myLimit.total : 0}
125.000.000 / 125.000.000
</Typography>
</Stack>
@@ -156,7 +146,7 @@ export default function CardBalance(props: CardBalanceProps) {
openDialog={openDialog}
setOpenDialog={setOpenDialog}
title={{ name: dialogTitle }}
// data={data?.members}
data={data?.members}
/>
)}

View File

@@ -14,18 +14,12 @@ import {
IconButton,
Card,
Grid,
FormControl,
InputLabel,
Select,
MenuItem,
SelectChangeEvent,
} from '@mui/material';
import { visuallyHidden } from '@mui/utils';
import { Add as AddIcon } from '@mui/icons-material';
/* ---------------------------------- axios --------------------------------- */
import axios from '../../utils/axios';
import axios from 'axios';
/* ---------------------------------- react --------------------------------- */
import { useEffect, useRef, useState } from 'react';
import { useEffect, useState } from 'react';
/* -------------------------------- component ------------------------------- */
import Iconify from '../../components/Iconify';
import BaseTablePagination from '../../components/BaseTablePagination';
@@ -34,6 +28,7 @@ import palette from '../../theme/palette';
import { useSearchParams } from 'react-router-dom';
/* ---------------------------------- types --------------------------------- */
type PaginationTableProps = {
current_page: number;
from: number;
@@ -68,13 +63,10 @@ interface EnhancedTableProps {
orderBy: string;
}
type DivisionDataProps = {
id: number;
name: string;
};
/* -------------------------------------------------------------------------- */
/* -------------------------- enchanced table head -------------------------- */
const headCells: readonly HeadCell[] = [
{
id: 'member_id',
@@ -147,14 +139,16 @@ function EnhancedTableHead({ order, orderBy, onRequestSort }: EnhancedTableProps
</TableHead>
);
}
/* -------------------------------------------------------------------------- */
export default function TableList(props: any) {
export default function TableList() {
const [order, setOrder] = useState<Order>('asc');
const [orderBy, setOrderBy] = useState('name');
const [searchParams, setSearchParams] = useSearchParams();
const [customSearchParams, setCustomSearchParams] = useSearchParams();
const [isLoading, setIsLoading] = useState(true);
const [dataTable, setDataTable] = useState([]);
const [dataDivision, setDataDivision] = useState([]);
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(10);
const [appliedParams, setAppliedParams] = useState({});
@@ -175,7 +169,7 @@ export default function TableList(props: any) {
setOrder(isAsc ? 'desc' : 'asc');
setOrderBy(property);
const params = Object.fromEntries([
...searchParams.entries(),
...customSearchParams.entries(),
['order', isAsc ? 'desc' : 'asc'],
['orderBy', property],
]);
@@ -183,75 +177,37 @@ export default function TableList(props: any) {
};
/* -------------------------------------------------------------------------- */
/* ----------------------------- Field Container ---------------------------- */
/* ----------------------------- division field ----------------------------- */
const [divisionValue, setDivisionValue] = useState('all');
const [divisionData, setDivisionData] = useState([]);
const handleDivisionChange = (event: SelectChangeEvent) => {
setDivisionValue(event.target.value as string);
if (event.target.value === 'all') {
searchParams.delete('division');
const params = Object.fromEntries([...searchParams.entries()]);
setAppliedParams(params);
} else {
const params = Object.fromEntries([
...searchParams.entries(),
['division', event.target.value as string],
]);
setAppliedParams(params);
}
};
/* -------------------------------------------------------------------------- */
/* ------------------------------ Search field ------------------------------ */
const [searchText, setSearchText] = useState('');
const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
setSearchText(event.target.value);
};
const handleSearchSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
setIsLoading(true);
const params = Object.fromEntries([...searchParams.entries(), ['search', searchText]]);
const params = Object.fromEntries([...customSearchParams.entries(), ['search', searchText]]);
await new Promise((resolve) => setTimeout(resolve, 500));
setAppliedParams(params);
setIsLoading(false);
};
/* -------------------------------------------------------------------------- */
/* ------------------------------ import button ----------------------------- */
const [currentImportFileName, setCurrentImportFileName] = useState(null);
const importForm = useRef<HTMLInputElement>(null);
const handleImportChange = (event: any) => {
if (event.target.files[0]) {
setCurrentImportFileName(event.target.files[0].name);
} else {
setCurrentImportFileName(null);
}
};
/* -------------------------------------------------------------------------- */
/* ------------------------------ create button ----------------------------- */
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* ---------------------------- table pagination ---------------------------- */
/* ------------------------ button change pagination ------------------------ */
const onPageChangeHandle = async (
event: React.MouseEvent<HTMLButtonElement> | null,
newPage: number
) => {
setIsLoading(true);
const params = Object.fromEntries([...searchParams.entries(), ['page', newPage + 1]]);
const params = Object.fromEntries([...customSearchParams.entries(), ['page', newPage + 1]]);
setPage(newPage);
await new Promise((resolve) => setTimeout(resolve, 500));
setAppliedParams(params);
setIsLoading(false);
// setSearchParams.set('page', newPage + 1);
// setCustomSearchParams.set('page', newPage + 1);
};
/* -------------------------------------------------------------------------- */
@@ -260,7 +216,7 @@ export default function TableList(props: any) {
setIsLoading(true);
setPage(0);
const params = Object.fromEntries([
...searchParams.entries(),
...customSearchParams.entries(),
['per_page', parseInt(event.target.value, 10)],
]);
setRowsPerPage(parseInt(event.target.value, 10));
@@ -269,104 +225,52 @@ export default function TableList(props: any) {
setIsLoading(false);
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
useEffect(() => {
(async () => {
setIsLoading(true);
const division = await axios.get('/division');
setDivisionData(division.data);
const params =
Object.keys(appliedParams).length !== 0
? appliedParams
: Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]);
: Object.fromEntries([
...customSearchParams.entries(),
['order', order],
['orderBy', orderBy],
]);
const response = await axios.get('/dashboard', {
const response = await axios.get('http://localhost:8001/api/dashboard', {
params: params,
});
console.log(response);
const division = await axios.get('http://localhost:8001/api/division');
setDataDivision(division.data);
setSearchParams(params);
// setDataTable(response.data.data);
// setPaginationTable(response.data.meta);
// setRowsPerPage(response.data.meta.per_page);
setCustomSearchParams(params);
setDataTable(response.data.data);
setPaginationTable(response.data.meta);
setRowsPerPage(response.data.meta.per_page);
setIsLoading(false);
})();
}, [appliedParams, searchParams, order, orderBy, setSearchParams]);
}, [appliedParams, customSearchParams, order, orderBy, setCustomSearchParams]);
return (
<Card>
<Grid container>
{/* Field 1 */}
<Grid item xs={12} paddingX="24px" paddingY="20px">
<Grid container spacing={2}>
<Grid item xs={12} lg={3} xl={2}>
<FormControl fullWidth>
<InputLabel id="simple-division-select-lable">Division</InputLabel>
<Select
labelId="simple-division-select-lable"
id="division-select-lable"
value={divisionValue}
label="Division"
onChange={handleDivisionChange}
>
<MenuItem value="all">All</MenuItem>
{divisionData.map((row: DivisionDataProps, index) => (
<MenuItem key={index} value={row.id}>
{row.name}
</MenuItem>
))}
</Select>
</FormControl>
</Grid>
<Grid item xs={12} lg={5} xl={6}>
<form onSubmit={handleSearchSubmit}>
<TextField
id="search-input"
label="Search"
variant="outlined"
onChange={(event) => setSearchText(event.target.value)}
value={searchText}
fullWidth
/>
</form>
</Grid>
<Grid item xs={12} lg={2} xl={2}>
<Button
id="import-button"
variant="outlined"
startIcon={<Iconify icon="material-symbols:download-rounded" />}
component="label"
fullWidth
sx={{ height: '100%' }}
>
Import
<input
type="file"
id="file"
ref={importForm}
style={{ display: 'none' }}
onChange={handleImportChange}
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"
/>
</Button>
</Grid>
<Grid item xs={12} lg={2} xl={2}>
<Button
id="import-button"
variant="contained"
startIcon={<AddIcon />}
onClick={handleClick}
fullWidth
sx={{ height: '100%' }}
>
Add Data
</Button>
</Grid>
</Grid>
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}>
<TextField
id="search-input"
label="Search"
variant="outlined"
fullWidth
onChange={handleSearch}
value={searchText}
/>
</form>
</Grid>
{/* End Field 1 */}
{/* Field 2 */}

View File

@@ -1,413 +0,0 @@
import * as Yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import { Autocomplete, Button, Card, Collapse, Divider, Grid, Stack, Table, TableBody, TableCell, TableRow, TextField, Typography } from '@mui/material';
import { Controller, useForm } from 'react-hook-form';
import { useParams, useNavigate } 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 { useEffect, useMemo, useRef, useState } from 'react';
import MemberSelectDialog from '../../components/dialogs/MemberSelectDialog';
import { styled } from '@mui/system';
import axios from '../../utils/axios';
import { enqueueSnackbar } from 'notistack';
import { LoadingButton } from '@mui/lab';
import { fCurrency } from '../../utils/formatNumber';
import Iconify from '../../components/Iconify';
export default function ClaimsCreate() {
const navigate = useNavigate();
const [member, setMember] = useState();
const selectedMemberDisplay = useRef<HTMLInputElement>(null);
const NewClaimSchema = Yup.object().shape({
member_id: Yup.string().required('Please select Member'),
total_claim: Yup.number().typeError('Claim should be a number').min(1, 'Claim cannot 0').required('Total Claim is required'),
diagnosis: Yup.object().required('Choose Diagnosis'),
benefit: Yup.object().required('Please Select Benefit')
});
const defaultValues = useMemo(
() => ({
member_id: null,
benefit_id: null,
diagnosis_id: null,
total_claim: 0,
benefit: null
}),
[]
);
const methods = useForm({
resolver: yupResolver(NewClaimSchema),
defaultValues,
});
const {
reset,
watch,
control,
setValue,
getValues,
setError,
handleSubmit,
formState: { isSubmitting },
} = methods;
const onSubmit = async (data: any) => {
axios.post('claims', getValues())
.then(function(res) {
console.log('SUCCESS', res)
enqueueSnackbar('Success Creating Claim', { variant: 'success' })
navigate('/claims');
})
.catch(function (err) {
console.log('ERROR CUK', err)
enqueueSnackbar('Failed Creating Claim : '+ err.response.data.message, { variant: 'error' })
})
};
const [memberBenefits, setMemberBenefits] = useState([]);
const getMemberBenefits = (member) => {
axios.get(`members/${member.id}/benefits`)
.then( (res) => {
setMemberBenefits(res.data);
})
.catch( (err) => {
enqueueSnackbar('Failed getting member benefits', { variant: 'error' })
})
}
const [isMemberDialogOpen, setIsMemberDialogOpen] = useState(false);
const memberSelected = (selectedMember: any) => {
// Reset Selected Benefit
setMemberBenefits([]);
setValue('benefit_id', null);
setValue('benefit', null);
setMember(selectedMember);
setValue('member_id', selectedMember.id)
getMemberBenefits(selectedMember)
};
const [diagnosis, setDiagnosis] = useState([]);
const searchDiagnosis = (search) => {
axios.get('master/diagnosis/search', {params: {search}})
.then(function(res) {
setDiagnosis(res.data);
})
}
useEffect(() => { // Trigger First Search
axios.get('master/diagnosis/search')
.then(function(res) {
setDiagnosis(res.data);
})
}, [])
const [isEligible, setIsEligible] = useState<boolean|null>(null)
const [isCheckingLimit, setIsCheckingLimit] = useState(false)
const checkLimit = (event) => {
event.preventDefault();
console.log(getValues('diagnosis_id'))
if (!member || !getValues('diagnosis_id')) {
enqueueSnackbar('Please Check the Data', { variant: 'error' })
return false;
}
setIsCheckingLimit(true)
axios.post('check-limit', {
'member_id' : member.id,
'diagnosis' : getValues('diagnosis_id'),
'total_claim' : getValues('total_claim')
})
.then((res) => {
setIsEligible(true)
})
.catch((err) => {
enqueueSnackbar('Failed Checking Limit : ' + err.message ?? '', { variant: 'error' })
})
.then(() => {
setIsCheckingLimit(false)
})
}
const headStyle = {
fontWeight: 'bold'
};
return (
<Page title="Create Claim" sx={{ mx: 2 }}>
<HeaderBreadcrumbs
heading={'Create Claim'}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Claims',
href: '/claims',
},
{
name: 'Create',
href: '/claims/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">Member</Typography>
<Stack spacing={2} direction="row">
<Grid item xs={12}>
<RHFTextField
name="member_id"
label="Member"
variant="outlined"
fullWidth
value={member?.name || ''}
ref={selectedMemberDisplay}
InputProps={{
readOnly: true,
}}
onClick={() => {setIsMemberDialogOpen(true)}}
/>
</Grid>
{/* <Grid item xs={2}>
<Button variant="outlined" fullWidth sx={{ p: 1.8 }} onClick={() => {
setIsMemberDialogOpen(true)
}}>
{member ? 'Change' : 'Search'}
</Button>
</Grid> */}
</Stack>
{ member && (
<Stack>
<Grid container spacing={2}>
<Grid item xs={12} md={6}>
<Table border="light-700">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left">Name</TableCell>
<TableCell align="left">{member.full_name}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">DOB</TableCell>
<TableCell align="left">{member.birth_date} ({member.age + ' years'})</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">Marital Status</TableCell>
<TableCell align="left">{member.marital_status}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">Record Type</TableCell>
<TableCell align="left">{member.record_type}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">Principal ID</TableCell>
<TableCell align="left">{member.principal_id} ({member.relation_with_principal})</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
<Grid item xs={12} md={6}>
<Table border="light-700">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left">Plan</TableCell>
<TableCell align="left">{member.current_plan.code}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">Active</TableCell>
<TableCell align="left">{member.current_plan.start} - {member.current_plan.end} (Active)</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">Corporate Limit</TableCell>
<TableCell align="left">{fCurrency(0)} / {fCurrency(member.current_plan.limit_rules)}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">Plan Usage</TableCell>
<TableCell align="left">{fCurrency(0)} / {fCurrency(member.current_plan.limit_rules)}</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
</Grid>
</Stack>
)}
<Controller
name="benefit"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
options={memberBenefits}
getOptionLabel={(option) =>
option ? `#${option.id} (${option.code}) ${option.description}` : ''
}
value={value || ''}
onChange={(event: any, newValue: any) => {
setValue('benefit_id', newValue?.id)
onChange(newValue);
}}
renderInput={(params) => (
<TextField
name="benefit"
{...params}
label="Benefit"
variant="outlined"
fullWidth
// onKeyPress={(event) => {
// if (event.key === 'Enter')
// searchDiagnosis(event.target.value)
// }}
/>
)}
/>
)}
/>
<Controller
name="diagnosis"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
options={diagnosis}
getOptionLabel={(option) =>
option ? `(${option.code}) ${option.name}` : ''
}
value={value || ''}
onChange={(event: any, newValue: any) => {
setValue('diagnosis_id', newValue?.id)
// setValue('diagnosis', newValue)
onChange(newValue);
}}
renderInput={(params) => (
<TextField
name="diagnosis"
{...params}
label="Diagnosis"
variant="outlined"
fullWidth
onKeyPress={(event) => {
if (event.key === 'Enter')
searchDiagnosis(event.target.value)
}}
/>
)}
/>
)}
/>
{ isCheckingLimit && (
<Stack sx={{ backgroundColor: 'gray', paddingY: 1, paddingX: 1.5, mb: 2, borderRadius: '3-xl' }}>
{/* Checking */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:info-circle"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Please Wait, Checking Eligibilty
</Typography>
</Typography>
</Stack>
)}
{ false && isCheckingLimit == false && isEligible == null && (
<Stack sx={{ backgroundColor: 'gray', paddingY: 1, paddingX: 1.5, mb: 2, borderRadius: '3-xl' }}>
{/* No Data Selected */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:info-circle"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Please Select Diagnosis !
</Typography>
</Typography>
</Stack>
)}
{ (!isCheckingLimit && isEligible !== null) && isEligible && (
<Stack sx={{ backgroundColor: '#B2E8E8', paddingY: 1, paddingX: 1.5, mb: 2, borderRadius: '3-xl' }}>
{/* Eligible */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:lock-alt"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Diagnosis is Eligible
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
125.000.000 / 125.000.000
</Typography>
</Stack>
)}
{ (!isCheckingLimit && isEligible !== null) && !isEligible && (
<Stack sx={{ backgroundColor: '#B2E8E8', paddingY: 1, paddingX: 1.5, mb: 2, borderRadius: '3-xl' }}>
{/* Not Eligible */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:lock-alt"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Not Eligible
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
125.000.000 / 125.000.000
</Typography>
</Stack>
)}
<RHFTextField type="number" name="total_claim" label="Total Claim" />
{ isEligible === true ? (
<LoadingButton onClick={handleSubmit(onSubmit)} variant="contained" color="success" style={{color: '#ffffff'}} size="large" fullWidth={true} loading={isCheckingLimit}>
Create Claim
</LoadingButton>
) : (
<LoadingButton onClick={checkLimit} variant="outlined" size="large" fullWidth={true} loading={isCheckingLimit}>
Check Limit
</LoadingButton>
)}
</Stack>
</FormProvider>
</Card>
</Grid>
</Grid>
<MemberSelectDialog
openDialog={isMemberDialogOpen}
setOpenDialog={setIsMemberDialogOpen}
onSelect={memberSelected}
></MemberSelectDialog>
</Page>
);
}

View File

@@ -0,0 +1,64 @@
import * as Yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import { Autocomplete, Button, Card, Collapse, Container, Divider, Grid, Stack, Table, TableBody, TableCell, TableRow, TextField, Typography } from '@mui/material';
import { Controller, useForm } from 'react-hook-form';
import { useParams, useNavigate } 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 { useEffect, useMemo, useRef, useState } from 'react';
import MemberSelectDialog from '../../components/dialogs/MemberSelectDialog';
import { styled } from '@mui/system';
import axios from '../../utils/axios';
import { enqueueSnackbar } from 'notistack';
import { LoadingButton } from '@mui/lab';
import { fCurrency } from '../../utils/formatNumber';
import Iconify from '../../components/Iconify';
import Form from './Form';
export default function ClaimsCreateUpdate() {
const { themeStretch } = useSettings();
const { id } = useParams();
const isEdit = id ? true : false;
const [currentClaim, setCurrentClaim] = useState();
useEffect(() => {
if (isEdit) {
axios.get('/claims/' + id).then((res) => {
// console.log('Yeet', res.data);
setCurrentClaim(res.data);
});
}
}, [id]);
return (
<Page title={isEdit ? `Edit Claim : ${currentClaim?.id}` : "Create New Claim"}>
<Container maxWidth={themeStretch ? false : 'xl'}>
<Stack direction="row" alignItems="center">
<HeaderBreadcrumbs
heading={
!isEdit
? 'Create New Claim'
: `Edit Claim : ${currentClaim?.code}`
}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Claim',
href: '/claims',
},
{ name: !isEdit ? 'Create' : currentClaim?.id ?? '' },
]}
/>
</Stack>
<Form isEdit={isEdit} currentClaim={currentClaim} />
</Container>
</Page>
);
}

View File

@@ -0,0 +1,596 @@
import * as Yup from 'yup';
import { useSnackbar } from 'notistack';
import { useNavigate } from 'react-router-dom';
import { yupResolver } from '@hookform/resolvers/yup';
import { Controller, useForm } from 'react-hook-form';
import React, { useEffect, useMemo, useState } from 'react';
import axios from '../../utils/axios';
import { FormProvider, RHFTextField } from '../../components/hook-form';
import {
Autocomplete,
Button,
Grid,
Stack,
Table,
TableBody,
TableCell,
TableRow,
TextField,
Typography,
useTheme,
List,
ListItem,
IconButton,
ListItemAvatar,
Avatar,
ListItemText,
} from '@mui/material';
import Iconify from '../../components/Iconify';
import { LoadingButton } from '@mui/lab';
import { fCurrency } from '../../utils/formatNumber';
import MemberSelectDialog from '../../components/dialogs/MemberSelectDialog';
import { Add, DeleteOutline } from '@mui/icons-material';
type Props = {
isEdit: boolean;
currentClaim?: any;
};
export default function ClaimForm({ isEdit, currentClaim }: Props) {
const navigate = useNavigate();
const { enqueueSnackbar } = useSnackbar();
const NewCorporateSchema = 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'),
// file: Yup.boolean().required('Corporate Status is required'),
});
const defaultValues = useMemo(
() => ({
member: currentClaim?.member || {},
member_id: currentClaim?.member_id || null,
diagnosis_id: currentClaim?.diagnosis_id || null,
total_claim: currentClaim?.total_claim || 0,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[currentClaim]
);
const methods = useForm<any>({
resolver: yupResolver(NewCorporateSchema),
defaultValues,
});
const {
reset,
watch,
control,
setValue,
getValues,
setError,
handleSubmit,
formState: { isSubmitting },
} = methods;
const values = watch();
const [isCheckingLimit, setIsCheckingLimit] = useState(false);
const [isEligible, setIsEligible] = useState(false);
const [memberBenefits, setMemberBenefits] = useState([]);
const [diagnosisOption, setDiagnosisOption] = useState([]);
const [isMemberDialogOpen, setIsMemberDialogOpen] = useState(false);
const [member, setMember] = useState({})
useEffect(() => {
console.log('defaultValues', defaultValues);
if (isEdit && currentClaim) {
reset(defaultValues);
setMember(defaultValues.member)
}
if (!isEdit) {
reset(defaultValues);
setMember(defaultValues.member)
}
}, [isEdit, currentClaim]);
const fileSelected = (event, type) => {
const files = event.target.files;
const currentFiles = getValues(`uploaded_files.${type}`) ?? [];
setValue(`uploaded_files.${type}`, [...currentFiles, ...files]);
console.log('currentFiles', getValues('uploaded_files'));
};
const memberSelected = (member) => {
setMember(member)
};
const checkLimit = async () => {
console.log('CHECKING LIMIT');
};
const onSubmit = async (data: any) => {
try {
if (!isEdit) {
const response = await axios.post('/claims', data);
} else {
const response = await axios.put('/claims/' + currentClaim?.id ?? '', data);
}
reset();
enqueueSnackbar(
!isEdit ? 'Organizations Created Successfully!' : 'Organizations Udpated Successfully!',
{ variant: 'success' }
);
navigate('/claims');
} catch (error: any) {
if (error && error.response.status === 422) {
for (const [key, value] of Object.entries(error.response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
}
} else {
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
}
}
const ascent = document?.querySelector('ascent');
if (ascent != null) {
ascent.innerHTML = '';
}
};
function generate(files, element: React.ReactElement) {
return files.map((value) =>
React.cloneElement(element, {
key: value,
})
);
}
const headStyle = {};
return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Stack spacing={3}>
<Typography variant="h6">Member</Typography>
<Stack spacing={2} direction="row">
<Grid item xs={12}>
<RHFTextField
name="member_id"
label="Member"
variant="outlined"
fullWidth
value={member?.name || ''}
InputProps={{
readOnly: true,
}}
onClick={() => {
if (!isEdit) setIsMemberDialogOpen(true);
if (isEdit) enqueueSnackbar('Cannot Change Member', { variant: 'error' });
}}
/>
</Grid>
{/* <Grid item xs={2}>
<Button variant="outlined" fullWidth sx={{ p: 1.8 }} onClick={() => {
setIsMemberDialogOpen(true)
}}>
{member ? 'Change' : 'Search'}
</Button>
</Grid> */}
</Stack>
{member?.id && (
<Stack>
<Grid container spacing={2}>
<Grid item xs={12} md={6}>
<Table border="light-700">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left">
Name
</TableCell>
<TableCell align="left">{member?.full_name}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
DOB
</TableCell>
<TableCell align="left">
{member?.birth_date} ({member?.age + ' years'})
</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Marital Status
</TableCell>
<TableCell align="left">{member?.marital_status}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Record Type
</TableCell>
<TableCell align="left">{member?.record_type}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Principal ID
</TableCell>
<TableCell align="left">
{member?.principal_id} (
{member?.relation_with_principal})
</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
<Grid item xs={12} md={6}>
<Table border="light-700">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left">
Plan
</TableCell>
<TableCell align="left">{member?.current_plan?.code}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Active
</TableCell>
<TableCell align="left">
{member?.current_plan?.start} -{' '}
{member?.current_plan?.end} (Active)
</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Corporate Limit
</TableCell>
<TableCell align="left">
{fCurrency(0)} / {fCurrency(member?.current_plan?.limit_rules)}
</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Plan Usage
</TableCell>
<TableCell align="left">
{fCurrency(0)} / {fCurrency(member?.current_plan?.limit_rules)}
</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
</Grid>
</Stack>
)}
<Controller
name="benefit"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
options={memberBenefits}
getOptionLabel={(option) =>
option ? `#${option.id} (${option.code}) ${option.description}` : ''
}
value={value || ''}
onChange={(event: any, newValue: any) => {
setValue('benefit_id', newValue?.id);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
name="benefit"
{...params}
label="Benefit"
variant="outlined"
fullWidth
// onKeyPress={(event) => {
// if (event.key === 'Enter')
// searchDiagnosis(event.target.value)
// }}
/>
)}
/>
)}
/>
<Controller
name="diagnosis"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
options={diagnosisOption}
getOptionLabel={(option) => (option ? `(${option.code}) ${option.name}` : '')}
value={value || ''}
onChange={(event: any, newValue: any) => {
setValue('diagnosis_id', newValue?.id);
// setValue('diagnosis', newValue)
onChange(newValue);
}}
renderInput={(params) => (
<TextField
name="diagnosis"
{...params}
label="Diagnosis"
variant="outlined"
fullWidth
onKeyPress={(event) => {
if (event.key === 'Enter') searchDiagnosis(event.target.value);
}}
/>
)}
/>
)}
/>
{isCheckingLimit && (
<Stack
sx={{
backgroundColor: 'gray',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* Checking */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:info-circle"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Please Wait, Checking Eligibilty
</Typography>
</Typography>
</Stack>
)}
{false && isCheckingLimit == false && isEligible == null && (
<Stack
sx={{
backgroundColor: 'gray',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* No Data Selected */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:info-circle"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Please Select Diagnosis !
</Typography>
</Typography>
</Stack>
)}
{!isCheckingLimit && isEligible !== null && isEligible && (
<Stack
sx={{
backgroundColor: '#B2E8E8',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* Eligible */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:lock-alt"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Diagnosis is Eligible
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
125.000.000 / 125.000.000
</Typography>
</Stack>
)}
{!isCheckingLimit && isEligible !== null && !isEligible && (
<Stack
sx={{
backgroundColor: '#B2E8E8',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* Not Eligible */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:lock-alt"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Not Eligible
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
125.000.000 / 125.000.000
</Typography>
</Stack>
)}
<RHFTextField type="number" name="total_claim" label="Total Claim" />
{isEdit && (
<React.Fragment>
<Typography variant="h6">Documents</Typography>
<List>
{(getValues('uploaded_files.invoice') && getValues('uploaded_files.invoice').length
? getValues('uploaded_files.invoice')
: []
).map((file, index) => (
<ListItem
secondaryAction={
<IconButton edge="end" aria-label="delete">
<DeleteOutline />
</IconButton>
}
>
<ListItemAvatar>
<Avatar>
{/* <FileIcon /> */}
I
</Avatar>
</ListItemAvatar>
<ListItemText primary={file.name} secondary={file.type} />
</ListItem>
))}
</List>
<Button
variant="outlined"
startIcon={<Add />}
component="label"
sx={{ paddingY: 2, width: '100%', ':hover': { border: 'none' } }}
>
Invoice
<input
name="invoice"
hidden
accept="image/*,application/pdf"
multiple
type="file"
onChange={(event) => {
fileSelected(event, 'invoice');
}}
/>
</Button>
<List>
{(getValues('uploaded_files.prescription') && getValues('uploaded_files.prescription').length
? getValues('uploaded_files.prescription')
: []
).map((file, index) => (
<ListItem
secondaryAction={
<IconButton edge="end" aria-label="delete">
<DeleteOutline />
</IconButton>
}
>
<ListItemAvatar>
<Avatar>
{/* <FileIcon /> */}
P
</Avatar>
</ListItemAvatar>
<ListItemText primary={file.name} secondary={file.type} />
</ListItem>
))}
</List>
<Button
variant="outlined"
startIcon={<Add />}
component="label"
sx={{ paddingY: 2, width: '100%', ':hover': { border: 'none' } }}
>
Prescription
<input
name="prescription"
hidden
accept="image/*,application/pdf"
multiple
type="file"
onChange={(event) => {
fileSelected(event, 'prescription');
}}
/>
</Button>
<List>
{(getValues('uploaded_files.diagnosis') && getValues('uploaded_files.diagnosis').length
? getValues('uploaded_files.diagnosis')
: []
).map((file, index) => (
<ListItem
secondaryAction={
<IconButton edge="end" aria-label="delete">
<DeleteOutline />
</IconButton>
}
>
<ListItemAvatar>
<Avatar>
{/* <FileIcon /> */}
DR
</Avatar>
</ListItemAvatar>
<ListItemText primary={file.name} secondary={file.type} />
</ListItem>
))}
</List>
<Button
variant="outlined"
startIcon={<Add />}
component="label"
sx={{ paddingY: 2, width: '100%', ':hover': { border: 'none' } }}
>
Doctor Result
<input
name="invoice"
hidden
accept="image/*,application/pdf"
multiple
type="file"
onChange={(event) => {
fileSelected(event, 'diagnosis');
}}
/>
</Button>
</React.Fragment>
)}
{isEligible === true ? (
<LoadingButton
onClick={handleSubmit(onSubmit)}
variant="contained"
color="success"
style={{ color: '#ffffff' }}
size="large"
fullWidth={true}
loading={isCheckingLimit}
>
Create Claim
</LoadingButton>
) : (
<LoadingButton
onClick={checkLimit}
variant="outlined"
size="large"
fullWidth={true}
loading={isCheckingLimit}
>
Check Limit
</LoadingButton>
)}
</Stack>
<MemberSelectDialog
openDialog={isMemberDialogOpen}
setOpenDialog={setIsMemberDialogOpen}
onSelect={memberSelected}
></MemberSelectDialog>
</FormProvider>
);
}

View File

@@ -22,9 +22,9 @@ export default function Claims() {
]}
/>
<Stack>
<List />
</Stack>
{/* <Stack> */}
<List />
{/* </Stack> */}
</Page>
);
}

View File

@@ -1,5 +1,22 @@
// @mui
import { Box, Button, Card, Collapse, IconButton, MenuItem, Table, TableBody, TableCell, TableRow, TextField, Typography, Stack, Menu, ButtonGroup, Link } from '@mui/material';
import {
Box,
Button,
Card,
Collapse,
IconButton,
MenuItem,
Table,
TableBody,
TableCell,
TableRow,
TextField,
Typography,
Stack,
Menu,
ButtonGroup,
Link,
} from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
@@ -7,39 +24,50 @@ import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel';
// hooks
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import { Navigate, useNavigate, useSearchParams } from 'react-router-dom';
// components
import axios from '../../utils/axios';
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
import DataTable from '../../components/LaravelTable';
import { fCurrency } from '../../utils/formatNumber';
import EditRoundedIcon from '@mui/icons-material/EditRounded';
export default function List() {
const [searchParams, setSearchParams] = useSearchParams();
const [importResult, setImportResult] = useState(null);
const navigate = useNavigate();
function SearchInput(props: any) {
// SEARCH
// SEARCH
const searchInput = useRef<HTMLInputElement>(null);
const [searchText, setSearchText] = useState("");
const [searchText, setSearchText] = useState('');
const handleSearchChange = (event: any) => {
const newSearchText = event.target.value ?? ''
const newSearchText = event.target.value ?? '';
setSearchText(newSearchText);
}
};
const handleSearchSubmit = (event: any) => {
event.preventDefault();
props.onSearch({search: searchText }); // Trigger to Parent
}
props.onSearch({ search: searchText }); // Trigger to Parent
};
useEffect(() => { // Trigger First Search
useEffect(() => {
// Trigger First Search
setSearchText(searchParams.get('search') ?? '');
}, [])
}, []);
return (
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}>
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/>
<TextField
id="search-input"
ref={searchInput}
label="Search"
variant="outlined"
fullWidth
onChange={handleSearchChange}
value={searchText}
/>
</form>
);
}
@@ -49,8 +77,8 @@ export default function List() {
// Create Button Menu
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const createMenu = Boolean(anchorEl);
const importForm = useRef<HTMLInputElement>(null)
const [currentImportFileName, setCurrentImportFileName] = useState(null)
const importForm = useRef<HTMLInputElement>(null);
const [currentImportFileName, setCurrentImportFileName] = useState(null);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
@@ -65,54 +93,61 @@ export default function List() {
handleClose();
importForm.current ? importForm.current.click() : console.log('No File selected');
} else {
alert('No file selected')
alert('No file selected');
}
}
};
const handleCancelImportButton = () => {
importForm.current.value = "";
importForm.current.dispatchEvent(new Event("change", { bubbles: true }));
}
importForm.current.value = '';
importForm.current.dispatchEvent(new Event('change', { bubbles: true }));
};
const handleImportChange = (event: any) => {
if (event.target.files[0]) {
setCurrentImportFileName(event.target.files[0].name)
setCurrentImportFileName(event.target.files[0].name);
} else {
setCurrentImportFileName(null);
}
}
};
const handleUpload = () => {
if (importForm.current?.files.length) {
const formData = new FormData();
formData.append("file", importForm.current?.files[0])
axios.post(`corporates/${corporate_id}/import-plan-benefit`, formData )
.then(response => {
formData.append('file', importForm.current?.files[0]);
axios
.post(`corporates/${corporate_id}/import-plan-benefit`, formData)
.then((response) => {
handleCancelImportButton();
loadDataTableData();
setImportResult(response.data)
setImportResult(response.data);
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
})
.catch(response => {
enqueueSnackbar('Looks like something went wrong. Please check your data and try again. ' + response.message, { variant: 'error' })
})
.catch((response) => {
enqueueSnackbar(
'Looks like something went wrong. Please check your data and try again. ' +
response.message,
{ variant: 'error' }
);
});
} else {
enqueueSnackbar('No File Selected', { variant: 'warning' })
enqueueSnackbar('No File Selected', { variant: 'warning' });
}
}
};
return (
<div>
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter}/>
<Link href="/claims/create" style={{ textDecoration: "none" }}>
<Button
variant='outlined'
startIcon={<AddIcon />} sx={{ p: 1.8 }}
>
Create
</Button>
</Link>
<SearchInput onSearch={applyFilter} />
<Button
variant="outlined"
startIcon={<AddIcon />}
sx={{ p: 1.8 }}
onClick={() => {
navigate('/claims/create');
}}
>
Create
</Button>
</Stack>
</div>
);
@@ -120,9 +155,11 @@ export default function List() {
// Dummy Default Data
const [dataTableIsLoading, setDataTableLoading] = useState(true);
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>(LaravelPaginatedDataDefault);
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>(
LaravelPaginatedDataDefault
);
const loadDataTableData = async (appliedFilter : any | null = null) => {
const loadDataTableData = async (appliedFilter: any | null = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/claims', { params: filter });
@@ -130,35 +167,37 @@ export default function List() {
setDataTableLoading(false);
setDataTableData(response.data);
}
};
const applyFilter = async (searchFilter: {search: string}) => {
const applyFilter = async (searchFilter: { search: string }) => {
await loadDataTableData(searchFilter);
setSearchParams(searchFilter);
}
};
const handlePageChange = (event : ChangeEvent, value: number) : void => {
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
const handlePageChange = (event: ChangeEvent, value: number): void => {
const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
loadDataTableData(filter);
setSearchParams(filter);
}
};
useEffect(() => {
loadDataTableData();
}, [])
}, []);
const headStyle = {
fontWeight: 'bold',
fontWeight: 'bold',
};
// Called on every row to map the data to the columns
function createData( data: any ): any {
function createData(data: any): any {
return {
...data,
}
};
}
{/* ------------------ TABLE ROW ------------------ */}
{
/* ------------------ TABLE ROW ------------------ */
}
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
@@ -167,11 +206,7 @@ export default function List() {
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell>
<IconButton
aria-label="expand row"
size="small"
onClick={() => setOpen(!open)}
>
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton>
</TableCell>
@@ -179,10 +214,18 @@ export default function List() {
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left">{row.plan?.code}</TableCell>
<TableCell align="left">{row.benefit?.code}</TableCell>
<TableCell align="left">({row.diagnosis?.code}) {row.diagnosis?.name}</TableCell>
<TableCell align="left">
({row.diagnosis?.code}) {row.diagnosis?.name}
</TableCell>
<TableCell align="left">{fCurrency(row.total_claim)}</TableCell>
{/* <TableCell align="right"><Button variant="outlined" color="error" size="small">Disable</Button></TableCell> */}
<TableCell align="right">
<EditRoundedIcon
onClick={(e) => {
navigate('/claims/' + row.id);
}}
/>
</TableCell>
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
@@ -199,7 +242,9 @@ export default function List() {
</React.Fragment>
);
}
{/* ------------------ END TABLE ROW ------------------ */}
{
/* ------------------ END TABLE ROW ------------------ */
}
function TableContent() {
return (
@@ -208,57 +253,69 @@ export default function List() {
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left" />
<TableCell style={headStyle} align="left">Code</TableCell>
<TableCell style={headStyle} align="left">Member Name</TableCell>
<TableCell style={headStyle} align="left">Plan</TableCell>
<TableCell style={headStyle} align="left">Benefit</TableCell>
<TableCell style={headStyle} align="left">Diagnosis</TableCell>
<TableCell style={headStyle} align="left">Total Claim</TableCell>
{/* <TableCell style={headStyle} align="right">Action</TableCell> */}
<TableCell style={headStyle} align="left">
Code
</TableCell>
<TableCell style={headStyle} align="left">
Member Name
</TableCell>
<TableCell style={headStyle} align="left">
Plan
</TableCell>
<TableCell style={headStyle} align="left">
Benefit
</TableCell>
<TableCell style={headStyle} align="left">
Diagnosis
</TableCell>
<TableCell style={headStyle} align="left">
Total Claim
</TableCell>
<TableCell style={headStyle} align="right">
Action
</TableCell>
</TableRow>
</TableBody>
{/* ------------------ END TABLE HEADER ------------------ */}
{/* ------------------ TABLE ROW ------------------ */}
{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.id} row={row} />
))}
</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.id} row={row} />
))}
</TableBody>
)}
{/* ------------------ END TABLE ROW ------------------ */}
</Table>
)
);
}
return (
<Card>
<ImportForm />
<DataTable
<DataTable
isLoading={dataTableIsLoading}
lastRequest={0}
data={dataTableData}
handlePageChange={handlePageChange}
TableContent={<TableContent />}
/>
</Card>

View File

@@ -1,14 +1,15 @@
import * as Yup from 'yup';
import { LoadingButton } from "@mui/lab";
import { Card, Grid, Stack, Typography } from "@mui/material";
import { CorporatePlan } from "../../../@types/corporates";
import { FormProvider, RHFEditor, RHFSwitch, RHFTextField } from "../../../components/hook-form";
import { useEffect, useMemo } from 'react';
import { LoadingButton } from '@mui/lab';
import { Card, Grid, Stack, Typography } from '@mui/material';
import { CorporatePlan } from '../../../@types/corporates';
import { FormProvider, RHFEditor, RHFSwitch, RHFTextField } from '../../../components/hook-form';
import { useEffect, useMemo, useState } from 'react';
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import { useSnackbar } from 'notistack';
import { useNavigate, useParams } from 'react-router-dom';
import axios from '../../../utils/axios';
import MemberSelectDialog from '../../../components/dialogs/MemberSelectDialog';
type Props = {
isEdit: boolean;
@@ -16,7 +17,6 @@ type Props = {
};
export default function CorporatePlanForm({ isEdit, currentCorporatePlan }: Props) {
const { enqueueSnackbar } = useSnackbar();
const navigate = useNavigate();
const { corporate_id } = useParams();
@@ -31,7 +31,7 @@ export default function CorporatePlanForm({ isEdit, currentCorporatePlan }: Prop
name: currentCorporatePlan?.name || '',
code: currentCorporatePlan?.code || '',
active: currentCorporatePlan?.active || true,
description: currentCorporatePlan?.description || ''
description: currentCorporatePlan?.description || '',
}),
[currentCorporatePlan]
);
@@ -61,75 +61,78 @@ export default function CorporatePlanForm({ isEdit, currentCorporatePlan }: Prop
formState: { isSubmitting },
} = methods;
const onSubmit = async (data: any) => {
if (!isEdit) {
await axios
.post('/corporates/' + corporate_id + '/corporate-plans', data)
.then((res) => {
enqueueSnackbar('Corporate Plan created successfully', { variant: 'success' });
})
.then((res) => {
navigate('/corporates/' + corporate_id + '/corporate-plans', { replace: true });
})
.catch(({ response }) => {
if (response.status === 422) {
for (const [key, value] of Object.entries(response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
.post('/corporates/' + corporate_id + '/corporate-plans', data)
.then((res) => {
enqueueSnackbar('Corporate Plan created successfully', { variant: 'success' });
})
.then((res) => {
navigate('/corporates/' + corporate_id + '/corporate-plans', { replace: true });
})
.catch(({ response }) => {
if (response.status === 422) {
for (const [key, value] of Object.entries(response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
}
} else {
enqueueSnackbar('Create Failed : ' + response.data.message, { variant: 'error' });
}
}
else {
enqueueSnackbar('Create Failed : '+ response.data.message, { variant: 'error' });
}
});
});
} else {
await axios
.put('/corporates/' + corporate_id + '/corporate-plans/' + currentCorporatePlan?.id , data)
.put('/corporates/' + corporate_id + '/corporate-plans/' + currentCorporatePlan?.id, data)
.then((res) => {
enqueueSnackbar('Corporate Plan updated successfully', { variant: 'success' });
})
.then((res) => {
navigate('/corporates/' + corporate_id + '/corporate-plans/' , { replace: true });
navigate('/corporates/' + corporate_id + '/corporate-plans/', { replace: true });
})
.catch(({ response }) => {
enqueueSnackbar('Update Failed : '+ response.data.message, { variant: 'error' });
enqueueSnackbar('Update Failed : ' + response.data.message, { variant: 'error' });
});
}
};
return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Grid container spacing={2}>
<Grid item xs={8}>
<Card sx={{ p: 2 }}>
<Stack spacing={3}>
<Grid container spacing={2}>
<Grid item xs={8}>
<Card sx={{ p: 2 }}>
<Stack spacing={3}>
<Typography variant="h6">Corporate Plan Detail</Typography>
<Typography variant="h6">Corporate Plan Detail</Typography>
<RHFTextField name="name" label="Name" />
<RHFTextField name="name" label="Name" />
<RHFTextField name="code" label="Code" />
<RHFTextField name="code" label="Code" />
<Stack spacing={1}>
<Typography variant="subtitle2" sx={{ color: 'text.secondary' }}>
Description
</Typography>
<RHFEditor name="description" />
</Stack>
<Stack spacing={1}>
<Typography variant='subtitle2' sx={{ color: "text.secondary" }}>Description</Typography>
<RHFEditor name="description" />
</Stack>
<LoadingButton type="submit" variant="contained" size="large" fullWidth={true} loading={isSubmitting}>
Create Corporate Plan
</LoadingButton>
</Stack>
</Card>
</Grid>
<Grid item xs={4}>
<Card sx={{ p:2 }}>
<RHFSwitch name="active" label="Active" />
</Card>
</Grid>
<LoadingButton
type="submit"
variant="contained"
size="large"
fullWidth={true}
loading={isSubmitting}
>
Create Corporate Plan
</LoadingButton>
</Stack>
</Card>
</Grid>
</FormProvider>
<Grid item xs={4}>
<Card sx={{ p: 2 }}>
<RHFSwitch name="active" label="Active" />
</Card>
</Grid>
</Grid>
</FormProvider>
);
}

View File

@@ -1,5 +1,5 @@
// @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 { 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, Grid } from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
@@ -43,7 +43,11 @@ export default function CorporatePlanList() {
const loadDataTableData = async (appliedFilter = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/corporates/'+corporate_id+'/members', { params: filter });
const response = await axios
.get('/corporates/'+corporate_id+'/members', { params: filter })
.catch((response) => {
enqueueSnackbar('Failed getting data. ' + response.message, { variant: 'error' })
});
// console.log(response.data);
setDataTableLoading(false);
@@ -278,14 +282,70 @@ export default function CorporatePlanList() {
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={10}>
<TableCell></TableCell>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={30}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
<Typography variant="body2" gutterBottom component="div">
No Extra Data
</Typography>
<Box sx={{ margin: 1, borderBottom: 1, pb: 2 }}>
<Typography sx={{ fontWeight: '600', mb: 1 }}>Claim History</Typography>
<Grid container>
<Grid item xs={6}>
<Grid container>
<Grid item xs={6}>
Requested
</Grid>
<Grid item xs={6}>
: {row.total_claims.requested}
</Grid>
<Grid item xs={6}>
Pending
</Grid>
<Grid item xs={6}>
: {row.total_claims.received}
</Grid>
<Grid item xs={6}>
Approved
</Grid>
<Grid item xs={6}>
: {row.total_claims.approved}
</Grid>
<Grid item xs={6}>
Declined
</Grid>
<Grid item xs={6}>
: {row.total_claims.declined}
</Grid>
<Grid item xs={6}>
Paid
</Grid>
<Grid item xs={6}>
: {row.total_claims.paid}
</Grid>
</Grid>
</Grid>
</Grid>
{/* <Typography sx={{ fontWeight: '600', mb: 1, mt: 2 }}>Sub Corporate</Typography>
<Grid container>
<Grid item xs={12}>
<Grid container>
<Grid item xs={6}>
Sub Corporates (asdasdasdasd)
</Grid>
<Grid item xs={6}>
: qweqweqweqwe
</Grid>
</Grid>
</Grid>
</Grid> */}
</Box>
{false && <Box sx={{ margin: 1 }} />}
</Collapse>
</TableCell>
</TableRow>

View File

@@ -11,188 +11,30 @@ import Page from '../../components/Page';
import axios from '../../utils/axios';
import useAuth from '../../hooks/useAuth';
import { Link , NavLink as RouterLink, useParams } from 'react-router-dom';
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { Theme, useTheme } from '@mui/material/styles';
import { Corporate } from '../../@types/corporates';
import { LaravelPaginatedData } from '../../@types/paginated-data';
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs';
import CorporateTabNavigations from './CorporateTabNavigations';
import { fCurrency } from '../../utils/formatNumber';
export default function Corporates() {
const { themeStretch } = useSettings();
// Called on every row to map the data to the columns
function createData( corporate: Corporate ): Corporate {
return {
...corporate,
}
}
// 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>
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ margin: 1 }}>
<Typography variant="h6" gutterBottom component="div">
History
</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={historyRow?.date}>
<TableCell component="th" scope="row">
{historyRow?.date}
</TableCell>
<TableCell>{historyRow?.customerId}</TableCell>
<TableCell align="right">{historyRow?.amount}</TableCell>
<TableCell align="right">
{Math.round(historyRow?.amount * 1000 * 100) / 100}
</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 () => {
setDataTableLoading(true);
const response = await axios.get('/corporates');
// console.log(response.data);
setDataTableLoading(false);
setDataTableData(response.data);
}
const { corporate_id } = useParams();
const [corporate, setCorporate] = useState<Corporate>();
useEffect(() => {
loadDataTableData();
// TODO Use Hooks
axios.get(`corporates/${corporate_id}`)
.then((res) => {
setCorporate(res.data)
})
}, [])
const headStyle = {
fontWeight: 'bold',
};
// FILTER SELECT
const ITEM_HEIGHT = 48;
const ITEM_PADDING_TOP = 8;
const MenuProps = {
PaperProps: {
style: {
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
width: 250,
},
},
};
const names = [
'PLAN001',
'PLAN002',
'PLAN003',
'PLAN004',
'PLAN005',
];
function getStyles(name: string, personName: string[], theme: Theme) {
return {
fontWeight:
personName.indexOf(name) === -1
? theme.typography.fontWeightRegular
: theme.typography.fontWeightMedium,
};
}
const theme = useTheme();
const [planIdFilter, setPlanIdFilter] = React.useState<string[]>([]);
const handleChangePlanID = (event: SelectChangeEvent<typeof planIdFilter>) => {
const {
target: { value },
} = event;
setPlanIdFilter(
// On autofill we get a stringified value.
typeof value === 'string' ? value.split(',') : value,
);
};
const [statusFilter, setStatusFilter] = React.useState<string[]>([]);
const handleChangeStatus = (event: SelectChangeEvent<typeof statusFilter>) => {
const {
target: { value },
} = event;
setStatusFilter(
// On autofill we get a stringified value.
typeof value === 'string' ? value.split(',') : value,
);
};
// END FILTER SELECT
// IMPORT
const importMember = React.useRef(null);
const handleImportButton = (event: any) => {
if (importMember?.current)
importMember.current ? importMember.current.click() : console.log('fuck');
else
alert('No file selected')
}
const { id } = useParams();
};
return (
<Page title="Dashboard">
@@ -204,8 +46,8 @@ export default function Corporates() {
href: '/corporates',
},
{
name: 'Corporate Name',
href: '/corporates/'+id,
name: corporate?.name ?? '-',
href: '/corporates/'+corporate_id,
},
]}
/>
@@ -217,10 +59,58 @@ export default function Corporates() {
<CorporateTabNavigations position=""/>
<Grid container spacing={3}>
<Grid item xs={12} sx={{ p:2 }}>
Corporate Dashboard / Report Goes Here
&nbsp;
<Grid item md={6} sx={{ p:2 }}>
<Typography sx={{...headStyle, px:3, fontSize:'24px'}}>Current Policy </Typography>
<Table>
<TableBody>
<TableRow>
<TableCell sx={headStyle}>Policy Name</TableCell>
<TableCell>{corporate?.current_policy?.code}</TableCell>
</TableRow>
<TableRow>
<TableCell sx={headStyle}>Total Premi</TableCell>
<TableCell>{fCurrency(corporate?.current_policy?.total_premi)}</TableCell>
</TableRow>
<TableRow>
<TableCell sx={headStyle}>Stop Service</TableCell>
<TableCell>{fCurrency(corporate?.current_policy?.minimal_stop_service_net)}</TableCell>
</TableRow>
<TableRow>
<TableCell sx={headStyle}>Balance</TableCell>
<TableCell>{fCurrency(corporate?.current_policy?.limit_balance)}</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
<Grid item md={6} sx={{ p:2 }}>
<Typography sx={{...headStyle, px:3, fontSize:'24px'}}>Claims</Typography>
<Table>
<TableBody>
<TableRow>
<TableCell sx={headStyle}>Number Of Claim</TableCell>
<TableCell>{corporate?.current_policy?.code}</TableCell>
</TableRow>
<TableRow>
<TableCell sx={headStyle}>Total Usage This Year</TableCell>
<TableCell>{fCurrency((corporate?.current_policy?.total_premi ?? 0) - (corporate?.current_policy?.limit_balance ?? 0))}</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
</Grid>
</Stack>
</Card>

View File

@@ -303,4 +303,4 @@ const CorporateHospitals = Loadable(lazy(() => import('../pages/Corporates/Hospi
const CorporateClaimHistories = Loadable(lazy(() => import('../pages/Corporates/ClaimHistory/Index')));
const Claims = Loadable(lazy(() => import('../pages/Claims/Index')));
const ClaimsCreate = Loadable(lazy(() => import('../pages/Claims/Create')));
const ClaimsCreate = Loadable(lazy(() => import('../pages/Claims/CreateUpdate')));

View File

@@ -1,7 +1,7 @@
<?php
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\MemberController;
use App\Http\Controllers\Api\MembershipController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
@@ -15,3 +15,8 @@ use Illuminate\Support\Facades\Route;
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('linksehat.old.auth')->group(function() {
Route::post('check-membership', [MembershipController::class, 'check']);
Route::post('check-limit', [MembershipController::class, 'checkLimit']);
});