Compare commits
108 Commits
mhmfajar
...
feature/ge
| Author | SHA1 | Date | |
|---|---|---|---|
| bcf6662db6 | |||
| 912edcdae7 | |||
| 5a7695b404 | |||
| 5f05f191c6 | |||
| 46af57b17c | |||
| 016bd3f605 | |||
| 093f8160d2 | |||
| d8f493103c | |||
| 7f77deb09e | |||
| d38bc8dbfc | |||
| b225084991 | |||
| d8a98f4648 | |||
|
|
f309f4039c | ||
|
|
387658a992 | ||
| 6491f4d3e3 | |||
| 5028b2d82b | |||
| 5d56434aa2 | |||
| 8e05280b7d | |||
| e3de0a3c04 | |||
| c3a425c93d | |||
| 431070efc3 | |||
| e8c3decf85 | |||
| 99c488baf3 | |||
| 0b50e4c980 | |||
| ba310a21c1 | |||
| 5a0136acf8 | |||
| 75c9781a22 | |||
| 2a1f0c854a | |||
| f0c787fede | |||
| 8d5f4bb0bd | |||
| 248047006e | |||
| 2c535b4021 | |||
| 59dd63a78f | |||
| 21282be7b3 | |||
|
|
8cbfb1929b | ||
| b8152e6b3f | |||
| cfbe108629 | |||
| a8821dfb3c | |||
|
|
1ce2655b65 | ||
|
|
335e24b17c | ||
|
|
4776eb5b0a | ||
| 17daf20167 | |||
| 18ace75fc7 | |||
| ad743de98d | |||
| 96a40842bd | |||
| 137fd07a28 | |||
| 21dc0b1fc1 | |||
| f56361de62 | |||
| 85f319878a | |||
| 23436164c2 | |||
| b19e0876e5 | |||
| 704c5ecc44 | |||
| 9087580138 | |||
| 7ff199a3c1 | |||
| 08a2502fb1 | |||
| 65c9153fee | |||
| 775f471a07 | |||
| f09eaef5ad | |||
| e116fb814a | |||
| 2f10f913c0 | |||
| 3a2dd84500 | |||
| 7d1872ef1e | |||
| 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 | |||
| 32efc28043 | |||
|
|
f164317b58 | ||
|
|
7a421e0619 | ||
|
|
9526092860 | ||
|
|
0c9362334c | ||
| 7d8a60f207 | |||
| aac9fcf58b |
@@ -15,6 +15,13 @@ DB_DATABASE=laravel
|
|||||||
DB_USERNAME=root
|
DB_USERNAME=root
|
||||||
DB_PASSWORD=
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
OLDLMS_DB_CONNECTION=mysql
|
||||||
|
OLDLMS_DB_HOST=127.0.0.1
|
||||||
|
OLDLMS_DB_PORT=3306
|
||||||
|
OLDLMS_DB_DATABASE=linksehat
|
||||||
|
OLDLMS_DB_USERNAME=mysql
|
||||||
|
OLDLMS_DB_PASSWORD=password
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
FILESYSTEM_DISK=local
|
FILESYSTEM_DISK=local
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ class AuthController extends Controller
|
|||||||
if (filter_var($request->phoneOrEmail, FILTER_VALIDATE_EMAIL)) {
|
if (filter_var($request->phoneOrEmail, FILTER_VALIDATE_EMAIL)) {
|
||||||
User::query()->find($user->id)->update([
|
User::query()->find($user->id)->update([
|
||||||
'email' => $request->phoneOrEmail,
|
'email' => $request->phoneOrEmail,
|
||||||
'otp' => rand(1000, 9999),
|
'otp' => 4444, //rand(1000, 9999),
|
||||||
'otp_created_at' => now()
|
'otp_created_at' => now()
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
User::query()->find($user->id)->update([
|
User::query()->find($user->id)->update([
|
||||||
'phone' => $request->phoneOrEmail,
|
'phone' => $request->phoneOrEmail,
|
||||||
'otp' => rand(1000, 9999),
|
'otp' => 4444,//rand(1000, 9999),
|
||||||
'otp_created_at' => now()
|
'otp_created_at' => now()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,23 +9,19 @@ use Illuminate\Routing\Controller;
|
|||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
class DivisionController extends Controller
|
class CorporateDivisionController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
* @return Renderable
|
* @return Renderable
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request, $corporate_id)
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$division = CorporateDivision::query()
|
||||||
|
->where('corporate_id', $corporate_id)
|
||||||
$corporate = $user->managedCorporates()->where('active', 1)->first();
|
|
||||||
|
|
||||||
$benefits = CorporateDivision::query()
|
|
||||||
->where('corporate_id', $corporate->id)
|
|
||||||
->get(['id', 'name']);
|
->get(['id', 'name']);
|
||||||
|
|
||||||
return $benefits;
|
return response()->json($division);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7,7 +7,7 @@ use Illuminate\Http\Request;
|
|||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class CorporateController extends Controller
|
class CorporateManageController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
@@ -18,8 +18,6 @@ class CorporateController extends Controller
|
|||||||
$userLogin = Auth::user();
|
$userLogin = Auth::user();
|
||||||
$corporate = $userLogin->managedCorporates()->select(['corporates.id', 'corporates.name'])->get();
|
$corporate = $userLogin->managedCorporates()->select(['corporates.id', 'corporates.name'])->get();
|
||||||
|
|
||||||
// corporate policy, all member list, notification
|
|
||||||
|
|
||||||
return response()->json($corporate);
|
return response()->json($corporate);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ use Illuminate\Routing\Controller;
|
|||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Modules\Client\Transformers\DashboardResources;
|
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.
|
||||||
@@ -20,7 +20,7 @@ class DashboardController extends Controller
|
|||||||
$currentCorporate = $user->managedCorporates()
|
$currentCorporate = $user->managedCorporates()
|
||||||
->with(['currentPolicy', 'employees'])
|
->with(['currentPolicy', 'employees'])
|
||||||
->find($corporate_id);
|
->find($corporate_id);
|
||||||
|
|
||||||
$data = DashboardResources::make($currentCorporate);
|
$data = DashboardResources::make($currentCorporate);
|
||||||
|
|
||||||
return response()->json($data);
|
return response()->json($data);
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Modules\Client\Http\Controllers\Api\AuthController;
|
use Modules\Client\Http\Controllers\Api\AuthController;
|
||||||
use Modules\Client\Http\Controllers\Api\CorporateController;
|
use Modules\Client\Http\Controllers\Api\CorporateDivisionController;
|
||||||
use Modules\Client\Http\Controllers\Api\DashboardController;
|
use Modules\Client\Http\Controllers\Api\CorporateManageController;
|
||||||
use Modules\Client\Http\Controllers\Api\DivisionController;
|
use Modules\Client\Http\Controllers\Api\CorporateMemberController;
|
||||||
use Modules\Client\Http\Controllers\Api\MemberController;
|
use Modules\Client\Http\Controllers\Api\CorporatePolicyController;
|
||||||
use Modules\Client\Http\Controllers\Api\UserController;
|
use Modules\Client\Http\Controllers\Api\UserController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -26,21 +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::prefix('{corporate_id}')->group(function() {
|
Route::get('corporate-manage', [CorporateManageController::class, 'index']);
|
||||||
Route::get('asd', function ($corporate_id) {
|
Route::prefix('{corporate_id}')->group(function () {
|
||||||
return $corporate_id;
|
Route::get('policy', [CorporatePolicyController::class, 'index']);
|
||||||
|
Route::get('division', [CorporateDivisionController::class, 'index']);
|
||||||
|
Route::get('members', [CorporateMemberController::class, 'index']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::get('dashboard', [DashboardController::class, 'index']);
|
|
||||||
Route::get('corporate', [CorporateController::class, 'index']);
|
|
||||||
Route::get('corporate/{corporate_id}', [CorporateController::class, 'show']);
|
|
||||||
Route::get('division', [DivisionController::class, 'index']);
|
|
||||||
Route::get('members', [MemberController::class, 'index']);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class DashboardResources extends JsonResource
|
|||||||
'myLimit' => [
|
'myLimit' => [
|
||||||
'balance' => $myLimitBalance,
|
'balance' => $myLimitBalance,
|
||||||
'total' => $myLimitTotal,
|
'total' => $myLimitTotal,
|
||||||
'percentage' => ($myLimitBalance / $myLimitTotal) * 100,
|
'percentage' => $myLimitTotal ? (($myLimitBalance / $myLimitTotal) * 100) : 0,
|
||||||
],
|
],
|
||||||
'lockLimit' => [
|
'lockLimit' => [
|
||||||
'balance' => $lockBalance,
|
'balance' => $lockBalance,
|
||||||
|
|||||||
@@ -15,11 +15,18 @@ class MemberResources extends JsonResource
|
|||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
'memberId' => $this->member_id,
|
'memberId' => $this->member_id,
|
||||||
'full_name' => $this->full_name,
|
'fullName' => $this->full_name,
|
||||||
'division' => $this->division->name,
|
$this->mergeWhen($request->input('claimMember') === 'false', [
|
||||||
'employeeLimit' => '',
|
'division' => $this->division->name ?? '',
|
||||||
'status' => $this->active
|
'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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\OLDLMS\Appointment;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\AppointmentResource;
|
||||||
|
|
||||||
|
class AppointmentController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$appointments = Appointment::query()
|
||||||
|
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare', 'user', 'user.detail')
|
||||||
|
->latest()
|
||||||
|
->paginate(15);
|
||||||
|
return response()->json(Helper::paginateResources(AppointmentResource::collection($appointments)));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$appointments = Appointment::query()
|
||||||
|
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare')
|
||||||
|
->where('nID', $id)
|
||||||
|
->first();
|
||||||
|
return response()->json(new AppointmentResource($appointments));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,12 +19,13 @@ 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
|
|
||||||
}
|
|
||||||
$reader->close();
|
|
||||||
Storage::delete('temp/'.$file_name);
|
|
||||||
// throw(404);
|
|
||||||
|
|
||||||
return [
|
// break; //only read first sheet
|
||||||
'total_successed_row' => $imported_benefit_data,
|
// }
|
||||||
'total_failed_row' => count($failed_benefit_data),
|
// $reader->close();
|
||||||
'failed_row' => $failed_benefit_data
|
// Storage::delete('temp/'.$file_name);
|
||||||
];
|
// // throw(404);
|
||||||
|
|
||||||
|
// return [
|
||||||
|
// 'total_successed_row' => $imported_benefit_data,
|
||||||
|
// 'total_failed_row' => count($failed_benefit_data),
|
||||||
|
// 'failed_row' => $failed_benefit_data
|
||||||
|
// ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
37
Modules/Client/Http/Controllers/Api/MemberController.php → Modules/Internal/Http/Controllers/Api/CityController.php
Executable file → Normal file
37
Modules/Client/Http/Controllers/Api/MemberController.php → Modules/Internal/Http/Controllers/Api/CityController.php
Executable file → Normal file
@@ -1,14 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Client\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Models\City;
|
||||||
use App\Models\Member;
|
|
||||||
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;
|
||||||
|
|
||||||
class MemberController extends Controller
|
class CityController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Display a listing of the resource.
|
* Display a listing of the resource.
|
||||||
@@ -16,27 +15,13 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$city = City::where('province_id', $request->province_id)->orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
$corporate = $user->managedCorporates()->first();
|
if (!$city) {
|
||||||
// $plans =
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
$members = Member::query()
|
return response(['message' => 'Data ditemukan', 'data' => $city]);
|
||||||
->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 +30,7 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('client::create');
|
return view('internal::create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +50,7 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('client::show');
|
return view('internal::show');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +60,7 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
return view('client::edit');
|
return view('internal::edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -6,10 +6,10 @@ use App\Models\Benefit;
|
|||||||
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 App\Services\ClaimService;
|
||||||
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\Services\ClaimService;
|
|
||||||
|
|
||||||
class ClaimController extends Controller
|
class ClaimController extends Controller
|
||||||
{
|
{
|
||||||
@@ -65,7 +65,7 @@ class ClaimController extends Controller
|
|||||||
|
|
||||||
// Store Claim
|
// Store Claim
|
||||||
if ($validation['isEligible']) {
|
if ($validation['isEligible']) {
|
||||||
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit);
|
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit, 'requested');
|
||||||
} else {
|
} else {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => $validation,
|
'data' => $validation,
|
||||||
@@ -83,7 +83,17 @@ class ClaimController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('internal::show');
|
$claim = Claim::query()
|
||||||
|
->with([
|
||||||
|
'member',
|
||||||
|
'member.currentPlan',
|
||||||
|
'diagnosis',
|
||||||
|
'benefit',
|
||||||
|
'files'
|
||||||
|
])
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
return response()->json($claim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -3,10 +3,15 @@
|
|||||||
namespace Modules\Internal\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
|
use App\Helpers\Helper;
|
||||||
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 +19,9 @@ 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\File as FacadesFile;
|
||||||
|
use Illuminate\Support\Facades\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Modules\Internal\Services\CorporateService;
|
use Modules\Internal\Services\CorporateService;
|
||||||
|
|
||||||
@@ -34,6 +42,9 @@ class CorporateController extends Controller
|
|||||||
->withCount([
|
->withCount([
|
||||||
'employees',
|
'employees',
|
||||||
'corporateBenefits',
|
'corporateBenefits',
|
||||||
|
'corporatePlans',
|
||||||
|
|
||||||
|
// 'claims'
|
||||||
])
|
])
|
||||||
->where('type', 'corporate')
|
->where('type', 'corporate')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
@@ -67,7 +78,7 @@ class CorporateController extends Controller
|
|||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'code' => 'required',
|
'code' => 'required|regex:/^[a-zA-Z0-9]+$/',
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
// 'logo' => 'required',
|
// 'logo' => 'required',
|
||||||
'policy_code' => 'required_with:policy_id',
|
'policy_code' => 'required_with:policy_id',
|
||||||
@@ -103,6 +114,135 @@ 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',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 6,
|
||||||
|
'name' => 'Medical Check Up',
|
||||||
|
'code' => 'MCU',
|
||||||
|
'description' => 'Medical Check Up',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
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();
|
||||||
@@ -119,7 +259,25 @@ class CorporateController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('internal::show');
|
$corporate = Corporate::query()
|
||||||
|
->with(['currentPolicy', 'plans'])
|
||||||
|
->withCount('corporatePlans')
|
||||||
|
->withCount('employees')
|
||||||
|
// ->withCount('employees.claims')
|
||||||
|
->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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,7 +301,7 @@ class CorporateController extends Controller
|
|||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'code' => 'required',
|
'code' => 'required|regex:/^[a-zA-Z0-9]+$/',
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'policy_code' => 'required_with:policy_id',
|
'policy_code' => 'required_with:policy_id',
|
||||||
'policy_total_premi' => 'required_with:policy_code',
|
'policy_total_premi' => 'required_with:policy_code',
|
||||||
@@ -157,9 +315,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(
|
||||||
@@ -179,6 +341,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();
|
||||||
@@ -225,7 +400,7 @@ class CorporateController extends Controller
|
|||||||
// 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));
|
||||||
@@ -246,7 +421,7 @@ class CorporateController extends Controller
|
|||||||
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
|
||||||
@@ -319,4 +494,31 @@ class CorporateController extends Controller
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function importDocumentExample($document_type)
|
||||||
|
{
|
||||||
|
switch ($document_type) {
|
||||||
|
case 'plan-benefit':
|
||||||
|
return Helper::responseJson([
|
||||||
|
'file_name' => "Corporate Plan & Benefit Import.xlsx",
|
||||||
|
"file_url" => url('files/Corporate Plan & Benefit Import.xlsx')
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'member':
|
||||||
|
return Helper::responseJson([
|
||||||
|
'file_name' => "Corporate Membership Import.xlsx",
|
||||||
|
"file_url" => url('files/Corporate Membership Import.xlsx')
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
case 'diagnosis-exclusion':
|
||||||
|
return Helper::responseJson([
|
||||||
|
'file_name' => "Corporate Exclusion Import.xlsx",
|
||||||
|
"file_url" => url('files/Corporate Exclusion Import.xlsx')
|
||||||
|
]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Helper::responseJson([], 'error', 404);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,20 @@
|
|||||||
namespace Modules\Internal\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Exceptions\ImportRowException;
|
use App\Exceptions\ImportRowException;
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Http\Resources\MemberDataTableResource;
|
||||||
use App\Models\Corporate;
|
use App\Models\Corporate;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
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;
|
||||||
|
use Carbon\Carbon;
|
||||||
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\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Modules\Internal\Services\MemberEnrollmentService;
|
use Modules\Internal\Services\MemberEnrollmentService;
|
||||||
|
use PDF;
|
||||||
|
|
||||||
class CorporateMemberController extends Controller
|
class CorporateMemberController extends Controller
|
||||||
{
|
{
|
||||||
@@ -35,15 +39,37 @@ class CorporateMemberController extends Controller
|
|||||||
->with([
|
->with([
|
||||||
'employeds',
|
'employeds',
|
||||||
'currentPolicy',
|
'currentPolicy',
|
||||||
// 'claims' => function ($claim) {
|
// 'claims',
|
||||||
// return $claim->used();
|
'claims' => function ($claim) {
|
||||||
// }
|
// return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
|
||||||
|
// return $claim->used(now()->startOfYear(), now()->endOfYear());
|
||||||
|
},
|
||||||
|
'currentPlan',
|
||||||
|
'currentPlan.benefits'
|
||||||
])
|
])
|
||||||
->with('currentPlan')
|
|
||||||
->paginate()
|
->paginate()
|
||||||
->appends($request->all());
|
->appends($request->all());
|
||||||
|
|
||||||
return $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'
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,9 +194,12 @@ class CorporateMemberController extends Controller
|
|||||||
'ingestion_code' => $e->getCode(),
|
'ingestion_code' => $e->getCode(),
|
||||||
'ingestion_status' => $e->getMessage(),
|
'ingestion_status' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
$singleRow = WriterEntityFactory::createRow($this->memberEnrollmentService->makeResultRowWithResultFormat($new_member_data));
|
// try {
|
||||||
$writer->addRow($singleRow);
|
$singleRow = WriterEntityFactory::createRow($this->memberEnrollmentService->makeResultRowWithResultFormat($new_member_data));
|
||||||
$failed_member_data[] = ['row_number' => $index, 'error' => $e->getMessage()];
|
$writer->addRow($singleRow);
|
||||||
|
// } catch (\Exception $e) {
|
||||||
|
$failed_member_data[] = ['row_number' => $index, 'error' => $e->getMessage(), 'data' => $new_member_data];
|
||||||
|
// }
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Write Server Error to File
|
// Write Server Error to File
|
||||||
$new_member_data = array_merge($new_member_data, [
|
$new_member_data = array_merge($new_member_data, [
|
||||||
@@ -201,4 +230,25 @@ class CorporateMemberController extends Controller
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function generateLog(Request $request, $member_id)
|
||||||
|
{
|
||||||
|
$member = Member::findOrFail($member_id)
|
||||||
|
->load([
|
||||||
|
'currentPlan',
|
||||||
|
'currentPolicy',
|
||||||
|
'currentPlan.corporateBenefits' => function ($benefit) use ($request) {
|
||||||
|
return $benefit->when($request->benefit_ids, function ($q, $ids) {
|
||||||
|
return $q->whereIn('id', $ids);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'currentPlan.corporateBenefits.benefit']);
|
||||||
|
|
||||||
|
$dateOfAdmission = $request->date_of_admission ? Carbon::parse($request->date_of_admission) : now();
|
||||||
|
|
||||||
|
// return view('pdf.guaranted_leter', compact('member'));
|
||||||
|
$pdf = PDF::loadView('pdf.guaranted_leter', compact(['member', 'dateOfAdmission']));
|
||||||
|
return $pdf->download('Guaranted Letter - '.$member->full_name.'.pdf');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,19 +99,32 @@ 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();
|
||||||
|
|
||||||
return response()->json(
|
return response()->json(
|
||||||
[
|
[
|
||||||
'corporate' => $corporate,
|
'corporate' => $corporate,
|
||||||
@@ -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,10 +109,10 @@ 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);
|
||||||
|
|
||||||
// $importLog = $corporate->importLogs()->create([
|
// $importLog = $corporate->importLogs()->create([
|
||||||
// 'type' => 'diagnosis-exclusions',
|
// 'type' => 'diagnosis-exclusions',
|
||||||
// 'file_path' => $file,
|
// 'file_path' => $file,
|
||||||
@@ -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;
|
||||||
@@ -148,12 +157,12 @@ class DiagnosisExclusionController extends Controller
|
|||||||
9 => 'keterangan',
|
9 => 'keterangan',
|
||||||
10 => 'maternity_waiting'
|
10 => 'maternity_waiting'
|
||||||
];
|
];
|
||||||
|
|
||||||
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
85
Modules/Internal/Http/Controllers/Api/DistrictController.php
Normal file
85
Modules/Internal/Http/Controllers/Api/DistrictController.php
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\District;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class DistrictController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$district = District::where('city_id', $request->city_id)->orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if (!$district) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $district]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
244
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
244
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\Person;
|
||||||
|
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 = 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->id ?? null, function ($query, $id) {
|
||||||
|
$query->where('id', $id);
|
||||||
|
})
|
||||||
|
->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)
|
||||||
|
{
|
||||||
|
$data_person = [
|
||||||
|
'name' => $request->name,
|
||||||
|
'gender' => $request->gender,
|
||||||
|
'address' => $request->address,
|
||||||
|
'phone' => $request->phone,
|
||||||
|
'email' => $request->email,
|
||||||
|
'birth_date' => date('Y-m-d', strtotime($request->birth_date)),
|
||||||
|
'birth_place' => $request->birth_place,
|
||||||
|
];
|
||||||
|
|
||||||
|
$person = Person::create($data_person);
|
||||||
|
$address = $person->addresses()->create([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$person->main_address_id = $address->id;
|
||||||
|
$person->save();
|
||||||
|
|
||||||
|
$practitioner = $person->practitioner()->create();
|
||||||
|
|
||||||
|
$practices = $request->practices;
|
||||||
|
if ($practices[0]['organization_id'] !== null) {
|
||||||
|
foreach ($practices as $key => $practice) {
|
||||||
|
if (isset($practice['specialities'])) {
|
||||||
|
//jika input spesialis
|
||||||
|
foreach ($practice['specialities'] as $key => $speciality) {
|
||||||
|
$speciality_id = $speciality['speciality_id'];
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->create([
|
||||||
|
'organization_id' => $organization_id,
|
||||||
|
'speciality_id' => $speciality_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//jika tidak input spesialis
|
||||||
|
$speciality_id = null;
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->create([
|
||||||
|
'organization_id' => $organization_id,
|
||||||
|
'speciality_id' => $speciality_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
|
||||||
|
return response()->json(DoctorResource::make($practitioner));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
|
||||||
|
return response()->json(DoctorResource::make($practitioner));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$practitioner = Practitioner::find($id);
|
||||||
|
$data_person = [
|
||||||
|
'name' => $request->name,
|
||||||
|
'gender' => $request->gender,
|
||||||
|
'address' => $request->address,
|
||||||
|
'phone' => $request->phone,
|
||||||
|
'email' => $request->email,
|
||||||
|
'birth_date' => date('Y-m-d', strtotime($request->birth_date)),
|
||||||
|
'birth_place' => $request->birth_place,
|
||||||
|
];
|
||||||
|
|
||||||
|
$person = $practitioner->person;
|
||||||
|
$person->update($data_person);
|
||||||
|
$address = $practitioner->person->addresses()->updateOrCreate([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
]);
|
||||||
|
$practitioner->person->main_address_id = $address->id;
|
||||||
|
$practitioner->person->save();
|
||||||
|
|
||||||
|
$practices = $request->practices;
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->get() ?? null;
|
||||||
|
|
||||||
|
foreach ($practices as $practice) {
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
foreach ($practice['specialities'] as $speciality) {
|
||||||
|
$speciality_id = $speciality['speciality_id'];
|
||||||
|
$cek = $practitionerRole->where('organization_id', $organization_id)
|
||||||
|
->where('speciality_id', $speciality_id)->first() ?? null;
|
||||||
|
if (!$cek || $practitionerRole->isEmpty()) {
|
||||||
|
// Create new practitioner role if not found
|
||||||
|
$practitioner->practitionerRoles()->create([
|
||||||
|
'organization_id' => $organization_id,
|
||||||
|
'speciality_id' => $speciality_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($practitionerRole) {
|
||||||
|
// Remove practitioner roles that are no longer exists
|
||||||
|
$currentRoleIds = $practitionerRole->pluck('id')->toArray();
|
||||||
|
$newRoleIds = [];
|
||||||
|
|
||||||
|
foreach ($practices as $practice) {
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
foreach ($practice['specialities'] as $speciality) {
|
||||||
|
$speciality_id = $speciality['speciality_id'];
|
||||||
|
$newPractitionerRole = $practitionerRole->where('organization_id', $organization_id)
|
||||||
|
->where('speciality_id', $speciality_id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($newPractitionerRole) {
|
||||||
|
$newRoleIds[] = $newPractitionerRole->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$deletedRoleIds = array_diff($currentRoleIds, $newRoleIds);
|
||||||
|
|
||||||
|
if (count($deletedRoleIds) > 0) {
|
||||||
|
// Delete practitioner roles that are no longer exists
|
||||||
|
$data = $practitionerRole->whereIn('id', $deletedRoleIds);
|
||||||
|
$data->each(function ($item) {
|
||||||
|
$item->delete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$practitioner = Practitioner::find($id);
|
||||||
|
$person = $practitioner->person->delete();
|
||||||
|
$address = $practitioner->person->addresses()->delete();
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->delete();
|
||||||
|
$practitioner->delete();
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data berhasil dihapus',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
90
Modules/Internal/Http/Controllers/Api/LivechatController.php
Normal file
90
Modules/Internal/Http/Controllers/Api/LivechatController.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\OLDLMS\Livechat;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\LivechatResource;
|
||||||
|
|
||||||
|
class LivechatController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||||
|
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||||
|
->latest()
|
||||||
|
->paginate(15);
|
||||||
|
|
||||||
|
return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||||
|
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||||
|
->where('nID', $id)
|
||||||
|
->first();
|
||||||
|
return response()->json(new LivechatResource($livechat));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
175
Modules/Internal/Http/Controllers/Api/OrganizationController.php
Normal file
175
Modules/Internal/Http/Controllers/Api/OrganizationController.php
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\OrganizationResource;
|
||||||
|
|
||||||
|
class OrganizationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchOrganization(Request $request)
|
||||||
|
{
|
||||||
|
$organizations = Organization::hospital()->get();
|
||||||
|
return response()->json(OrganizationResource::collection($organizations));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$organization = [
|
||||||
|
'code' => $request->code,
|
||||||
|
'name' => $request->name,
|
||||||
|
'type' => 'hospital',
|
||||||
|
'status' => $request->active == 1 ? 'active' : 'inactive',
|
||||||
|
'description' => $request->description,
|
||||||
|
];
|
||||||
|
|
||||||
|
$create_organization = Organization::create($organization);
|
||||||
|
|
||||||
|
if ($request->phone != null) {
|
||||||
|
$create_organization->metas()->create([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'phone',
|
||||||
|
'value' => $request->phone,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$address = $create_organization->addresses()->create([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
'province_id' => $request->province_id,
|
||||||
|
'city_id' => $request->city_id,
|
||||||
|
'district_id' => $request->district_id,
|
||||||
|
'village_id' => $request->village_id,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lng' => $request->lng,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$create_organization->main_address_id = $address->id;
|
||||||
|
$create_organization->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
'data' => new OrganizationResource($create_organization)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return response()->json(OrganizationResource::make(Organization::find($id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return response()->json(OrganizationResource::make(Organization::find($id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$update_organization = Organization::find($id);
|
||||||
|
|
||||||
|
$update_organization->update([
|
||||||
|
'code' => $request->code,
|
||||||
|
'name' => $request->name,
|
||||||
|
'type' => 'hospital',
|
||||||
|
'status' => $request->active == 1 ? 'active' : 'inactive',
|
||||||
|
'description' => $request->description,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->phone != null) {
|
||||||
|
$update_organization->metas()->updateOrCreate([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'phone',
|
||||||
|
], [
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'phone',
|
||||||
|
'value' => $request->phone,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$update_organization->addresses()->updateOrCreate([
|
||||||
|
'id' => $update_organization->main_address_id
|
||||||
|
], [
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
'province_id' => $request->province_id,
|
||||||
|
'city_id' => $request->city_id,
|
||||||
|
'district_id' => $request->district_id,
|
||||||
|
'village_id' => $request->village_id,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lng' => $request->lng,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Data berhasil diubah',
|
||||||
|
'data' => new OrganizationResource($update_organization)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$delete_organization = Organization::find($id);
|
||||||
|
$delete_organization->addresses()->delete();
|
||||||
|
$delete_organization->delete();
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Data berhasil dihapus',
|
||||||
|
'data' => new OrganizationResource($delete_organization)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,16 +28,16 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,14 +105,14 @@ 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;
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ class PlanController extends Controller
|
|||||||
// Create Directly
|
// Create Directly
|
||||||
try {
|
try {
|
||||||
$rowResponse = $this->corporateService->handlePlanRow($corporate, $plan_row);
|
$rowResponse = $this->corporateService->handlePlanRow($corporate, $plan_row);
|
||||||
|
|
||||||
// Write Success Result to File
|
// Write Success Result to File
|
||||||
array_push($plan_row, 'SUCCESS');
|
array_push($plan_row, 'SUCCESS');
|
||||||
$import->addArrayToRow($plan_row);
|
$import->addArrayToRow($plan_row);
|
||||||
@@ -160,11 +160,11 @@ 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,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
86
Modules/Internal/Http/Controllers/Api/ProvinceController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/ProvinceController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Province;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class ProvinceController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$province = Province::orderBy('name', 'ASC')->get();
|
||||||
|
|
||||||
|
if (empty($province)) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $province]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
86
Modules/Internal/Http/Controllers/Api/VillageController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/VillageController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Village;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class VillageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$villages = Village::where('district_id', $request->district_id)->orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if (!$villages) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $villages]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
use App\Http\Controllers\Api\MemberController as ApiMemberController;
|
use App\Http\Controllers\Api\MemberController as ApiMemberController;
|
||||||
use Modules\Internal\Http\Controllers\Api\AuthController;
|
use Modules\Internal\Http\Controllers\Api\AuthController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\AppointmentController;
|
||||||
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\CityController;
|
||||||
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
||||||
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
|
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
|
||||||
use Modules\Internal\Http\Controllers\Api\CorporateController;
|
use Modules\Internal\Http\Controllers\Api\CorporateController;
|
||||||
@@ -13,11 +15,18 @@ use Modules\Internal\Http\Controllers\Api\CorporatePlanController;
|
|||||||
use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
|
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\DistrictController;
|
||||||
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\LivechatController;
|
||||||
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\ProvinceController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\SpecialityController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\VillageController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -36,16 +45,19 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::post('login', [AuthController::class, 'login'])->name('login');
|
Route::post('login', [AuthController::class, 'login'])->name('login');
|
||||||
Route::post('forget-password', [AuthController::class, 'forgetPassword'])->name('forget-password');
|
Route::post('forget-password', [AuthController::class, 'forgetPassword'])->name('forget-password');
|
||||||
Route::post('verify-email', [AuthController::class, 'verifyEmail'])->name('verify-email');
|
Route::post('verify-email', [AuthController::class, 'verifyEmail'])->name('verify-email');
|
||||||
|
|
||||||
|
|
||||||
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', 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::get('corporates/import-document-example/{document_type}', [CorporateController::class, 'importDocumentExample']);
|
||||||
Route::put('corporates/{corporate_id}/activation', [CorporateController::class, 'activation']);
|
Route::put('corporates/{corporate_id}/activation', [CorporateController::class, 'activation']);
|
||||||
Route::post('corporates/{corporate_id}/import-plan-benefit', [CorporateController::class, 'importPlanBenefit']);
|
Route::post('corporates/{corporate_id}/import-plan-benefit', [CorporateController::class, 'importPlanBenefit']);
|
||||||
|
|
||||||
@@ -53,14 +65,16 @@ 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']);
|
||||||
|
|
||||||
Route::get('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'index']);
|
Route::get('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'index']);
|
||||||
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 +86,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 +99,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']);
|
||||||
@@ -97,12 +116,28 @@ Route::prefix('internal')->group(function () {
|
|||||||
|
|
||||||
Route::get('members', [MemberController::class, 'index']);
|
Route::get('members', [MemberController::class, 'index']);
|
||||||
Route::get('members/{member_id}/benefits', [MemberController::class, 'benefits']);
|
Route::get('members/{member_id}/benefits', [MemberController::class, 'benefits']);
|
||||||
|
|
||||||
Route::get('claims', [ClaimController::class, 'index']);
|
Route::get('claims', [ClaimController::class, 'index']);
|
||||||
Route::post('claims', [ClaimController::class, 'store']);
|
Route::post('claims', [ClaimController::class, 'store']);
|
||||||
|
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('appointments', AppointmentController::class);
|
||||||
|
Route::resource('live-chat', LivechatController::class);
|
||||||
|
|
||||||
|
Route::resource('doctors', DoctorController::class);
|
||||||
|
|
||||||
|
Route::post('generate-log/{member_id}', [CorporateMemberController::class, 'generateLog']);
|
||||||
|
|
||||||
|
Route::get('claim-requests', [ClaimRequestController::class, 'index'])->name('claim-requests.index');
|
||||||
|
Route::post('claim-requests/{id}/approve', [ClaimRequestController::class, 'approve'])->name('claim-requests.approve');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
|
Route::get('province', [ProvinceController::class, 'index']);
|
||||||
|
Route::get('city', [CityController::class, 'index']);
|
||||||
|
Route::get('district', [DistrictController::class, 'index']);
|
||||||
|
Route::get('village', [VillageController::class, 'index']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Modules\Internal\Http\Controllers\Api\CorporateMemberController;
|
||||||
|
|
||||||
Route::prefix('internal')->group(function() {
|
Route::prefix('internal')->group(function() {
|
||||||
Route::get('/', 'InternalController@index');
|
Route::get('/', 'InternalController@index');
|
||||||
});
|
});
|
||||||
@@ -7,109 +7,5 @@ use Illuminate\Support\Facades\DB;
|
|||||||
|
|
||||||
class ClaimService
|
class ClaimService
|
||||||
{
|
{
|
||||||
public static function checkMemberEligibility($member, $benefit, $diagnosis, $totalClaim = 0)
|
|
||||||
{
|
|
||||||
$currentPlan = $member->currentPlan;
|
|
||||||
$policy = $member->currentPolicy;
|
|
||||||
$corporate = $policy->corporate;
|
|
||||||
|
|
||||||
|
|
||||||
$isEligible = true;
|
|
||||||
$validationErrors = [];
|
|
||||||
|
|
||||||
// Eligibility Validation
|
|
||||||
|
|
||||||
if (!in_array($member->marital_status, explode(',', $benefit->msc))) {
|
|
||||||
$validationErrors[] = [
|
|
||||||
'error' => 'msc',
|
|
||||||
'message' => 'Only '.$benefit->msc
|
|
||||||
];
|
|
||||||
$isEligible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!in_array($member->gender_code, explode(',', $benefit->genders))) {
|
|
||||||
$validationErrors[] = [
|
|
||||||
'error' => 'genders',
|
|
||||||
'message' => 'Only '.$benefit->genders
|
|
||||||
];
|
|
||||||
$isEligible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($benefit->min_age) && $member->age < $benefit->min_age) {
|
|
||||||
$validationErrors[] = [
|
|
||||||
'error' => 'min_age',
|
|
||||||
'message' => 'Minimum Age is '.$benefit->min_age
|
|
||||||
];
|
|
||||||
$isEligible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($benefit->max_age) && $member->age > $benefit->max_age) {
|
|
||||||
$validationErrors[] = [
|
|
||||||
'error' => 'max_age',
|
|
||||||
'message' => 'Maximum Age is '.$benefit->min_age
|
|
||||||
];
|
|
||||||
$isEligible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO complete validations
|
|
||||||
|
|
||||||
// Limit Validation
|
|
||||||
if ($totalClaim > 0) {
|
|
||||||
if (bcsub($corporate->limit_balance, $totalClaim) < 0) {
|
|
||||||
$validationErrors[] = [
|
|
||||||
'error' => 'corporate_limit',
|
|
||||||
'message' => 'Corporate Limit cannot cover this'
|
|
||||||
];
|
|
||||||
$isEligible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bcsub($benefit->limit_amount, $totalClaim) < 0) {
|
|
||||||
$validationErrors[] = [
|
|
||||||
'error' => 'benefit_limit',
|
|
||||||
'message' => 'Benefit Limit cannot cover this'
|
|
||||||
];
|
|
||||||
$isEligible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO complete validations
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'isEligible' => $isEligible,
|
|
||||||
'errors' => $validationErrors
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
DB::beginTransaction();
|
|
||||||
|
|
||||||
$claim = Claim::create([
|
|
||||||
'member_id' => $member->id,
|
|
||||||
'diagnosis_id' => $diagnosis->id,
|
|
||||||
'total_claim' => $totalClaim,
|
|
||||||
'currency' => 'IDR',
|
|
||||||
'plan_id' => $member->currentPlan->id,
|
|
||||||
'benefit_id' => $benefit->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$policy = $member->currentPolicy;
|
|
||||||
$policy->limitJournals()->create([
|
|
||||||
'previous_balance' => $policy->limit_balance,
|
|
||||||
'total_credit' => $totalClaim,
|
|
||||||
'type' => 'credit',
|
|
||||||
'balance' => bcsub($policy->limit_balance, $totalClaim),
|
|
||||||
'description' => 'Log for Claim #'. $claim->code,
|
|
||||||
]);
|
|
||||||
|
|
||||||
DB::commit();
|
|
||||||
return $claim;
|
|
||||||
} catch (\Exception $error) {
|
|
||||||
DB::rollBack();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,11 +5,12 @@ 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;
|
||||||
|
|
||||||
class CorporateService
|
class CorporateService
|
||||||
{
|
{
|
||||||
protected function validatePlanRow($row)
|
protected function validatePlanRow($row)
|
||||||
{
|
{
|
||||||
if (empty($row['service_code'])) {
|
if (empty($row['service_code'])) {
|
||||||
@@ -41,10 +42,8 @@ class CorporateService
|
|||||||
|
|
||||||
$this->validatePlanRow($plan_data);
|
$this->validatePlanRow($plan_data);
|
||||||
|
|
||||||
$plan = Plan::updateOrCreate([
|
$plan = $corporate->plans()->updateOrCreate([
|
||||||
'service_code' => $plan_data['service_code'],
|
'service_code' => $plan_data['service_code'],
|
||||||
'corporate_id' => $corporate->id,
|
|
||||||
'code' => $plan_data['code'],
|
|
||||||
], $plan_data);
|
], $plan_data);
|
||||||
|
|
||||||
return $plan;
|
return $plan;
|
||||||
@@ -61,10 +60,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 +82,37 @@ 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 = $corporate->plans()
|
||||||
'plan_code' => $benefit_data['plan_code'],
|
->where('corporate_plan_id', $benefit_data['plan_code'])
|
||||||
'corporate_id' => $corporate->id,
|
->first();
|
||||||
|
|
||||||
|
// $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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ class ExclusionService
|
|||||||
'service_code' => 'OP',
|
'service_code' => 'OP',
|
||||||
'type' => 'diagnosis'
|
'type' => 'diagnosis'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
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
|
||||||
@@ -84,10 +91,10 @@ class ExclusionService
|
|||||||
'service_code' => 'OP',
|
'service_code' => 'OP',
|
||||||
'type' => 'diagnosis'
|
'type' => 'diagnosis'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
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
|
||||||
@@ -133,10 +147,10 @@ class ExclusionService
|
|||||||
'service_code' => 'OP',
|
'service_code' => 'OP',
|
||||||
'type' => 'diagnosis'
|
'type' => 'diagnosis'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
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,10 +10,12 @@ 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;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use DateTime;
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
class MemberEnrollmentService
|
class MemberEnrollmentService
|
||||||
@@ -44,6 +46,7 @@ class MemberEnrollmentService
|
|||||||
"The Right Classes Room of BPJS Participants" => "bpjs_class",
|
"The Right Classes Room of BPJS Participants" => "bpjs_class",
|
||||||
"Name of Faskes" => "faskes_name",
|
"Name of Faskes" => "faskes_name",
|
||||||
"Rule_BPJSK ('Y' or 'N')" => "bpjsk",
|
"Rule_BPJSK ('Y' or 'N')" => "bpjsk",
|
||||||
|
"Rule BPJSK" => "bpjsk",
|
||||||
"Agent Code / intermediary code" => "agent_code",
|
"Agent Code / intermediary code" => "agent_code",
|
||||||
"Member Name" => "name",
|
"Member Name" => "name",
|
||||||
"Address1" => "address1",
|
"Address1" => "address1",
|
||||||
@@ -122,7 +125,7 @@ class MemberEnrollmentService
|
|||||||
"faskes_fkrtl" => "Faskes FKRTL (Next Level Provider) or Individual group preferred provider",
|
"faskes_fkrtl" => "Faskes FKRTL (Next Level Provider) or Individual group preferred provider",
|
||||||
"bpjs_class" => "The Right Classes Room of BPJS Participants",
|
"bpjs_class" => "The Right Classes Room of BPJS Participants",
|
||||||
"faskes_name" => "Name of Faskes",
|
"faskes_name" => "Name of Faskes",
|
||||||
"bpjsk" => "Rule_BPJSK ('Y' or 'N')",
|
"bpjsk" => "Rule BPJSK",
|
||||||
"agent_code" => "Agent Code / intermediary code",
|
"agent_code" => "Agent Code / intermediary code",
|
||||||
"name" => "Member Name",
|
"name" => "Member Name",
|
||||||
"address1" => "Address1",
|
"address1" => "Address1",
|
||||||
@@ -194,8 +197,8 @@ class MemberEnrollmentService
|
|||||||
"Faskes FKRTL (Next Level Provider) or Individual group preferred provider",
|
"Faskes FKRTL (Next Level Provider) or Individual group preferred provider",
|
||||||
"The Right Classes Room of BPJS Participants",
|
"The Right Classes Room of BPJS Participants",
|
||||||
"Name of Faskes",
|
"Name of Faskes",
|
||||||
"Rule_BPJSK ('Y' or 'N')",
|
"Rule BPJSK",
|
||||||
"Agent Code / intermediary code",
|
"Internal Use",
|
||||||
"Member Name",
|
"Member Name",
|
||||||
"Address1",
|
"Address1",
|
||||||
"Address 1",
|
"Address 1",
|
||||||
@@ -246,6 +249,10 @@ class MemberEnrollmentService
|
|||||||
$this->member = $member;
|
$this->member = $member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dateParser($date_from_row) {
|
||||||
|
return is_string($date_from_row) ? Carbon::parse(strtotime($date_from_row)) : Carbon::parse($date_from_row);
|
||||||
|
}
|
||||||
|
|
||||||
protected function validateRow($row)
|
protected function validateRow($row)
|
||||||
{
|
{
|
||||||
if (empty($row['record_type'])) {
|
if (empty($row['record_type'])) {
|
||||||
@@ -359,10 +366,10 @@ class MemberEnrollmentService
|
|||||||
"member_id" => $row['member_id'] ?? null,
|
"member_id" => $row['member_id'] ?? null,
|
||||||
"payor_id" => $row['payor_id'] ?? null,
|
"payor_id" => $row['payor_id'] ?? null,
|
||||||
"nik" => $row['nik'] ?? null,
|
"nik" => $row['nik'] ?? null,
|
||||||
"birth_date" => Carbon::parse(strtotime($row['date_of_birth'])),
|
"birth_date" => $this->dateParser($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,
|
||||||
@@ -408,6 +415,20 @@ class MemberEnrollmentService
|
|||||||
|
|
||||||
// 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' => $this->dateParser($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']
|
||||||
@@ -439,16 +460,28 @@ 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' => $this->dateParser($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,
|
||||||
'policy_id' => $row['policy_number'],
|
'policy_id' => $row['policy_number'],
|
||||||
'start' => Carbon::parse(strtotime($row['member_effective_date'])),
|
'start' => $this->dateParser($row['member_effective_date']),
|
||||||
'end' => Carbon::parse(strtotime($row['member_expiry_date'])),
|
'end' => $this->dateParser($row['member_expiry_date']),
|
||||||
'status' => 'active'
|
'status' => 'active'
|
||||||
]);
|
]);
|
||||||
$memberPolicy->save();
|
$memberPolicy->save();
|
||||||
@@ -457,20 +490,10 @@ class MemberEnrollmentService
|
|||||||
$division_id = CorporateDivision::query()->where('code', $row['division_name'])->pluck('id')->first();
|
$division_id = CorporateDivision::query()->where('code', $row['division_name'])->pluck('id')->first();
|
||||||
|
|
||||||
if (empty($division_id)) {
|
if (empty($division_id)) {
|
||||||
$corporateCodeArray = explode(' ', $row['division_name']);
|
$division = CorporateDivision::query()->updateOrCreate(['name' => $row['division_name'], 'code' => $row['division_name']], [
|
||||||
|
|
||||||
if (!empty($corporateCodeArray[1])) {
|
|
||||||
$corporateCode = substr($corporateCodeArray[0], 0, 1) . substr($corporateCodeArray[1], 0, 1);
|
|
||||||
} elseif (!empty($corporateCodeArray[2])) {
|
|
||||||
$corporateCode = substr($corporateCodeArray[0], 0, 1) . substr($corporateCodeArray[1], 0, 1);
|
|
||||||
} else {
|
|
||||||
$corporateCode = substr($row['division_name'], 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$division = CorporateDivision::query()->create([
|
|
||||||
'corporate_id' => $corporate->id,
|
'corporate_id' => $corporate->id,
|
||||||
'name' => $row['division_name'],
|
'name' => $row['division_name'],
|
||||||
'code' => $corporateCode,
|
'code' => $row['division_name'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$division_id = $division->id;
|
$division_id = $division->id;
|
||||||
@@ -488,8 +511,8 @@ class MemberEnrollmentService
|
|||||||
$member->memberPlans()->create([
|
$member->memberPlans()->create([
|
||||||
'plan_id' => $plan->id,
|
'plan_id' => $plan->id,
|
||||||
'status' => 'active',
|
'status' => 'active',
|
||||||
'start' => Carbon::parse(strtotime($row['member_effective_date'])),
|
'start' => $this->dateParser($row['member_effective_date']),
|
||||||
'end' => Carbon::parse(strtotime($row['member_expiry_date'])),
|
'end' => $this->dateParser($row['member_expiry_date']),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
@@ -603,13 +626,13 @@ class MemberEnrollmentService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse(strtotime($row['member_expiry_date']))) {
|
if ($this->dateParser($row['member_effective_date']) > $this->dateParser($row['member_expiry_date'])) {
|
||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|
Carbon::parse($memberPolicy->end) > $this->dateParser($row['member_expiry_date'])
|
||||||
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
|
|| $memberPolicy->end > $this->dateParser($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);
|
||||||
}
|
}
|
||||||
@@ -646,13 +669,13 @@ class MemberEnrollmentService
|
|||||||
]), 0, null, $row);
|
]), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse(strtotime($row['member_expiry_date']))) {
|
if ($this->dateParser($row['member_effective_date']) > $this->dateParser($row['member_expiry_date'])) {
|
||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
Carbon::parse($memberPolicy->end) > Carbon::parse(strtotime($row['member_expiry_date']))
|
Carbon::parse($memberPolicy->end) > $this->dateParser($row['member_expiry_date'])
|
||||||
|| $memberPolicy->end > Carbon::parse(strtotime($row['member_expiry_date']))
|
|| $memberPolicy->end > $this->dateParser($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);
|
||||||
}
|
}
|
||||||
@@ -833,11 +856,11 @@ class MemberEnrollmentService
|
|||||||
]), 0, null, $row);
|
]), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::parse(strtotime($row['member_effective_date'])) < now() || Carbon::parse(strtotime($row['member_expiry_date'])) < now()) {
|
if ($this->dateParser($row['member_effective_date']) < now() || $this->dateParser($row['member_expiry_date']) < now()) {
|
||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_MUST_BE_AFTER_TODAY'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_MUST_BE_AFTER_TODAY'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse(strtotime($row['member_expiry_date']))) {
|
if ($this->dateParser($row['member_effective_date']) > $this->dateParser($row['member_expiry_date'])) {
|
||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -872,8 +895,8 @@ class MemberEnrollmentService
|
|||||||
$newMemberPolicy->fill([
|
$newMemberPolicy->fill([
|
||||||
'member_id' => $row['member_id'],
|
'member_id' => $row['member_id'],
|
||||||
'policy_id' => $row['policy_number'],
|
'policy_id' => $row['policy_number'],
|
||||||
'start' => Carbon::parse(strtotime($row['member_effective_date'])),
|
'start' => $this->dateParser($row['member_effective_date']),
|
||||||
'end' => Carbon::parse(strtotime($row['member_expiry_date'])),
|
'end' => $this->dateParser($row['member_expiry_date']),
|
||||||
'status' => 'active'
|
'status' => 'active'
|
||||||
]);
|
]);
|
||||||
$newMemberPolicy->save();
|
$newMemberPolicy->save();
|
||||||
@@ -914,7 +937,7 @@ class MemberEnrollmentService
|
|||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_NO_CHANGE'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_NO_CHANGE'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Carbon::parse(strtotime($row['member_effective_date'])) > Carbon::parse(strtotime($row['member_expiry_date']))) {
|
if ($this->dateParser($row['member_effective_date']) > $this->dateParser($row['member_expiry_date'])) {
|
||||||
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
throw new ImportRowException(__('enrollment.MEMBER_EXPIRY_DATE_INVALID'), 0, null, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -999,7 +1022,15 @@ class MemberEnrollmentService
|
|||||||
$cells = [];
|
$cells = [];
|
||||||
foreach ($this->result_doc_headers as $header) {
|
foreach ($this->result_doc_headers as $header) {
|
||||||
$value = $row_data[$this->doc_headers_to_field_map[$header]] ?? null;
|
$value = $row_data[$this->doc_headers_to_field_map[$header]] ?? null;
|
||||||
$cells[] = WriterEntityFactory::createCell($value);
|
if (is_string($value)) {
|
||||||
|
$cells[] = WriterEntityFactory::createCell($value);
|
||||||
|
}
|
||||||
|
else if ($value instanceof DateTime) {
|
||||||
|
$cells[] = WriterEntityFactory::createCell(Carbon::parse($value)->format('Ymd'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$cells[] = WriterEntityFactory::createCell(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cells;
|
return $cells;
|
||||||
|
|||||||
53
Modules/Internal/Transformers/AppointmentResource.php
Normal file
53
Modules/Internal/Transformers/AppointmentResource.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class AppointmentResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$appointment = [
|
||||||
|
'id' => $this->nID,
|
||||||
|
'patient_name' => $this->user ? $this->user->full_name : '',
|
||||||
|
'doctor_name' => $this->doctor ? $this->doctor->user?->full_name : '',
|
||||||
|
'speciality' => $this->doctor->speciality->sKeterangan,
|
||||||
|
'date_appointment' => Carbon::parse($this->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointmentDetail->tTimeAppointment,
|
||||||
|
'date_created' => Carbon::parse($this->dCreateOn)->format('d-m-Y H:i:s') ?? null,
|
||||||
|
'appointment_media' => $this->sMedia,
|
||||||
|
'status' => $this->status_name,
|
||||||
|
'health_care' => $this->healthCare->sHealthCare ?? null,
|
||||||
|
'payment_method' => $this->payment_method ?? null,
|
||||||
|
'patient' => $this->user,
|
||||||
|
'booking_code' => $this->sBookingCode,
|
||||||
|
'his_detail' => [
|
||||||
|
'RegID' => $this->sRegID,
|
||||||
|
'Medrec' => $this->sNomorRekamMedis
|
||||||
|
],
|
||||||
|
'type' => $this->type
|
||||||
|
];
|
||||||
|
|
||||||
|
$payment_detail = null;
|
||||||
|
if ($this->appointmentDetail->sPaymentDetails != null) {
|
||||||
|
$payment_detail = [
|
||||||
|
'payment_type' => $this->appointmentDetail->sPaymentDetails['payment_type'] ?? '',
|
||||||
|
'transaction_time' => $this->appointmentDetail->sPaymentDetails['transaction_time'] ?? '',
|
||||||
|
'gross_amount' => $this->appointmentDetail->sPaymentDetails['gross_amount'] ?? '',
|
||||||
|
'currency' => $this->appointmentDetail->sPaymentDetails['currency'] ?? '',
|
||||||
|
'status_message' => $this->appointmentDetail->sPaymentDetails['status_message'] ?? '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$appointment['payment_detail'] = $payment_detail;
|
||||||
|
|
||||||
|
return $appointment;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Modules/Internal/Transformers/ClaimResource.php
Normal file
22
Modules/Internal/Transformers/ClaimResource.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class ClaimResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$claimData = parent::toArray($request);
|
||||||
|
$claimData['uploaded_files'] = $this->files->groupBy('type');
|
||||||
|
|
||||||
|
return $claimData;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,15 +15,83 @@ 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,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
71
Modules/Internal/Transformers/DoctorResource.php
Normal file
71
Modules/Internal/Transformers/DoctorResource.php
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
use function PHPSTORM_META\map;
|
||||||
|
|
||||||
|
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 ?? null,
|
||||||
|
'email' => $this->person->email ?? null,
|
||||||
|
'birth_date' => $this->person->birth_date ?? null,
|
||||||
|
'birth_place' => $this->person->birth_place ?? null,
|
||||||
|
'gender' => $this->person->gender == "L" || $this->person->gender == "male" ? 'male' : 'female',
|
||||||
|
'address' => $this->person->currentAddress->text ?? null,
|
||||||
|
'organizations' => $this->practitionerRoles->unique('organization_id')->map(function ($practitionerRole) {
|
||||||
|
return [
|
||||||
|
'organization_id' => $practitionerRole->organization->id,
|
||||||
|
'organization_name' => $practitionerRole->organization->name,
|
||||||
|
];
|
||||||
|
})->values(),
|
||||||
|
"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 ?? null,
|
||||||
|
// ];
|
||||||
|
// }) ?? null,
|
||||||
|
'education' => $this->meta->education ?? null,
|
||||||
|
'experience' => $this->meta->work_experience ?? null,
|
||||||
|
'award' => $this->meta->award ?? null,
|
||||||
|
'keilmuan' => $this->meta->Keilmuan ?? null,
|
||||||
|
'tipe_dokter' => $this->meta->tipeDokter ?? null,
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$grouped = $this->collection($this->practitionerRoles)->groupBy('organization_id');
|
||||||
|
$grouped->transform(function ($items, $key) {
|
||||||
|
return [
|
||||||
|
'organization_id' => $key,
|
||||||
|
'specialities' => $items->map(function ($item) {
|
||||||
|
return [
|
||||||
|
'speciality_id' => $item->speciality->id,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$doctor['practices'] = $grouped->toArray();
|
||||||
|
|
||||||
|
return $doctor;
|
||||||
|
}
|
||||||
|
}
|
||||||
62
Modules/Internal/Transformers/LivechatResource.php
Normal file
62
Modules/Internal/Transformers/LivechatResource.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class LivechatResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$livechat = [
|
||||||
|
'id' => $this->nID,
|
||||||
|
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
|
||||||
|
'speciality' => $this->doctor->speciality->sKeterangan ?? null,
|
||||||
|
'health_care' => $this->healthCare->sHealthCare ?? null,
|
||||||
|
'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y')
|
||||||
|
. ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null,
|
||||||
|
'status_appointment' => $this->appointment->status_name ?? null,
|
||||||
|
'date_created' => Carbon::parse($this->appointment->dCreateOn)->format('d-m-Y H:i:s') ?? null,
|
||||||
|
'patient_media' => $this->sMedia ?? null,
|
||||||
|
'doctor_media' => $this->sMediaDokter ?? null,
|
||||||
|
'appointment_media' => $this->appointment->sMedia ?? null,
|
||||||
|
'status_chat' => $this->status_name ?? null,
|
||||||
|
'payment_method' => $this->appointment->payment_method ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
|
$start_time = $this->dStartTime;
|
||||||
|
$end_time = $this->dEndTime;
|
||||||
|
$data_duration = 0 . ' jam ' . 0 . ' menit ' . 0 . ' detik';
|
||||||
|
if ($start_time != null && $end_time != null) {
|
||||||
|
$duration = Carbon::parse($start_time)->diffInMinutes(Carbon::parse($end_time));
|
||||||
|
$hours = floor($duration / 60);
|
||||||
|
$minutes = $duration % 60;
|
||||||
|
$seconds = ($duration - ($hours * 60) - $minutes) * 60;
|
||||||
|
|
||||||
|
$data_duration = $hours . ' jam ' . $minutes . ' menit ' . $seconds . ' detik';
|
||||||
|
}
|
||||||
|
|
||||||
|
$livechat['duration'] = $data_duration;
|
||||||
|
|
||||||
|
$payment_detail = null;
|
||||||
|
if ($this->appointment->appointmentDetail->sPaymentDetails != null) {
|
||||||
|
$payment_detail = [
|
||||||
|
'payment_type' => $this->appointment->appointmentDetail->sPaymentDetails['payment_type'],
|
||||||
|
'transaction_time' => $this->appointment->appointmentDetail->sPaymentDetails['transaction_time'],
|
||||||
|
'gross_amount' => $this->appointment->appointmentDetail->sPaymentDetails['gross_amount'],
|
||||||
|
'currency' => $this->appointment->appointmentDetail->sPaymentDetails['currency'],
|
||||||
|
'status_message' => $this->appointment->appointmentDetail->sPaymentDetails['status_message'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$livechat['payment_detail'] = $payment_detail;
|
||||||
|
return $livechat;
|
||||||
|
}
|
||||||
|
}
|
||||||
39
Modules/Internal/Transformers/OrganizationResource.php
Normal file
39
Modules/Internal/Transformers/OrganizationResource.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?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->text ?? null,
|
||||||
|
'province_id' => $this->currentAddress->province_id ?? null,
|
||||||
|
'city_id' => $this->currentAddress->city_id ?? null,
|
||||||
|
'district_id' => $this->currentAddress->district_id ?? null,
|
||||||
|
'village_id' => $this->currentAddress->village_id ?? null,
|
||||||
|
'postal_code' => $this->currentAddress->postal_code ?? null,
|
||||||
|
'active' => $this->status == 'active' ? 1 : 0,
|
||||||
|
];
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,10 +8,10 @@ use Throwable;
|
|||||||
class ImportRowException extends Exception
|
class ImportRowException extends Exception
|
||||||
{
|
{
|
||||||
protected $data = null;
|
protected $data = null;
|
||||||
|
|
||||||
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()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
88
app/Http/Controllers/Api/OLDLMS/ClaimController.php
Normal file
88
app/Http/Controllers/Api/OLDLMS/ClaimController.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?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\Models\Claim;
|
||||||
|
use App\Models\Speciality;
|
||||||
|
use App\Services\ClaimService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ClaimController extends Controller
|
||||||
|
{
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'member_id' => 'required',
|
||||||
|
'user_id' => 'required',
|
||||||
|
'type' => 'required|in:consultation,teleconsultation,medicine',
|
||||||
|
// 'speciality_code' => 'required',
|
||||||
|
'total_claim' => 'required',
|
||||||
|
'detail' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$currentSpeciality = Speciality::where('code', $request->speciality_code)->first();
|
||||||
|
|
||||||
|
$gpSpecialityName = config('aso.general_practitioner_speciality_name', 'Umum');
|
||||||
|
$isGp = $gpSpecialityName == ($currentSpeciality ? $currentSpeciality->name : false);
|
||||||
|
|
||||||
|
if ($request->type == 'medicine') {
|
||||||
|
$benefitCode = 'OPMEDI1';
|
||||||
|
} else if ($isGp) {
|
||||||
|
$benefitCode = 'OPCONS1';
|
||||||
|
} else {
|
||||||
|
$benefitCode = 'OPCONS2';
|
||||||
|
}
|
||||||
|
|
||||||
|
$member = Member::query()
|
||||||
|
->where('member_id', $request->member_id)
|
||||||
|
->with([
|
||||||
|
'currentPlan',
|
||||||
|
])
|
||||||
|
->firstOrFail();
|
||||||
|
$benefit = $member->currentPlan->benefits()->where('code', $benefitCode)->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'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$claim = Claim::where('code', $request->claim_code)->firstOrFail();
|
||||||
|
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
$claim->fill(['status' => 'postpone'])->update();
|
||||||
|
|
||||||
|
$icds = Icd::whereIn('code', $request['icd_codes'])->get();
|
||||||
|
$icds = $icds->map(function($icd) use ($claim) {
|
||||||
|
return [
|
||||||
|
'claim_id' => $claim->id,
|
||||||
|
'type' => 'primary',
|
||||||
|
'diagnosis_id' => $icd->id,
|
||||||
|
'note' => 'HIS Summary',
|
||||||
|
'description'=> ''
|
||||||
|
];
|
||||||
|
})->toArray();
|
||||||
|
|
||||||
|
return $claim->diagnoses()->insert($icds);
|
||||||
|
DB::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollback();
|
||||||
|
|
||||||
|
return Helper::responseJson($e, 500);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
172
app/Http/Controllers/Api/OLDLMS/MembershipController.php
Normal file
172
app/Http/Controllers/Api/OLDLMS/MembershipController.php
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
<?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,teleconsultation,medicine',
|
||||||
|
// 'speciality_code' => 'sometimes'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$member = Member::query()
|
||||||
|
->where('member_id', $request->member_id)
|
||||||
|
->with(['currentCorporate', 'currentPolicy', 'currentPlan', 'postponedClaims'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$corporateService = $member->currentCorporate->corporateServices()
|
||||||
|
->active()
|
||||||
|
->where('service_code', 'OP')
|
||||||
|
->with([
|
||||||
|
'configs',
|
||||||
|
'specialities' => function ($speciality) use ($request) {
|
||||||
|
$speciality->where('code', $request->speciality_code ?? null)
|
||||||
|
->wherePivot('active', 1);
|
||||||
|
}
|
||||||
|
])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$currentSpeciality = $corporateService->specialities->first();
|
||||||
|
|
||||||
|
if ($currentSpeciality) {
|
||||||
|
$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'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$corporateServiceSpeciality = $corporateService->corporateServiceSpecialities->first() ?? null;
|
||||||
|
|
||||||
|
$serviceSpecialityRules = $corporateServiceSpeciality->exclusions->first()->rules ?? collect([]);
|
||||||
|
$serviceSpecialityRules = $serviceSpecialityRules->mapWithKeys(function ($rule) {
|
||||||
|
return [$rule->name => $rule];
|
||||||
|
});
|
||||||
|
|
||||||
|
$configs = $corporateService->configs->mapWithKeys(function ($config) {
|
||||||
|
return [$config->name => $config];
|
||||||
|
});
|
||||||
|
|
||||||
|
$gpSpecialityName = config('aso.general_practitioner_speciality_name', 'Umum');
|
||||||
|
$isGp = $gpSpecialityName == ($currentSpeciality ? $currentSpeciality->name : false);
|
||||||
|
|
||||||
|
if ($request->type == 'medicine') {
|
||||||
|
$benefitCode = 'OPMEDI1';
|
||||||
|
} else if ($isGp) {
|
||||||
|
$benefitCode = 'OPCONS1';
|
||||||
|
} else {
|
||||||
|
$benefitCode = 'OPCONS2';
|
||||||
|
}
|
||||||
|
|
||||||
|
$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');
|
||||||
|
|
||||||
|
$coverage['medicine_benefit'] = false;
|
||||||
|
if ($benefitCode = 'OPMEDI1') {
|
||||||
|
$medicineBenefit = $member->currentPlan->benefits()->where('code', $benefitCode)->wherePivot('active', 1)->first();
|
||||||
|
$coverage['medicine_benefit'] = !empty($medicineBenefit);
|
||||||
|
}
|
||||||
|
$coverage['medicine_delivery_fee'] = (($configs['delivery_fee']['value'] ?? 1) == 1);
|
||||||
|
|
||||||
|
if ($currentSpeciality) {
|
||||||
|
$xCoverage['sp_consultation_benefit'] = (($configs['sp_internal_doctor_offline']['value'] ?? 1) == 1);
|
||||||
|
$xCoverage['sp_teleconsultation_benefit'] = (($configs['sp_internal_doctor_online']['value'] ?? 1) == 1);
|
||||||
|
$xCoverage['gp_consultation_benefit'] = (($configs['gp_internal_doctor_offline']['value'] ?? 1) == 1);
|
||||||
|
$xCoverage['gp_teleconsultation_benefit'] = (($configs['gp_internal_doctor_online']['value'] ?? 1) == 1);
|
||||||
|
$coverage['consultation_benefit'] = ($isGp)
|
||||||
|
? $xCoverage['gp_consultation_benefit']
|
||||||
|
: $xCoverage['sp_consultation_benefit'];
|
||||||
|
$coverage['teleconsultation_benefit'] = ($isGp)
|
||||||
|
? $xCoverage['gp_teleconsultation_benefit']
|
||||||
|
: $xCoverage['sp_teleconsultation_benefit'];
|
||||||
|
|
||||||
|
$xCoverage['sp_admin_fee'] = (($configs['specialist_practitioner_fee']['value'] ?? 1) == 1);
|
||||||
|
$xCoverage['gp_admin_fee'] = (($configs['general_practitioner_fee']['value'] ?? 1) == 1);
|
||||||
|
$coverage['admin_fee'] = ($isGp)
|
||||||
|
? $xCoverage['gp_admin_fee']
|
||||||
|
: $xCoverage['sp_admin_fee'];
|
||||||
|
} else {
|
||||||
|
// Not Supported
|
||||||
|
$coverage['consultation_benefit'] = false;
|
||||||
|
$coverage['teleconsultation_benefit'] = false;
|
||||||
|
$coverage['admin_fee'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$limits['coverage'] = $coverage;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,5 +64,6 @@ class Kernel extends HttpKernel
|
|||||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'linksehat.old.auth' => \App\Http\Middleware\LinksehatOldAuthMiddleware::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
28
app/Http/Middleware/LinksehatOldAuthMiddleware.php
Normal file
28
app/Http/Middleware/LinksehatOldAuthMiddleware.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class LinksehatOldAuthMiddleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if ($request->header('authorization') == 'Bearer LpMbGm0NQvFC3lUBiy1Ch3NzS0CIPSmanR12FcdP') {
|
||||||
|
Auth::loginUsingId(1);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return abort(401, "Unauthenticated");
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Http/Resources/MemberDataTableResource.php
Normal file
32
app/Http/Resources/MemberDataTableResource.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class MemberDataTableResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
$data = parent::toArray($request);
|
||||||
|
$data['claim_grouped_by_status'] = $this->claims->groupBy('status');
|
||||||
|
$data['total_claims'] = [
|
||||||
|
'draft' => count($data['claim_grouped_by_status']['draft'] ?? []),
|
||||||
|
'requested' => count($data['claim_grouped_by_status']['requested'] ?? []),
|
||||||
|
'received' => count($data['claim_grouped_by_status']['received'] ?? []),
|
||||||
|
'approved' => count($data['claim_grouped_by_status']['approved'] ?? []),
|
||||||
|
'paid' => count($data['claim_grouped_by_status']['paid'] ?? []),
|
||||||
|
'declined' => count($data['claim_grouped_by_status']['declined'] ?? [])
|
||||||
|
];
|
||||||
|
|
||||||
|
// $data = ['fuck' => 'you'];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,7 +27,17 @@ class Address extends Model
|
|||||||
'period_start',
|
'period_start',
|
||||||
'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,141 +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 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) {
|
||||||
@@ -159,13 +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([
|
||||||
|
// TODO corporate_benefits pivot
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,22 +2,31 @@
|
|||||||
|
|
||||||
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\Database\Eloquent\SoftDeletes;
|
||||||
|
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, SoftDeletes;
|
||||||
|
|
||||||
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',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $hidden = [
|
protected $hidden = [
|
||||||
@@ -34,6 +43,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'
|
||||||
];
|
];
|
||||||
@@ -49,6 +59,55 @@ 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()
|
||||||
|
{
|
||||||
|
return $this->morphMany(File::class, 'fileable');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function member()
|
public function member()
|
||||||
@@ -56,9 +115,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()
|
||||||
@@ -71,11 +140,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);
|
||||||
@@ -77,6 +105,8 @@ class Corporate extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function
|
||||||
|
|
||||||
public function importLogs()
|
public function importLogs()
|
||||||
{
|
{
|
||||||
return $this->morphMany(ImportLog::class, 'importable');
|
return $this->morphMany(ImportLog::class, 'importable');
|
||||||
@@ -92,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,225 @@ 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 scopeActive($query)
|
||||||
|
{
|
||||||
|
$query->where('active', 1);
|
||||||
|
}
|
||||||
|
|
||||||
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 . "%");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class CorporateManager extends Model
|
class CorporateManager extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
protected $table = 'corporate_manager';
|
protected $table = 'corporate_manager';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 . "%");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ class CorporatePolicy extends Model
|
|||||||
'end',
|
'end',
|
||||||
'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'])) {
|
||||||
|
|||||||
@@ -16,9 +16,23 @@ class CorporateServiceConfig extends Model
|
|||||||
'name',
|
'name',
|
||||||
'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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,15 @@ class Exclusion extends Model
|
|||||||
'exclusionable_id',
|
'exclusionable_id',
|
||||||
'exclusionable_type',
|
'exclusionable_type',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ class ExclusionRules extends Model
|
|||||||
'name',
|
'name',
|
||||||
'values',
|
'values',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function exclusion()
|
public function exclusion()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,15 @@ class LimitJournal extends Model
|
|||||||
'balance',
|
'balance',
|
||||||
'description',
|
'description',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function journalable()
|
public function journalable()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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');
|
||||||
@@ -99,17 +109,24 @@ class Member extends Model
|
|||||||
|
|
||||||
public function currentCorporate()
|
public function currentCorporate()
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
|
// return $this->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
|
||||||
// ->withPivot([
|
// // ->withPivot([
|
||||||
// 'branch_code',
|
// // 'branch_code',
|
||||||
// 'divison_id',
|
// // 'divison_id',
|
||||||
// 'nik',
|
// // 'nik',
|
||||||
// 'status',
|
// // 'status',
|
||||||
// 'start',
|
// // 'start',
|
||||||
// 'end'
|
// // 'end'
|
||||||
// ])
|
// // ])
|
||||||
->where('start', '<', now())
|
// ->where('start', '<', now())
|
||||||
->where('end', '>', now());
|
// ->where('end', '>', now());
|
||||||
|
|
||||||
|
|
||||||
|
return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id');
|
||||||
|
// ->where('corporate_policies.start', '<', now())
|
||||||
|
// ->where('corporate_policies.end', '>', now())
|
||||||
|
// ->where('member_policies.start', '<', now())
|
||||||
|
// ->where('member_policies.end', '>', now());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function memberPlans()
|
public function memberPlans()
|
||||||
@@ -153,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);
|
||||||
@@ -170,24 +190,41 @@ 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) {
|
||||||
|
$query->where('name', 'like', "%" . $search . "%");
|
||||||
|
$query->orWhere('phone', 'like', "%" . $search . "%");
|
||||||
|
})
|
||||||
|
->orWhereHas('currentPlan', function ($query) use ($search) {
|
||||||
|
$query->where('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 . "%");
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function corporateEmployee()
|
|
||||||
// {
|
|
||||||
// return $this->hasOne(CorporateEmployee::class, 'member_id');
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function division()
|
public function division()
|
||||||
{
|
{
|
||||||
return $this->hasOneThrough(CorporateDivision::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'division_id');
|
return $this->hasOneThrough(CorporateDivision::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'division_id');
|
||||||
|
|||||||
113
app/Models/OLDLMS/Appointment.php
Normal file
113
app/Models/OLDLMS/Appointment.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
|
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';
|
||||||
|
|
||||||
|
public $sStatusNames = [
|
||||||
|
0 => 'Menunggu Pembayaran',
|
||||||
|
1 => 'Pembayaran Terkonfirmasi', // Pembayaran Diterima
|
||||||
|
2 => 'Ditolak',
|
||||||
|
3 => 'Dibatalkan', // Canceled
|
||||||
|
4 => 'Expired',
|
||||||
|
];
|
||||||
|
|
||||||
|
public $sPaymentMethodName = [
|
||||||
|
1 => 'Pribadi',
|
||||||
|
2 => 'On-Site Payment',
|
||||||
|
3 => 'OVO',
|
||||||
|
4 => 'Asuransi',
|
||||||
|
5 => 'Voucher',
|
||||||
|
];
|
||||||
|
|
||||||
|
public $nIDJenisBookingNames = [
|
||||||
|
1 => 'Rawat Jalan',
|
||||||
|
2 => 'Telekonsultasi',
|
||||||
|
3 => 'Chat Sekarang'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_appointment';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public $incrementing = false;
|
||||||
|
|
||||||
|
protected $keyType = 'string';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'nID',
|
||||||
|
'nIDDokter',
|
||||||
|
'nIDUser',
|
||||||
|
'sStatus',
|
||||||
|
'dCreateOn',
|
||||||
|
'dUpdateOn',
|
||||||
|
'dDeleteOn',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'status_name',
|
||||||
|
'payment_method',
|
||||||
|
'type'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function statusName(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function ($value) {
|
||||||
|
return $this->sStatusNames[$this->sStatus] ?? '-';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function paymentMethod(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function ($value) {
|
||||||
|
return $this->sPaymentMethodName[$this->sPaymentMethod] ?? '-';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function type(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function($value) {
|
||||||
|
return $this->nIDJenisBookingNames[$this->nIDJenisBooking] ?? '-';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function appointmentDetail()
|
||||||
|
{
|
||||||
|
return $this->hasOne(AppointmentDetail::class, 'nIDAppointment', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doctor()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function healthCare()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Models/OLDLMS/AppointmentDetail.php
Normal file
26
app/Models/OLDLMS/AppointmentDetail.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AppointmentDetail extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_appointment_detail';
|
||||||
|
protected $casts = [
|
||||||
|
'sPaymentDetails' => 'array',
|
||||||
|
];
|
||||||
|
public function appointment()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
37
app/Models/OLDLMS/Dokter.php
Normal file
37
app/Models/OLDLMS/Dokter.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Dokter extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tm_dokter';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function jadwalDokter()
|
||||||
|
{
|
||||||
|
return $this->hasMany(JadwalDokter::class, 'nIDDokter', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function speciality()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Speciality::class, 'nIDSpesialis', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Models/OLDLMS/Healthcare.php
Normal file
27
app/Models/OLDLMS/Healthcare.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Healthcare extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tm_healthcare';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function jadwalDokter()
|
||||||
|
{
|
||||||
|
return $this->hasMany(JadwalDokter::class, 'nIDHealthCare', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
32
app/Models/OLDLMS/JadwalDokter.php
Normal file
32
app/Models/OLDLMS/JadwalDokter.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class JadwalDokter extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_jadwal_dokter';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function jadwalDokterDay()
|
||||||
|
{
|
||||||
|
return $this->hasMany(JadwalDokterDay::class, 'nIDJadwalDokter', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function healthcare()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Models/OLDLMS/JadwalDokterDay.php
Normal file
22
app/Models/OLDLMS/JadwalDokterDay.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class JadwalDokterDay extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_jadwal_dokter_detail';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
}
|
||||||
64
app/Models/OLDLMS/Livechat.php
Normal file
64
app/Models/OLDLMS/Livechat.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Livechat extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
|
||||||
|
public $sStatusNames = [
|
||||||
|
0 => 'Menunggu Konfirmasi',
|
||||||
|
1 => 'Diterima',
|
||||||
|
2 => 'Ditolak',
|
||||||
|
3 => 'Selesai',
|
||||||
|
4 => 'Expired',
|
||||||
|
];
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tx_livechat';
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'status_name',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function statusName(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function ($value) {
|
||||||
|
return $this->sStatusNames[$this->sStatus] ?? '-';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function doctor()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function appointment()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function healthCare()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Models/OLDLMS/Speciality.php
Normal file
26
app/Models/OLDLMS/Speciality.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Speciality extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tm_spesialis';
|
||||||
|
|
||||||
|
protected $primaryKey = 'nID';
|
||||||
|
|
||||||
|
public function dokter()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Dokter::class, 'nIDSpesialis', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Models/OLDLMS/User.php
Normal file
47
app/Models/OLDLMS/User.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class User extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tm_users';
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'full_name',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function fullName(): Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make(
|
||||||
|
get: function ($value) {
|
||||||
|
$names = [];
|
||||||
|
if (!empty($this->sFirstName)) {
|
||||||
|
array_push($names, $this->sFirstName);
|
||||||
|
}
|
||||||
|
if (!empty($this->sLastName)) {
|
||||||
|
array_push($names, $this->sLastName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(' ', $names);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
return $this->hasOne(UserDetail::class, 'nIDUser', 'nID');
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Models/OLDLMS/UserDetail.php
Normal file
20
app/Models/OLDLMS/UserDetail.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\OLDLMS;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserDetail extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
const CREATED_AT = 'dCreateOn';
|
||||||
|
const UPDATED_AT = 'dUpdateOn';
|
||||||
|
const DELETED_AT = 'dDeleteOn';
|
||||||
|
|
||||||
|
protected $connection = 'oldlms';
|
||||||
|
|
||||||
|
protected $table = 'tm_users_detail';
|
||||||
|
|
||||||
|
}
|
||||||
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',
|
||||||
@@ -38,6 +40,15 @@ class Person extends Model
|
|||||||
'updated_by',
|
'updated_by',
|
||||||
'deleted_by'
|
'deleted_by'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $hidden = [
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'deleted_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
|
'deleted_by',
|
||||||
|
];
|
||||||
|
|
||||||
public function getFullNameAttribute()
|
public function getFullNameAttribute()
|
||||||
{
|
{
|
||||||
@@ -103,8 +114,36 @@ class Person extends Model
|
|||||||
return $this->hasOne(User::class, 'person_id');
|
return $this->hasOne(User::class, 'person_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function practitioner()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Practitioner::class, 'person_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function appointmentParticipantables()
|
public function appointmentParticipantables()
|
||||||
{
|
{
|
||||||
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",
|
||||||
@@ -62,6 +64,15 @@ class Plan extends Model
|
|||||||
"max_surgery_reinstatement_days",
|
"max_surgery_reinstatement_days",
|
||||||
"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",
|
||||||
@@ -138,7 +149,7 @@ class Plan extends Model
|
|||||||
{
|
{
|
||||||
$this->attributes['max_surgery_reinstatement_days'] = empty($value) ? null : $value;
|
$this->attributes['max_surgery_reinstatement_days'] = empty($value) ? null : $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMaxSurgeryPeriodeDaysAttribute($value)
|
public function setMaxSurgeryPeriodeDaysAttribute($value)
|
||||||
{
|
{
|
||||||
$this->attributes['max_surgery_periode_days'] = empty($value) ? null : $value;
|
$this->attributes['max_surgery_periode_days'] = empty($value) ? null : $value;
|
||||||
@@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user