[WIP] ASO Payment
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Member;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MemberController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$members = [];
|
||||
|
||||
$faker = \Faker\Factory::create();
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$members[] = [
|
||||
'id' => (10-$i),
|
||||
'code' => 'UT0000'.sprintf("%02d", 10-$i),
|
||||
'nik' => 'UNTR0000'.sprintf("%02d", $i),
|
||||
'name' => $faker->name,
|
||||
'plan_code' => collect(['PLAN001', 'PLAN002', 'PLAN003', 'PLAN004', 'PLAN005'])->random(),
|
||||
'number_of_families' => random_int(2,4),
|
||||
'number_of_claim' => random_int(0,2),
|
||||
'active' => true,
|
||||
'history' => []
|
||||
];
|
||||
}
|
||||
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,12 @@ class ClaimController extends Controller
|
||||
'currentPlan',
|
||||
])
|
||||
->firstOrFail();
|
||||
$benefit = $member->currentPlan->benefits()->where('benefit_code', $benefitCode)->first();
|
||||
$benefit = $member->currentPlan->benefits()->where('code', $benefitCode)->first();
|
||||
// $diagnosis = Icd::first();
|
||||
|
||||
$claim = ClaimService::storeClaim($member, null, $request->total_claim, $benefit, 'approved');
|
||||
$claim = ClaimService::storeClaim($member, null, $request->total_claim, $benefit, 'requested');
|
||||
$claim->status = 'approved';
|
||||
$claim->save();
|
||||
|
||||
return Helper::responseJson($claim);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class MembershipController extends Controller
|
||||
{
|
||||
$request->validate([
|
||||
'member_id' => 'required',
|
||||
'birth_date' => 'required',
|
||||
// 'birth_date' => 'required',
|
||||
]);
|
||||
|
||||
$member = Member::where('member_id', $request->member_id)->first();
|
||||
@@ -28,7 +28,6 @@ class MembershipController extends Controller
|
||||
return Helper::responseJson(statusCode: 406, message: 'The Member '.$request->member_id.' is Inactive.', status: 'error');
|
||||
}
|
||||
|
||||
|
||||
return Helper::responseJson(data: $member, message: 'Member Found');
|
||||
}
|
||||
|
||||
@@ -36,7 +35,8 @@ class MembershipController extends Controller
|
||||
{
|
||||
$request->validate([
|
||||
'member_id' => 'required',
|
||||
'type' => 'required|in:consultation-gp,consultation-specialist,medicine'
|
||||
'type' => 'required|in:consultation-gp,consultation-specialist,medicine',
|
||||
// 'speciality_code' => 'sometimes'
|
||||
]);
|
||||
|
||||
if ($request->type == 'consultation-gp') {
|
||||
@@ -49,9 +49,170 @@ class MembershipController extends Controller
|
||||
$benefitCode = 'OPMEDI1';
|
||||
}
|
||||
|
||||
$member = Member::where('member_id', $request->member_id)->with(['currentCorporate', 'currentPolicy', 'currentPlan'])->first();
|
||||
|
||||
$member = Member::where('member_id', $request->member_id)->with(['currentCorporate', 'currentPolicy', 'currentPlan', 'postponedClaims'])->first();
|
||||
|
||||
$limits = ClaimService::showMemberBenefitLimit($member, $benefitCode);
|
||||
$limits['postponed_claims'] = $member->postponedClaims;
|
||||
$limits['postponed_claims_payment_url'] = "http://google.com";
|
||||
$limits['postponed_claims_unpaid_total'] = $member->postponedClaims->sum('total_claim');
|
||||
|
||||
if ($request->has('speciality_code') && !empty($request->speciality_code)) {
|
||||
$corporateService = $member->currentCorporate
|
||||
->corporateServices()
|
||||
->active()
|
||||
->where('service_code', 'OP')
|
||||
->with([
|
||||
'specialities' => function ($speciality) use ($request) {
|
||||
$speciality->where('code', $request->speciality_code)
|
||||
->wherePivot('active', 1);
|
||||
}])
|
||||
->first();
|
||||
|
||||
// $rules = $corporateServiceConfigs->
|
||||
// dd($corporateServiceConfigs->toArray());
|
||||
if (empty($corporateService)) {
|
||||
$limit['coverage'] = [
|
||||
'benefit' => false,
|
||||
'admin_fee' => false,
|
||||
'delivery_fee' => false
|
||||
];
|
||||
|
||||
return Helper::responseJson(data: $limits);
|
||||
}
|
||||
|
||||
if (empty($corporateService->specialities)) {
|
||||
$limit['coverage'] = [
|
||||
'benefit' => false,
|
||||
'admin_fee' => false,
|
||||
'delivery_fee' => false
|
||||
];
|
||||
|
||||
return Helper::responseJson(data: $limits);
|
||||
}
|
||||
|
||||
$currentSpeciality = $corporateService->specialities->first();
|
||||
|
||||
// Load the Relation Data after speciality check is supported
|
||||
$corporateService->load([
|
||||
'configs',
|
||||
// 'configs.exclusions.rules',
|
||||
'corporateServiceSpecialities' => function ($corporateServiceSpeciality) use ($currentSpeciality) {
|
||||
$corporateServiceSpeciality->where('speciality_id', $currentSpeciality->id);
|
||||
},
|
||||
'corporateServiceSpecialities.exclusions' => function ($exclusion) {
|
||||
$exclusion->where('service_code', 'OP');
|
||||
},
|
||||
'corporateServiceSpecialities.exclusions.rules'
|
||||
]);
|
||||
|
||||
$configs = $corporateService->configs->mapWithKeys(function ($config) {
|
||||
return [$config->name => $config];
|
||||
});
|
||||
|
||||
$serviceSpeciality = $corporateService->corporateServiceSpecialities->first() ?? null;
|
||||
$serviceSpecialityRules = $serviceSpeciality->exclusions->first()->rules ?? collect([]);
|
||||
$serviceSpecialityRules = $serviceSpecialityRules->mapWithKeys(function ($rule) {
|
||||
return [$rule->name => $rule];
|
||||
});
|
||||
|
||||
$gpSpecialityName = config('aso.general_practitioner_speciality_name', 'Umum');
|
||||
// dd($serviceSpecialityRules->toArray());
|
||||
|
||||
$coverage = [
|
||||
'benefit' => false,
|
||||
'admin_fee' => false,
|
||||
'delivery_fee' => false
|
||||
];
|
||||
|
||||
// dd($configs->toArray());
|
||||
// dd($gpSpecialityName, $currentSpeciality->name);
|
||||
|
||||
if ($gpSpecialityName == $currentSpeciality->name) {
|
||||
// To General Practitioner
|
||||
if (($configs['gp_internal_doctor_online']['value'] ?? 1) == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
|
||||
if (($configs['general_practitioner_fee']['value'] ?? 1) == 1) {
|
||||
$coverage['admin_fee'] = true;
|
||||
}
|
||||
|
||||
if ($serviceSpeciality->active == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
// To Specialist
|
||||
if (($configs['sp_internal_doctor_online']['value'] ?? 1) == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
// dd($configs['specialist_practitioner_fee']['value'], $configs['specialist_practitioner_fee']['value'] ?? 1, ($configs['specialist_practitioner_fee']['value'] ?? 1) == 1);
|
||||
|
||||
if (($configs['specialist_practitioner_fee']['value'] ?? 1) == 1) {
|
||||
$coverage['admin_fee'] = true;
|
||||
}
|
||||
|
||||
if ($serviceSpeciality->active == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO THIS EXCLUSION IS USED AS INCLUSION NOW, MUST BE CHANGE TO USED AS EXCLUSION AND MAYBE MOVE THE TABLE
|
||||
$excluded = [];
|
||||
foreach ($serviceSpecialityRules as $ruleName => $rule) {
|
||||
if ($ruleName == 'msc') {
|
||||
$values = explode(',', $rule->values);
|
||||
if (!in_array(strtolower($member->marital_status), $values)) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'gender') {
|
||||
$values = explode(',', $rule->values);
|
||||
if (!in_array(strtolower($member->gender), $values)) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'min_age') {
|
||||
if (!empty($rule->values) && $member->age < $rule->values) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'max_age') {
|
||||
if (!empty($rule->values) && $member->age > $rule->values) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'plan') {
|
||||
$values = explode(',', $rule->values);
|
||||
if (!in_array($member->currentPlan->code, $values)) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($excluded) ) {
|
||||
$coverage['benefit'] = false;
|
||||
$coverage['benefit_exclusion'] = $excluded;
|
||||
} else {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
|
||||
|
||||
$limits['coverage'] = $coverage;
|
||||
} else {
|
||||
|
||||
$limits['coverage'] = [
|
||||
'benefit' => true,
|
||||
'admin_fee' => true,
|
||||
'delivery_fee' => true
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
return Helper::responseJson(data: $limits);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user