Compare commits
56 Commits
feature/li
...
feature/lm
| Author | SHA1 | Date | |
|---|---|---|---|
| 552a2367f5 | |||
| 804ac883fa | |||
|
|
0fdad5a6c2 | ||
|
|
40ad4a22c7 | ||
| 0781e1ea00 | |||
|
|
cb834d10bb | ||
|
|
77f67fca1e | ||
|
|
1884d32c4b | ||
|
|
55ae0efc66 | ||
|
|
9400145990 | ||
|
|
e15dda0955 | ||
|
|
3c49b98721 | ||
| 9fe12b5948 | |||
|
|
2321e708c5 | ||
|
|
b1c908a6f6 | ||
|
|
88ad144921 | ||
|
|
da14589328 | ||
|
|
2bf3ae7b2b | ||
| 7c4886d57f | |||
|
|
0d6c2ab30b | ||
|
|
1857653ce0 | ||
| 1baaf80b2b | |||
| 74aa5f0486 | |||
| ad46f5a2f0 | |||
| 9ae069718e | |||
| ad090112eb | |||
| 96dc557a59 | |||
| c67026413f | |||
| 9d261d4dfc | |||
| 37b1b24551 | |||
| 6a4447a549 | |||
|
|
6d6439cc94 | ||
|
|
a3760b8757 | ||
| 23468df422 | |||
| 5100a72bbd | |||
| cd77ed8c3b | |||
| ab7f19dc17 | |||
| 3d9dab502b | |||
| 83408f4431 | |||
|
|
f164317b58 | ||
|
|
7a421e0619 | ||
|
|
9526092860 | ||
|
|
0c9362334c | ||
| df34c3919d | |||
|
|
5840a311e0 | ||
| 8d6b6e41d7 | |||
| 3c18ae2852 | |||
|
|
f20cb5b44c | ||
|
|
52633f438f | ||
|
|
e13b99a34a | ||
|
|
2bac2bfeb7 | ||
|
|
723c9f1895 | ||
|
|
b26ccdd0e6 | ||
|
|
405ca24c6a | ||
|
|
f18e7126d3 | ||
|
|
86076ff1d7 |
@@ -81,7 +81,7 @@ class AuthController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Helper::responseJson(message: 'OTP yang anda masukan salah!');
|
return Helper::responseJson(status: 'error', message: 'OTP yang anda masukan salah!');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout(Request $request)
|
public function logout(Request $request)
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Client\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
class ClaimReportController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
116
Modules/Client/Http/Controllers/Api/CorporateDivisionController.php
Executable file
116
Modules/Client/Http/Controllers/Api/CorporateDivisionController.php
Executable file
@@ -0,0 +1,116 @@
|
|||||||
|
<?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 CorporateDivisionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request, $corporate_id)
|
||||||
|
{
|
||||||
|
$division = CorporateDivision::query()
|
||||||
|
->where('corporate_id', $corporate_id)
|
||||||
|
->get(['id', 'name']);
|
||||||
|
|
||||||
|
return response()->json($division);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
73
Modules/Client/Http/Controllers/Api/CorporateManageController.php
Executable file
73
Modules/Client/Http/Controllers/Api/CorporateManageController.php
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
<?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 CorporateManageController 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();
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
112
Modules/Client/Http/Controllers/Api/CorporateMemberController.php
Executable file
112
Modules/Client/Http/Controllers/Api/CorporateMemberController.php
Executable file
@@ -0,0 +1,112 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Client\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\Member;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Client\Transformers\MemberResources;
|
||||||
|
|
||||||
|
class CorporateMemberController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request, $corporate_id)
|
||||||
|
{
|
||||||
|
$limit = $request->has('per_page') ? $request->per_page : 10;
|
||||||
|
|
||||||
|
$members = Member::query()
|
||||||
|
->whereHas('employeds', function ($corporateEmployee) use ($corporate_id) {
|
||||||
|
$corporateEmployee->where('corporate_id', $corporate_id);
|
||||||
|
})->when($request->input('search'), function ($query, $search) {
|
||||||
|
$query->where('member_id', 'like', "%" . $search . "%")
|
||||||
|
->orWhere('name', 'like', "%" . $search . "%");
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($request->input('claimMember') === 'false') {
|
||||||
|
$members = $members->when($request->input('division'), function ($division, $division_id) {
|
||||||
|
$division->whereHas('division', function ($corporateEmployee) use ($division_id) {
|
||||||
|
$corporateEmployee->where('division_id', $division_id);
|
||||||
|
});
|
||||||
|
})->when($request->has('orderBy'), function ($query) use ($request) {
|
||||||
|
$query->orderBy($request->orderBy, $request->order);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// else {
|
||||||
|
// $members = $members->get();
|
||||||
|
|
||||||
|
// return response()->json(MemberResources::collection($members));
|
||||||
|
// }
|
||||||
|
$members->with('currentPlan');
|
||||||
|
$members->withSum('claims', 'total_claim');
|
||||||
|
|
||||||
|
$members = $members->paginate($limit);
|
||||||
|
// return $members;
|
||||||
|
|
||||||
|
return response()->json(Helper::paginateResources(MemberResources::collection($members)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('client::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('client::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,25 +5,25 @@ namespace Modules\Client\Http\Controllers\Api;
|
|||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Modules\Client\Transformers\DashboardResources;
|
||||||
|
|
||||||
class DashboardController extends Controller
|
class CorporatePolicyController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = Auth::user();
|
||||||
|
$currentCorporate = $user->managedCorporates()
|
||||||
|
->with(['currentPolicy', 'employees'])
|
||||||
|
->find($corporate_id);
|
||||||
|
|
||||||
$corporate = $user->managedCorporates()
|
$data = DashboardResources::make($currentCorporate);
|
||||||
->withCount('employees')
|
|
||||||
->with(['policies' => function ($policy) {
|
|
||||||
$policy->limit(1)->latest();
|
|
||||||
}])
|
|
||||||
->first();
|
|
||||||
|
|
||||||
return response()->json(compact('corporate'));
|
return response()->json($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -5,6 +5,7 @@ namespace Modules\Client\Http\Controllers\Api;
|
|||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@@ -14,7 +15,10 @@ class UserController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
return response()->json(auth()->user());
|
$userLogin = Auth::user();
|
||||||
|
$corporateSelected = $userLogin->managedCorporates()->select('corporates.id')->where('active', 1)->first();
|
||||||
|
|
||||||
|
return response()->json(['user' => $userLogin, 'corporate' => $corporateSelected]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Modules\Client\Http\Controllers\Api\AuthController;
|
use Modules\Client\Http\Controllers\Api\AuthController;
|
||||||
use Modules\Client\Http\Controllers\Api\DashboardController;
|
use Modules\Client\Http\Controllers\Api\CorporateDivisionController;
|
||||||
use Modules\Client\Http\Controllers\Api\MemberController;
|
use Modules\Client\Http\Controllers\Api\CorporateManageController;
|
||||||
|
use Modules\Client\Http\Controllers\Api\CorporateMemberController;
|
||||||
|
use Modules\Client\Http\Controllers\Api\CorporatePolicyController;
|
||||||
use Modules\Client\Http\Controllers\Api\UserController;
|
use Modules\Client\Http\Controllers\Api\UserController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -24,11 +26,14 @@ Route::prefix('client')->group(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware('auth:sanctum')->group(function () {
|
Route::middleware('auth:sanctum')->group(function () {
|
||||||
|
|
||||||
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
||||||
Route::get('/user', [UserController::class, 'index']);
|
Route::get('user', [UserController::class, 'index']);
|
||||||
|
|
||||||
Route::get('dashboard', [DashboardController::class, 'index']);
|
Route::get('corporate-manage', [CorporateManageController::class, 'index']);
|
||||||
Route::get('members', [MemberController::class, 'index']);
|
Route::prefix('{corporate_id}')->group(function () {
|
||||||
|
Route::get('policy', [CorporatePolicyController::class, 'index']);
|
||||||
|
Route::get('division', [CorporateDivisionController::class, 'index']);
|
||||||
|
Route::get('members', [CorporateMemberController::class, 'index']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
38
Modules/Client/Transformers/DashboardResources.php
Normal file
38
Modules/Client/Transformers/DashboardResources.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?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
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Modules/Client/Transformers/MemberResources.php
Normal file
32
Modules/Client/Transformers/MemberResources.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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 [
|
||||||
|
'id' => $this->id,
|
||||||
|
'memberId' => $this->member_id,
|
||||||
|
'fullName' => $this->full_name,
|
||||||
|
$this->mergeWhen($request->input('claimMember') === 'false', [
|
||||||
|
'division' => $this->division->name ?? '',
|
||||||
|
'status' => $this->active
|
||||||
|
]),
|
||||||
|
'limit' => [
|
||||||
|
'current' => $this->claims_sum_total_claim,
|
||||||
|
'total' => $this->currentPlan->limit_rules ?? 0,
|
||||||
|
'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->claims_sum_total_claim / $this->currentPlan->limit_rules) * 100) : 0
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
37
Modules/Internal/Emails/SendVerifyEmail.php
Normal file
37
Modules/Internal/Emails/SendVerifyEmail.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Emails;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
|
||||||
|
class SendVerifyEmail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
public $data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the message.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
$this->subject('Verify Email')
|
||||||
|
->markdown('verify_email');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
33
Modules/Internal/Events/ForgetPassword.php
Normal file
33
Modules/Internal/Events/ForgetPassword.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ForgetPassword
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
public $data;
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should be broadcast on.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,14 @@ namespace Modules\Internal\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Crypt;
|
||||||
|
use Error;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Modules\Internal\Emails\SendVerifyEmail;
|
||||||
|
use Modules\Internal\Events\ForgetPassword;
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
@@ -18,8 +23,8 @@ class AuthController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$user = User::query()
|
$user = User::query()
|
||||||
->where('email', $request->email)
|
->where('email', $request->email)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return response(['message' => 'User Tidak Ditemukan'], 404);
|
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||||
@@ -43,4 +48,81 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
return response(['message' => 'Berhasil Logout.']);
|
return response(['message' => 'Berhasil Logout.']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resetPassword(Request $request)
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'old_password' => 'required',
|
||||||
|
'new_password' => 'required',
|
||||||
|
'confirm_new_password' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!Hash::check($request['old_password'], $user->password)) {
|
||||||
|
return response(['message' => 'Password Salah'], 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request["new_password"] != $request["confirm_new_password"]) {
|
||||||
|
return response([
|
||||||
|
'message' => "Password Tidak Sama"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'password' => Hash::make($request->confirm_new_password),
|
||||||
|
]);
|
||||||
|
return response()->json($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyEmail(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => 'required|email',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::query()
|
||||||
|
->where('email', $request->email)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
Event(new ForgetPassword($user));
|
||||||
|
|
||||||
|
// Mail::to($user->email)->send(new SendVerifyEmail($user));
|
||||||
|
|
||||||
|
return response()->json($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forgetPassword(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'new_password' => 'required',
|
||||||
|
'confirm_new_password' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$token = Crypt::decryptString($request->token);
|
||||||
|
$email = explode('|', $token)[0];
|
||||||
|
|
||||||
|
$user = User::query()
|
||||||
|
->where('email', $email)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request["new_password"] != $request["confirm_new_password"]) {
|
||||||
|
return response([
|
||||||
|
'message' => "Password Tidak Sama"
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'password' => Hash::make($request->confirm_new_password),
|
||||||
|
]);
|
||||||
|
return response()->json($user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Modules\Internal\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Models\Benefit;
|
use App\Models\Benefit;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
use App\Models\MemberBenefit;
|
use App\Models\MemberBenefit;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -18,11 +19,12 @@ class BenefitController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$benefits = Benefit::query()
|
$benefits = CorporateBenefit::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->paginate()
|
->with('benefit', 'plan')
|
||||||
->appends($request->all());
|
->paginate()
|
||||||
|
->appends($request->all());
|
||||||
|
|
||||||
return $benefits;
|
return $benefits;
|
||||||
}
|
}
|
||||||
@@ -89,59 +91,59 @@ class BenefitController extends Controller
|
|||||||
|
|
||||||
public function memberBenefitImport(Request $request, $corporate_id)
|
public function memberBenefitImport(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$request->validate([
|
// $request->validate([
|
||||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
// 'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||||
]);
|
// ]);
|
||||||
$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);
|
// $file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
|
|
||||||
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
|
// $reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
|
||||||
$reader->open(Storage::path('temp/'.$file_name));
|
// $reader->open(Storage::path('temp/'.$file_name));
|
||||||
|
|
||||||
$headers_map_to_table_fields = Benefit::$doc_headers_to_field_map;
|
// $headers_map_to_table_fields = Benefit::$doc_headers_to_field_map;
|
||||||
|
|
||||||
$imported_benefit_data = 0;
|
// $imported_benefit_data = 0;
|
||||||
$failed_benefit_data = [];
|
// $failed_benefit_data = [];
|
||||||
foreach ($reader->getSheetIterator() as $sheet) {
|
// foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
$doc_headers_indexes = [];
|
// $doc_headers_indexes = [];
|
||||||
foreach ($sheet->getRowIterator() as $index => $row) {
|
// foreach ($sheet->getRowIterator() as $index => $row) {
|
||||||
if ($index == 1) { // First Row Must be Header
|
// if ($index == 1) { // First Row Must be Header
|
||||||
foreach ($row->getCells() as $index => $cell) {
|
// foreach ($row->getCells() as $index => $cell) {
|
||||||
$doc_headers_indexes[$index] = rtrim($cell->getValue());
|
// $doc_headers_indexes[$index] = rtrim($cell->getValue());
|
||||||
}
|
// }
|
||||||
} else { // Next Row Should be Data
|
// } else { // Next Row Should be Data
|
||||||
$new_benefit_data = [];
|
// $new_benefit_data = [];
|
||||||
foreach ($row->getCells() as $index => $cell) {
|
// foreach ($row->getCells() as $index => $cell) {
|
||||||
$new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
|
// $new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// $imported_plan_data[] = $new_row; // Insert to Array
|
// // $imported_plan_data[] = $new_row; // Insert to Array
|
||||||
// Create Directly
|
// // Create Directly
|
||||||
$new_benefit_data['corporate_id'] = $corporate_id;
|
// $new_benefit_data['corporate_id'] = $corporate_id;
|
||||||
try {
|
// try {
|
||||||
Benefit::updateOrCreate([
|
// Benefit::updateOrCreate([
|
||||||
'corporate_id' => $corporate_id,
|
// 'corporate_id' => $corporate_id,
|
||||||
'code' => $new_benefit_data['code']
|
// 'code' => $new_benefit_data['code']
|
||||||
], $new_benefit_data);
|
// ], $new_benefit_data);
|
||||||
|
|
||||||
$imported_benefit_data++;
|
// $imported_benefit_data++;
|
||||||
} catch(\Exception $e) {
|
// } catch(\Exception $e) {
|
||||||
$new_benefit_data['error'] = $e->getMessage();
|
// $new_benefit_data['error'] = $e->getMessage();
|
||||||
$failed_benefit_data[] = $new_benefit_data;
|
// $failed_benefit_data[] = $new_benefit_data;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
break; //only read first sheet
|
// break; //only read first sheet
|
||||||
}
|
// }
|
||||||
$reader->close();
|
// $reader->close();
|
||||||
Storage::delete('temp/'.$file_name);
|
// Storage::delete('temp/'.$file_name);
|
||||||
// throw(404);
|
// // throw(404);
|
||||||
|
|
||||||
return [
|
// return [
|
||||||
'total_successed_row' => $imported_benefit_data,
|
// 'total_successed_row' => $imported_benefit_data,
|
||||||
'total_failed_row' => count($failed_benefit_data),
|
// 'total_failed_row' => count($failed_benefit_data),
|
||||||
'failed_row' => $failed_benefit_data
|
// 'failed_row' => $failed_benefit_data
|
||||||
];
|
// ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,30 @@ class CorporateBenefitController extends Controller
|
|||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$benefits = CorporateBenefit::query()
|
$benefits = CorporateBenefit::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->paginate(0)
|
->paginate(0)
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return $benefits;
|
return $benefits;
|
||||||
}
|
}
|
||||||
|
public function activation(Request $request, $benefit_id)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'active' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// abort(404);
|
||||||
|
|
||||||
|
$benefit = CorporateBenefit::findOrFail($benefit_id);
|
||||||
|
$benefit->active = $request->active == '1';
|
||||||
|
|
||||||
|
if ($benefit->save()) {
|
||||||
|
return response()->json([
|
||||||
|
'benefit' => $benefit,
|
||||||
|
'message' => 'Status Updated Successfully'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ namespace Modules\Internal\Http\Controllers\Api;
|
|||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
use App\Imports\PlansImport;
|
use App\Imports\PlansImport;
|
||||||
use App\Models\Benefit;
|
use App\Models\Benefit;
|
||||||
|
use App\Models\Claim;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
|
use App\Models\Service;
|
||||||
|
use App\Models\User;
|
||||||
use App\Services\ImportService;
|
use App\Services\ImportService;
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
@@ -14,6 +18,8 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
|
use App\Models\File;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Modules\Internal\Services\CorporateService;
|
use Modules\Internal\Services\CorporateService;
|
||||||
|
|
||||||
@@ -26,18 +32,20 @@ class CorporateController extends Controller
|
|||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$corporates = Corporate::query()
|
$corporates = Corporate::query()
|
||||||
->when($request->search, function ($query, $search) {
|
->when($request->search, function ($query, $search) {
|
||||||
return $query->where('name', 'LIKE', '%'.$search.'%')
|
return $query->where('name', 'LIKE', '%' . $search . '%')
|
||||||
->orWhere('code', 'LIKE', '%'.$search.'%');
|
->orWhere('code', 'LIKE', '%' . $search . '%');
|
||||||
})
|
})
|
||||||
->with('currentPolicy', 'subCorporates')
|
->with('currentPolicy', 'subCorporates')
|
||||||
->withCount([
|
->withCount([
|
||||||
'employees',
|
'employees',
|
||||||
'corporatePlans',
|
'corporateBenefits',
|
||||||
'corporateBenefits',
|
'corporatePlans',
|
||||||
])
|
|
||||||
->where('type', 'corporate')
|
// 'claims'
|
||||||
->paginate(10);
|
])
|
||||||
|
->where('type', 'corporate')
|
||||||
|
->paginate(10);
|
||||||
|
|
||||||
return $corporates;
|
return $corporates;
|
||||||
}
|
}
|
||||||
@@ -48,10 +56,10 @@ class CorporateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$corporateGroups = Corporate::whereNull('parent_id')->get()->map(function($corporate) {
|
$corporateGroups = Corporate::whereNull('parent_id')->get()->map(function ($corporate) {
|
||||||
return [
|
return [
|
||||||
'value' => $corporate->id,
|
'value' => $corporate->id,
|
||||||
'label' => $corporate->name.' ('.$corporate->code.')',
|
'label' => $corporate->name . ' (' . $corporate->code . ')',
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,6 +112,129 @@ class CorporateController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Service
|
||||||
|
$services = [
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'Out Patient',
|
||||||
|
'code' => 'OP',
|
||||||
|
'description' => 'Out Patient',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 2,
|
||||||
|
'name' => 'Inpatient',
|
||||||
|
'code' => 'IP',
|
||||||
|
'description' => 'Inpatient',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 3,
|
||||||
|
'name' => 'Dental',
|
||||||
|
'code' => 'DE',
|
||||||
|
'description' => 'Dental',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 4,
|
||||||
|
'name' => 'Maternal',
|
||||||
|
'code' => 'MA',
|
||||||
|
'description' => 'Maternal',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 5,
|
||||||
|
'name' => 'Optical',
|
||||||
|
'code' => 'OPT',
|
||||||
|
'description' => 'Optical',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($services as $service) {
|
||||||
|
|
||||||
|
$corporateService = $newCorporate->corporateServices()->create([
|
||||||
|
'service_code' => $service['code'],
|
||||||
|
'status' => 'inactive'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$corporateService->configs()->insert([
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'gp_external_doctor_online',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'gp_external_doctor_offline',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'gp_internal_doctor_online',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'gp_internal_doctor_offline',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'sp_external_doctor_online',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'sp_external_doctor_offline',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'sp_internal_doctor_online',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'sp_internal_doctor_offline',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'vitamins',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'delivery_fee',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'general_practitioner_fee',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'name' => 'specialist_practitioner_fee',
|
||||||
|
'value' => false,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Remove This
|
||||||
|
// Assign Managed to Manager one
|
||||||
|
$managerOne = User::where('email', 'manager+one@gmail.com')->first();
|
||||||
|
$managerOne->managedCorporates()->attach($newCorporate);
|
||||||
|
|
||||||
|
if ($request->hasFile('logo')) {
|
||||||
|
$pathFileAvatar = File::storeFile('avatar', $newCorporate->id, $request->file('logo'));
|
||||||
|
$newCorporate->files()->updateOrCreate([
|
||||||
|
'type' => 'avatar',
|
||||||
|
'name' => File::getFileName('avatar', $newCorporate->id, $request->file('logo')),
|
||||||
|
'extension' => $request->file('logo')->getClientOriginalExtension(),
|
||||||
|
'path' => $pathFileAvatar,
|
||||||
|
'created_by' => auth()->user()->id,
|
||||||
|
'updated_by' => auth()->user()->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
@@ -121,11 +252,22 @@ class CorporateController extends Controller
|
|||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$corporate = Corporate::query()
|
$corporate = Corporate::query()
|
||||||
->with(['currentPolicy'])
|
->with(['currentPolicy', 'plans'])
|
||||||
->withCount('corporatePlans')
|
->withCount('corporatePlans')
|
||||||
->withCount('employees')
|
->withCount('employees')
|
||||||
// ->withCount('employees.claims')
|
// ->withCount('employees.claims')
|
||||||
->findOrFail($id);
|
->findOrFail($id);
|
||||||
|
$plans = $corporate['plans']->map(function ($plan) {
|
||||||
|
return [
|
||||||
|
'id' => $plan['id'],
|
||||||
|
'code' => $plan['code'],
|
||||||
|
'corporate_id' => $plan['corporate_id'],
|
||||||
|
'corporate_plan_id' => $plan['corporate_plan_id'],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
unset($corporate['plans']);
|
||||||
|
$corporate['plans'] = $plans;
|
||||||
|
|
||||||
return response()->json($corporate);
|
return response()->json($corporate);
|
||||||
}
|
}
|
||||||
@@ -165,9 +307,13 @@ class CorporateController extends Controller
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
//karena pake formdata
|
||||||
|
$linkingRules = $request->linking_rules;
|
||||||
|
$linkingRules = explode(',', $linkingRules);
|
||||||
|
|
||||||
$corporate = Corporate::findOrFail($id);
|
$corporate = Corporate::findOrFail($id);
|
||||||
$corporate->fill($request->toArray());
|
$corporate->fill($request->all());
|
||||||
|
$corporate->linking_rules = $linkingRules;
|
||||||
$corporate->save();
|
$corporate->save();
|
||||||
|
|
||||||
$corporate->policies()->updateOrCreate(
|
$corporate->policies()->updateOrCreate(
|
||||||
@@ -187,6 +333,19 @@ class CorporateController extends Controller
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($request->hasFile('logo')) {
|
||||||
|
$pathFileAvatar = File::storeFile('avatar', $corporate->id, $request->file('logo'));
|
||||||
|
|
||||||
|
$corporate->files()->updateOrCreate([
|
||||||
|
'type' => 'avatar',
|
||||||
|
'name' => File::getFileName('avatar', $corporate->id, $request->file('logo')),
|
||||||
|
'extension' => $request->file('logo')->getClientOriginalExtension(),
|
||||||
|
'path' => $pathFileAvatar,
|
||||||
|
'created_by' => auth()->user()->id,
|
||||||
|
'updated_by' => auth()->user()->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
@@ -206,7 +365,8 @@ class CorporateController extends Controller
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activation(Request $request, $corporate_id) {
|
public function activation(Request $request, $corporate_id)
|
||||||
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'active' => 'required'
|
'active' => 'required'
|
||||||
]);
|
]);
|
||||||
@@ -230,16 +390,16 @@ class CorporateController extends Controller
|
|||||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||||
]);
|
]);
|
||||||
// dd($request->toArray());
|
// 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);
|
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
$corporate = Corporate::findOrFail($corporate_id);
|
$corporate = Corporate::with(['plans'])->findOrFail($corporate_id);
|
||||||
|
|
||||||
$import = new ImportService();
|
$import = new ImportService();
|
||||||
$import->read(Storage::path('temp/'.$file_name));
|
$import->read(Storage::path('temp/' . $file_name));
|
||||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
|
||||||
|
|
||||||
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
||||||
if ( !in_array($sheet->getName(), ['Plan', 'Benefit']) ) {
|
if (!in_array($sheet->getName(), ['Plan', 'Benefit'])) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if ($sheetIndex == 1) { // Rename First Sheet to Writer
|
if ($sheetIndex == 1) { // Rename First Sheet to Writer
|
||||||
@@ -250,17 +410,16 @@ class CorporateController extends Controller
|
|||||||
$nextWriterSheet->setName($sheet->getName());
|
$nextWriterSheet->setName($sheet->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $sheet->getName() == 'Plan' ) {
|
if ($sheet->getName() == 'Plan') {
|
||||||
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
$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;
|
$headers_map_to_table_fields = CorporateBenefit::$doc_headers_to_field_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write Header to File
|
// Write Header to File
|
||||||
$result_headers = array_keys($headers_map_to_table_fields);
|
$result_headers = array_keys($headers_map_to_table_fields);
|
||||||
$result_headers = array_merge($result_headers, ['Ingest Code', 'Ingest Note']);
|
$result_headers = array_merge($result_headers, ['Ingest Code', 'Ingest Note']);
|
||||||
$import->addArrayToRow($result_headers);
|
$import->addArrayToRow($result_headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc_headers_indexes = [];
|
$doc_headers_indexes = [];
|
||||||
@@ -268,8 +427,8 @@ class CorporateController extends Controller
|
|||||||
if ($index == 1) { // First Row Must be Header
|
if ($index == 1) { // First Row Must be Header
|
||||||
foreach ($row->getCells() as $index => $cell) {
|
foreach ($row->getCells() as $index => $cell) {
|
||||||
$title = $cell->getValue();
|
$title = $cell->getValue();
|
||||||
$title = preg_replace( "/\r|\n/", " ", $title );
|
$title = preg_replace("/\r|\n/", " ", $title);
|
||||||
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
$title = preg_replace('/\xc2\xa0/', " ", $title);
|
||||||
$title = rtrim($title);
|
$title = rtrim($title);
|
||||||
$title = ltrim($title);
|
$title = ltrim($title);
|
||||||
$doc_headers_indexes[$index] = $title;
|
$doc_headers_indexes[$index] = $title;
|
||||||
@@ -285,9 +444,9 @@ class CorporateController extends Controller
|
|||||||
|
|
||||||
try { // Process the Row Data
|
try { // Process the Row Data
|
||||||
$corporateService = new CorporateService();
|
$corporateService = new CorporateService();
|
||||||
if ( $sheet->getName() == 'Plan' ) {
|
if ($sheet->getName() == 'Plan') {
|
||||||
$corporateService->handlePlanRow($corporate, $row_data);
|
$corporateService->handlePlanRow($corporate, $row_data);
|
||||||
} else if ( $sheet->getName() == 'Benefit' ) {
|
} else if ($sheet->getName() == 'Benefit') {
|
||||||
$corporateService->handleBenefitRow($corporate, $row_data);
|
$corporateService->handleBenefitRow($corporate, $row_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +455,6 @@ class CorporateController extends Controller
|
|||||||
'Ingest Code' => 200,
|
'Ingest Code' => 200,
|
||||||
'Ingest Note' => 'Success',
|
'Ingest Note' => 'Success',
|
||||||
]), $sheet->getName());
|
]), $sheet->getName());
|
||||||
|
|
||||||
} catch (ImportRowException $e) {
|
} catch (ImportRowException $e) {
|
||||||
// Write Data Validation Error to File
|
// Write Data Validation Error to File
|
||||||
$import->addArrayToRow(array_merge($row_data, [
|
$import->addArrayToRow(array_merge($row_data, [
|
||||||
@@ -315,7 +473,7 @@ class CorporateController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$import->reader->close();
|
$import->reader->close();
|
||||||
Storage::delete('temp/'.$file_name);
|
Storage::delete('temp/' . $file_name);
|
||||||
$import->writer->close();
|
$import->writer->close();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -323,8 +481,8 @@ class CorporateController extends Controller
|
|||||||
// 'total_failed_row' => count($failed_plan_data),
|
// 'total_failed_row' => count($failed_plan_data),
|
||||||
// 'failed_row' => $failed_plan_data,
|
// 'failed_row' => $failed_plan_data,
|
||||||
'result_file' => [
|
'result_file' => [
|
||||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||||
'name' => 'result-'.$file_name,
|
'name' => 'result-' . $file_name,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,28 +29,47 @@ class CorporateMemberController extends Controller
|
|||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$members = Member::query()
|
$members = Member::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
// ->where('corporate_id', $corporate_id)
|
// ->where('corporate_id', $corporate_id)
|
||||||
->whereHas('employeds', function ($employeds) use ($corporate_id) {
|
->whereHas('employeds', function ($employeds) use ($corporate_id) {
|
||||||
$employeds->where('corporate_id', $corporate_id);
|
$employeds->where('corporate_id', $corporate_id);
|
||||||
})
|
})
|
||||||
->with([
|
->with([
|
||||||
'employeds',
|
'employeds',
|
||||||
'currentPolicy',
|
'currentPolicy',
|
||||||
// 'claims',
|
// 'claims',
|
||||||
'claims' => function ($claim) {
|
'claims' => function ($claim) {
|
||||||
return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
|
// return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
|
||||||
// return $claim->used(now()->startOfYear(), now()->endOfYear());
|
// return $claim->used(now()->startOfYear(), now()->endOfYear());
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
->with('currentPlan')
|
->with('currentPlan')
|
||||||
// ->with
|
// ->with
|
||||||
->paginate()
|
->paginate()
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return Helper::paginateResources(MemberDataTableResource::collection($members));
|
return Helper::paginateResources(MemberDataTableResource::collection($members));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function activation(Request $request, $member_id)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'active' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// abort(404);
|
||||||
|
|
||||||
|
$member = Member::findOrFail($member_id);
|
||||||
|
$member->active = $request->active == '1';
|
||||||
|
|
||||||
|
if ($member->save()) {
|
||||||
|
return response()->json([
|
||||||
|
'member' => $member,
|
||||||
|
'message' => 'Status Updated Successfully'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
@@ -119,14 +138,14 @@ class CorporateMemberController extends Controller
|
|||||||
]);
|
]);
|
||||||
$corporate = Corporate::findOrFail($corporate_id)->load('currentPolicy');
|
$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);
|
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
|
|
||||||
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
|
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/' . $file_name));
|
||||||
$reader->open(Storage::path('temp/'.$file_name));
|
$reader->open(Storage::path('temp/' . $file_name));
|
||||||
|
|
||||||
$writer = WriterEntityFactory::createXLSXWriter();
|
$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;
|
$headers_map_to_table_fields = $this->memberEnrollmentService->doc_headers_to_field_map;
|
||||||
|
|
||||||
@@ -144,8 +163,8 @@ class CorporateMemberController extends Controller
|
|||||||
foreach ($row->getCells() as $index => $cell) {
|
foreach ($row->getCells() as $index => $cell) {
|
||||||
// Clear up the string and remove all spaces
|
// Clear up the string and remove all spaces
|
||||||
$title = $cell->getValue();
|
$title = $cell->getValue();
|
||||||
$title = preg_replace( "/\r|\n/", " ", $title );
|
$title = preg_replace("/\r|\n/", " ", $title);
|
||||||
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
$title = preg_replace('/\xc2\xa0/', " ", $title);
|
||||||
$title = rtrim($title);
|
$title = rtrim($title);
|
||||||
$title = ltrim($title);
|
$title = ltrim($title);
|
||||||
$doc_headers_indexes[$index] = $title;
|
$doc_headers_indexes[$index] = $title;
|
||||||
@@ -187,14 +206,13 @@ class CorporateMemberController extends Controller
|
|||||||
$failed_member_data[] = ['row_number' => $index, 'error' => $e->getMessage()];
|
$failed_member_data[] = ['row_number' => $index, 'error' => $e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break; //only read first sheet
|
break; //only read first sheet
|
||||||
}
|
}
|
||||||
$reader->close();
|
$reader->close();
|
||||||
$writer->close();
|
$writer->close();
|
||||||
Storage::delete('temp/'.$file_name);
|
Storage::delete('temp/' . $file_name);
|
||||||
// throw(404);
|
// throw(404);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -202,8 +220,8 @@ class CorporateMemberController extends Controller
|
|||||||
'total_failed_row' => count($failed_member_data),
|
'total_failed_row' => count($failed_member_data),
|
||||||
'failed_row' => $failed_member_data,
|
'failed_row' => $failed_member_data,
|
||||||
'result_file' => [
|
'result_file' => [
|
||||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||||
'name' => 'result-'.$file_name,
|
'name' => 'result-' . $file_name,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,33 @@ class CorporatePlanController extends Controller
|
|||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$benefits = CorporatePlan::query()
|
$benefits = CorporatePlan::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->paginate(0)
|
->paginate(0)
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return $benefits;
|
return $benefits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function activation(Request $request, $plan_id)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'active' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// abort(404);
|
||||||
|
|
||||||
|
$plan = CorporatePlan::findOrFail($plan_id);
|
||||||
|
$plan->active = $request->active == '1';
|
||||||
|
|
||||||
|
if ($plan->save()) {
|
||||||
|
return response()->json([
|
||||||
|
'plan' => $plan,
|
||||||
|
'message' => 'Status Updated Successfully'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for creating a new resource.
|
* Show the form for creating a new resource.
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use Illuminate\Contracts\Support\Renderable;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
use Modules\Internal\Transformers\CorporateServiceConfigResource;
|
use Modules\Internal\Transformers\CorporateServiceConfigResource;
|
||||||
|
use Termwind\Components\Dd;
|
||||||
|
|
||||||
class CorporateServiceController extends Controller
|
class CorporateServiceController extends Controller
|
||||||
{
|
{
|
||||||
@@ -74,6 +75,7 @@ class CorporateServiceController extends Controller
|
|||||||
public function update(Request $request, $corporate_id)
|
public function update(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$corporateService = CorporateService::where('corporate_id', $corporate_id)->where('service_code', $request->service_code)->first();
|
$corporateService = CorporateService::where('corporate_id', $corporate_id)->where('service_code', $request->service_code)->first();
|
||||||
|
|
||||||
$corporateServiceConfig = $corporateService->configs()->updateOrCreate([
|
$corporateServiceConfig = $corporateService->configs()->updateOrCreate([
|
||||||
'corporate_service_id' => $corporateService->id,
|
'corporate_service_id' => $corporateService->id,
|
||||||
'name' => $request->config_name
|
'name' => $request->config_name
|
||||||
@@ -97,16 +99,29 @@ class CorporateServiceController extends Controller
|
|||||||
|
|
||||||
public function corporateServiceIndex($corporate_id, $service_code)
|
public function corporateServiceIndex($corporate_id, $service_code)
|
||||||
{
|
{
|
||||||
$corporate = Corporate::findOrFail($corporate_id);
|
$corporate = Corporate::findOrFail($corporate_id)->with(['plans'])->first();
|
||||||
|
$plans = $corporate['plans']->map(function ($plan) {
|
||||||
|
return [
|
||||||
|
'id' => $plan['id'],
|
||||||
|
'code' => $plan['code'],
|
||||||
|
'corporate_id' => $plan['corporate_id'],
|
||||||
|
'corporate_plan_id' => $plan['corporate_plan_id'],
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
unset($corporate['plans']);
|
||||||
|
$corporate['plans'] = $plans;
|
||||||
|
|
||||||
$corporateService = CorporateService::query()
|
$corporateService = CorporateService::query()
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->where('service_code', $service_code)
|
->where('service_code', $service_code)
|
||||||
->with(['configs', 'service',
|
->with([
|
||||||
'specialities' => function($speciality) {
|
'configs', 'service',
|
||||||
$speciality->where('status', 'active');
|
'corporateServiceSpecialities',
|
||||||
},
|
'corporateServiceSpecialities.speciality',
|
||||||
'specialities.speciality'])
|
'corporateServiceSpecialities.exclusions.rules'
|
||||||
->first();
|
])
|
||||||
|
->first();
|
||||||
// $service = CorporateServiceConfigResource::make($corporateService);
|
// $service = CorporateServiceConfigResource::make($corporateService);
|
||||||
$specialities = Speciality::get();
|
$specialities = Speciality::get();
|
||||||
|
|
||||||
@@ -123,10 +138,10 @@ class CorporateServiceController extends Controller
|
|||||||
{
|
{
|
||||||
// $corporate = Corporate::findOrFail($corporate_id);
|
// $corporate = Corporate::findOrFail($corporate_id);
|
||||||
$corporateService = CorporateService::query()
|
$corporateService = CorporateService::query()
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->where('service_code', $service_code)
|
->where('service_code', $service_code)
|
||||||
// ->with('configs', 'service')
|
// ->with('configs', 'service')
|
||||||
->first();
|
->first();
|
||||||
$corporateService->fill([
|
$corporateService->fill([
|
||||||
'status' => $request->status == 'active' ? 'active' : 'inactive'
|
'status' => $request->status == 'active' ? 'active' : 'inactive'
|
||||||
]);
|
]);
|
||||||
@@ -137,26 +152,288 @@ class CorporateServiceController extends Controller
|
|||||||
|
|
||||||
public function corporateServiceSpecialityUpdate(Request $request, $corporate_id, $service_code)
|
public function corporateServiceSpecialityUpdate(Request $request, $corporate_id, $service_code)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// return response()->json([$request->checked, $request->value, $request->speciality_id]);
|
||||||
|
|
||||||
$corporateService = CorporateService::query()
|
$corporateService = CorporateService::query()
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->where('service_code', $service_code)
|
->where('service_code', $service_code)
|
||||||
->first();
|
->first();
|
||||||
CorporateServiceSpeciality::updateOrCreate([
|
|
||||||
|
|
||||||
|
$corporateServiceSpeciality = CorporateServiceSpeciality::updateOrCreate([
|
||||||
'corporate_service_id' => $corporateService->id,
|
'corporate_service_id' => $corporateService->id,
|
||||||
'speciality_id' => $request->speciality_id,
|
'speciality_id' => $request->speciality_id,
|
||||||
], [
|
], [
|
||||||
'corporate_service_id' => $corporateService->id,
|
'corporate_service_id' => $corporateService->id,
|
||||||
'speciality_id' => $request->speciality_id,
|
'speciality_id' => $request->speciality_id,
|
||||||
'status' => $request->status
|
'active' => $request->active
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$exclusion = $corporateServiceSpeciality->exclusions()->updateOrCreate([
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'service_code' => $service_code,
|
||||||
|
], [
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'service_code' => $service_code,
|
||||||
|
'type' => 'speciality',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$selected_specialities = CorporateServiceSpeciality::query()
|
$selected_specialities = CorporateServiceSpeciality::query()
|
||||||
->where('corporate_service_id', $corporateService->id)
|
->where('corporate_service_id', $corporateService->id)
|
||||||
->where('status', 'active')
|
->where('active', true)
|
||||||
->with('speciality')
|
->with('speciality')
|
||||||
->get()
|
->get()
|
||||||
->pluck('speciality.name', 'speciality.id');
|
->pluck('speciality.name', 'speciality.id');
|
||||||
|
|
||||||
return response()->json($selected_specialities);
|
return response()->json($selected_specialities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function storeExclusion(Request $request, $corporate_id, $service_code)
|
||||||
|
{
|
||||||
|
|
||||||
|
$corporateService = CorporateService::query()
|
||||||
|
->where('corporate_id', $corporate_id)
|
||||||
|
->where('service_code', $service_code)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$corporateServiceSpeciality = CorporateServiceSpeciality::where('corporate_service_id', $corporateService->id)
|
||||||
|
->where('speciality_id', $request->speciality_id)
|
||||||
|
->with('exclusions.rules')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (empty($corporateServiceSpeciality)) {
|
||||||
|
$corporateServiceSpeciality = CorporateServiceSpeciality::create([
|
||||||
|
'corporate_service_id' => $corporateService->id,
|
||||||
|
'speciality_id' => $request->speciality_id,
|
||||||
|
'active' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$corporateServiceSpeciality->exclusions()->updateOrCreate([
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'service_code' => $service_code,
|
||||||
|
], [
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'service_code' => $service_code,
|
||||||
|
'type' => 'speciality',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$exclusion = $corporateServiceSpeciality->exclusions()->where('corporate_id', $corporate_id)->where('service_code', $service_code)->first();
|
||||||
|
|
||||||
|
|
||||||
|
if ($request->type == 'msc') {
|
||||||
|
|
||||||
|
$value_input = $request->value;
|
||||||
|
$current_msc = $exclusion->rules()->where('name', 'msc')->first()->values ?? null;
|
||||||
|
|
||||||
|
if (!empty($current_msc)) {
|
||||||
|
|
||||||
|
$values = "";
|
||||||
|
if ($request->value == 'm' && $request->checked == "1") {
|
||||||
|
$values = $current_msc . "," . $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 's' && $request->checked == "1") {
|
||||||
|
$values = $current_msc . "," . $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'c' && $request->checked == "1") {
|
||||||
|
$values = $current_msc . "," . $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'm' && $request->checked == "0") {
|
||||||
|
$values = str_replace($value_input, "", $current_msc);
|
||||||
|
$values = str_replace(",,", ",", $values);
|
||||||
|
$values = trim($values, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 's' && $request->checked == "0") {
|
||||||
|
$values = str_replace($value_input, "", $current_msc);
|
||||||
|
$values = str_replace(",,", ",", $values);
|
||||||
|
$values = trim($values, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'c' && $request->checked == "0") {
|
||||||
|
$values = str_replace($value_input, "", $current_msc);
|
||||||
|
$values = str_replace(",,", ",", $values);
|
||||||
|
$values = trim($values, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'msc',
|
||||||
|
], [
|
||||||
|
'name' => 'msc',
|
||||||
|
'values' => $values,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
if ($request->value == 'm' && $request->checked == "1") {
|
||||||
|
$values = $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 's' && $request->checked == "1") {
|
||||||
|
$values = $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'c' && $request->checked == "1") {
|
||||||
|
$values = $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'msc',
|
||||||
|
], [
|
||||||
|
'name' => 'msc',
|
||||||
|
'values' => $values,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == 'gender') {
|
||||||
|
$value_input = $request->value;
|
||||||
|
$current_gender = $exclusion->rules()->where('name', 'gender')->first()->values ?? null;
|
||||||
|
|
||||||
|
if (!empty($current_gender)) {
|
||||||
|
$values = "";
|
||||||
|
if ($request->value == 'male' && $request->checked == "1") {
|
||||||
|
$values = $current_gender . "," . $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'female' && $request->checked == "1") {
|
||||||
|
$values = $current_gender . "," . $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'male' && $request->checked == "0") {
|
||||||
|
if (substr($current_gender, 0, 4) == "male") {
|
||||||
|
$values = str_replace($value_input, "", $value_input) . substr($current_gender, 5, 10);
|
||||||
|
} else {
|
||||||
|
$values = str_replace($value_input, "", $value_input) . substr($current_gender, 0, 6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'female' && $request->checked == "0") {
|
||||||
|
$values = str_replace($value_input, "", $current_gender);
|
||||||
|
$values = str_replace(",,", ",", $values);
|
||||||
|
$values = trim($values, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'gender',
|
||||||
|
], [
|
||||||
|
'name' => 'gender',
|
||||||
|
'values' => $values,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
if ($request->value == 'male' && $request->checked == "1") {
|
||||||
|
$values = $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->value == 'female' && $request->checked == "1") {
|
||||||
|
$values = $value_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'gender',
|
||||||
|
], [
|
||||||
|
'name' => 'gender',
|
||||||
|
'values' => $values,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == "min_age") {
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'min_age',
|
||||||
|
], [
|
||||||
|
'name' => 'min_age',
|
||||||
|
'values' => $request->value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == "max_age") {
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'max_age',
|
||||||
|
], [
|
||||||
|
'name' => 'max_age',
|
||||||
|
'values' => $request->value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == "plan") {
|
||||||
|
$value = $request->value;
|
||||||
|
foreach ($value as $key => $val) {
|
||||||
|
$item[] = $val['value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$plan = implode(",", $item);
|
||||||
|
|
||||||
|
$exclusion_rule = $exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'plan',
|
||||||
|
], [
|
||||||
|
'name' => 'plan',
|
||||||
|
'values' => $plan ?? '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->type == "one_row") {
|
||||||
|
$data = $request->one_row;
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'min_age',
|
||||||
|
], [
|
||||||
|
'name' => 'min_age',
|
||||||
|
'values' => $data['min_age'] ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'max_age',
|
||||||
|
], [
|
||||||
|
'name' => 'max_age',
|
||||||
|
'values' => $data['max_age'] ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'plan',
|
||||||
|
], [
|
||||||
|
'name' => 'plan',
|
||||||
|
'values' => $data['plan'] ?? '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$selected_specialities = CorporateServiceSpeciality::query()
|
||||||
|
->where('corporate_service_id', $corporateService->id)
|
||||||
|
->where('active', true)
|
||||||
|
->with('speciality')
|
||||||
|
->get()
|
||||||
|
->pluck('speciality.name', 'speciality.id');
|
||||||
|
|
||||||
|
$corporateService = CorporateService::query()
|
||||||
|
->where('corporate_id', $corporate_id)
|
||||||
|
->where('service_code', $service_code)
|
||||||
|
->with([
|
||||||
|
'configs', 'service',
|
||||||
|
'corporateServiceSpecialities',
|
||||||
|
'corporateServiceSpecialities.speciality',
|
||||||
|
'corporateServiceSpecialities.exclusions.rules'
|
||||||
|
])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'selected_specialities' => $selected_specialities,
|
||||||
|
'service' => CorporateServiceConfigResource::make($corporateService),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Modules\Internal\Http\Controllers\Api;
|
|||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateService;
|
||||||
use App\Models\Exclusion;
|
use App\Models\Exclusion;
|
||||||
use App\Models\Icd;
|
use App\Models\Icd;
|
||||||
use App\Models\ImportLog;
|
use App\Models\ImportLog;
|
||||||
@@ -26,10 +27,12 @@ class DiagnosisExclusionController extends Controller
|
|||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$exclusions = Exclusion::query()
|
$exclusions = Exclusion::query()
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->with(['exclusionable', 'rules'])
|
->where('type', 'diagnosis')
|
||||||
->filter($request->toArray())
|
->where('deleted_at', null)
|
||||||
->paginate();
|
->with(['exclusionable', 'rules'])
|
||||||
|
->filter($request->toArray())
|
||||||
|
->paginate();
|
||||||
// return $exclusions;
|
// return $exclusions;
|
||||||
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
||||||
}
|
}
|
||||||
@@ -91,7 +94,13 @@ class DiagnosisExclusionController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
//
|
$exclusion = Exclusion::findOrFail($id);
|
||||||
|
|
||||||
|
$exclusion->rules()->delete();
|
||||||
|
$exclusion->delete();
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Exclusion deleted successfully'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function import(Request $request, $corporate_id)
|
public function import(Request $request, $corporate_id)
|
||||||
@@ -100,7 +109,7 @@ class DiagnosisExclusionController extends Controller
|
|||||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||||
]);
|
]);
|
||||||
// dd($request->toArray());
|
// 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);
|
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
$corporate = Corporate::findOrFail($corporate_id);
|
$corporate = Corporate::findOrFail($corporate_id);
|
||||||
|
|
||||||
@@ -112,8 +121,8 @@ class DiagnosisExclusionController extends Controller
|
|||||||
// ]);
|
// ]);
|
||||||
|
|
||||||
$import = new ImportService();
|
$import = new ImportService();
|
||||||
$import->read(Storage::path('temp/'.$file_name));
|
$import->read(Storage::path('temp/' . $file_name));
|
||||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
|
||||||
|
|
||||||
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
||||||
$doc_headers_indexes = [];
|
$doc_headers_indexes = [];
|
||||||
@@ -121,8 +130,8 @@ class DiagnosisExclusionController extends Controller
|
|||||||
if ($index == 1) { // First Row Must be Header
|
if ($index == 1) { // First Row Must be Header
|
||||||
foreach ($row->getCells() as $index => $cell) {
|
foreach ($row->getCells() as $index => $cell) {
|
||||||
$title = $cell->getValue();
|
$title = $cell->getValue();
|
||||||
$title = preg_replace( "/\r|\n/", " ", $title );
|
$title = preg_replace("/\r|\n/", " ", $title);
|
||||||
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
$title = preg_replace('/\xc2\xa0/', " ", $title);
|
||||||
$title = rtrim($title);
|
$title = rtrim($title);
|
||||||
$title = ltrim($title);
|
$title = ltrim($title);
|
||||||
$doc_headers_indexes[$index] = $title;
|
$doc_headers_indexes[$index] = $title;
|
||||||
@@ -152,8 +161,8 @@ class DiagnosisExclusionController extends Controller
|
|||||||
foreach ($row->getCells() as $header_index => $cell) {
|
foreach ($row->getCells() as $header_index => $cell) {
|
||||||
if (isset($row_map[$header_index])) {
|
if (isset($row_map[$header_index])) {
|
||||||
$value = $cell->getValue();
|
$value = $cell->getValue();
|
||||||
$value = preg_replace( "/\r|\n/", " ", $value );
|
$value = preg_replace("/\r|\n/", " ", $value);
|
||||||
$value = preg_replace('/\xc2\xa0/', " ", $value );
|
$value = preg_replace('/\xc2\xa0/', " ", $value);
|
||||||
$value = rtrim($value);
|
$value = rtrim($value);
|
||||||
$value = ltrim($value);
|
$value = ltrim($value);
|
||||||
$row_data[$row_map[$header_index]] = $cell->getValue();
|
$row_data[$row_map[$header_index]] = $cell->getValue();
|
||||||
@@ -171,7 +180,8 @@ class DiagnosisExclusionController extends Controller
|
|||||||
empty($row_data['sp_exclusion']) &&
|
empty($row_data['sp_exclusion']) &&
|
||||||
empty($row_data['pre_exis_exclusion']) &&
|
empty($row_data['pre_exis_exclusion']) &&
|
||||||
empty($row_data['op_de_exclusion']) &&
|
empty($row_data['op_de_exclusion']) &&
|
||||||
empty($row_data['maternity_waiting'])) {
|
empty($row_data['maternity_waiting'])
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +194,6 @@ class DiagnosisExclusionController extends Controller
|
|||||||
'Ingest Code' => 200,
|
'Ingest Code' => 200,
|
||||||
'Ingest Note' => 'Success',
|
'Ingest Note' => 'Success',
|
||||||
]), $sheet->getName());
|
]), $sheet->getName());
|
||||||
|
|
||||||
} catch (ImportRowException $e) {
|
} catch (ImportRowException $e) {
|
||||||
// Write Data Validation Error to File
|
// Write Data Validation Error to File
|
||||||
$import->addArrayToRow(array_merge($row_data, [
|
$import->addArrayToRow(array_merge($row_data, [
|
||||||
@@ -205,7 +214,7 @@ class DiagnosisExclusionController extends Controller
|
|||||||
break; // Only Read First Row
|
break; // Only Read First Row
|
||||||
}
|
}
|
||||||
$import->reader->close();
|
$import->reader->close();
|
||||||
Storage::delete('temp/'.$file_name);
|
Storage::delete('temp/' . $file_name);
|
||||||
$import->writer->close();
|
$import->writer->close();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -213,9 +222,102 @@ class DiagnosisExclusionController extends Controller
|
|||||||
// 'total_failed_row' => count($failed_plan_data),
|
// 'total_failed_row' => count($failed_plan_data),
|
||||||
// 'failed_row' => $failed_plan_data,
|
// 'failed_row' => $failed_plan_data,
|
||||||
'result_file' => [
|
'result_file' => [
|
||||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||||
'name' => 'result-'.$file_name,
|
'name' => 'result-' . $file_name,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function storeExclusion(Request $request, $corporate_id)
|
||||||
|
{
|
||||||
|
$exclusion = Exclusion::where('corporate_id', $corporate_id)
|
||||||
|
->where('id', $request->icd_id)
|
||||||
|
->where('type', 'diagnosis')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
|
||||||
|
if ($request->type == "one_row") {
|
||||||
|
$data = $request->one_row;
|
||||||
|
|
||||||
|
foreach ($data['msc'] as $key => $value) {
|
||||||
|
if ($key == 'm' && $value == "1") {
|
||||||
|
$msc[] = $key;
|
||||||
|
} elseif ($key == 's' && $value == "1") {
|
||||||
|
$msc[] = $key;
|
||||||
|
} elseif ($key == 'c' && $value == "1") {
|
||||||
|
$msc[] = $key;
|
||||||
|
} else {
|
||||||
|
$msc[] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$msc = implode(",", $msc);
|
||||||
|
$msc = trim($msc, ",");
|
||||||
|
$msc = str_replace(",,", ",", $msc);
|
||||||
|
|
||||||
|
foreach ($data['gender'] as $key => $value) {
|
||||||
|
if ($key == 'male' && $value == "1") {
|
||||||
|
$gender[] = $key;
|
||||||
|
} elseif ($key == 'female' && $value == "1") {
|
||||||
|
$gender[] = $key;
|
||||||
|
} else {
|
||||||
|
$gender[] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$gender = implode(",", $gender);
|
||||||
|
$gender = trim($gender, ",");
|
||||||
|
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'msc',
|
||||||
|
], [
|
||||||
|
'name' => 'msc',
|
||||||
|
'values' => $msc ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'gender',
|
||||||
|
], [
|
||||||
|
'name' => 'gender',
|
||||||
|
'values' => $gender ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'min_age',
|
||||||
|
], [
|
||||||
|
'name' => 'min_age',
|
||||||
|
'values' => $data['min_age'] ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'max_age',
|
||||||
|
], [
|
||||||
|
'name' => 'max_age',
|
||||||
|
'values' => $data['max_age'] ?? '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$exclusion->rules()->updateOrCreate([
|
||||||
|
'exclusion_id' => $exclusion->id,
|
||||||
|
'name' => 'plan',
|
||||||
|
], [
|
||||||
|
'name' => 'plan',
|
||||||
|
'values' => $data['plan'] ?? '',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$exclusions = Exclusion::query()
|
||||||
|
->where('corporate_id', $corporate_id)
|
||||||
|
->where('type', 'diagnosis')
|
||||||
|
->with(['exclusionable', 'rules'])
|
||||||
|
->filter($request->toArray())
|
||||||
|
->paginate();
|
||||||
|
// return $exclusions;
|
||||||
|
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ class DivisionController extends Controller
|
|||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$benefits = CorporateDivision::query()
|
$benefits = CorporateDivision::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
->paginate(0)
|
->paginate(0)
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return $benefits;
|
return $benefits;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,6 @@ class DivisionController extends Controller
|
|||||||
$request->validate([
|
$request->validate([
|
||||||
'code' => [
|
'code' => [
|
||||||
'required',
|
'required',
|
||||||
Rule::unique('corporate_plans')->where('corporate_id', $corporate_id)
|
|
||||||
],
|
],
|
||||||
'name' => 'required'
|
'name' => 'required'
|
||||||
]);
|
]);
|
||||||
|
|||||||
111
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
111
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\Practitioner;
|
||||||
|
use App\Models\PractitionerRole;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\DoctorResource;
|
||||||
|
|
||||||
|
class DoctorController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
// $doctors = PractitionerRole::active()->with('practitioner.person', 'organization')
|
||||||
|
// ->when($request->search ?? null, function ($query, $search) {
|
||||||
|
// $query->whereHas('practitioner.person', function ($person) use ($search) {
|
||||||
|
// $person->where('name', 'LIKE', '%' . $search . '%');
|
||||||
|
// });
|
||||||
|
// })->paginate();
|
||||||
|
|
||||||
|
$doctors = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')
|
||||||
|
->when($request->search ?? null, function ($query, $search) {
|
||||||
|
$query->whereHas('person', function ($person) use ($search) {
|
||||||
|
$person->where('name', 'LIKE', '%' . $search . '%');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->organization_id ?? null, function ($query, $organization_id) {
|
||||||
|
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($organization_id) {
|
||||||
|
$practitionerRole->where('organization_id', $organization_id);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($request->speciality_id ?? null, function ($query, $speciality_id) {
|
||||||
|
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($speciality_id) {
|
||||||
|
$practitionerRole->where('speciality_id', $speciality_id);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->paginate();
|
||||||
|
|
||||||
|
// return $doctors;
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json(Helper::paginateResources(DoctorResource::collection($doctors)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('internal::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('internal::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
44
Modules/Client/Http/Controllers/Api/MemberController.php → Modules/Internal/Http/Controllers/Api/OrganizationController.php
Executable file → Normal file
44
Modules/Client/Http/Controllers/Api/MemberController.php → Modules/Internal/Http/Controllers/Api/OrganizationController.php
Executable file → Normal file
@@ -1,14 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Client\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use App\Models\Member;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\OrganizationResource;
|
||||||
|
|
||||||
class MemberController extends Controller
|
class OrganizationController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
@@ -16,27 +17,18 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$organizations = Organization::hospital()->with('currentAddress')
|
||||||
|
->when($request->search ?? null, function ($query, $search) {
|
||||||
|
$query->where('name', 'LIKE', '%' . $search . '%');
|
||||||
|
})
|
||||||
|
->paginate();
|
||||||
|
return response()->json(Helper::paginateResources(OrganizationResource::collection($organizations)));
|
||||||
|
}
|
||||||
|
|
||||||
$corporate = $user->managedCorporates()->first();
|
public function searchOrganization(Request $request)
|
||||||
// $plans =
|
{
|
||||||
|
$organizations = Organization::hospital()->get();
|
||||||
$members = Member::query()
|
return response()->json(OrganizationResource::collection($organizations));
|
||||||
->whereHas('employeds', function($corporateEmployee) use ($corporate) {
|
|
||||||
$corporateEmployee->where('corporate_id', $corporate->id);
|
|
||||||
});
|
|
||||||
if ($request->has('search')) {
|
|
||||||
$members
|
|
||||||
->where('member_id', 'like', "%" . $request->search . "%")
|
|
||||||
->orWhere('payor_id', 'like', "%" . $request->search . "%")
|
|
||||||
->orWhere('name', 'like', "%" . $request->search . "%");
|
|
||||||
}
|
|
||||||
|
|
||||||
$members = $members->paginate();
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'members' => Helper::paginateResources($members)
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +37,7 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('client::create');
|
return view('internal::create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +57,7 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('client::show');
|
return view('internal::show');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +67,7 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
return view('client::edit');
|
return view('internal::edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,15 +28,15 @@ class PlanController extends Controller
|
|||||||
public function index(Request $request, $corporate_id)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$plans = Plan::query()
|
$plans = Plan::query()
|
||||||
->filter($request->all())
|
->filter($request->all())
|
||||||
->where('corporate_id', $corporate_id)
|
->where('corporate_id', $corporate_id)
|
||||||
// ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) {
|
// ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) {
|
||||||
// $corporatePlan->where('corporate_id', $corporate_id);
|
// $corporatePlan->where('corporate_id', $corporate_id);
|
||||||
// })
|
// })
|
||||||
// ->with('corporatePlan')
|
// ->with('corporatePlan')
|
||||||
->orderBy('corporate_plan_id', 'ASC')
|
->orderBy('corporate_plan_id', 'ASC')
|
||||||
->paginate()
|
->paginate()
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return $plans;
|
return $plans;
|
||||||
}
|
}
|
||||||
@@ -106,13 +106,13 @@ class PlanController extends Controller
|
|||||||
$request->validate([
|
$request->validate([
|
||||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||||
]);
|
]);
|
||||||
$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);
|
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
$corporate = Corporate::findOrFail($corporate_id);
|
$corporate = Corporate::findOrFail($corporate_id);
|
||||||
|
|
||||||
$import = $this->importService;
|
$import = $this->importService;
|
||||||
$import->read(Storage::path('temp/'.$file_name));
|
$import->read(Storage::path('temp/' . $file_name));
|
||||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
|
||||||
|
|
||||||
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ class PlanController extends Controller
|
|||||||
break; //only read first sheet
|
break; //only read first sheet
|
||||||
}
|
}
|
||||||
$import->reader->close();
|
$import->reader->close();
|
||||||
Storage::delete('temp/'.$file_name);
|
Storage::delete('temp/' . $file_name);
|
||||||
$import->writer->close();
|
$import->writer->close();
|
||||||
// throw(404);
|
// throw(404);
|
||||||
|
|
||||||
@@ -173,8 +173,8 @@ class PlanController extends Controller
|
|||||||
'total_failed_row' => count($failed_plan_data),
|
'total_failed_row' => count($failed_plan_data),
|
||||||
'failed_row' => $failed_plan_data,
|
'failed_row' => $failed_plan_data,
|
||||||
'result_file' => [
|
'result_file' => [
|
||||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||||
'name' => 'result-'.$file_name,
|
'name' => 'result-' . $file_name,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Speciality;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class SpecialityController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$specialiy = Speciality::get();
|
||||||
|
return response()->json($specialiy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchSpeciality(Request $request)
|
||||||
|
{
|
||||||
|
$specialiy = Speciality::get();
|
||||||
|
return response()->json($specialiy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('internal::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('internal::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
37
Modules/Internal/Listeners/SendVerifyEmail.php
Normal file
37
Modules/Internal/Listeners/SendVerifyEmail.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Listeners;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Modules\Internal\Events\ForgetPassword;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Modules\Internal\Notifications\NotifyVerifyEmail;
|
||||||
|
|
||||||
|
class SendVerifyEmail
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param ForgetPassword $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(ForgetPassword $event)
|
||||||
|
{
|
||||||
|
User::where('email', $event->data['email'])
|
||||||
|
->each(function ($user) use ($event) {
|
||||||
|
$user->notify(new NotifyVerifyEmail($event->data));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
70
Modules/Internal/Notifications/NotifyVerifyEmail.php
Normal file
70
Modules/Internal/Notifications/NotifyVerifyEmail.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Notifications;
|
||||||
|
|
||||||
|
use Crypt;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
|
||||||
|
class NotifyVerifyEmail extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
protected $data;
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail($notifiable)
|
||||||
|
{
|
||||||
|
|
||||||
|
$token = Crypt::encryptString($this->data['email'] . '|' . now());
|
||||||
|
|
||||||
|
$url = env('INTERNAL_URL', 'https://aso.linksehat.com') . '/auth/forget-password?token=' . $token;
|
||||||
|
|
||||||
|
return (new MailMessage)
|
||||||
|
->subject('Verify Email')
|
||||||
|
->markdown('verify_email', ['url' => $url]);
|
||||||
|
// return (new MailMessage)
|
||||||
|
// ->line('The introduction to the notification.')
|
||||||
|
// ->action('Notification Action', 'https://laravel.com')
|
||||||
|
// ->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Modules/Internal/Providers/EventServiceProvider.php
Normal file
50
Modules/Internal/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Modules\Internal\Events\ForgetPassword;
|
||||||
|
use Modules\Internal\Listeners\SendVerifyEmail;
|
||||||
|
|
||||||
|
class EventServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
// protected $listen = [
|
||||||
|
// ForgetPassword::class => [
|
||||||
|
// SendVerifyEmail::class,
|
||||||
|
// ],
|
||||||
|
// ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Event::listen(
|
||||||
|
ForgetPassword::class,
|
||||||
|
[SendVerifyEmail::class, 'handle']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,11 @@ use Illuminate\Database\Eloquent\Factory;
|
|||||||
|
|
||||||
class InternalServiceProvider extends ServiceProvider
|
class InternalServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
protected $listen = [
|
||||||
|
ForgetPassword::class => [
|
||||||
|
SendVerifyEmail::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
/**
|
/**
|
||||||
* @var string $moduleName
|
* @var string $moduleName
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +56,8 @@ class InternalServiceProvider extends ServiceProvider
|
|||||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||||
], 'config');
|
], 'config');
|
||||||
$this->mergeConfigFrom(
|
$this->mergeConfigFrom(
|
||||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
module_path($this->moduleName, 'Config/config.php'),
|
||||||
|
$this->moduleNameLower
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
|
|||||||
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
|
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
|
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DivisionController;
|
use Modules\Internal\Http\Controllers\Api\DivisionController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\DoctorController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DrugController;
|
use Modules\Internal\Http\Controllers\Api\DrugController;
|
||||||
use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
||||||
use Modules\Internal\Http\Controllers\Api\MemberController;
|
use Modules\Internal\Http\Controllers\Api\MemberController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\OrganizationController;
|
||||||
use Modules\Internal\Http\Controllers\Api\PlanController;
|
use Modules\Internal\Http\Controllers\Api\PlanController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\SpecialityController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -44,6 +47,8 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::get('/user', function (Request $request) {
|
Route::get('/user', function (Request $request) {
|
||||||
return $request->user();
|
return $request->user();
|
||||||
});
|
});
|
||||||
|
Route::put('reset-password', [AuthController::class, 'resetPassword'])->name('resetPassword');
|
||||||
|
|
||||||
|
|
||||||
Route::resource('corporates', CorporateController::class);
|
Route::resource('corporates', CorporateController::class);
|
||||||
Route::put('corporates/{corporate_id}/activation', [CorporateController::class, 'activation']);
|
Route::put('corporates/{corporate_id}/activation', [CorporateController::class, 'activation']);
|
||||||
@@ -53,6 +58,7 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
||||||
Route::get('corporates/{corporate_id}/corporate-plans/{id}/edit', [CorporatePlanController::class, 'edit']);
|
Route::get('corporates/{corporate_id}/corporate-plans/{id}/edit', [CorporatePlanController::class, 'edit']);
|
||||||
Route::put('corporates/{corporate_id}/corporate-plans/{id}', [CorporatePlanController::class, 'update']);
|
Route::put('corporates/{corporate_id}/corporate-plans/{id}', [CorporatePlanController::class, 'update']);
|
||||||
|
Route::put('plans/{plan_id}/activation', [CorporatePlanController::class, 'activation']);
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
||||||
Route::post('corporates/{corporate_id}/plans/import', [PlanController::class, 'planImport']);
|
Route::post('corporates/{corporate_id}/plans/import', [PlanController::class, 'planImport']);
|
||||||
@@ -61,6 +67,7 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::post('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'store']);
|
Route::post('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'store']);
|
||||||
Route::get('corporates/{corporate_id}/corporate-benefits/{id}/edit', [CorporateBenefitController::class, 'edit']);
|
Route::get('corporates/{corporate_id}/corporate-benefits/{id}/edit', [CorporateBenefitController::class, 'edit']);
|
||||||
Route::put('corporates/{corporate_id}/corporate-benefits/{id}', [CorporateBenefitController::class, 'update']);
|
Route::put('corporates/{corporate_id}/corporate-benefits/{id}', [CorporateBenefitController::class, 'update']);
|
||||||
|
Route::put('benefits/{benefit_id}/activation', [CorporateBenefitController::class, 'activation']);
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/benefits', [BenefitController::class, 'index']);
|
Route::get('corporates/{corporate_id}/benefits', [BenefitController::class, 'index']);
|
||||||
Route::post('corporates/{corporate_id}/benefits/import', [BenefitController::class, 'memberBenefitImport']);
|
Route::post('corporates/{corporate_id}/benefits/import', [BenefitController::class, 'memberBenefitImport']);
|
||||||
@@ -72,8 +79,12 @@ Route::prefix('internal')->group(function () {
|
|||||||
|
|
||||||
Route::get('corporates/{corporate_id}/members', [CorporateMemberController::class, 'index']);
|
Route::get('corporates/{corporate_id}/members', [CorporateMemberController::class, 'index']);
|
||||||
Route::post('corporates/{corporate_id}/members/import', [CorporateMemberController::class, 'import']);
|
Route::post('corporates/{corporate_id}/members/import', [CorporateMemberController::class, 'import']);
|
||||||
|
Route::put('members/{member_id}/activation', [CorporateMemberController::class, 'activation']);
|
||||||
|
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']);
|
Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']);
|
||||||
|
Route::post('corporates/{corporate_id}/diagnosis-exclusions/store', [DiagnosisExclusionController::class, 'storeExclusion']);
|
||||||
|
Route::delete('diagnosis-exclusions/{id}', [DiagnosisExclusionController::class, 'destroy']);
|
||||||
Route::post('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);
|
Route::post('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/services', [CorporateServiceController::class, 'index']);
|
Route::get('corporates/{corporate_id}/services', [CorporateServiceController::class, 'index']);
|
||||||
@@ -81,6 +92,7 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::get('corporates/{corporate_id}/services/{service_code}', [CorporateServiceController::class, 'corporateServiceIndex']);
|
Route::get('corporates/{corporate_id}/services/{service_code}', [CorporateServiceController::class, 'corporateServiceIndex']);
|
||||||
Route::put('corporates/{corporate_id}/services/{service_code}', [CorporateServiceController::class, 'corporateServiceUpdate']);
|
Route::put('corporates/{corporate_id}/services/{service_code}', [CorporateServiceController::class, 'corporateServiceUpdate']);
|
||||||
Route::post('corporates/{corporate_id}/services/{service_code}/specialities', [CorporateServiceController::class, 'corporateServiceSpecialityUpdate']);
|
Route::post('corporates/{corporate_id}/services/{service_code}/specialities', [CorporateServiceController::class, 'corporateServiceSpecialityUpdate']);
|
||||||
|
Route::post('corporates/{corporate_id}/services/{service_code}/specialities/exclusion', [CorporateServiceController::class, 'storeExclusion']);
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/formulariums', [CorporateFormulariumController::class, 'index']);
|
Route::get('corporates/{corporate_id}/formulariums', [CorporateFormulariumController::class, 'index']);
|
||||||
Route::put('corporates/{corporate_id}/formulariums/{formularium_id}/{action}', [CorporateFormulariumController::class, 'updateStatus']);
|
Route::put('corporates/{corporate_id}/formulariums/{formularium_id}/{action}', [CorporateFormulariumController::class, 'updateStatus']);
|
||||||
@@ -103,7 +115,14 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||||
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
|
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
|
||||||
|
|
||||||
|
Route::get('search-organizations', [OrganizationController::class, 'searchOrganization']);
|
||||||
|
Route::get('search-specialities', [SpecialityController::class, 'searchSpeciality']);
|
||||||
|
Route::resource('organizations', OrganizationController::class);
|
||||||
|
Route::resource('doctors', DoctorController::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Route::resource('organizations', OrganizationController::class);
|
||||||
|
// Route::resource('doctors', DoctorController::class);
|
||||||
|
|
||||||
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
|
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Modules\Internal\Services;
|
|||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
use App\Models\Benefit;
|
use App\Models\Benefit;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
|
use App\Models\CorporateBenefit;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
|
|
||||||
@@ -61,10 +62,10 @@ class CorporateService
|
|||||||
if (empty($row['plan_code'])) {
|
if (empty($row['plan_code'])) {
|
||||||
throw new ImportRowException(__('benefit.PLAN_CODE_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('benefit.PLAN_CODE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
if (empty($row['benefit_code'])) {
|
if (empty($row['code'])) {
|
||||||
throw new ImportRowException(__('benefit.BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('benefit.BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
if (empty($row['code'])) {
|
if (empty($row['corporate_benefit_code'])) {
|
||||||
throw new ImportRowException(__('benefit.CUSTOMER_BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('benefit.CUSTOMER_BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
if (empty($row['description'])) {
|
if (empty($row['description'])) {
|
||||||
@@ -83,21 +84,35 @@ class CorporateService
|
|||||||
|
|
||||||
public function handleBenefitRow(Corporate $corporate, $row)
|
public function handleBenefitRow(Corporate $corporate, $row)
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$benefit_data = $row;
|
$benefit_data = $row;
|
||||||
$benefit_data["corporate_id"] = $corporate->id;
|
$benefit_data["corporate_id"] = $corporate->id;
|
||||||
|
|
||||||
$this->validateBenefitRow($benefit_data);
|
$this->validateBenefitRow($benefit_data);
|
||||||
|
|
||||||
$plan = Benefit::updateOrCreate([
|
|
||||||
'service_code' => $benefit_data['service_code'],
|
$plan = Plan::where('corporate_plan_id', $benefit_data['plan_code'])->first();
|
||||||
'plan_code' => $benefit_data['plan_code'],
|
|
||||||
'corporate_id' => $corporate->id,
|
// $corporate->plans->where('corporate_plan_id', $benefit_data['plan_code'])->first();
|
||||||
|
$benefit_data['plan_code'] = $plan->id;
|
||||||
|
|
||||||
|
$benefit = Benefit::updateOrCreate([
|
||||||
'code' => $benefit_data['code'],
|
'code' => $benefit_data['code'],
|
||||||
|
'service_code' => $plan->service_code,
|
||||||
|
], [
|
||||||
|
'code' => $benefit_data['code'],
|
||||||
|
'service_code' => $plan->service_code,
|
||||||
|
'active' => true
|
||||||
|
]);
|
||||||
|
|
||||||
|
$corporateBenefit = $corporate->corporateBenefits()->updateOrCreate([
|
||||||
|
'benefit_id' => $benefit->id,
|
||||||
|
'plan_id' => $plan->id
|
||||||
], $benefit_data);
|
], $benefit_data);
|
||||||
|
|
||||||
return $plan;
|
return $corporateBenefit;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
// dd($e->getMessage());
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ExclusionService
|
|||||||
|
|
||||||
if (!empty($excl_array[1])) { //msc
|
if (!empty($excl_array[1])) { //msc
|
||||||
$msc = explode(',', $excl_array[1]);
|
$msc = explode(',', $excl_array[1]);
|
||||||
collect($msc)->each(function($m) use ($exclusion) {
|
collect($msc)->each(function ($m) use ($exclusion) {
|
||||||
$exclusion->rules()->create([
|
$exclusion->rules()->create([
|
||||||
'name' => 'msc',
|
'name' => 'msc',
|
||||||
'values' => $m
|
'values' => $m
|
||||||
@@ -44,11 +44,18 @@ class ExclusionService
|
|||||||
}
|
}
|
||||||
if (!empty($excl_array[2])) { //genders
|
if (!empty($excl_array[2])) { //genders
|
||||||
$genders = explode(',', $excl_array[2]);
|
$genders = explode(',', $excl_array[2]);
|
||||||
collect($genders)->each(function($gender) use ($exclusion) {
|
collect($genders)->each(function ($gender) use ($exclusion) {
|
||||||
$exclusion->rules()->create([
|
if ($gender == 'M') {
|
||||||
'name' => 'gender',
|
$exclusion->rules()->create([
|
||||||
'values' => $gender
|
'name' => 'gender',
|
||||||
]);
|
'values' => 'male'
|
||||||
|
]);
|
||||||
|
} else if ($gender == 'F') {
|
||||||
|
$exclusion->rules()->create([
|
||||||
|
'name' => 'gender',
|
||||||
|
'values' => 'female'
|
||||||
|
]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!empty($excl_array[3])) { //min_age
|
if (!empty($excl_array[3])) { //min_age
|
||||||
@@ -87,7 +94,7 @@ class ExclusionService
|
|||||||
|
|
||||||
if (!empty($excl_array[1])) { //msc
|
if (!empty($excl_array[1])) { //msc
|
||||||
$msc = explode(',', $excl_array[1]);
|
$msc = explode(',', $excl_array[1]);
|
||||||
collect($msc)->each(function($m) use ($exclusion) {
|
collect($msc)->each(function ($m) use ($exclusion) {
|
||||||
$exclusion->rules()->create([
|
$exclusion->rules()->create([
|
||||||
'name' => 'msc',
|
'name' => 'msc',
|
||||||
'values' => $m
|
'values' => $m
|
||||||
@@ -96,11 +103,18 @@ class ExclusionService
|
|||||||
}
|
}
|
||||||
if (!empty($excl_array[2])) { //genders
|
if (!empty($excl_array[2])) { //genders
|
||||||
$genders = explode(',', $excl_array[2]);
|
$genders = explode(',', $excl_array[2]);
|
||||||
collect($genders)->each(function($gender) use ($exclusion) {
|
collect($genders)->each(function ($gender) use ($exclusion) {
|
||||||
$exclusion->rules()->create([
|
if ($gender == 'M') {
|
||||||
'name' => 'gender',
|
$exclusion->rules()->create([
|
||||||
'values' => $gender
|
'name' => 'gender',
|
||||||
]);
|
'values' => 'male'
|
||||||
|
]);
|
||||||
|
} else if ($gender == 'F') {
|
||||||
|
$exclusion->rules()->create([
|
||||||
|
'name' => 'gender',
|
||||||
|
'values' => 'female'
|
||||||
|
]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!empty($excl_array[3])) { //min_age
|
if (!empty($excl_array[3])) { //min_age
|
||||||
@@ -136,7 +150,7 @@ class ExclusionService
|
|||||||
|
|
||||||
if (!empty($excl_array[1])) { //msc
|
if (!empty($excl_array[1])) { //msc
|
||||||
$msc = explode(',', $excl_array[1]);
|
$msc = explode(',', $excl_array[1]);
|
||||||
collect($msc)->each(function($m) use ($exclusion) {
|
collect($msc)->each(function ($m) use ($exclusion) {
|
||||||
$exclusion->rules()->create([
|
$exclusion->rules()->create([
|
||||||
'name' => 'msc',
|
'name' => 'msc',
|
||||||
'values' => $m
|
'values' => $m
|
||||||
@@ -145,11 +159,18 @@ class ExclusionService
|
|||||||
}
|
}
|
||||||
if (!empty($excl_array[2])) { //genders
|
if (!empty($excl_array[2])) { //genders
|
||||||
$genders = explode(',', $excl_array[2]);
|
$genders = explode(',', $excl_array[2]);
|
||||||
collect($genders)->each(function($gender) use ($exclusion) {
|
collect($genders)->each(function ($gender) use ($exclusion) {
|
||||||
$exclusion->rules()->create([
|
if ($gender == 'M') {
|
||||||
'name' => 'gender',
|
$exclusion->rules()->create([
|
||||||
'values' => $gender
|
'name' => 'gender',
|
||||||
]);
|
'values' => 'male'
|
||||||
|
]);
|
||||||
|
} else if ($gender == 'F') {
|
||||||
|
$exclusion->rules()->create([
|
||||||
|
'name' => 'gender',
|
||||||
|
'values' => 'female'
|
||||||
|
]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!empty($excl_array[3])) { //min_age
|
if (!empty($excl_array[3])) { //min_age
|
||||||
@@ -177,7 +198,6 @@ class ExclusionService
|
|||||||
$excl_array = explode('|', $row['ma_exclusion']);
|
$excl_array = explode('|', $row['ma_exclusion']);
|
||||||
dd($excl_array);
|
dd($excl_array);
|
||||||
if ($excl_array[0]) {
|
if ($excl_array[0]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +205,6 @@ class ExclusionService
|
|||||||
$excl_array = explode('|', $row['sp_exclusion']);
|
$excl_array = explode('|', $row['sp_exclusion']);
|
||||||
dd($excl_array);
|
dd($excl_array);
|
||||||
if ($excl_array[0]) {
|
if ($excl_array[0]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +212,6 @@ class ExclusionService
|
|||||||
$excl_array = explode('|', $row['pre_exist_exclusion']);
|
$excl_array = explode('|', $row['pre_exist_exclusion']);
|
||||||
dd($excl_array);
|
dd($excl_array);
|
||||||
if ($excl_array[0]) {
|
if ($excl_array[0]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +219,6 @@ class ExclusionService
|
|||||||
$excl_array = explode('|', $row['op_de_exclusion']);
|
$excl_array = explode('|', $row['op_de_exclusion']);
|
||||||
dd($excl_array);
|
dd($excl_array);
|
||||||
if ($excl_array[0]) {
|
if ($excl_array[0]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +226,6 @@ class ExclusionService
|
|||||||
$excl_array = explode('|', $row['maternity_waiting']);
|
$excl_array = explode('|', $row['maternity_waiting']);
|
||||||
dd($excl_array);
|
dd($excl_array);
|
||||||
if ($excl_array[0]) {
|
if ($excl_array[0]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use App\Models\CorporateDivision;
|
|||||||
use App\Models\CorporatePlan;
|
use App\Models\CorporatePlan;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\MemberPolicy;
|
use App\Models\MemberPolicy;
|
||||||
|
use App\Models\Person;
|
||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Box\Spout\Common\Entity\Row;
|
use Box\Spout\Common\Entity\Row;
|
||||||
@@ -27,7 +28,7 @@ class MemberEnrollmentService
|
|||||||
"Halodoc Member ID" => "halodoc_member_id",
|
"Halodoc Member ID" => "halodoc_member_id",
|
||||||
"Corporate ID" => "corporate_id",
|
"Corporate ID" => "corporate_id",
|
||||||
"NIK" => "nik",
|
"NIK" => "nik",
|
||||||
"Division" => "division_code",
|
"Division" => "division_name",
|
||||||
"Branch Code" => "branch_code",
|
"Branch Code" => "branch_code",
|
||||||
"Bank Info" => "banks_info",
|
"Bank Info" => "banks_info",
|
||||||
"Language" => "language",
|
"Language" => "language",
|
||||||
@@ -106,7 +107,7 @@ class MemberEnrollmentService
|
|||||||
"halodoc_member_id" => "Halodoc Member ID",
|
"halodoc_member_id" => "Halodoc Member ID",
|
||||||
"corporate_id" => "Corporate ID",
|
"corporate_id" => "Corporate ID",
|
||||||
"nik" => "NIK",
|
"nik" => "NIK",
|
||||||
"division_code" => "Division",
|
"division_name" => "Division",
|
||||||
"branch_code" => "Branch Code",
|
"branch_code" => "Branch Code",
|
||||||
"banks_info" => "Bank Info",
|
"banks_info" => "Bank Info",
|
||||||
"language" => "Language",
|
"language" => "Language",
|
||||||
@@ -306,12 +307,12 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('enrollment.INVALID_MARITAL_STATUS'), 0, null, $row);
|
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);
|
throw new ImportRowException(__('enrollment.MEMBER_EFFECTIVE_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
// TODO EFFECTIVE DATE VALIDATION
|
// 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);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
// TODO EFFECTIVE DATE VALIDATION
|
// TODO EFFECTIVE DATE VALIDATION
|
||||||
@@ -327,13 +328,17 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('enrollment.NAME_REQUIRED'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.NAME_REQUIRED'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($row['telephone_mobile'])
|
if (
|
||||||
&& !(substr($row['telephone_mobile'], 0, 4) == '+628' || substr($row['telephone_mobile'], 0, 3) == '628')) {
|
!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);
|
throw new ImportRowException(__('enrollment.PHONE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($row['email'])
|
if (
|
||||||
&& !filter_var($row['email'], FILTER_VALIDATE_EMAIL)) {
|
!empty($row['email'])
|
||||||
|
&& !filter_var($row['email'], FILTER_VALIDATE_EMAIL)
|
||||||
|
) {
|
||||||
throw new ImportRowException(__('enrollment.EMAIL_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.EMAIL_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,8 +362,8 @@ class MemberEnrollmentService
|
|||||||
"nik" => $row['nik'] ?? null,
|
"nik" => $row['nik'] ?? null,
|
||||||
"birth_date" => Carbon::parse(strtotime($row['date_of_birth'])),
|
"birth_date" => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||||
"gender" => Helper::genderNormalization($row['sex']),
|
"gender" => Helper::genderNormalization($row['sex']),
|
||||||
"language" => $row['language'] ?? null,
|
// "language" => $row['language'] ?? null,
|
||||||
"race" => $row['race'] ?? null,
|
// "race" => $row['race'] ?? null,
|
||||||
"marital_status" => $row['marital_status'] ?? null,
|
"marital_status" => $row['marital_status'] ?? null,
|
||||||
"record_type" => $row['record_type'] ?? null,
|
"record_type" => $row['record_type'] ?? null,
|
||||||
"principal_id" => $row['principal_id'] ?? null,
|
"principal_id" => $row['principal_id'] ?? null,
|
||||||
@@ -396,14 +401,28 @@ class MemberEnrollmentService
|
|||||||
switch ($row['record_mode']) {
|
switch ($row['record_mode']) {
|
||||||
case "1": // New Member
|
case "1": // New Member
|
||||||
$member = Member::query()
|
$member = Member::query()
|
||||||
->where('member_id', $row['member_id'])
|
->where('member_id', $row['member_id'])
|
||||||
// ->whereHas('employeds', function ($query) use ($corporate) {
|
// ->whereHas('employeds', function ($query) use ($corporate) {
|
||||||
// $query->where('corporate_id', $corporate->id);
|
// $query->where('corporate_id', $corporate->id);
|
||||||
// })
|
// })
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// Validate If Exist Member
|
// Validate If Exist Member
|
||||||
if ($member) {
|
if ($member) {
|
||||||
|
$person = Person::updateOrCreate(
|
||||||
|
[
|
||||||
|
'id' => $member->person_id
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => $row['name'] ?? null,
|
||||||
|
'birth_date' => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||||
|
'gender' => Helper::genderPerson($row['sex']),
|
||||||
|
'language' => $row['language'] ?? null,
|
||||||
|
'race' => $row['race'] ?? null,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$member->person_id = $person->id;
|
||||||
|
$member->save();
|
||||||
throw new ImportRowException(__('enrollment.MEMBER_UNIQUE', [
|
throw new ImportRowException(__('enrollment.MEMBER_UNIQUE', [
|
||||||
'member_id' => $row['member_id'],
|
'member_id' => $row['member_id'],
|
||||||
'policy_id' => $row['policy_number']
|
'policy_id' => $row['policy_number']
|
||||||
@@ -435,10 +454,22 @@ class MemberEnrollmentService
|
|||||||
|
|
||||||
$this->validateRow($row);
|
$this->validateRow($row);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$member->fill($member_data);
|
$member->fill($member_data);
|
||||||
if ($member->save()) {
|
if ($member->save()) {
|
||||||
|
|
||||||
|
$person = Person::create([
|
||||||
|
'name' => $row['name'],
|
||||||
|
'birth_date' => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||||
|
'gender' => Helper::genderPerson($row['sex']),
|
||||||
|
'language' => $row['language'] ?? null,
|
||||||
|
'race' => $row['race'] ?? null,
|
||||||
|
]);
|
||||||
|
$member->person_id = $person->id;
|
||||||
|
$member->save();
|
||||||
|
|
||||||
$memberPolicy = new MemberPolicy();
|
$memberPolicy = new MemberPolicy();
|
||||||
$memberPolicy->fill([
|
$memberPolicy->fill([
|
||||||
'member_id' => $member->member_id,
|
'member_id' => $member->member_id,
|
||||||
@@ -449,8 +480,18 @@ class MemberEnrollmentService
|
|||||||
]);
|
]);
|
||||||
$memberPolicy->save();
|
$memberPolicy->save();
|
||||||
|
|
||||||
if (!empty($row['division'])) {
|
if (!empty($row['division_name'])) {
|
||||||
$division_id = CorporateDivision::where('code', $row['division_code'])->where('')->pluck('id');
|
$division_id = CorporateDivision::query()->where('code', $row['division_name'])->pluck('id')->first();
|
||||||
|
|
||||||
|
if (empty($division_id)) {
|
||||||
|
$division = CorporateDivision::query()->updateOrCreate(['name' => $row['division_name'], 'code' => $row['division_name']], [
|
||||||
|
'corporate_id' => $corporate->id,
|
||||||
|
'name' => $row['division_name'],
|
||||||
|
'code' => $row['division_name'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$division_id = $division->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$member->employeds()->create([
|
$member->employeds()->create([
|
||||||
@@ -476,8 +517,8 @@ class MemberEnrollmentService
|
|||||||
break;
|
break;
|
||||||
case "2": // Member Information Update (Without Replacement Card)
|
case "2": // Member Information Update (Without Replacement Card)
|
||||||
$member = Member::query()
|
$member = Member::query()
|
||||||
->where('member_id', $row['member_id'])
|
->where('member_id', $row['member_id'])
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// Validate If Exist Member
|
// Validate If Exist Member
|
||||||
if (!$member) {
|
if (!$member) {
|
||||||
@@ -523,8 +564,8 @@ class MemberEnrollmentService
|
|||||||
break;
|
break;
|
||||||
case "3": // Member Deletion
|
case "3": // Member Deletion
|
||||||
$member = Member::query()
|
$member = Member::query()
|
||||||
->where('member_id', $row['member_id'])
|
->where('member_id', $row['member_id'])
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// Validate If Exist Member
|
// Validate If Exist Member
|
||||||
if (!$member) {
|
if (!$member) {
|
||||||
@@ -583,9 +624,10 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|
if (
|
||||||
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
|
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);
|
throw new ImportRowException(__('enrollment.MEMBER_RENEWAL_STILL_ACTIVE'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,9 +667,10 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|
if (
|
||||||
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
|
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);
|
throw new ImportRowException(__('enrollment.MEMBER_RENEWAL_STILL_ACTIVE'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -743,7 +786,7 @@ class MemberEnrollmentService
|
|||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
if ( !empty($record_type_new) ) {
|
if (!empty($record_type_new)) {
|
||||||
$member = $memberPolicy->member;
|
$member = $memberPolicy->member;
|
||||||
$member->record_type = $record_type_new;
|
$member->record_type = $record_type_new;
|
||||||
$member->principal_id = $row['principal_id'];
|
$member->principal_id = $row['principal_id'];
|
||||||
@@ -751,7 +794,7 @@ class MemberEnrollmentService
|
|||||||
$member->save();
|
$member->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($corp_code_new) ) {
|
if (!empty($corp_code_new)) {
|
||||||
$oldCorporate = Corporate::where('code', $corp_code_old)->first();
|
$oldCorporate = Corporate::where('code', $corp_code_old)->first();
|
||||||
$newCorporate = Corporate::where('code', $corp_code_new)->first();
|
$newCorporate = Corporate::where('code', $corp_code_new)->first();
|
||||||
|
|
||||||
@@ -759,24 +802,26 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('enrollment.CORPORATE_NOT_FOUND'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.CORPORATE_NOT_FOUND'), 0, null, $row);
|
||||||
}
|
}
|
||||||
$corporateEmployee = CorporateEmployee::where('corporate_id', $oldCorporate->id)
|
$corporateEmployee = CorporateEmployee::where('corporate_id', $oldCorporate->id)
|
||||||
->where('member_id', $memberPolicy->member->id)
|
->where('member_id', $memberPolicy->member->id)
|
||||||
->first();
|
->first();
|
||||||
$newCorporateEmployee = CorporateEmployee::updateOrCreate([
|
$newCorporateEmployee = CorporateEmployee::updateOrCreate(
|
||||||
'corporate_id' => $oldCorporate->id,
|
[
|
||||||
'member_id' => $memberPolicy->member->id
|
'corporate_id' => $oldCorporate->id,
|
||||||
],
|
'member_id' => $memberPolicy->member->id
|
||||||
[
|
],
|
||||||
'corporate_id' => $newCorporate->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->policy_id = $policy_number_new;
|
||||||
$memberPolicy->save();
|
$memberPolicy->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($member_id_new) ) {
|
if (!empty($member_id_new)) {
|
||||||
$memberPolicy->member_id = $member_id_new;
|
$memberPolicy->member_id = $member_id_new;
|
||||||
$memberPolicy->save();
|
$memberPolicy->save();
|
||||||
|
|
||||||
@@ -854,7 +899,7 @@ class MemberEnrollmentService
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// THESE MODES BELOW ARE DISABLED
|
// THESE MODES BELOW ARE DISABLED
|
||||||
case "4": // Member Update Start and End Date
|
case "4": // Member Update Start and End Date
|
||||||
throw new ImportRowException(__('MODE 4 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
throw new ImportRowException(__('MODE 4 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
||||||
break;
|
break;
|
||||||
@@ -896,9 +941,9 @@ class MemberEnrollmentService
|
|||||||
case "8": // Member Information Update (With Replacement Card)
|
case "8": // Member Information Update (With Replacement Card)
|
||||||
throw new ImportRowException(__('MODE 8 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
throw new ImportRowException(__('MODE 8 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
||||||
break;
|
break;
|
||||||
// case "10": // No Information Available
|
// case "10": // No Information Available
|
||||||
|
|
||||||
// break;
|
// break;
|
||||||
case "11": // Advance Renewal with OLD Card No. (PRINT)
|
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);
|
throw new ImportRowException(__('MODE 11 NOT HANDLED PROPERLY, TRY TO USE MODE 13'), 0, null, $row);
|
||||||
@@ -907,9 +952,9 @@ class MemberEnrollmentService
|
|||||||
|
|
||||||
throw new ImportRowException(__('MODE 12 NOT HANDLED PROPERLY, TRY TO USE MODE 13'), 0, null, $row);
|
throw new ImportRowException(__('MODE 12 NOT HANDLED PROPERLY, TRY TO USE MODE 13'), 0, null, $row);
|
||||||
break;
|
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)
|
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);
|
throw new ImportRowException(__('MODE 15 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
||||||
@@ -918,10 +963,10 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('MODE 16 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
throw new ImportRowException(__('MODE 16 NOT HANDLED PROPERLY, TRY TO USE MODE 2'), 0, null, $row);
|
||||||
break;
|
break;
|
||||||
$plan = CorporatePlan::query()
|
$plan = CorporatePlan::query()
|
||||||
->where('corporate_id', $corporate->id)
|
->where('corporate_id', $corporate->id)
|
||||||
->where('code', $row['plan_id'])
|
->where('code', $row['plan_id'])
|
||||||
->where('active', true)
|
->where('active', true)
|
||||||
->first();
|
->first();
|
||||||
if (!$plan) {
|
if (!$plan) {
|
||||||
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.PLAN_NOT_FOUND'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CorporateServiceConfigResource extends JsonResource
|
|||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
$data = [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'corporate_id' => $this->corporate_id,
|
'corporate_id' => $this->corporate_id,
|
||||||
'service_code' => $this->service_code,
|
'service_code' => $this->service_code,
|
||||||
@@ -23,7 +23,75 @@ class CorporateServiceConfigResource extends JsonResource
|
|||||||
'name' => $this->service->name,
|
'name' => $this->service->name,
|
||||||
'description' => $this->service->description,
|
'description' => $this->service->description,
|
||||||
'configurations' => $this->configs->pluck('value', 'name'),
|
'configurations' => $this->configs->pluck('value', 'name'),
|
||||||
'selected_specialities' => $this->specialities->pluck('speciality.name', 'speciality_id')
|
'selected_specialities' => $this->corporateServiceSpecialities->where('active', true)->pluck('speciality.name', 'speciality_id'),
|
||||||
|
'exclusions' => $this->corporateServiceSpecialities->map(function ($speciality) {
|
||||||
|
return [
|
||||||
|
'speciality_id' => $speciality->speciality_id,
|
||||||
|
// 'rules' => $speciality->exclusions->first()->rules->map(
|
||||||
|
// function ($rule) {
|
||||||
|
// return [
|
||||||
|
// 'name' => $rule->name,
|
||||||
|
// 'value' => explode(',', $rule->values)
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
// ),
|
||||||
|
|
||||||
|
];
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$list_msc = $this->corporateServiceSpecialities->map(function ($speciality) {
|
||||||
|
return explode(',', $speciality->exclusions->first()->rules->where('name', 'msc')->first()->values ?? '');
|
||||||
|
})->map(function ($item) {
|
||||||
|
return [
|
||||||
|
'm' => in_array('m', $item),
|
||||||
|
's' => in_array('s', $item),
|
||||||
|
'c' => in_array('c', $item),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$list_gender = $this->corporateServiceSpecialities->map(function ($speciality) {
|
||||||
|
// dd($speciality->exclusions->first()->rules);
|
||||||
|
return explode(',', $speciality->exclusions->first()->rules->where('name', 'gender')->first()->values ?? '');
|
||||||
|
})->map(function ($item) {
|
||||||
|
|
||||||
|
return [
|
||||||
|
'male' => in_array('male', $item),
|
||||||
|
'female' => in_array('female', $item),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$min_age = $this->corporateServiceSpecialities->map(function ($speciality) {
|
||||||
|
return $speciality->exclusions->first()->rules->where('name', 'min_age')->first()->values ?? '';
|
||||||
|
});
|
||||||
|
|
||||||
|
$max_age = $this->corporateServiceSpecialities->map(function ($speciality) {
|
||||||
|
return $speciality->exclusions->first()->rules->where('name', 'max_age')->first()->values ?? '';
|
||||||
|
});
|
||||||
|
|
||||||
|
$plan = $this->corporateServiceSpecialities->map(function ($speciality) {
|
||||||
|
return $speciality->exclusions->first()->rules->where('name', 'plan')->first()->values ?? null;
|
||||||
|
});
|
||||||
|
|
||||||
|
$data['exclusions'] = $data['exclusions']->map(function ($item, $key) use (
|
||||||
|
$list_msc,
|
||||||
|
$list_gender,
|
||||||
|
$min_age,
|
||||||
|
$max_age,
|
||||||
|
$plan,
|
||||||
|
) {
|
||||||
|
$item['msc'] = $list_msc[$key];
|
||||||
|
$item['gender'] = $list_gender[$key];
|
||||||
|
$item['min_age'] = $min_age[$key];
|
||||||
|
$item['max_age'] = $max_age[$key];
|
||||||
|
$item['plan'] = $plan[$key];
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class DiagnosisExclusionResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return [
|
$data = [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'code' => $this->exclusionable->code,
|
'code' => $this->exclusionable->code,
|
||||||
'name' => $this->exclusionable->name,
|
'name' => $this->exclusionable->name,
|
||||||
@@ -25,5 +25,36 @@ class DiagnosisExclusionResource extends JsonResource
|
|||||||
return [$item['name'] => $item['values']];
|
return [$item['name'] => $item['values']];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$msc = explode(',', $this->rules->where('name', 'msc')->first()->values ?? '');
|
||||||
|
$list_msc = [
|
||||||
|
'm' => in_array('m', $msc),
|
||||||
|
's' => in_array('s', $msc),
|
||||||
|
'c' => in_array('c', $msc),
|
||||||
|
];
|
||||||
|
|
||||||
|
$gender = explode(',', $this->rules->where('name', 'gender')->first()->values ?? '');
|
||||||
|
$list_gender = [
|
||||||
|
'male' => in_array('male', $gender),
|
||||||
|
'female' => in_array('female', $gender),
|
||||||
|
];
|
||||||
|
|
||||||
|
$min_age = $this->rules->where('name', 'min_age')->first()->values ?? '';
|
||||||
|
$max_age = $this->rules->where('name', 'max_age')->first()->values ?? '';
|
||||||
|
$plan = $this->rules->where('name', 'plan')->first()->values ?? '';
|
||||||
|
|
||||||
|
$value_plan = [
|
||||||
|
'plan' => $plan,
|
||||||
|
'gender' => $list_gender,
|
||||||
|
'msc' => $list_msc,
|
||||||
|
'min_age' => $min_age,
|
||||||
|
'max_age' => $max_age,
|
||||||
|
];
|
||||||
|
|
||||||
|
$data['value_rules'] = $value_plan;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
Modules/Internal/Transformers/DoctorResource.php
Normal file
53
Modules/Internal/Transformers/DoctorResource.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class DoctorResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$doctor = [
|
||||||
|
'id' => $this->id,
|
||||||
|
// 'his_dokter_id' => $this->practitionerRoles->meta,
|
||||||
|
'name' => $this->person->name,
|
||||||
|
'person_id' => $this->person->id,
|
||||||
|
'phone' => $this->person->phone,
|
||||||
|
'email' => $this->person->email,
|
||||||
|
'gender' => $this->person->gender == "L" ? 'Laki-laki' : 'Perempuan',
|
||||||
|
'address' => $this->person->currentAddress->text,
|
||||||
|
'organizations' => $this->practitionerRoles->unique('organization_id')->map(function ($practitionerRole) {
|
||||||
|
return [
|
||||||
|
'organization_id' => $practitionerRole->organization->id,
|
||||||
|
'organization_name' => $practitionerRole->organization->name,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
"specialties" => $this->practitionerRoles->unique('speciality_id')->map(function ($practitionerRole) {
|
||||||
|
return [
|
||||||
|
'specialty_id' => $practitionerRole->speciality->id,
|
||||||
|
'specialty_name' => $practitionerRole->speciality->name,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
"departemen" => $this->practitionerRoles->map(function ($practitionerRole) {
|
||||||
|
return [
|
||||||
|
'departemen_id' => $practitionerRole->meta->DepartemenID,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
'education' => $this->meta->education,
|
||||||
|
'experience' => $this->meta->work_experience,
|
||||||
|
'award' => $this->meta->award,
|
||||||
|
'keilmuan' => $this->meta->Keilmuan,
|
||||||
|
'tipe_dokter' => $this->meta->tipeDokter,
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
return $doctor;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Modules/Internal/Transformers/OrganizationResource.php
Normal file
32
Modules/Internal/Transformers/OrganizationResource.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class OrganizationResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$organization = [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'type' => $this->type,
|
||||||
|
'code' => $this->code,
|
||||||
|
'description' => $this->description,
|
||||||
|
'kodeRs' => $this->meta->kodeRs ?? null,
|
||||||
|
'phone' => $this->meta->phone ?? null,
|
||||||
|
'lat' => $this->currentAddress->lat ?? null,
|
||||||
|
'lng' => $this->currentAddress->lng ?? null,
|
||||||
|
'address' => $this->currentAddress ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
|
return $organization;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"keywords": [],
|
"keywords": [],
|
||||||
"priority": 0,
|
"priority": 0,
|
||||||
"providers": [
|
"providers": [
|
||||||
"Modules\\Internal\\Providers\\InternalServiceProvider"
|
"Modules\\Internal\\Providers\\InternalServiceProvider",
|
||||||
|
"Modules\\Internal\\Providers\\EventServiceProvider"
|
||||||
],
|
],
|
||||||
"aliases": {},
|
"aliases": {},
|
||||||
"files": [],
|
"files": [],
|
||||||
|
|||||||
39
app/Events/ClaimApproved.php
Normal file
39
app/Events/ClaimApproved.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Claim;
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClaimApproved
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $claim;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Claim $claim)
|
||||||
|
{
|
||||||
|
$this->claim = $claim;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Events/ClaimDeclined.php
Normal file
36
app/Events/ClaimDeclined.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClaimDeclined
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Events/ClaimPaid.php
Normal file
36
app/Events/ClaimPaid.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClaimPaid
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Events/ClaimPostpone.php
Normal file
36
app/Events/ClaimPostpone.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClaimPostpone
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Events/ClaimReceived.php
Normal file
36
app/Events/ClaimReceived.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClaimReceived
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Events/ClaimRequested.php
Normal file
36
app/Events/ClaimRequested.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class ClaimRequested
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return new PrivateChannel('channel-name');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ class ImportRowException extends Exception
|
|||||||
|
|
||||||
public function __construct($message, $code = 0, Throwable $previous = null, $data)
|
public function __construct($message, $code = 0, Throwable $previous = null, $data)
|
||||||
{
|
{
|
||||||
parent::__construct($message, $code, $previous);
|
parent::__construct($message, (int)$code, $previous);
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,21 @@ class Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function genderPerson($anyGenderCode)
|
||||||
|
{
|
||||||
|
if ($anyGenderCode == 'M') {
|
||||||
|
return 'L';
|
||||||
|
} else if ($anyGenderCode == 'F') {
|
||||||
|
return 'P';
|
||||||
|
} else if ($anyGenderCode == 'O') {
|
||||||
|
return 'others';
|
||||||
|
} else if ($anyGenderCode == 'U') {
|
||||||
|
return 'unknown';
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function paginateResources($resource)
|
public static function paginateResources($resource)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -35,6 +50,8 @@ class Helper
|
|||||||
'last_page_url' => '',
|
'last_page_url' => '',
|
||||||
'links' => $resource->links(null, $resource->items()),
|
'links' => $resource->links(null, $resource->items()),
|
||||||
'next_page_url' => $resource->nextPageUrl(),
|
'next_page_url' => $resource->nextPageUrl(),
|
||||||
|
'per_page' => $resource->perPage(),
|
||||||
|
'total' => $resource->total()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,10 +175,10 @@ class Helper
|
|||||||
* @param string $message
|
* @param string $message
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public static function responseJson(array|object $data = [], int $statusCode = Response::HTTP_OK, string $message = 'Data berhasil di ambil'): JsonResponse
|
public static function responseJson(array|object $data = [], string $status = 'success', int $statusCode = Response::HTTP_OK, string $message = 'Data berhasil di ambil'): JsonResponse
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => in_array($statusCode, [200, 201, 204]) ? 'success' : 'error',
|
'status' => $status,
|
||||||
'statusCode' => $statusCode,
|
'statusCode' => $statusCode,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
|
|||||||
@@ -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)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
60
app/Http/Controllers/Api/OLDLMS/ClaimController.php
Normal file
60
app/Http/Controllers/Api/OLDLMS/ClaimController.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\OLDLMS;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Icd;
|
||||||
|
use App\Models\Member;
|
||||||
|
use App\Services\ClaimService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ClaimController extends Controller
|
||||||
|
{
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'member_id' => 'required',
|
||||||
|
'user_id' => 'required',
|
||||||
|
'type' => 'required|in:consultation-gp,consultation-specialist,medicine',
|
||||||
|
'total_claim' => 'required',
|
||||||
|
'detail' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->type == 'consultation-gp') {
|
||||||
|
$benefitCode = 'OPCONS1';
|
||||||
|
}
|
||||||
|
if ($request->type == 'consultation-specialist') {
|
||||||
|
$benefitCode = 'OPCONS2';
|
||||||
|
}
|
||||||
|
if ($request->type == 'medicine') {
|
||||||
|
$benefitCode = 'OPMEDI1';
|
||||||
|
}
|
||||||
|
|
||||||
|
$member = Member::query()
|
||||||
|
->where('member_id', $request->member_id)
|
||||||
|
->with([
|
||||||
|
'currentPlan',
|
||||||
|
])
|
||||||
|
->firstOrFail();
|
||||||
|
$benefit = $member->currentPlan->benefits()->where('code', $benefitCode)->first();
|
||||||
|
// $diagnosis = Icd::first();
|
||||||
|
|
||||||
|
$claim = ClaimService::storeClaim($member, null, $request->total_claim, $benefit, 'requested');
|
||||||
|
$claim->status = 'approved';
|
||||||
|
$claim->save();
|
||||||
|
|
||||||
|
return Helper::responseJson($claim);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateClaimDiagnosis(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'claim_code' => 'required',
|
||||||
|
'icd_codes' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// dd($request->toArray());
|
||||||
|
return $request->toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
199
app/Http/Controllers/Api/OLDLMS/MembershipController.php
Normal file
199
app/Http/Controllers/Api/OLDLMS/MembershipController.php
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\OLDLMS;
|
||||||
|
|
||||||
|
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.', status: 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$member->active) {
|
||||||
|
return Helper::responseJson(statusCode: 406, message: 'The Member '.$request->member_id.' is Inactive.', status: 'error');
|
||||||
|
}
|
||||||
|
|
||||||
|
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',
|
||||||
|
// 'speciality_code' => 'sometimes'
|
||||||
|
]);
|
||||||
|
|
||||||
|
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', 'postponedClaims'])->first();
|
||||||
|
|
||||||
|
$limits = ClaimService::showMemberBenefitLimit($member, $benefitCode);
|
||||||
|
$limits['postponed_claims'] = $member->postponedClaims;
|
||||||
|
$limits['postponed_claims_payment_url'] = route('postpone-pay', $member->member_id);
|
||||||
|
$limits['postponed_claims_unpaid_total'] = $member->postponedClaims->sum('total_claim');
|
||||||
|
|
||||||
|
$corporateService = $member->currentCorporate
|
||||||
|
->corporateServices()
|
||||||
|
->active()
|
||||||
|
->where('service_code', 'OP')
|
||||||
|
->with([
|
||||||
|
'configs',
|
||||||
|
'specialities' => function ($speciality) use ($request) {
|
||||||
|
$speciality->where('code', $request->speciality_code)
|
||||||
|
->wherePivot('active', 1);
|
||||||
|
}])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$configs = $corporateService->configs->mapWithKeys(function ($config) {
|
||||||
|
return [$config->name => $config];
|
||||||
|
});
|
||||||
|
|
||||||
|
$coverage = [
|
||||||
|
'benefit' => false,
|
||||||
|
'admin_fee' => false,
|
||||||
|
'medicine_benefit' => true, // TODO Make this into setting ?
|
||||||
|
'medicine_delivery_fee' => false
|
||||||
|
];
|
||||||
|
$coverage['medicine_delivery_fee'] = (($configs['delivery_fee']['value'] ?? 1) == 1);
|
||||||
|
$coverage['gp_benefit'] = (($configs['gp_internal_doctor_online']['value'] ?? 1) == 1);
|
||||||
|
$coverage['gp_admin_fee'] = (($configs['general_practitioner_fee']['value'] ?? 1) == 1);
|
||||||
|
$coverage['sp_benefit'] = (($configs['sp_internal_doctor_online']['value'] ?? 1) == 1);
|
||||||
|
$coverage['sp_admin_fee'] = (($configs['specialist_practitioner_fee']['value'] ?? 1) == 1);
|
||||||
|
|
||||||
|
if ($request->has('speciality_code') && !empty($request->speciality_code)) {
|
||||||
|
|
||||||
|
if (empty($corporateService) || empty($corporateService->specialities)) {
|
||||||
|
$coverage['benefit'] = false;
|
||||||
|
$coverage['admin_fee'] = false;
|
||||||
|
$limits['coverage'] = $coverage;
|
||||||
|
|
||||||
|
return Helper::responseJson(data: $limits);
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentSpeciality = $corporateService->specialities->first();
|
||||||
|
|
||||||
|
// Load the Relation Data after speciality check is supported
|
||||||
|
$corporateService->load([
|
||||||
|
'corporateServiceSpecialities' => function ($corporateServiceSpeciality) use ($currentSpeciality) {
|
||||||
|
$corporateServiceSpeciality->where('speciality_id', $currentSpeciality->id);
|
||||||
|
},
|
||||||
|
'corporateServiceSpecialities.exclusions' => function ($exclusion) {
|
||||||
|
$exclusion->where('service_code', 'OP');
|
||||||
|
},
|
||||||
|
'corporateServiceSpecialities.exclusions.rules'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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');
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
return Helper::responseJson(data: $limits);
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/Http/Controllers/Api/OLDLMS/PaymentController.php
Normal file
55
app/Http/Controllers/Api/OLDLMS/PaymentController.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api\OLDLMS;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Member;
|
||||||
|
use App\Services\Duitku;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Str;
|
||||||
|
|
||||||
|
class PaymentController extends Controller
|
||||||
|
{
|
||||||
|
public function postponePay($memberId)
|
||||||
|
{
|
||||||
|
$member = Member::where('member_id', $memberId)->with('postponedClaims')->firstOrFail();
|
||||||
|
|
||||||
|
$totalBill = $member->postponedClaims->sum('total_claim');
|
||||||
|
|
||||||
|
$config_duitku = [
|
||||||
|
'merchant_code' => env('DUITKU_MERCHANT_CODE'),
|
||||||
|
'merchant_key' => env('DUITKU_MERCHANT_KEY'),
|
||||||
|
];
|
||||||
|
$paymentService = new Duitku($config_duitku);
|
||||||
|
|
||||||
|
$invoice = (object) [
|
||||||
|
'invoice_number' => 'INV'.Str::random(5, 5),
|
||||||
|
];
|
||||||
|
|
||||||
|
$user = (object) [
|
||||||
|
'email' => $member->email,
|
||||||
|
'phone' => $member->phone,
|
||||||
|
'name' => $member->name,
|
||||||
|
'last_name' => $member->last_name ?? '',
|
||||||
|
'address' => collect([
|
||||||
|
'line' => 'Alamat',
|
||||||
|
'city' => (object) [
|
||||||
|
'name' => 'Tangerang Selatan'
|
||||||
|
]
|
||||||
|
]),
|
||||||
|
'postal_code' => '124123',
|
||||||
|
];
|
||||||
|
|
||||||
|
$paymentCreate = (object) [
|
||||||
|
'transaction_id' => Str::random(10, 10)
|
||||||
|
];
|
||||||
|
$paymentMethod = (object) [
|
||||||
|
'code' => 'BC',
|
||||||
|
'timeout' => 60
|
||||||
|
];
|
||||||
|
$paymentService->applyInvoice($user, $invoice, $paymentCreate, $totalBill, $paymentMethod);
|
||||||
|
$duitkuPayment = $paymentService->createPayment();
|
||||||
|
|
||||||
|
return redirect($duitkuPayment->paymentUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Http\Middleware;
|
|||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class LinksehatOldAuthMiddleware
|
class LinksehatOldAuthMiddleware
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,8 @@ class LinksehatOldAuthMiddleware
|
|||||||
public function handle(Request $request, Closure $next)
|
public function handle(Request $request, Closure $next)
|
||||||
{
|
{
|
||||||
if ($request->header('authorization') == 'Bearer LpMbGm0NQvFC3lUBiy1Ch3NzS0CIPSmanR12FcdP') {
|
if ($request->header('authorization') == 'Bearer LpMbGm0NQvFC3lUBiy1Ch3NzS0CIPSmanR12FcdP') {
|
||||||
|
Auth::loginUsingId(1);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
app/Http/Resources/OLDLMS/MemberLimitResource.php
Normal file
19
app/Http/Resources/OLDLMS/MemberLimitResource.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class MemberLimitResource 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 parent::toArray($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Resources/OLDLMS/MemberResource.php
Normal file
19
app/Http/Resources/OLDLMS/MemberResource.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class MemberResource 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 parent::toArray($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
37
app/Jobs/TestJob.php
Normal file
37
app/Jobs/TestJob.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
class TestJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
// dd('asdasd');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
// dd('adsasd');
|
||||||
|
Mail::raw('Hello World!', function($msg) {$msg->to('myemail@gmail.com')->subject('Test Email'); });
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Listeners/LogClaimJournal.php
Normal file
40
app/Listeners/LogClaimJournal.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class LogClaimJournal
|
||||||
|
{
|
||||||
|
|
||||||
|
public $afterCommit = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
$policy = $event->claim->member->currentPolicy;
|
||||||
|
$policy->limitJournals()->create([
|
||||||
|
'previous_balance' => $policy->limit_balance,
|
||||||
|
'total_credit' => $event->claim->total_claim * -1,
|
||||||
|
'type' => 'credit',
|
||||||
|
'balance' => bcsub($policy->limit_balance, $event->claim->total_claim),
|
||||||
|
'description' => 'Log for Claim #'. $event->claim->code,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,16 @@ class Address extends Model
|
|||||||
'period_end',
|
'period_end',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function addressable()
|
public function addressable()
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
|
|||||||
@@ -12,156 +12,12 @@ class Benefit extends Model
|
|||||||
use HasFactory, SoftDeletes, Blameable;
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_id',
|
|
||||||
'service_code',
|
'service_code',
|
||||||
'plan_code',
|
|
||||||
'benefit_code',
|
|
||||||
'code',
|
'code',
|
||||||
'description',
|
'description',
|
||||||
'budget',
|
'active'
|
||||||
'budget_conditions',
|
|
||||||
'budget_code',
|
|
||||||
'primary_benefit_code',
|
|
||||||
'benefit_mode',
|
|
||||||
'room_class_coverage',
|
|
||||||
'max_bed_coverage',
|
|
||||||
'tolerance_parameter',
|
|
||||||
'max_room_class',
|
|
||||||
'limit_amount',
|
|
||||||
'area_limit',
|
|
||||||
'shared_benefit',
|
|
||||||
'shared_benefit_type',
|
|
||||||
'msc',
|
|
||||||
'genders',
|
|
||||||
'min_age',
|
|
||||||
'max_age',
|
|
||||||
'max_frequency_period',
|
|
||||||
'daily_frequency',
|
|
||||||
'weekly_frequency',
|
|
||||||
'monthly_frequency',
|
|
||||||
'yearly_frequency',
|
|
||||||
'custom_frequency_days',
|
|
||||||
'custom_duration_value',
|
|
||||||
'allowed_transaction_types',
|
|
||||||
'high_plan_factor',
|
|
||||||
'pre_post_treatment',
|
|
||||||
'pre_treatment_days',
|
|
||||||
'post_treatment_days',
|
|
||||||
'layer_type_1',
|
|
||||||
'layer_value_1',
|
|
||||||
'layer_type_2',
|
|
||||||
'layer_value_2',
|
|
||||||
'cashless_percentage',
|
|
||||||
'reimbursement_percentage',
|
|
||||||
'digital_percentage',
|
|
||||||
'co_share_m_percentage',
|
|
||||||
'co_share_s_percentage',
|
|
||||||
'co_share_c_percentage',
|
|
||||||
'cashless_deductible',
|
|
||||||
'reimbursement_deductible',
|
|
||||||
'digital_deductible',
|
|
||||||
'co_share_m_deductible',
|
|
||||||
'co_share_s_deductible',
|
|
||||||
'co_share_c_deductible',
|
|
||||||
'prorate_type',
|
|
||||||
'prorate_lookup',
|
|
||||||
'max_days_for_disability',
|
|
||||||
'max_period_for_disability',
|
|
||||||
'currency',
|
|
||||||
'show_benefit_item',
|
|
||||||
'show_benefit_value',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $doc_headers_to_field_map = [
|
|
||||||
"Service" => 'service_code',
|
|
||||||
"Plan" => 'plan_code',
|
|
||||||
"Benefit Code" => 'benefit_code',
|
|
||||||
"Customer Benefit Code" => 'code',
|
|
||||||
"Detail Benefit" => 'description',
|
|
||||||
"ASO/Budget" => 'budget',
|
|
||||||
"Budget Condition" => 'budget_conditions',
|
|
||||||
"Budget Code" => 'budget_code',
|
|
||||||
"Primary benefit" => 'primary_benefit_code',
|
|
||||||
"Benefit Mode" => 'benefit_mode',
|
|
||||||
"Room Class" => 'room_class_coverage',
|
|
||||||
"Max Bed" => 'max_bed_coverage',
|
|
||||||
"Tolerance Paramater" => 'tolerance_parameter',
|
|
||||||
"Max. Room Class" => 'max_room_class',
|
|
||||||
"Limit Value" => 'limit_amount',
|
|
||||||
"Area" => 'area_limit',
|
|
||||||
"Shared Benefit With" => 'shared_benefit',
|
|
||||||
"Shared Benefit Type" => 'shared_benefit_type',
|
|
||||||
"MSC" => 'msc',
|
|
||||||
"Gender" => 'genders',
|
|
||||||
"Min Age" => 'min_age',
|
|
||||||
"Max Age" => 'max_age',
|
|
||||||
"Freq. Period" => 'max_frequency_period',
|
|
||||||
"Daily Frequency" => 'daily_frequency',
|
|
||||||
"Weekly Frequency" => 'weekly_frequency',
|
|
||||||
"Monthly Frequency" => 'monthly_frequency',
|
|
||||||
"Yearly Frequency" => 'yearly_frequency',
|
|
||||||
"Custom Duration" => 'custom_frequency_days',
|
|
||||||
"Custom Duration Value" => 'custom_duration_value',
|
|
||||||
"Cashless, Reimbursement" => 'allowed_transaction_types',
|
|
||||||
"High Plan Factor" => 'high_plan_factor',
|
|
||||||
"Pre Post Treatment" => 'pre_post_treatment',
|
|
||||||
"Pre Treatment" => 'pre_treatment_days',
|
|
||||||
"Post Treatment" => 'post_treatment_days',
|
|
||||||
"Layer Type 1" => 'layer_type_1',
|
|
||||||
"Layer Value 1" => 'layer_value_1',
|
|
||||||
"Layer Type 2" => 'layer_type_2',
|
|
||||||
"Layer Value 2" => 'layer_value_2',
|
|
||||||
"Cashless (%)" => 'cashless_percentage',
|
|
||||||
"Reimburse (%)" => 'reimbursement_percentage',
|
|
||||||
"Digital (%)" => 'digital_percentage',
|
|
||||||
"CoShareM (%)" => 'co_share_m_percentage',
|
|
||||||
"CoShareS (%)" => 'co_share_s_percentage',
|
|
||||||
"CoShareC (%)" => 'co_share_c_percentage',
|
|
||||||
"Cashless Deductible" => 'cashless_deductible',
|
|
||||||
"Reimbursement Deductible" => 'reimbursement_deductible',
|
|
||||||
"Digital Deductible" => 'digital_deductible',
|
|
||||||
"DeductibleM" => 'co_share_m_deductible',
|
|
||||||
"DeductibleS" => 'co_share_s_deductible',
|
|
||||||
"DeductibleC" => 'co_share_c_deductible',
|
|
||||||
"Prorate Type" => 'prorate_type',
|
|
||||||
"Prorate Lookup" => 'prorate_lookup',
|
|
||||||
"Max Days for Disability" => 'max_days_for_disability',
|
|
||||||
"Max Periode of Disability" => 'max_period_for_disability',
|
|
||||||
"Currency" => 'currency',
|
|
||||||
"Show Benefit Item" => 'show_benefit_item',
|
|
||||||
"Show Benefit Value" => 'show_benefit_value',
|
|
||||||
];
|
|
||||||
|
|
||||||
public 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPrePostTreatmentAttribute($value)
|
|
||||||
{
|
|
||||||
$this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrePostTreatmentAttribute($value)
|
|
||||||
{
|
|
||||||
return empty($value) ? null : ($value ? 'Y' : 'N');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function scopeFilter($query, array $filters)
|
public function scopeFilter($query, array $filters)
|
||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
@@ -174,51 +30,17 @@ class Benefit extends Model
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function benefit()
|
// public function benefit()
|
||||||
{
|
// {
|
||||||
return $this->belongsTo(Benefit::class, 'benefit_code', 'code');
|
// return $this->belongsTo(Benefit::class, 'benefit_code', 'code');
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function plan()
|
public function plans()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Plan::class, 'plan_code', 'code');
|
return $this->belongsToMany(Plan::class, 'corporate_benefits', 'benefit_id', 'id')
|
||||||
}
|
->withTimestamps()
|
||||||
|
->withPivot([
|
||||||
public function getMaxFrequencyPeriodNameAttribute()
|
// TODO corporate_benefits pivot
|
||||||
{
|
]);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,33 +2,30 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Events\ClaimApproved;
|
||||||
|
use App\Events\ClaimDeclined;
|
||||||
|
use App\Events\ClaimPaid;
|
||||||
|
use App\Events\ClaimPostpone;
|
||||||
|
use App\Events\ClaimReceived;
|
||||||
|
use App\Events\ClaimRequested;
|
||||||
|
use App\Traits\Blameable;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Claim extends Model
|
class Claim extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory, Blameable;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'code',
|
'code',
|
||||||
'member_id',
|
'member_id',
|
||||||
'diagnosis_id',
|
|
||||||
'total_claim',
|
'total_claim',
|
||||||
'currency',
|
'currency',
|
||||||
'plan_id',
|
'plan_id',
|
||||||
'benefit_id',
|
'benefit_id',
|
||||||
'status',
|
'status',
|
||||||
'requested_at',
|
|
||||||
'requested_by',
|
|
||||||
'received_at',
|
|
||||||
'received_by',
|
|
||||||
'approved_at',
|
|
||||||
'approved_by',
|
|
||||||
'declined',
|
|
||||||
'declined_by',
|
|
||||||
'paid_at',
|
|
||||||
'paid_by',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@@ -45,6 +42,7 @@ class Claim extends Model
|
|||||||
'requested' => 'Requested',
|
'requested' => 'Requested',
|
||||||
'received' => 'Received',
|
'received' => 'Received',
|
||||||
'approved' => 'Approved',
|
'approved' => 'Approved',
|
||||||
|
'postpone' => 'Postpone',
|
||||||
'paid' => 'Paid',
|
'paid' => 'Paid',
|
||||||
'declined' => 'Declined'
|
'declined' => 'Declined'
|
||||||
];
|
];
|
||||||
@@ -60,6 +58,50 @@ class Claim extends Model
|
|||||||
abort(500, $e->getMessage());
|
abort(500, $e->getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static::created(function ($model) {
|
||||||
|
try {
|
||||||
|
if (!empty($model->status)) {
|
||||||
|
$model->statusHistories()->create([
|
||||||
|
'status' => $model->status
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
abort(500, $e->getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
static::updated(function ($model) {
|
||||||
|
if ($model->hasChanges(['status'])) {
|
||||||
|
$model->statusHistories()->create([
|
||||||
|
'status' => $model->status
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($model->status == 'requested') {
|
||||||
|
ClaimRequested::dispatch($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->status == 'received') {
|
||||||
|
ClaimReceived::dispatch($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->status == 'approved') {
|
||||||
|
ClaimApproved::dispatch($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->status == 'postpone') {
|
||||||
|
ClaimPostpone::dispatch($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->status == 'paid') {
|
||||||
|
ClaimPaid::dispatch($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->status == 'declined') {
|
||||||
|
ClaimDeclined::dispatch($model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function files()
|
public function files()
|
||||||
@@ -72,9 +114,19 @@ class Claim extends Model
|
|||||||
return $this->belongsTo(Member::class, 'member_id');
|
return $this->belongsTo(Member::class, 'member_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function diagnoses()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ClaimDiagnosis::class, 'claim_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Remove this !, Sementara
|
||||||
public function diagnosis()
|
public function diagnosis()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Icd::class, 'diagnosis_id');
|
return $this->hasOne(ClaimDiagnosis::class, 'claim_id')->ofMany([
|
||||||
|
'id' => 'min',
|
||||||
|
], function ($query) {
|
||||||
|
$query->where('type', 'primary');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function plan()
|
public function plan()
|
||||||
@@ -87,11 +139,16 @@ class Claim extends Model
|
|||||||
return $this->belongsTo(Benefit::class, 'benefit_id');
|
return $this->belongsTo(Benefit::class, 'benefit_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function statusHistories()
|
||||||
|
{
|
||||||
|
return $this->morphMany(StatusHistory::class, 'statusable');
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeUsed($query, $startDate, $endDate)
|
public function scopeUsed($query, $startDate, $endDate)
|
||||||
{
|
{
|
||||||
return $query
|
return $query
|
||||||
->whereIn('status', ['approved', 'paid'])
|
->whereIn('status', ['approved', 'paid']);
|
||||||
->whereBetween('requested_at', [$startDate, $endDate]);
|
// ->whereBetween('requested_at', [$startDate, $endDate]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
app/Models/ClaimDiagnosis.php
Normal file
13
app/Models/ClaimDiagnosis.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ClaimDiagnosis extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'claim_diagnosis';
|
||||||
|
}
|
||||||
@@ -26,6 +26,19 @@ class Corporate extends Model
|
|||||||
'linking_rules' => 'array',
|
'linking_rules' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'avatar_url',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function imports()
|
public function imports()
|
||||||
{
|
{
|
||||||
return $this->morphMany(ImportLog::class, 'importable');
|
return $this->morphMany(ImportLog::class, 'importable');
|
||||||
@@ -36,6 +49,21 @@ class Corporate extends Model
|
|||||||
return $this->morphMany(File::class, 'fileable');
|
return $this->morphMany(File::class, 'fileable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function avatar()
|
||||||
|
{
|
||||||
|
return $this->morphOne(File::class, 'fileable')->where('type', 'avatar')->latest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAvatarUrlAttribute()
|
||||||
|
{
|
||||||
|
return $this->avatar ? $this->avatar->url : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function plans()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Plan::class, 'corporate_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function policies()
|
public function policies()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CorporatePolicy::class);
|
return $this->hasMany(CorporatePolicy::class);
|
||||||
@@ -44,10 +72,10 @@ class Corporate extends Model
|
|||||||
public function currentPolicy()
|
public function currentPolicy()
|
||||||
{
|
{
|
||||||
return $this->hasOne(CorporatePolicy::class)
|
return $this->hasOne(CorporatePolicy::class)
|
||||||
// ->where('start', '<=', now())
|
// ->where('start', '<=', now())
|
||||||
// ->where('end', '>=', now())
|
// ->where('end', '>=', now())
|
||||||
->where('active', true)
|
->where('active', true)
|
||||||
->latestOfMany();
|
->latestOfMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function corporatePlans()
|
public function corporatePlans()
|
||||||
@@ -94,6 +122,11 @@ class Corporate extends Model
|
|||||||
return $this->hasManyThrough(CorporateService::class, Service::class, 'corporate_id', 'service_code', 'id', 'service_code');
|
return $this->hasManyThrough(CorporateService::class, Service::class, 'corporate_id', 'service_code', 'id', 'service_code');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function claims()
|
||||||
|
// {
|
||||||
|
// return $this->hasManyThrough()
|
||||||
|
// }
|
||||||
|
|
||||||
public function corporateServices()
|
public function corporateServices()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CorporateService::class, 'corporate_id');
|
return $this->hasMany(CorporateService::class, 'corporate_id');
|
||||||
|
|||||||
@@ -13,23 +13,220 @@ class CorporateBenefit extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_id',
|
'corporate_id',
|
||||||
'code',
|
'plan_id',
|
||||||
'name',
|
'benefit_id',
|
||||||
'description',
|
'corporate_benefit_code',
|
||||||
|
'budget',
|
||||||
|
'budget_conditions',
|
||||||
|
'budget_code',
|
||||||
|
'primary_benefit_code',
|
||||||
|
'benefit_mode',
|
||||||
|
'room_class_coverage',
|
||||||
|
'max_bed_coverage',
|
||||||
|
'tolerance_parameter',
|
||||||
|
'max_room_class',
|
||||||
|
'limit_amount',
|
||||||
|
'area_limit',
|
||||||
|
'shared_benefit',
|
||||||
|
'shared_benefit_type',
|
||||||
|
'msc',
|
||||||
|
'genders',
|
||||||
|
'min_age',
|
||||||
|
'max_age',
|
||||||
|
'max_frequency_period',
|
||||||
|
'daily_frequency',
|
||||||
|
'weekly_frequency',
|
||||||
|
'monthly_frequency',
|
||||||
|
'yearly_frequency',
|
||||||
|
'custom_frequency_days',
|
||||||
|
'custom_duration_value',
|
||||||
|
'allowed_transaction_types',
|
||||||
|
'high_plan_factor',
|
||||||
|
'pre_post_treatment',
|
||||||
|
'pre_treatment_days',
|
||||||
|
'post_treatment_days',
|
||||||
|
'layer_type_1',
|
||||||
|
'layer_value_1',
|
||||||
|
'layer_type_2',
|
||||||
|
'layer_value_2',
|
||||||
|
'cashless_percentage',
|
||||||
|
'reimbursement_percentage',
|
||||||
|
'digital_percentage',
|
||||||
|
'co_share_m_percentage',
|
||||||
|
'co_share_s_percentage',
|
||||||
|
'co_share_c_percentage',
|
||||||
|
'cashless_deductible',
|
||||||
|
'reimbursement_deductible',
|
||||||
|
'digital_deductible',
|
||||||
|
'co_share_m_deductible',
|
||||||
|
'co_share_s_deductible',
|
||||||
|
'co_share_c_deductible',
|
||||||
|
'prorate_type',
|
||||||
|
'prorate_lookup',
|
||||||
|
'max_days_for_disability',
|
||||||
|
'max_period_for_disability',
|
||||||
|
'currency',
|
||||||
|
'show_benefit_item',
|
||||||
|
'show_benefit_value',
|
||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static $doc_headers_to_field_map = [
|
||||||
|
"Service" => 'service_code',
|
||||||
|
"Plan" => 'plan_code',
|
||||||
|
"Benefit Code" => 'code',
|
||||||
|
"Customer Benefit Code" => 'corporate_benefit_code',
|
||||||
|
"Detail Benefit" => 'description',
|
||||||
|
"ASO/Budget" => 'budget',
|
||||||
|
"Budget Condition" => 'budget_conditions',
|
||||||
|
"Budget Code" => 'budget_code',
|
||||||
|
"Primary benefit" => 'primary_benefit_code',
|
||||||
|
"Benefit Mode" => 'benefit_mode',
|
||||||
|
"Room Class" => 'room_class_coverage',
|
||||||
|
"Max Bed" => 'max_bed_coverage',
|
||||||
|
"Tolerance Paramater" => 'tolerance_parameter',
|
||||||
|
"Max. Room Class" => 'max_room_class',
|
||||||
|
"Limit Value" => 'limit_amount',
|
||||||
|
"Area" => 'area_limit',
|
||||||
|
"Shared Benefit With" => 'shared_benefit',
|
||||||
|
"Shared Benefit Type" => 'shared_benefit_type',
|
||||||
|
"MSC" => 'msc',
|
||||||
|
"Gender" => 'genders',
|
||||||
|
"Min Age" => 'min_age',
|
||||||
|
"Max Age" => 'max_age',
|
||||||
|
"Freq. Period" => 'max_frequency_period',
|
||||||
|
"Daily Frequency" => 'daily_frequency',
|
||||||
|
"Weekly Frequency" => 'weekly_frequency',
|
||||||
|
"Monthly Frequency" => 'monthly_frequency',
|
||||||
|
"Yearly Frequency" => 'yearly_frequency',
|
||||||
|
"Custom Duration" => 'custom_frequency_days',
|
||||||
|
"Custom Duration Value" => 'custom_duration_value',
|
||||||
|
"Cashless, Reimbursement" => 'allowed_transaction_types',
|
||||||
|
"High Plan Factor" => 'high_plan_factor',
|
||||||
|
"Pre Post Treatment" => 'pre_post_treatment',
|
||||||
|
"Pre Treatment" => 'pre_treatment_days',
|
||||||
|
"Post Treatment" => 'post_treatment_days',
|
||||||
|
"Layer Type 1" => 'layer_type_1',
|
||||||
|
"Layer Value 1" => 'layer_value_1',
|
||||||
|
"Layer Type 2" => 'layer_type_2',
|
||||||
|
"Layer Value 2" => 'layer_value_2',
|
||||||
|
"Cashless (%)" => 'cashless_percentage',
|
||||||
|
"Reimburse (%)" => 'reimbursement_percentage',
|
||||||
|
"Digital (%)" => 'digital_percentage',
|
||||||
|
"CoShareM (%)" => 'co_share_m_percentage',
|
||||||
|
"CoShareS (%)" => 'co_share_s_percentage',
|
||||||
|
"CoShareC (%)" => 'co_share_c_percentage',
|
||||||
|
"Cashless Deductible" => 'cashless_deductible',
|
||||||
|
"Reimbursement Deductible" => 'reimbursement_deductible',
|
||||||
|
"Digital Deductible" => 'digital_deductible',
|
||||||
|
"DeductibleM" => 'co_share_m_deductible',
|
||||||
|
"DeductibleS" => 'co_share_s_deductible',
|
||||||
|
"DeductibleC" => 'co_share_c_deductible',
|
||||||
|
"Prorate Type" => 'prorate_type',
|
||||||
|
"Prorate Lookup" => 'prorate_lookup',
|
||||||
|
"Max Days for Disability" => 'max_days_for_disability',
|
||||||
|
"Max Periode of Disability" => 'max_period_for_disability',
|
||||||
|
"Currency" => 'currency',
|
||||||
|
"Show Benefit Item" => 'show_benefit_item',
|
||||||
|
"Show Benefit Value" => 'show_benefit_value',
|
||||||
|
];
|
||||||
|
|
||||||
|
public 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrePostTreatmentAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrePostTreatmentAttribute($value)
|
||||||
|
{
|
||||||
|
return empty($value) ? null : ($value ? 'Y' : 'N');
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function benefit()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Benefit::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function corporate()
|
public function corporate()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Corporate::class);
|
return $this->belongsTo(Corporate::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function plan()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plan::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeFilter($query, array $filters)
|
public function scopeFilter($query, array $filters)
|
||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
return $query
|
return $query
|
||||||
->where('code', 'like', "%" . $search . "%")
|
->whereHas('benefit', function ($query) use ($search) {
|
||||||
->orWhere('name', 'like', "%" . $search . "%");
|
$query->where('code', 'like', "%" . $search . "%")
|
||||||
|
->orWhere('service_code', 'like', "%" . $search . "%");
|
||||||
|
})->orWhereHas('plan', function ($query) use ($search) {
|
||||||
|
$query->where('code', 'like', "%" . $search . "%");
|
||||||
|
});
|
||||||
|
// ->where('code', 'like', "%" . $search . "%")
|
||||||
|
// ->orWhere('name', 'like', "%" . $search . "%");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,4 +19,9 @@ class CorporateEmployee extends Model
|
|||||||
'nik',
|
'nik',
|
||||||
'status'
|
'status'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function division()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(CorporateDivision::class, 'division_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ class CorporatePlan extends Model
|
|||||||
{
|
{
|
||||||
use HasFactory, SoftDeletes, Blameable;
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
|
protected $table = 'plans';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_id',
|
'corporate_id',
|
||||||
'code',
|
'code',
|
||||||
@@ -28,8 +30,8 @@ class CorporatePlan extends Model
|
|||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
return $query
|
return $query
|
||||||
->where('code', 'like', "%" . $search . "%")
|
->where('code', 'like', "%" . $search . "%")
|
||||||
->orWhere('name', 'like', "%" . $search . "%");
|
->orWhere('name', 'like', "%" . $search . "%");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ class CorporatePolicy extends Model
|
|||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
protected $with = [
|
protected $with = [
|
||||||
'latestLimitJournal'
|
'latestLimitJournal'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ class CorporateService extends Model
|
|||||||
'status',
|
'status',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function corporate()
|
public function corporate()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Corporate::class);
|
return $this->belongsTo(Corporate::class);
|
||||||
@@ -33,10 +42,20 @@ class CorporateService extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function specialities()
|
public function specialities()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Speciality::class, 'corporate_service_specialities', 'corporate_service_id', 'speciality_id', 'id', 'id')
|
||||||
|
->withPivot(['active']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function corporateServiceSpecialities()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CorporateServiceSpeciality::class, 'corporate_service_id');
|
return $this->hasMany(CorporateServiceSpeciality::class, 'corporate_service_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeActive($query) {
|
||||||
|
$query->where('status', 'active');
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeFilter($query, array $filters)
|
public function scopeFilter($query, array $filters)
|
||||||
{
|
{
|
||||||
if (!empty($filters['search'])) {
|
if (!empty($filters['search'])) {
|
||||||
|
|||||||
@@ -17,8 +17,22 @@ class CorporateServiceConfig extends Model
|
|||||||
'value'
|
'value'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function corporateService()
|
public function corporateService()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(CorporateService::class, 'corporate_service_id');
|
return $this->belongsTo(CorporateService::class, 'corporate_service_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exclusions()
|
||||||
|
{
|
||||||
|
return $this->morphMany(Exclusion::class, 'exclusionable');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,16 @@ class CorporateServiceSpeciality extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'corporate_service_id',
|
'corporate_service_id',
|
||||||
'speciality_id',
|
'speciality_id',
|
||||||
'status'
|
'active'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function corporateService()
|
public function corporateService()
|
||||||
@@ -31,4 +40,9 @@ class CorporateServiceSpeciality extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Speciality::class, 'speciality_id');
|
return $this->belongsTo(Speciality::class, 'speciality_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exclusions()
|
||||||
|
{
|
||||||
|
return $this->morphMany(Exclusion::class, 'exclusionable');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ class Exclusion extends Model
|
|||||||
'exclusionable_type',
|
'exclusionable_type',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ExclusionRules::class, 'exclusion_id');
|
return $this->hasMany(ExclusionRules::class, 'exclusion_id');
|
||||||
|
|||||||
@@ -17,6 +17,15 @@ class ExclusionRules extends Model
|
|||||||
'values',
|
'values',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function exclusion()
|
public function exclusion()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Exclusion::class, 'exclusion_id');
|
return $this->belongsTo(Exclusion::class, 'exclusion_id');
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ class LimitJournal extends Model
|
|||||||
'description',
|
'description',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function journalable()
|
public function journalable()
|
||||||
{
|
{
|
||||||
return $this->morphTo();
|
return $this->morphTo();
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Member extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"id",
|
"id",
|
||||||
|
"person_id",
|
||||||
"member_id",
|
"member_id",
|
||||||
"record_type",
|
"record_type",
|
||||||
"payor_id",
|
"payor_id",
|
||||||
@@ -61,7 +62,6 @@ class Member extends Model
|
|||||||
'full_name',
|
'full_name',
|
||||||
'age',
|
'age',
|
||||||
'gender_code',
|
'gender_code',
|
||||||
''
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@@ -78,6 +78,16 @@ class Member extends Model
|
|||||||
return $this->hasMany(Claim::class, 'member_id', 'id');
|
return $this->hasMany(Claim::class, 'member_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function postponedClaims()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Claim::class, 'member_id', 'id')->where('status', 'postpone');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function person()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Person::class, 'person_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function employeds()
|
public function employeds()
|
||||||
{
|
{
|
||||||
return $this->hasMany(CorporateEmployee::class, 'member_id');
|
return $this->hasMany(CorporateEmployee::class, 'member_id');
|
||||||
@@ -86,15 +96,15 @@ class Member extends Model
|
|||||||
public function corporates()
|
public function corporates()
|
||||||
{
|
{
|
||||||
return $this
|
return $this
|
||||||
->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
|
->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
|
||||||
->withPivot([
|
->withPivot([
|
||||||
'branch_code',
|
'branch_code',
|
||||||
'divison_id',
|
'division_id',
|
||||||
'nik',
|
'nik',
|
||||||
'status',
|
'status',
|
||||||
'start',
|
'start',
|
||||||
'end'
|
'end'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currentCorporate()
|
public function currentCorporate()
|
||||||
@@ -113,10 +123,10 @@ class Member extends Model
|
|||||||
|
|
||||||
|
|
||||||
return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id');
|
return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id');
|
||||||
// ->where('corporate_policies.start', '<', now())
|
// ->where('corporate_policies.start', '<', now())
|
||||||
// ->where('corporate_policies.end', '>', now())
|
// ->where('corporate_policies.end', '>', now())
|
||||||
// ->where('member_policies.start', '<', now())
|
// ->where('member_policies.start', '<', now())
|
||||||
// ->where('member_policies.end', '>', now());
|
// ->where('member_policies.end', '>', now());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function memberPlans()
|
public function memberPlans()
|
||||||
@@ -142,10 +152,10 @@ class Member extends Model
|
|||||||
public function currentPolicy()
|
public function currentPolicy()
|
||||||
{
|
{
|
||||||
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
|
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
|
||||||
->where('corporate_policies.start', '<', now())
|
->where('corporate_policies.start', '<', now())
|
||||||
->where('corporate_policies.end', '>', now())
|
->where('corporate_policies.end', '>', now())
|
||||||
->where('member_policies.start', '<', now())
|
->where('member_policies.start', '<', now())
|
||||||
->where('member_policies.end', '>', now());
|
->where('member_policies.end', '>', now());
|
||||||
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
|
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,13 +170,16 @@ class Member extends Model
|
|||||||
|
|
||||||
public function getFullNameAttribute()
|
public function getFullNameAttribute()
|
||||||
{
|
{
|
||||||
$arr = [];
|
if (!$this->person) {
|
||||||
if (!empty($this->name_prefix)) {
|
return null;
|
||||||
$arr[] = $this->name_prefix;
|
|
||||||
}
|
}
|
||||||
$arr[] = $this->name;
|
$arr = [];
|
||||||
if (!empty($this->name_suffix)) {
|
if (!empty($this->person->name_prefix)) {
|
||||||
$arr[] = $this->name_suffix;
|
$arr[] = $this->person->name_prefix;
|
||||||
|
}
|
||||||
|
$arr[] = $this->person->name;
|
||||||
|
if (!empty($this->person->name_suffix)) {
|
||||||
|
$arr[] = $this->person->name_suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(' ', $arr);
|
return implode(' ', $arr);
|
||||||
@@ -177,17 +190,43 @@ class Member extends Model
|
|||||||
return $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender;
|
return $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNameAttribute()
|
||||||
|
{
|
||||||
|
return $this->person->name ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBirthDateAttribute()
|
||||||
|
{
|
||||||
|
return Carbon::parse($this->person->birth_date ?? null)->format('Y-m-d') ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenderAttribute()
|
||||||
|
{
|
||||||
|
return $this->person->gender ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
public function scopeFilter($query, array $filters)
|
public function scopeFilter($query, array $filters)
|
||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
return $query
|
return $query
|
||||||
->where('member_id', 'like', "%" . $search . "%")
|
->where('member_id', 'like', "%" . $search . "%")
|
||||||
->orWhere('payor_id', 'like', "%" . $search . "%")
|
->orWhere('payor_id', 'like', "%" . $search . "%")
|
||||||
->orWhere('name', 'like', "%" . $search . "%")
|
->orWhere('email', 'like', "%" . $search . "%")
|
||||||
;
|
->orWhereHas('person', function ($query) use ($search) {
|
||||||
// ->orWhereHas('corporatePlan', function ($query) use ($search) {
|
$query->where('name', 'like', "%" . $search . "%");
|
||||||
// $query->where('code', 'like', "%" . $search . "%");
|
$query->orWhere('phone', 'like', "%" . $search . "%");
|
||||||
// });
|
})
|
||||||
|
->orWhereHas('currentPlan', function ($query) use ($search) {
|
||||||
|
$query->where('code', 'like', "%" . $search . "%");
|
||||||
|
});
|
||||||
|
// ->orWhereHas('corporatePlan', function ($query) use ($search) {
|
||||||
|
// $query->where('code', 'like', "%" . $search . "%");
|
||||||
|
// });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function division()
|
||||||
|
{
|
||||||
|
return $this->hasOneThrough(CorporateDivision::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'division_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
app/Models/OLDLMS/Appointment.php
Normal file
25
app/Models/OLDLMS/Appointment.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Appointment extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_appointment';
|
||||||
|
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
return $this->hasOne(AppointmentDetail::class, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/AppointmentDetail.php
Normal file
11
app/Models/OLDLMS/AppointmentDetail.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AppointmentDetail extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/Healthcare.php
Normal file
11
app/Models/OLDLMS/Healthcare.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Healthcare extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/Insurance.php
Normal file
11
app/Models/OLDLMS/Insurance.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Insurance extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/User.php
Normal file
11
app/Models/OLDLMS/User.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class User extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/UserDetail.php
Normal file
11
app/Models/OLDLMS/UserDetail.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserDetail extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/UserInsurance.php
Normal file
11
app/Models/OLDLMS/UserInsurance.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserInsurance extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/OLDLMS/UserInsuranceDetail.php
Normal file
11
app/Models/OLDLMS/UserInsuranceDetail.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserInsuranceDetail extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
@@ -24,9 +24,18 @@ class Organization extends Model
|
|||||||
// 'metas'
|
// 'metas'
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// public $appends = [
|
public $appends = [
|
||||||
// 'meta'
|
'meta'
|
||||||
// ];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to only include active data.
|
* Scope a query to only include active data.
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class Person extends Model
|
|||||||
'gender',
|
'gender',
|
||||||
'birth_date',
|
'birth_date',
|
||||||
'birth_place',
|
'birth_place',
|
||||||
|
'language',
|
||||||
|
'race',
|
||||||
'citizenship',
|
'citizenship',
|
||||||
'current_employment',
|
'current_employment',
|
||||||
'last_education',
|
'last_education',
|
||||||
@@ -39,6 +41,15 @@ class Person extends Model
|
|||||||
'deleted_by'
|
'deleted_by'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function getFullNameAttribute()
|
public function getFullNameAttribute()
|
||||||
{
|
{
|
||||||
$arr = [];
|
$arr = [];
|
||||||
@@ -107,4 +118,27 @@ class Person extends Model
|
|||||||
{
|
{
|
||||||
return $this->morphMany(AppointmentParticipant::class, 'participantable');
|
return $this->morphMany(AppointmentParticipant::class, 'participantable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setGenderAttribute($value)
|
||||||
|
{
|
||||||
|
if ($value == "M" || $value == "L") {
|
||||||
|
return $this->attributes['gender'] = "male";
|
||||||
|
} else if ($value == "F" || $value == "P") {
|
||||||
|
return $this->attributes['gender'] = "female";
|
||||||
|
} else {
|
||||||
|
return $this->attributes['gender'] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenderAttribute()
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($this->attributes['gender'] == "male" || $this->attributes['gender'] == "L") {
|
||||||
|
return "male";
|
||||||
|
} else if ($this->attributes['gender'] == "female" || $this->attributes['gender'] == "P") {
|
||||||
|
return "female";
|
||||||
|
} else {
|
||||||
|
return "other";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ class Plan extends Model
|
|||||||
{
|
{
|
||||||
use HasFactory, SoftDeletes, Blameable;
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
|
protected $table = "plans";
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"service_code",
|
"service_code",
|
||||||
"corporate_id",
|
"corporate_id",
|
||||||
@@ -63,6 +65,15 @@ class Plan extends Model
|
|||||||
"max_surgery_periode_days",
|
"max_surgery_periode_days",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public static $doc_headers_to_field_map = [
|
public static $doc_headers_to_field_map = [
|
||||||
"Service" => "service_code",
|
"Service" => "service_code",
|
||||||
"Plan" => "corporate_plan_id",
|
"Plan" => "corporate_plan_id",
|
||||||
@@ -148,11 +159,11 @@ class Plan extends Model
|
|||||||
{
|
{
|
||||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
return $query
|
return $query
|
||||||
->where('service_code', 'like', "%" . $search . "%")
|
->where('service_code', 'like', "%" . $search . "%")
|
||||||
->orWhere('code', 'like', "%" . $search . "%")
|
->orWhere('code', 'like', "%" . $search . "%")
|
||||||
->orWhereHas('corporatePlan', function ($query) use ($search) {
|
->orWhereHas('corporatePlan', function ($query) use ($search) {
|
||||||
$query->where('code', 'like', "%" . $search . "%");
|
$query->where('code', 'like', "%" . $search . "%");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +179,15 @@ class Plan extends Model
|
|||||||
|
|
||||||
public function benefits()
|
public function benefits()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Benefit::class, 'plan_code', 'id');
|
return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'plan_id', 'benefit_id')
|
||||||
|
->withTimestamps()
|
||||||
|
->withPivot([
|
||||||
|
// TODO corporate_benefits pivot
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function corporateBenefits()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CorporateBenefit::class, 'plan_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,21 @@ class PractitionerRole extends Model
|
|||||||
'active',
|
'active',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $appends = [
|
||||||
|
'meta'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getMetaAttribute()
|
||||||
|
{
|
||||||
|
$orgMeta = [];
|
||||||
|
foreach ($this->metas as $meta) {
|
||||||
|
$orgMeta[$meta->type] = $meta->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) $orgMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope a query to only include active data.
|
* Scope a query to only include active data.
|
||||||
*
|
*
|
||||||
|
|||||||
16
app/Models/StatusHistory.php
Normal file
16
app/Models/StatusHistory.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Traits\Blameable;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StatusHistory extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, Blameable;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'status'
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Providers;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -25,5 +26,9 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
|
|
||||||
|
Str::macro('initials', fn($value, $sep = ' ', $glue = '') => trim(collect(explode($sep, $value))->map(function ($segment) {
|
||||||
|
return $segment[0] ?? '';
|
||||||
|
})->join($glue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
app/Providers/DuitkuServiceProvider.php
Normal file
28
app/Providers/DuitkuServiceProvider.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class DuitkuServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
require_once app_path() . '/Services/Duitku.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Events\ClaimApproved;
|
||||||
|
use App\Listeners\LogClaimJournal;
|
||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
@@ -18,6 +20,10 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
Registered::class => [
|
Registered::class => [
|
||||||
SendEmailVerificationNotification::class,
|
SendEmailVerificationNotification::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
ClaimApproved::class => [
|
||||||
|
LogClaimJournal::class,
|
||||||
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Events\ClaimApproved;
|
||||||
use App\Models\Claim;
|
use App\Models\Claim;
|
||||||
use App\Models\Icd;
|
use App\Models\Icd;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use DB;
|
||||||
use Str;
|
use Str;
|
||||||
|
|
||||||
class ClaimService{
|
class ClaimService{
|
||||||
@@ -110,22 +112,24 @@ class ClaimService{
|
|||||||
// $policy = $member->currentPolicy;
|
// $policy = $member->currentPolicy;
|
||||||
// $corporate = $member->currentCorporate;
|
// $corporate = $member->currentCorporate;
|
||||||
$benefit = $member->currentPlan->benefits()->where('code', $benefit_code)->first();
|
$benefit = $member->currentPlan->benefits()->where('code', $benefit_code)->first();
|
||||||
|
// dd($member->currentPlan->benefits->toArray());
|
||||||
|
$corporateBenefit = $member->currentPlan->corporateBenefits()->where('benefit_id', $benefit->id)->first();
|
||||||
|
|
||||||
// dd($benefit->toArray());
|
// dd($benefit->toArray());
|
||||||
// dd(compact(['plan', 'policy', 'corporate', 'benefit']));
|
// dd(compact(['plan', 'policy', 'corporate', 'benefit']));
|
||||||
$limits = [
|
$limits = [
|
||||||
'total_limit' => $benefit->limit_amount,
|
'total_limit' => $corporateBenefit ? $corporateBenefit->limit_amount : 0,
|
||||||
'frequency_limit_name' => $benefit->max_frequency_period_name,
|
'frequency_limit_name' => $corporateBenefit ? $corporateBenefit->max_frequency_period_name : null,
|
||||||
'frequency_limit' => $benefit->max_frequency,
|
'frequency_limit' => $corporateBenefit ? $corporateBenefit->max_frequency : 0,
|
||||||
'total_claim' => 0,
|
'total_claim' => 0,
|
||||||
'remaining_limit' => $benefit->limit_amount,
|
'remaining_limit' => $corporateBenefit ? $corporateBenefit->limit_amount : 0,
|
||||||
'usage_daily' => null,
|
'usage_daily' => null,
|
||||||
'usage_weekly' => null,
|
'usage_weekly' => null,
|
||||||
'usage_monthly' => null,
|
'usage_monthly' => null,
|
||||||
'usage_yearly' => null
|
'usage_yearly' => null
|
||||||
];
|
];
|
||||||
|
|
||||||
switch ($benefit->max_frequency_period) {
|
switch ($corporateBenefit->max_frequency_period) {
|
||||||
case(0) :
|
case(0) :
|
||||||
$limits['usage_yearly'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->count();
|
$limits['usage_yearly'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->count();
|
||||||
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->sum('total_claim');
|
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->sum('total_claim');
|
||||||
@@ -150,7 +154,7 @@ class ClaimService{
|
|||||||
// return null;
|
// return null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$limits['remaining_limit'] = $benefit->limit_amount - $limits['total_claim'];
|
$limits['remaining_limit'] = $corporateBenefit->limit_amount - $limits['total_claim'];
|
||||||
|
|
||||||
return $limits;
|
return $limits;
|
||||||
}
|
}
|
||||||
@@ -162,27 +166,18 @@ class ClaimService{
|
|||||||
|
|
||||||
$claimData = [
|
$claimData = [
|
||||||
'member_id' => $member->id,
|
'member_id' => $member->id,
|
||||||
'diagnosis_id' => $diagnosis->id,
|
'diagnosis_id' => $diagnosis->id ?? null,
|
||||||
'total_claim' => $totalClaim,
|
'total_claim' => $totalClaim,
|
||||||
'currency' => 'IDR',
|
'currency' => 'IDR',
|
||||||
'plan_id' => $member->currentPlan->id,
|
'plan_id' => $member->currentPlan->id,
|
||||||
'benefit_id' => $benefit->id,
|
'benefit_id' => $benefit->id,
|
||||||
'status' => $status
|
'status' => $status
|
||||||
];
|
];
|
||||||
$claimData[$status.'_at'] = now();
|
// $claimData[$status.'_at'] = now();
|
||||||
$claimData[$status.'_by'] = auth()->user()->id ?? null;
|
// $claimData[$status.'_by'] = auth()->user()->id ?? null;
|
||||||
|
|
||||||
$claim = Claim::create($claimData);
|
$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();
|
DB::commit();
|
||||||
return $claim;
|
return $claim;
|
||||||
} catch (\Exception $error) {
|
} catch (\Exception $error) {
|
||||||
@@ -191,4 +186,23 @@ class ClaimService{
|
|||||||
throw new \Exception($error);
|
throw new \Exception($error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static function claimApprove(Claim $claim)
|
||||||
|
// {
|
||||||
|
// if (!in_array($claim->status, ['approved', 'paid', 'declined'])) {
|
||||||
|
|
||||||
|
// // Only Update Claim is not approved yet
|
||||||
|
// if (empty($claim->approved_at)) {
|
||||||
|
// $claim->approved_at = now();
|
||||||
|
// $claim->status = 'approved';
|
||||||
|
|
||||||
|
// $claim->save();
|
||||||
|
|
||||||
|
// ClaimApproved::dispatch($claim);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
222
app/Services/DoctorService.php
Normal file
222
app/Services/DoctorService.php
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\Person;
|
||||||
|
use App\Models\Practitioner;
|
||||||
|
use App\Models\PractitionerRole;
|
||||||
|
use App\Models\Speciality;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
|
||||||
|
class DoctorService
|
||||||
|
{
|
||||||
|
public function getData()
|
||||||
|
{
|
||||||
|
$mapSpecialities = [
|
||||||
|
'Akupunktur' => 'SP027',
|
||||||
|
'Anak' => 'SP001',
|
||||||
|
'Andrologi' => 'SP029',
|
||||||
|
'Anastesia' => 'SP015',
|
||||||
|
'Bedah Anak' => '',
|
||||||
|
'Bedah Digestif' => '',
|
||||||
|
'Bedah Mulut' => '',
|
||||||
|
'Bedah Onkologi' => '',
|
||||||
|
'Bedah Orthopedi' => 'SP007',
|
||||||
|
'Bedah Plastik & Rekonstruksi' => 'SP005',
|
||||||
|
'Bedah Saraf' => '',
|
||||||
|
'Bedah Thorak & Kardiovaskuler' => '',
|
||||||
|
'Bedah Umum' => 'SP004',
|
||||||
|
'Bedah Vaskuler' => '',
|
||||||
|
'Dokter Gigi' => 'SP026',
|
||||||
|
'Fisik & Rehabilitasi' => 'SP014',
|
||||||
|
'Gastroenterologi Hepatologi' => '',
|
||||||
|
'Ginjal Hipertensi' => '',
|
||||||
|
'Gizi Klinik' => 'SP019',
|
||||||
|
'Hematologi Onkologi' => '',
|
||||||
|
'Jantung & Pembuluh Darah' => 'SP008',
|
||||||
|
'Kardio Vaskuler' => '',
|
||||||
|
'Kebidanan & Kandungan' => 'SP003',
|
||||||
|
'Kesehatan Jiwa' => 'SP018',
|
||||||
|
'Kulit & Kelamin' => 'SP013',
|
||||||
|
'Laboratorium' => '',
|
||||||
|
'Mata' => 'SP011',
|
||||||
|
'Okupasi' => 'SP016',
|
||||||
|
'Paru' => 'SP009',
|
||||||
|
'Patologi Klinik' => 'SP021',
|
||||||
|
'Penyakit Dalam' => 'SP002',
|
||||||
|
'Psikologi' => 'SP042',
|
||||||
|
'Radiologi' => 'SP020',
|
||||||
|
'Rehabilitasi Medik' => 'SP039',
|
||||||
|
'Rheumatologi' => '',
|
||||||
|
'Saraf' => 'SP012',
|
||||||
|
'THT' => 'SP010',
|
||||||
|
'Umum' => 'SP025',
|
||||||
|
'Urologi' => 'SP006',
|
||||||
|
'Lain-Lain' => '',
|
||||||
|
];
|
||||||
|
|
||||||
|
$organizations = Organization::query()
|
||||||
|
->whereHas('metas', function ($meta) {
|
||||||
|
$meta->where('type', 'KodeRS');
|
||||||
|
})
|
||||||
|
->with('metas')
|
||||||
|
->get();
|
||||||
|
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||||
|
foreach ($organizations as $organization) {
|
||||||
|
|
||||||
|
$hisOrganizationCode = $organization->meta->KodeRS ?? null;
|
||||||
|
|
||||||
|
if (empty($hisOrganizationCode)) {
|
||||||
|
$this->command->warn('NO ORGANIZATION CODE' . $organization->name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$primayaApiService = new PrimayaApi($hisOrganizationCode);
|
||||||
|
|
||||||
|
$this->command->info('Getting RS ' . $hisOrganizationCode . '-' . $organization->name . ' PractitionerRole');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$doctors = $primayaApiService->doctors();
|
||||||
|
$this->processDoctors($doctors, $mapSpecialities, $organization, $specialities);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->command->warn('Something Went Wrong :' . $hisOrganizationCode . ' - ' . $organization->name . ' - ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected function processDoctors($doctors, $mapSpecialities, $organization, $specialities)
|
||||||
|
{
|
||||||
|
// foreach ($doctors['data'] as $doctor) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
$organizations = Organization::query()
|
||||||
|
->whereHas('metas', function ($meta) {
|
||||||
|
$meta->where('type', 'KodeRS');
|
||||||
|
})
|
||||||
|
->with('metas')
|
||||||
|
->get();
|
||||||
|
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||||
|
|
||||||
|
foreach ($organizations as $organization) {
|
||||||
|
$response = Http::get('https://app.primaya.id/temp/practitioners?code=' . $organization->meta->KodeRS);
|
||||||
|
|
||||||
|
foreach ($response->json()['practitioners'] as $practitioner) {
|
||||||
|
$practitioner = json_decode(json_encode($practitioner));
|
||||||
|
|
||||||
|
dd($practitioner);
|
||||||
|
if (!empty($practitioner->meta->NIK)) {
|
||||||
|
$newPerson = Person::updateOrCreate([
|
||||||
|
'nik' => $practitioner->meta->NIK
|
||||||
|
], [
|
||||||
|
'nik' => $practitioner->meta->NIK,
|
||||||
|
'name' => $practitioner->doctor->name,
|
||||||
|
'gender' => $practitioner->doctor->gender,
|
||||||
|
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$newPerson = Person::create([
|
||||||
|
'name' => $practitioner->doctor->name,
|
||||||
|
'gender' => $practitioner->doctor->gender,
|
||||||
|
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$newPerson->addresses()->create([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $practitioner->doctor->address,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newPractitioner = Practitioner::updateOrCreate([
|
||||||
|
'person_id' => $newPerson->id
|
||||||
|
], [
|
||||||
|
'person_id' => $newPerson->id
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'medical_treatment',
|
||||||
|
'value' => $practitioner->doctor->meta->MedicalTreatment ?? null,
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'education',
|
||||||
|
'value' => $practitioner->doctor->meta->Education ?? null,
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'award',
|
||||||
|
'value' => $practitioner->doctor->meta->Award ?? null,
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'work_experience',
|
||||||
|
'value' => $practitioner->doctor->meta->WorkExperience ?? null,
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'primaya-his',
|
||||||
|
'type' => 'alias',
|
||||||
|
'value' => $practitioner->meta->Sapaan ?? null,
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'primaya-his',
|
||||||
|
'type' => 'Keilmuan',
|
||||||
|
'value' => $practitioner->meta->Keilmuan ?? null,
|
||||||
|
]);
|
||||||
|
$newPractitioner->metas()->create([
|
||||||
|
'system' => 'primaya-his',
|
||||||
|
'type' => 'description',
|
||||||
|
'value' => $practitioner->doctor->description ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$newPractitionerRole = PractitionerRole::create([
|
||||||
|
'practitioner_id' => $newPractitioner->id,
|
||||||
|
'organization_id' => $organization->id,
|
||||||
|
'speciality_id' => $practitioner->speciality ? ($specialities[$practitioner->speciality->name] ?? null) : null,
|
||||||
|
'active' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (empty($newPractitionerRole->speciality_id)) {
|
||||||
|
$newPractitionerRole->metas()->updateOrCreate([
|
||||||
|
'type' => 'speciality_code',
|
||||||
|
], [
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'speciality_code',
|
||||||
|
'value' => $practitioner->speciality->code ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newPractitionerRole->metas()->updateOrCreate([
|
||||||
|
'type' => 'speciality',
|
||||||
|
], [
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'speciality',
|
||||||
|
'value' => $practitioner->speciality->name ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newPractitionerRole->metas()->updateOrCreate([
|
||||||
|
'type' => 'speciality_image',
|
||||||
|
], [
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'speciality_image',
|
||||||
|
'value' => $practitioner->speciality->name ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$newPractitionerRole->metas()->updateOrCreate([
|
||||||
|
'type' => 'primaya-his',
|
||||||
|
'type' => 'DokterID',
|
||||||
|
], [
|
||||||
|
'system' => 'primaya-his',
|
||||||
|
'type' => 'DokterID',
|
||||||
|
'value' => $practitioner->meta->DokterID ?? null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
228
app/Services/Duitku.php
Normal file
228
app/Services/Duitku.php
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
// use Illuminate\Support\Facades\Config;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
use Duitku\Config;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class Duitku
|
||||||
|
{
|
||||||
|
public function __construct($config_duitku)
|
||||||
|
{
|
||||||
|
$merchantKey = $config_duitku['merchant_key'];
|
||||||
|
$merchantCode = $config_duitku['merchant_code'];
|
||||||
|
|
||||||
|
$this->duitkuConfig = new Config($merchantKey, $merchantCode);
|
||||||
|
$this->duitkuConfig->setSandboxMode(env('DUITKU_SANDBOX', true));
|
||||||
|
|
||||||
|
|
||||||
|
// $duitkuConfig = new \Duitku\Config("3b4264fb0118bab008448a67e83f6cbe", "DS12798");
|
||||||
|
|
||||||
|
// // false for production mode
|
||||||
|
// // true for sandbox mode
|
||||||
|
// $duitkuConfig->setSandboxMode(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function applyInvoice($patient, $invoices, $paymentCreate, $total_price, $paymentMethods)
|
||||||
|
{
|
||||||
|
|
||||||
|
$paymentMethod = $paymentMethods->code;
|
||||||
|
$paymentAmount = $total_price; // Amount
|
||||||
|
|
||||||
|
$email = $patient->email ?? ''; //"customer@gmail.com"; // your customer email
|
||||||
|
$phoneNumber = $patient->phone ?? ''; //"081234567890"; // your customer phone number (optional)
|
||||||
|
$productDetails = $invoices->invoice_number;
|
||||||
|
|
||||||
|
$merchantOrderId = $paymentCreate->transaction_id; // from merchant, unique
|
||||||
|
// dd($merchantOrderId);
|
||||||
|
$additionalParam = ''; // optional
|
||||||
|
$merchantUserInfo = ''; // optional
|
||||||
|
$customerVaName = $patient->name ?? ''; // display name on bank confirmation display
|
||||||
|
$callbackUrl = env('DUITKU_PAYMENT_CALLBACK_URL'); // url for callback
|
||||||
|
$returnUrl = 'https://dev-superapp.primaya.id';
|
||||||
|
$expiryPeriod = $paymentMethods->timeout; // set the expired time in minutes
|
||||||
|
|
||||||
|
// Customer Detail
|
||||||
|
$firstName = $patient->name ?? '';
|
||||||
|
// dd($firstName);
|
||||||
|
$lastName = $patient->last_name ?? '';
|
||||||
|
|
||||||
|
// Address
|
||||||
|
$alamat = $patient->address->first()->line ?? '';
|
||||||
|
// dd($alamat);
|
||||||
|
$city = $patient->address->first()->city->name ?? '';
|
||||||
|
// dd($city);
|
||||||
|
$postalCode = $patient->postal_code ?? '';
|
||||||
|
$countryCode = "ID";
|
||||||
|
|
||||||
|
$address = array(
|
||||||
|
'firstName' => $firstName,
|
||||||
|
'lastName' => $lastName,
|
||||||
|
'address' => $alamat,
|
||||||
|
'city' => $city,
|
||||||
|
'postalCode' => $postalCode,
|
||||||
|
'phone' => $phoneNumber,
|
||||||
|
'countryCode' => $countryCode
|
||||||
|
);
|
||||||
|
|
||||||
|
$customerDetail = array(
|
||||||
|
'firstName' => $firstName,
|
||||||
|
'lastName' => $lastName,
|
||||||
|
'email' => $email,
|
||||||
|
'phoneNumber' => $phoneNumber,
|
||||||
|
'billingAddress' => $address,
|
||||||
|
// 'shippingAddress' => $address
|
||||||
|
);
|
||||||
|
|
||||||
|
// $itemDetails = [];
|
||||||
|
// foreach ($invoices->items as $item) {
|
||||||
|
// $itemDetails[] = [
|
||||||
|
// 'name' => $invoices->invoice_number,
|
||||||
|
// 'price' => (int) $item->price_net,
|
||||||
|
// 'quantity' => 1,
|
||||||
|
// ];
|
||||||
|
// }
|
||||||
|
|
||||||
|
$itemDetails = array(
|
||||||
|
array(
|
||||||
|
'name' => $invoices->invoice_number,
|
||||||
|
'price' => (int) $total_price,
|
||||||
|
'quantity' => 1,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'paymentMethod' => $paymentMethod,
|
||||||
|
'paymentAmount' => (int) $paymentAmount,
|
||||||
|
'merchantOrderId' => $merchantOrderId,
|
||||||
|
'productDetails' => $productDetails,
|
||||||
|
'additionalParam' => $additionalParam,
|
||||||
|
'merchantUserInfo' => $merchantUserInfo,
|
||||||
|
'customerVaName' => $customerVaName,
|
||||||
|
'email' => $email,
|
||||||
|
'phoneNumber' => $phoneNumber,
|
||||||
|
'itemDetails' => $itemDetails,
|
||||||
|
'customerDetail' => $customerDetail,
|
||||||
|
'callbackUrl' => $callbackUrl,
|
||||||
|
'returnUrl' => $returnUrl,
|
||||||
|
'expiryPeriod' => $expiryPeriod
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->transaction_details = $params;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPayment()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// createInvoice Request
|
||||||
|
$responseDuitku = \Duitku\Api::createInvoice($this->transaction_details, $this->duitkuConfig);
|
||||||
|
|
||||||
|
return json_decode($responseDuitku);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function checkTransaction($paymentCreate)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// $merchantOrderId = "96ce0853-35e2-4809-97bf-47463d236773";
|
||||||
|
$merchantOrderId = $paymentCreate->first()->transaction_id;
|
||||||
|
// dd($merchantOrderId);
|
||||||
|
|
||||||
|
$transactionList = \Duitku\Api::transactionStatus($merchantOrderId, $this->duitkuConfig);
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
$transaction = json_decode($transactionList);
|
||||||
|
|
||||||
|
// var_dump($transactionList);
|
||||||
|
|
||||||
|
if ($transaction->statusCode == "00") {
|
||||||
|
return response()->json([
|
||||||
|
'data' => $transaction
|
||||||
|
]);
|
||||||
|
} else if ($transaction->statusCode == "01") {
|
||||||
|
return response()->json([
|
||||||
|
'data' => $transaction
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return response()->json([
|
||||||
|
'data' => $transaction
|
||||||
|
]);
|
||||||
|
// Action Failed Or Expired
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function getSignature($merchantCode, $amount, $merchantOrderId, $apiKey)
|
||||||
|
{
|
||||||
|
$params = $merchantCode . $amount . $merchantOrderId . $apiKey;
|
||||||
|
|
||||||
|
// DS12798
|
||||||
|
// 110.000,00
|
||||||
|
// 96ce58d2-0aec-4a1a-b0b1-c96c0e2ff2d8
|
||||||
|
// 3b4264fb0118bab008448a67e83f6cbe
|
||||||
|
return md5($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateCallback($config_duitku, $merchantCode, $amount, $merchantOrderId, $signature)
|
||||||
|
{
|
||||||
|
|
||||||
|
$apiKey = $config_duitku['merchant_key'];
|
||||||
|
|
||||||
|
if (!empty($merchantCode) && !empty($amount) && !empty($merchantOrderId) && !empty($signature)) {
|
||||||
|
$this->params = $merchantCode . $amount . $merchantOrderId . $apiKey;
|
||||||
|
$calcSignature = $this->getSignature($merchantCode, $amount, $merchantOrderId, $apiKey);
|
||||||
|
|
||||||
|
if ($signature == $calcSignature) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
throw new \Exception('Bad Signature');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new \Exception('Bad Parameter');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function translatePaymentStatus($paymentStatusCode)
|
||||||
|
{
|
||||||
|
switch ($paymentStatusCode) {
|
||||||
|
case '00':
|
||||||
|
$status = 'success';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$status = 'failed';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function paymentMethod()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$paymentAmount = "10000"; //"YOUR_AMOUNT";
|
||||||
|
$paymentMethodList = \Duitku\Api::getPaymentMethod($paymentAmount, $this->duitkuConfig);
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
// return
|
||||||
|
$paymentMethod = json_decode($paymentMethodList);
|
||||||
|
return response()->json($paymentMethod->paymentFee);
|
||||||
|
// echo $paymentMethodList->paymentFee;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
app/Services/PrimayaApi.php
Normal file
123
app/Services/PrimayaApi.php
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Request;
|
||||||
|
use Mockery\Generator\Parameter;
|
||||||
|
use Psy\CodeCleaner\FunctionContextPass;
|
||||||
|
use Termwind\Components\Dd;
|
||||||
|
|
||||||
|
class PrimayaApi
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* __construct
|
||||||
|
*
|
||||||
|
* @param string $KodeRS C,DE,...
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(string $KodeRS)
|
||||||
|
{
|
||||||
|
// TODO Feels Wrong
|
||||||
|
$endpointMaps = [
|
||||||
|
"C" => [
|
||||||
|
"base_url" => "http://tgr.primaya.id:1234",
|
||||||
|
"token" => "1|QGYpSbyi9snAj1bHl1lP6apLJxbl20gsAoPmu1oh",
|
||||||
|
],
|
||||||
|
"D" => [
|
||||||
|
"base_url" => "http://primaya-hospital.com:38588",
|
||||||
|
"token" => "1|nbVbBmNmm967qYs9dNA0JvFNGvArGFGwFHJ8C9nK",
|
||||||
|
],
|
||||||
|
"E" => [
|
||||||
|
"base_url" => "http://evasari.fortiddns.com:9280",
|
||||||
|
"token" => "1|qb17AM6BB5sw1a3vZ2BTfIHXbPisqLSBdhwZKGJv",
|
||||||
|
],
|
||||||
|
"F" => [
|
||||||
|
"base_url" => "http://mks.primaya.id:2588",
|
||||||
|
"token" => null,
|
||||||
|
],
|
||||||
|
"M" => [ // Bektim
|
||||||
|
"base_url" => 'http://101.255.124.84',
|
||||||
|
"token" => null,
|
||||||
|
],
|
||||||
|
"O" => [
|
||||||
|
"base_url" => "http://rsinco.fortiddns.com:88",
|
||||||
|
"token" => "1|7e64N6gfSxsBic7DgwVec6EKQAIAx9Dd7is7K5Db",
|
||||||
|
],
|
||||||
|
"P" => [
|
||||||
|
"base_url" => "http://bekut.primaya.id:88",
|
||||||
|
"token" => "1|N5s4oKJNRnrpA2lneFI5LBhGNq6xwioY6PKDIA10",
|
||||||
|
],
|
||||||
|
"Q" => [
|
||||||
|
"base_url" => "http://krw.primaya.id:4040",
|
||||||
|
"token" => "1|zyS7AbeqzwKavfXFu0ReQOn5npIjdzVqA0pMqaMt",
|
||||||
|
],
|
||||||
|
"N" => [
|
||||||
|
"base_url" => "http://pky.primaya.id:88",
|
||||||
|
"token" => "1|yiajZEyu7pBkJNacv60tmb6McimbakG5lGzhm1Oy",
|
||||||
|
],
|
||||||
|
"SG" => [
|
||||||
|
"base_url" => "http://smg.primaya.id:4040",
|
||||||
|
"token" => "1|2lXZqpzhofXA2IjPdL7z52iBRiqrK5Eio924hMxi",
|
||||||
|
],
|
||||||
|
"BW" => [
|
||||||
|
"base_url" => "http://bwp.primaya.id:4040",
|
||||||
|
"token" => "1|8I6mdDxSUO0019GbbVx6olcACjaklxLUgmg0zUKh",
|
||||||
|
],
|
||||||
|
"SK" => [
|
||||||
|
"base_url" => "http://skb.primaya.id:4040",
|
||||||
|
"token" => "1|nYXzAvDbTceumUIDCr9sqXzj2Hq1kvfjYWeVg60P",
|
||||||
|
],
|
||||||
|
"PK" => [
|
||||||
|
"base_url" => "http://pkt.primaya.id:4040",
|
||||||
|
"token" => "2|nvIdQ7gzJnB7xQhfdjxlkr3oRSqBIvBOunjj72QO",
|
||||||
|
],
|
||||||
|
"CK" => [
|
||||||
|
"base_url" => "http://103.154.92.150:4040",
|
||||||
|
"token" => "1|BEKJwPhrmyjGwYVbl6xARV2auLSMtgYJyP4E3Kgd",
|
||||||
|
],
|
||||||
|
"DE" => [
|
||||||
|
"base_url" => "http://202.148.23.68:38807",
|
||||||
|
"token" => "1|DgEL6wte9vmg5X74AUBPVlbMtTIbDqrrp990Kqrt",
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$config = $endpointMaps[$KodeRS];
|
||||||
|
$this->base_url = !empty($config['base_url']) ? ($config['base_url'] . '/api') : null;
|
||||||
|
|
||||||
|
$this->headers = [
|
||||||
|
'Authorization' => 'Bearer ' . ($config['token'] ?? null)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBaseUrl()
|
||||||
|
{
|
||||||
|
return config('lms-api.base_url');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDefaultHeaders()
|
||||||
|
{
|
||||||
|
return ['id' => config('lms-api.auth_id')];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function consultationPrice($LayananKodes = [], $timeout = 30)
|
||||||
|
{
|
||||||
|
$response = Http::timeout($timeout)
|
||||||
|
->withHeaders($this->headers)
|
||||||
|
->post(
|
||||||
|
$this->base_url . '/consultation-price',
|
||||||
|
empty($LayananKodes) ? null : $LayananKodes
|
||||||
|
)->json();
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doctors($page = 1)
|
||||||
|
{
|
||||||
|
$response = Http::withHeaders($this->headers)
|
||||||
|
->get($this->base_url . '/doctors' . '?page=' . $page)
|
||||||
|
->json();
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ trait Blameable {
|
|||||||
public static function bootBlameable() {
|
public static function bootBlameable() {
|
||||||
static::creating(function ($model) {
|
static::creating(function ($model) {
|
||||||
$model->created_by = auth()->id() ?? NULL;
|
$model->created_by = auth()->id() ?? NULL;
|
||||||
|
$model->updated_by = auth()->id() ?? NULL;
|
||||||
});
|
});
|
||||||
|
|
||||||
static::updating(function ($model) {
|
static::updating(function ($model) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0.2",
|
"php": "^8.0.2",
|
||||||
"box/spout": "^3.3",
|
"box/spout": "^3.3",
|
||||||
|
"duitkupg/duitku-php": "dev-master",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"laravel/framework": "^9.11",
|
"laravel/framework": "^9.11",
|
||||||
"laravel/sanctum": "^2.15",
|
"laravel/sanctum": "^2.15",
|
||||||
@@ -14,7 +15,8 @@
|
|||||||
"laravel/tinker": "^2.7",
|
"laravel/tinker": "^2.7",
|
||||||
"maatwebsite/excel": "^3.1",
|
"maatwebsite/excel": "^3.1",
|
||||||
"nwidart/laravel-modules": "^9.0",
|
"nwidart/laravel-modules": "^9.0",
|
||||||
"psr/simple-cache": "^1.0"
|
"psr/simple-cache": "^1.0",
|
||||||
|
"pusher/pusher-php-server": "^7.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"barryvdh/laravel-debugbar": "^3.7",
|
"barryvdh/laravel-debugbar": "^3.7",
|
||||||
|
|||||||
2363
composer.lock
generated
2363
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -193,7 +193,10 @@ return [
|
|||||||
*/
|
*/
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
App\Providers\AuthServiceProvider::class,
|
App\Providers\AuthServiceProvider::class,
|
||||||
// App\Providers\BroadcastServiceProvider::class,
|
App\Providers\DuitkuServiceProvider::class,
|
||||||
|
|
||||||
|
|
||||||
|
App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
|
||||||
@@ -212,6 +215,7 @@ return [
|
|||||||
|
|
||||||
'aliases' => Facade::defaultAliases()->merge([
|
'aliases' => Facade::defaultAliases()->merge([
|
||||||
// 'ExampleClass' => App\Example\ExampleClass::class,
|
// 'ExampleClass' => App\Example\ExampleClass::class,
|
||||||
|
'Duitku' => App\Services\Duitku::class,
|
||||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||||
'LmsApi' => App\Services\LmsApi::class,
|
'LmsApi' => App\Services\LmsApi::class,
|
||||||
])->toArray(),
|
])->toArray(),
|
||||||
|
|||||||
5
config/aso.php
Normal file
5
config/aso.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'general_practitioner_speciality_name' => 'Umum'
|
||||||
|
];
|
||||||
@@ -36,8 +36,11 @@ return [
|
|||||||
'secret' => env('PUSHER_APP_SECRET'),
|
'secret' => env('PUSHER_APP_SECRET'),
|
||||||
'app_id' => env('PUSHER_APP_ID'),
|
'app_id' => env('PUSHER_APP_ID'),
|
||||||
'options' => [
|
'options' => [
|
||||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||||
'useTLS' => true,
|
'port' => env('PUSHER_PORT', 443),
|
||||||
|
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||||
|
'encrypted' => true,
|
||||||
|
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||||
],
|
],
|
||||||
'client_options' => [
|
'client_options' => [
|
||||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||||
|
|||||||
@@ -63,6 +63,26 @@ return [
|
|||||||
]) : [],
|
]) : [],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'oldlms' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('OLDLMS_DATABASE_URL'),
|
||||||
|
'host' => env('OLDLMS_DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('OLDLMS_DB_PORT', '3306'),
|
||||||
|
'database' => env('OLDLMS_DB_DATABASE', 'forge'),
|
||||||
|
'username' => env('OLDLMS_DB_USERNAME', 'forge'),
|
||||||
|
'password' => env('OLDLMS_DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('OLDLMS_DB_SOCKET', ''),
|
||||||
|
'charset' => 'utf8mb4',
|
||||||
|
'collation' => 'utf8mb4_unicode_ci',
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
'pgsql' => [
|
'pgsql' => [
|
||||||
'driver' => 'pgsql',
|
'driver' => 'pgsql',
|
||||||
'url' => env('DATABASE_URL'),
|
'url' => env('DATABASE_URL'),
|
||||||
|
|||||||
@@ -15,64 +15,66 @@ return new class extends Migration
|
|||||||
{
|
{
|
||||||
Schema::create('benefits', function (Blueprint $table) {
|
Schema::create('benefits', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('corporate_id')->index()->nullable();
|
// $table->foreignId('corporate_id')->index()->nullable();
|
||||||
$table->string('service_code')->index()->nullable();
|
$table->string('service_code')->index()->nullable();
|
||||||
$table->string('plan_code')->index()->nullable();
|
// $table->string('plan_code')->index()->nullable();
|
||||||
$table->string('benefit_code')->index()->nullable();
|
// $table->string('benefit_code')->index()->nullable();
|
||||||
$table->string('code')->index()->nullable();
|
$table->string('code')->index();
|
||||||
$table->text('description')->nullable();
|
$table->text('description')->nullable();
|
||||||
$table->string('budget')->nullable();
|
// $table->string('budget')->nullable();
|
||||||
$table->string('budget_conditions')->nullable();
|
// $table->string('budget_conditions')->nullable();
|
||||||
$table->string('budget_code')->nullable();
|
// $table->string('budget_code')->nullable();
|
||||||
$table->string('primary_benefit_code')->index()->nullable();
|
// $table->string('primary_benefit_code')->index()->nullable();
|
||||||
$table->string('benefit_mode')->nullable();
|
// $table->string('benefit_mode')->nullable();
|
||||||
$table->string('room_class_coverage')->nullable();
|
// $table->string('room_class_coverage')->nullable();
|
||||||
$table->string('max_bed_coverage')->nullable();
|
// $table->string('max_bed_coverage')->nullable();
|
||||||
$table->string('tolerance_parameter')->nullable();
|
// $table->string('tolerance_parameter')->nullable();
|
||||||
$table->string('max_room_class')->nullable();
|
// $table->string('max_room_class')->nullable();
|
||||||
$table->string('limit_amount', 30)->nullable();
|
// $table->string('limit_amount', 30)->nullable();
|
||||||
$table->boolean('area_limit')->default(false)->nullable();
|
// $table->boolean('area_limit')->default(false)->nullable();
|
||||||
$table->string('shared_benefit')->nullable();
|
// $table->string('shared_benefit')->nullable();
|
||||||
$table->string('shared_benefit_type')->nullable();
|
// $table->string('shared_benefit_type')->nullable();
|
||||||
$table->string('msc')->nullable();
|
// $table->string('msc')->nullable();
|
||||||
$table->string('genders')->nullable();
|
// $table->string('genders')->nullable();
|
||||||
$table->string('min_age')->nullable();
|
// $table->string('min_age')->nullable();
|
||||||
$table->string('max_age')->nullable();
|
// $table->string('max_age')->nullable();
|
||||||
$table->string('max_frequency_period')->nullable();
|
// $table->string('max_frequency_period')->nullable();
|
||||||
$table->string('daily_frequency')->nullable();
|
// $table->string('daily_frequency')->nullable();
|
||||||
$table->string('weekly_frequency')->nullable();
|
// $table->string('weekly_frequency')->nullable();
|
||||||
$table->string('monthly_frequency')->nullable();
|
// $table->string('monthly_frequency')->nullable();
|
||||||
$table->string('yearly_frequency')->nullable();
|
// $table->string('yearly_frequency')->nullable();
|
||||||
$table->string('custom_frequency_days')->nullable();
|
// $table->string('custom_frequency_days')->nullable();
|
||||||
$table->string('custom_duration_value')->nullable();
|
// $table->string('custom_duration_value')->nullable();
|
||||||
$table->string('allowed_transaction_types')->nullable();
|
// $table->string('allowed_transaction_types')->nullable();
|
||||||
$table->string('high_plan_factor')->nullable();
|
// $table->string('high_plan_factor')->nullable();
|
||||||
$table->boolean('pre_post_treatment')->nullable();
|
// $table->boolean('pre_post_treatment')->nullable();
|
||||||
$table->string('pre_treatment_days')->nullable();
|
// $table->string('pre_treatment_days')->nullable();
|
||||||
$table->string('post_treatment_days')->nullable();
|
// $table->string('post_treatment_days')->nullable();
|
||||||
$table->string('layer_type_1')->nullable();
|
// $table->string('layer_type_1')->nullable();
|
||||||
$table->string('layer_value_1')->nullable();
|
// $table->string('layer_value_1')->nullable();
|
||||||
$table->string('layer_type_2')->nullable();
|
// $table->string('layer_type_2')->nullable();
|
||||||
$table->string('layer_value_2')->nullable();
|
// $table->string('layer_value_2')->nullable();
|
||||||
$table->string('cashless_percentage')->default(100)->nullable();
|
// $table->string('cashless_percentage')->default(100)->nullable();
|
||||||
$table->string('reimbursement_percentage')->default(100)->nullable();
|
// $table->string('reimbursement_percentage')->default(100)->nullable();
|
||||||
$table->string('digital_percentage')->default(100)->nullable();
|
// $table->string('digital_percentage')->default(100)->nullable();
|
||||||
$table->string('co_share_m_percentage')->default(100)->nullable();
|
// $table->string('co_share_m_percentage')->default(100)->nullable();
|
||||||
$table->string('co_share_s_percentage')->default(100)->nullable();
|
// $table->string('co_share_s_percentage')->default(100)->nullable();
|
||||||
$table->string('co_share_c_percentage')->default(100)->nullable();
|
// $table->string('co_share_c_percentage')->default(100)->nullable();
|
||||||
$table->string('cashless_deductible', 30)->nullable();
|
// $table->string('cashless_deductible', 30)->nullable();
|
||||||
$table->string('reimbursement_deductible', 30)->nullable();
|
// $table->string('reimbursement_deductible', 30)->nullable();
|
||||||
$table->string('digital_deductible', 30)->nullable();
|
// $table->string('digital_deductible', 30)->nullable();
|
||||||
$table->string('co_share_m_deductible', 30)->nullable();
|
// $table->string('co_share_m_deductible', 30)->nullable();
|
||||||
$table->string('co_share_s_deductible', 30)->nullable();
|
// $table->string('co_share_s_deductible', 30)->nullable();
|
||||||
$table->string('co_share_c_deductible', 30)->nullable();
|
// $table->string('co_share_c_deductible', 30)->nullable();
|
||||||
$table->string('prorate_type')->nullable();
|
// $table->string('prorate_type')->nullable();
|
||||||
$table->string('prorate_lookup')->nullable();
|
// $table->string('prorate_lookup')->nullable();
|
||||||
$table->string('max_days_for_disability')->nullable();
|
// $table->string('max_days_for_disability')->nullable();
|
||||||
$table->string('max_period_for_disability')->nullable();
|
// $table->string('max_period_for_disability')->nullable();
|
||||||
$table->string('currency')->nullable();
|
// $table->string('currency')->nullable();
|
||||||
$table->string('show_benefit_item')->nullable();
|
// $table->string('show_benefit_item')->nullable();
|
||||||
$table->string('show_benefit_value')->nullable();
|
// $table->string('show_benefit_value')->nullable();
|
||||||
|
|
||||||
|
$table->boolean('active')->default(true);
|
||||||
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user