Compare commits
45 Commits
mhmfajar
...
feature/co
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 |
@@ -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\Validation\Rule;
|
||||
|
||||
class DivisionController extends Controller
|
||||
class CorporateDivisionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$corporate = $user->managedCorporates()->where('active', 1)->first();
|
||||
|
||||
$benefits = CorporateDivision::query()
|
||||
->where('corporate_id', $corporate->id)
|
||||
$division = CorporateDivision::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->get(['id', 'name']);
|
||||
|
||||
return $benefits;
|
||||
return response()->json($division);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class CorporateController extends Controller
|
||||
class CorporateManageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@@ -18,8 +18,6 @@ class CorporateController extends Controller
|
||||
$userLogin = Auth::user();
|
||||
$corporate = $userLogin->managedCorporates()->select(['corporates.id', 'corporates.name'])->get();
|
||||
|
||||
// corporate policy, all member list, notification
|
||||
|
||||
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 Modules\Client\Transformers\DashboardResources;
|
||||
|
||||
class DashboardController extends Controller
|
||||
class CorporatePolicyController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@@ -20,7 +20,7 @@ class DashboardController extends Controller
|
||||
$currentCorporate = $user->managedCorporates()
|
||||
->with(['currentPolicy', 'employees'])
|
||||
->find($corporate_id);
|
||||
|
||||
|
||||
$data = DashboardResources::make($currentCorporate);
|
||||
|
||||
return response()->json($data);
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Modules\Client\Http\Controllers\Api\AuthController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporateController;
|
||||
use Modules\Client\Http\Controllers\Api\DashboardController;
|
||||
use Modules\Client\Http\Controllers\Api\DivisionController;
|
||||
use Modules\Client\Http\Controllers\Api\MemberController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporateDivisionController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporateManageController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporateMemberController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporatePolicyController;
|
||||
use Modules\Client\Http\Controllers\Api\UserController;
|
||||
|
||||
/*
|
||||
@@ -26,21 +26,14 @@ Route::prefix('client')->group(function () {
|
||||
});
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
||||
Route::get('user', [UserController::class, 'index']);
|
||||
Route::get('user', [UserController::class, 'index']);
|
||||
|
||||
Route::prefix('{corporate_id}')->group(function() {
|
||||
Route::get('asd', function ($corporate_id) {
|
||||
return $corporate_id;
|
||||
Route::get('corporate-manage', [CorporateManageController::class, 'index']);
|
||||
Route::prefix('{corporate_id}')->group(function () {
|
||||
Route::get('policy', [CorporatePolicyController::class, 'index']);
|
||||
Route::get('division', [CorporateDivisionController::class, 'index']);
|
||||
Route::get('members', [CorporateMemberController::class, 'index']);
|
||||
});
|
||||
|
||||
|
||||
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']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,11 +15,18 @@ class MemberResources extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'memberId' => $this->member_id,
|
||||
'full_name' => $this->full_name,
|
||||
'division' => $this->division->name,
|
||||
'employeeLimit' => '',
|
||||
'status' => $this->active
|
||||
'fullName' => $this->full_name,
|
||||
$this->mergeWhen($request->input('claimMember') === 'false', [
|
||||
'division' => $this->division->name ?? '',
|
||||
'status' => $this->active
|
||||
]),
|
||||
'limit' => [
|
||||
'current' => $this->claims_sum_total_claim,
|
||||
'total' => $this->currentPlan->limit_rules ?? 0,
|
||||
'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->claims_sum_total_claim / $this->currentPlan->limit_rules) * 100) : 0
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
37
Modules/Internal/Emails/SendVerifyEmail.php
Normal file
37
Modules/Internal/Emails/SendVerifyEmail.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Emails;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
class SendVerifyEmail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$this->subject('Verify Email')
|
||||
->markdown('verify_email');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
33
Modules/Internal/Events/ForgetPassword.php
Normal file
33
Modules/Internal/Events/ForgetPassword.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Events;
|
||||
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ForgetPassword
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
public $data;
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should be broadcast on.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new PrivateChannel('channel-name');
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,14 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use Crypt;
|
||||
use Error;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Modules\Internal\Emails\SendVerifyEmail;
|
||||
use Modules\Internal\Events\ForgetPassword;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
@@ -18,8 +23,8 @@ class AuthController extends Controller
|
||||
]);
|
||||
|
||||
$user = User::query()
|
||||
->where('email', $request->email)
|
||||
->first();
|
||||
->where('email', $request->email)
|
||||
->first();
|
||||
|
||||
if (!$user) {
|
||||
return response(['message' => 'User Tidak Ditemukan'], 404);
|
||||
@@ -43,4 +48,81 @@ class AuthController extends Controller
|
||||
|
||||
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;
|
||||
|
||||
use App\Models\Benefit;
|
||||
use App\Models\CorporateBenefit;
|
||||
use App\Models\MemberBenefit;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,12 +19,13 @@ class BenefitController extends Controller
|
||||
*/
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$benefits = Benefit::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
$benefits = CorporateBenefit::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->with('benefit', 'plan')
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
return $benefits;
|
||||
}
|
||||
|
||||
@@ -89,59 +91,59 @@ class BenefitController extends Controller
|
||||
|
||||
public function memberBenefitImport(Request $request, $corporate_id)
|
||||
{
|
||||
$request->validate([
|
||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||
]);
|
||||
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||
// $request->validate([
|
||||
// 'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||
// ]);
|
||||
// $file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||
// $file = $request->file('file')->storeAs('temp', $file_name);
|
||||
|
||||
$reader = ReaderEntityFactory::createReaderFromFile(Storage::path('temp/'.$file_name));
|
||||
$reader->open(Storage::path('temp/'.$file_name));
|
||||
// $reader = ReaderEntityFactory::createReaderFromFile(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;
|
||||
$failed_benefit_data = [];
|
||||
foreach ($reader->getSheetIterator() as $sheet) {
|
||||
$doc_headers_indexes = [];
|
||||
foreach ($sheet->getRowIterator() as $index => $row) {
|
||||
if ($index == 1) { // First Row Must be Header
|
||||
foreach ($row->getCells() as $index => $cell) {
|
||||
$doc_headers_indexes[$index] = rtrim($cell->getValue());
|
||||
}
|
||||
} else { // Next Row Should be Data
|
||||
$new_benefit_data = [];
|
||||
foreach ($row->getCells() as $index => $cell) {
|
||||
$new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
|
||||
}
|
||||
// $imported_benefit_data = 0;
|
||||
// $failed_benefit_data = [];
|
||||
// foreach ($reader->getSheetIterator() as $sheet) {
|
||||
// $doc_headers_indexes = [];
|
||||
// foreach ($sheet->getRowIterator() as $index => $row) {
|
||||
// if ($index == 1) { // First Row Must be Header
|
||||
// foreach ($row->getCells() as $index => $cell) {
|
||||
// $doc_headers_indexes[$index] = rtrim($cell->getValue());
|
||||
// }
|
||||
// } else { // Next Row Should be Data
|
||||
// $new_benefit_data = [];
|
||||
// foreach ($row->getCells() as $index => $cell) {
|
||||
// $new_benefit_data[$headers_map_to_table_fields[$doc_headers_indexes[$index]]] = $cell->getValue();
|
||||
// }
|
||||
|
||||
// $imported_plan_data[] = $new_row; // Insert to Array
|
||||
// Create Directly
|
||||
$new_benefit_data['corporate_id'] = $corporate_id;
|
||||
try {
|
||||
Benefit::updateOrCreate([
|
||||
'corporate_id' => $corporate_id,
|
||||
'code' => $new_benefit_data['code']
|
||||
], $new_benefit_data);
|
||||
// // $imported_plan_data[] = $new_row; // Insert to Array
|
||||
// // Create Directly
|
||||
// $new_benefit_data['corporate_id'] = $corporate_id;
|
||||
// try {
|
||||
// Benefit::updateOrCreate([
|
||||
// 'corporate_id' => $corporate_id,
|
||||
// 'code' => $new_benefit_data['code']
|
||||
// ], $new_benefit_data);
|
||||
|
||||
$imported_benefit_data++;
|
||||
} catch(\Exception $e) {
|
||||
$new_benefit_data['error'] = $e->getMessage();
|
||||
$failed_benefit_data[] = $new_benefit_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break; //only read first sheet
|
||||
}
|
||||
$reader->close();
|
||||
Storage::delete('temp/'.$file_name);
|
||||
// throw(404);
|
||||
// $imported_benefit_data++;
|
||||
// } catch(\Exception $e) {
|
||||
// $new_benefit_data['error'] = $e->getMessage();
|
||||
// $failed_benefit_data[] = $new_benefit_data;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return [
|
||||
'total_successed_row' => $imported_benefit_data,
|
||||
'total_failed_row' => count($failed_benefit_data),
|
||||
'failed_row' => $failed_benefit_data
|
||||
];
|
||||
// break; //only read first sheet
|
||||
// }
|
||||
// $reader->close();
|
||||
// Storage::delete('temp/'.$file_name);
|
||||
// // throw(404);
|
||||
|
||||
// return [
|
||||
// 'total_successed_row' => $imported_benefit_data,
|
||||
// 'total_failed_row' => count($failed_benefit_data),
|
||||
// 'failed_row' => $failed_benefit_data
|
||||
// ];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ use App\Models\Benefit;
|
||||
use App\Models\Claim;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Member;
|
||||
use App\Services\ClaimService;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Services\ClaimService;
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
@@ -65,7 +65,7 @@ class ClaimController extends Controller
|
||||
|
||||
// Store Claim
|
||||
if ($validation['isEligible']) {
|
||||
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit);
|
||||
$claim = ClaimService::storeClaim($member, $diagnosis, $request->total_claim, $benefit, 'requested');
|
||||
} else {
|
||||
return response()->json([
|
||||
'data' => $validation,
|
||||
@@ -83,7 +83,17 @@ class ClaimController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
$claim = Claim::query()
|
||||
->with([
|
||||
'member',
|
||||
'member.currentPlan',
|
||||
'diagnosis',
|
||||
'benefit',
|
||||
'files'
|
||||
])
|
||||
->findOrFail($id);
|
||||
|
||||
return response()->json($claim);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,14 +18,30 @@ class CorporateBenefitController extends Controller
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$benefits = CorporateBenefit::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->paginate(0)
|
||||
->appends($request->all());
|
||||
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->paginate(0)
|
||||
->appends($request->all());
|
||||
return $benefits;
|
||||
}
|
||||
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.
|
||||
* @return Renderable
|
||||
|
||||
@@ -5,8 +5,12 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
use App\Exceptions\ImportRowException;
|
||||
use App\Imports\PlansImport;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Claim;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\CorporateBenefit;
|
||||
use App\Models\Plan;
|
||||
use App\Models\Service;
|
||||
use App\Models\User;
|
||||
use App\Services\ImportService;
|
||||
use DB;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
@@ -14,6 +18,8 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use App\Models\File;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Internal\Services\CorporateService;
|
||||
|
||||
@@ -34,6 +40,9 @@ class CorporateController extends Controller
|
||||
->withCount([
|
||||
'employees',
|
||||
'corporateBenefits',
|
||||
'corporatePlans',
|
||||
|
||||
// 'claims'
|
||||
])
|
||||
->where('type', 'corporate')
|
||||
->paginate(10);
|
||||
@@ -103,6 +112,129 @@ class CorporateController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// Service
|
||||
$services = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'Out Patient',
|
||||
'code' => 'OP',
|
||||
'description' => 'Out Patient',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'Inpatient',
|
||||
'code' => 'IP',
|
||||
'description' => 'Inpatient',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => 'Dental',
|
||||
'code' => 'DE',
|
||||
'description' => 'Dental',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => 'Maternal',
|
||||
'code' => 'MA',
|
||||
'description' => 'Maternal',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'name' => 'Optical',
|
||||
'code' => 'OPT',
|
||||
'description' => 'Optical',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($services as $service) {
|
||||
|
||||
$corporateService = $newCorporate->corporateServices()->create([
|
||||
'service_code' => $service['code'],
|
||||
'status' => 'inactive'
|
||||
]);
|
||||
|
||||
$corporateService->configs()->insert([
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_external_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_external_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_internal_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'gp_internal_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_external_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_external_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_internal_doctor_online',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'sp_internal_doctor_offline',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'vitamins',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'delivery_fee',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'general_practitioner_fee',
|
||||
'value' => false,
|
||||
],
|
||||
[
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => 'specialist_practitioner_fee',
|
||||
'value' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
// TODO Remove This
|
||||
// Assign Managed to Manager one
|
||||
$managerOne = User::where('email', 'manager+one@gmail.com')->first();
|
||||
$managerOne->managedCorporates()->attach($newCorporate);
|
||||
|
||||
if ($request->hasFile('logo')) {
|
||||
$pathFileAvatar = File::storeFile('avatar', $newCorporate->id, $request->file('logo'));
|
||||
$newCorporate->files()->updateOrCreate([
|
||||
'type' => 'avatar',
|
||||
'name' => File::getFileName('avatar', $newCorporate->id, $request->file('logo')),
|
||||
'extension' => $request->file('logo')->getClientOriginalExtension(),
|
||||
'path' => $pathFileAvatar,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
@@ -119,7 +251,25 @@ class CorporateController extends Controller
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,9 +307,13 @@ class CorporateController extends Controller
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
//karena pake formdata
|
||||
$linkingRules = $request->linking_rules;
|
||||
$linkingRules = explode(',', $linkingRules);
|
||||
|
||||
$corporate = Corporate::findOrFail($id);
|
||||
$corporate->fill($request->toArray());
|
||||
$corporate->fill($request->all());
|
||||
$corporate->linking_rules = $linkingRules;
|
||||
$corporate->save();
|
||||
|
||||
$corporate->policies()->updateOrCreate(
|
||||
@@ -179,6 +333,19 @@ class CorporateController extends Controller
|
||||
]
|
||||
);
|
||||
|
||||
if ($request->hasFile('logo')) {
|
||||
$pathFileAvatar = File::storeFile('avatar', $corporate->id, $request->file('logo'));
|
||||
|
||||
$corporate->files()->updateOrCreate([
|
||||
'type' => 'avatar',
|
||||
'name' => File::getFileName('avatar', $corporate->id, $request->file('logo')),
|
||||
'extension' => $request->file('logo')->getClientOriginalExtension(),
|
||||
'path' => $pathFileAvatar,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
@@ -225,7 +392,7 @@ class CorporateController extends Controller
|
||||
// dd($request->toArray());
|
||||
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
|
||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||
$corporate = Corporate::findOrFail($corporate_id);
|
||||
$corporate = Corporate::with(['plans'])->findOrFail($corporate_id);
|
||||
|
||||
$import = new ImportService();
|
||||
$import->read(Storage::path('temp/' . $file_name));
|
||||
@@ -246,7 +413,7 @@ class CorporateController extends Controller
|
||||
if ($sheet->getName() == 'Plan') {
|
||||
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
||||
} 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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Exceptions\ImportRowException;
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Resources\MemberDataTableResource;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\Member;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
@@ -35,15 +37,37 @@ class CorporateMemberController extends Controller
|
||||
->with([
|
||||
'employeds',
|
||||
'currentPolicy',
|
||||
// 'claims' => function ($claim) {
|
||||
// return $claim->used();
|
||||
// }
|
||||
// 'claims',
|
||||
'claims' => function ($claim) {
|
||||
// return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
|
||||
// return $claim->used(now()->startOfYear(), now()->endOfYear());
|
||||
}
|
||||
])
|
||||
->with('currentPlan')
|
||||
// ->with
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
return $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'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,14 +17,33 @@ class CorporatePlanController extends Controller
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$benefits = CorporatePlan::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->paginate(0)
|
||||
->appends($request->all());
|
||||
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
->paginate(0)
|
||||
->appends($request->all());
|
||||
|
||||
return $benefits;
|
||||
}
|
||||
|
||||
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.
|
||||
* @return Renderable
|
||||
|
||||
@@ -12,6 +12,7 @@ use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\CorporateServiceConfigResource;
|
||||
use Termwind\Components\Dd;
|
||||
|
||||
class CorporateServiceController extends Controller
|
||||
{
|
||||
@@ -74,6 +75,7 @@ class CorporateServiceController extends Controller
|
||||
public function update(Request $request, $corporate_id)
|
||||
{
|
||||
$corporateService = CorporateService::where('corporate_id', $corporate_id)->where('service_code', $request->service_code)->first();
|
||||
|
||||
$corporateServiceConfig = $corporateService->configs()->updateOrCreate([
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'name' => $request->config_name
|
||||
@@ -97,19 +99,32 @@ class CorporateServiceController extends Controller
|
||||
|
||||
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()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('service_code', $service_code)
|
||||
->with(['configs', 'service',
|
||||
'specialities' => function($speciality) {
|
||||
$speciality->where('status', 'active');
|
||||
},
|
||||
'specialities.speciality'])
|
||||
->first();
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('service_code', $service_code)
|
||||
->with([
|
||||
'configs', 'service',
|
||||
'corporateServiceSpecialities',
|
||||
'corporateServiceSpecialities.speciality',
|
||||
'corporateServiceSpecialities.exclusions.rules'
|
||||
])
|
||||
->first();
|
||||
// $service = CorporateServiceConfigResource::make($corporateService);
|
||||
$specialities = Speciality::get();
|
||||
|
||||
|
||||
return response()->json(
|
||||
[
|
||||
'corporate' => $corporate,
|
||||
@@ -123,10 +138,10 @@ class CorporateServiceController extends Controller
|
||||
{
|
||||
// $corporate = Corporate::findOrFail($corporate_id);
|
||||
$corporateService = CorporateService::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('service_code', $service_code)
|
||||
// ->with('configs', 'service')
|
||||
->first();
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('service_code', $service_code)
|
||||
// ->with('configs', 'service')
|
||||
->first();
|
||||
$corporateService->fill([
|
||||
'status' => $request->status == 'active' ? 'active' : 'inactive'
|
||||
]);
|
||||
@@ -137,26 +152,288 @@ class CorporateServiceController extends Controller
|
||||
|
||||
public function corporateServiceSpecialityUpdate(Request $request, $corporate_id, $service_code)
|
||||
{
|
||||
|
||||
|
||||
// return response()->json([$request->checked, $request->value, $request->speciality_id]);
|
||||
|
||||
$corporateService = CorporateService::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('service_code', $service_code)
|
||||
->first();
|
||||
CorporateServiceSpeciality::updateOrCreate([
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('service_code', $service_code)
|
||||
->first();
|
||||
|
||||
|
||||
$corporateServiceSpeciality = CorporateServiceSpeciality::updateOrCreate([
|
||||
'corporate_service_id' => $corporateService->id,
|
||||
'speciality_id' => $request->speciality_id,
|
||||
], [
|
||||
'corporate_service_id' => $corporateService->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()
|
||||
->where('corporate_service_id', $corporateService->id)
|
||||
->where('status', 'active')
|
||||
->with('speciality')
|
||||
->get()
|
||||
->pluck('speciality.name', 'speciality.id');
|
||||
->where('corporate_service_id', $corporateService->id)
|
||||
->where('active', true)
|
||||
->with('speciality')
|
||||
->get()
|
||||
->pluck('speciality.name', 'speciality.id');
|
||||
|
||||
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\Helpers\Helper;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\CorporateService;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\Icd;
|
||||
use App\Models\ImportLog;
|
||||
@@ -26,10 +27,12 @@ class DiagnosisExclusionController extends Controller
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$exclusions = Exclusion::query()
|
||||
->where('corporate_id', $corporate_id)
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
->where('corporate_id', $corporate_id)
|
||||
->where('type', 'diagnosis')
|
||||
->where('deleted_at', null)
|
||||
->with(['exclusionable', 'rules'])
|
||||
->filter($request->toArray())
|
||||
->paginate();
|
||||
// return $exclusions;
|
||||
return Helper::paginateResources(DiagnosisExclusionResource::collection($exclusions));
|
||||
}
|
||||
@@ -91,7 +94,13 @@ class DiagnosisExclusionController extends Controller
|
||||
*/
|
||||
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)
|
||||
@@ -100,10 +109,10 @@ class DiagnosisExclusionController extends Controller
|
||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||
]);
|
||||
// dd($request->toArray());
|
||||
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
|
||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||
$corporate = Corporate::findOrFail($corporate_id);
|
||||
|
||||
|
||||
// $importLog = $corporate->importLogs()->create([
|
||||
// 'type' => 'diagnosis-exclusions',
|
||||
// 'file_path' => $file,
|
||||
@@ -112,8 +121,8 @@ class DiagnosisExclusionController extends Controller
|
||||
// ]);
|
||||
|
||||
$import = new ImportService();
|
||||
$import->read(Storage::path('temp/'.$file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
||||
$import->read(Storage::path('temp/' . $file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
|
||||
|
||||
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
||||
$doc_headers_indexes = [];
|
||||
@@ -121,8 +130,8 @@ class DiagnosisExclusionController extends Controller
|
||||
if ($index == 1) { // First Row Must be Header
|
||||
foreach ($row->getCells() as $index => $cell) {
|
||||
$title = $cell->getValue();
|
||||
$title = preg_replace( "/\r|\n/", " ", $title );
|
||||
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
||||
$title = preg_replace("/\r|\n/", " ", $title);
|
||||
$title = preg_replace('/\xc2\xa0/', " ", $title);
|
||||
$title = rtrim($title);
|
||||
$title = ltrim($title);
|
||||
$doc_headers_indexes[$index] = $title;
|
||||
@@ -148,12 +157,12 @@ class DiagnosisExclusionController extends Controller
|
||||
9 => 'keterangan',
|
||||
10 => 'maternity_waiting'
|
||||
];
|
||||
|
||||
|
||||
foreach ($row->getCells() as $header_index => $cell) {
|
||||
if (isset($row_map[$header_index])) {
|
||||
$value = $cell->getValue();
|
||||
$value = preg_replace( "/\r|\n/", " ", $value );
|
||||
$value = preg_replace('/\xc2\xa0/', " ", $value );
|
||||
$value = preg_replace("/\r|\n/", " ", $value);
|
||||
$value = preg_replace('/\xc2\xa0/', " ", $value);
|
||||
$value = rtrim($value);
|
||||
$value = ltrim($value);
|
||||
$row_data[$row_map[$header_index]] = $cell->getValue();
|
||||
@@ -171,7 +180,8 @@ class DiagnosisExclusionController extends Controller
|
||||
empty($row_data['sp_exclusion']) &&
|
||||
empty($row_data['pre_exis_exclusion']) &&
|
||||
empty($row_data['op_de_exclusion']) &&
|
||||
empty($row_data['maternity_waiting'])) {
|
||||
empty($row_data['maternity_waiting'])
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -184,7 +194,6 @@ class DiagnosisExclusionController extends Controller
|
||||
'Ingest Code' => 200,
|
||||
'Ingest Note' => 'Success',
|
||||
]), $sheet->getName());
|
||||
|
||||
} catch (ImportRowException $e) {
|
||||
// Write Data Validation Error to File
|
||||
$import->addArrayToRow(array_merge($row_data, [
|
||||
@@ -205,7 +214,7 @@ class DiagnosisExclusionController extends Controller
|
||||
break; // Only Read First Row
|
||||
}
|
||||
$import->reader->close();
|
||||
Storage::delete('temp/'.$file_name);
|
||||
Storage::delete('temp/' . $file_name);
|
||||
$import->writer->close();
|
||||
|
||||
return [
|
||||
@@ -213,9 +222,102 @@ class DiagnosisExclusionController extends Controller
|
||||
// 'total_failed_row' => count($failed_plan_data),
|
||||
// 'failed_row' => $failed_plan_data,
|
||||
'result_file' => [
|
||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
||||
'name' => 'result-'.$file_name,
|
||||
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||
'name' => 'result-' . $file_name,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
111
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
111
Modules/Internal/Http/Controllers/Api/DoctorController.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Practitioner;
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\DoctorResource;
|
||||
|
||||
class DoctorController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// $doctors = PractitionerRole::active()->with('practitioner.person', 'organization')
|
||||
// ->when($request->search ?? null, function ($query, $search) {
|
||||
// $query->whereHas('practitioner.person', function ($person) use ($search) {
|
||||
// $person->where('name', 'LIKE', '%' . $search . '%');
|
||||
// });
|
||||
// })->paginate();
|
||||
|
||||
$doctors = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')
|
||||
->when($request->search ?? null, function ($query, $search) {
|
||||
$query->whereHas('person', function ($person) use ($search) {
|
||||
$person->where('name', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
})
|
||||
->when($request->organization_id ?? null, function ($query, $organization_id) {
|
||||
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($organization_id) {
|
||||
$practitionerRole->where('organization_id', $organization_id);
|
||||
});
|
||||
})
|
||||
->when($request->speciality_id ?? null, function ($query, $speciality_id) {
|
||||
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($speciality_id) {
|
||||
$practitionerRole->where('speciality_id', $speciality_id);
|
||||
});
|
||||
})
|
||||
->paginate();
|
||||
|
||||
// return $doctors;
|
||||
|
||||
|
||||
return response()->json(Helper::paginateResources(DoctorResource::collection($doctors)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
44
Modules/Client/Http/Controllers/Api/MemberController.php → Modules/Internal/Http/Controllers/Api/OrganizationController.php
Executable file → Normal file
44
Modules/Client/Http/Controllers/Api/MemberController.php → Modules/Internal/Http/Controllers/Api/OrganizationController.php
Executable file → Normal file
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\OrganizationResource;
|
||||
|
||||
class MemberController extends Controller
|
||||
class OrganizationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
@@ -16,27 +17,18 @@ class MemberController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$organizations = Organization::hospital()->with('currentAddress')
|
||||
->when($request->search ?? null, function ($query, $search) {
|
||||
$query->where('name', 'LIKE', '%' . $search . '%');
|
||||
})
|
||||
->paginate();
|
||||
return response()->json(Helper::paginateResources(OrganizationResource::collection($organizations)));
|
||||
}
|
||||
|
||||
$corporate = $user->managedCorporates()->first();
|
||||
// $plans =
|
||||
|
||||
$members = Member::query()
|
||||
->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)
|
||||
]);
|
||||
public function searchOrganization(Request $request)
|
||||
{
|
||||
$organizations = Organization::hospital()->get();
|
||||
return response()->json(OrganizationResource::collection($organizations));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +37,7 @@ class MemberController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('client::create');
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +57,7 @@ class MemberController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('client::show');
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +67,7 @@ class MemberController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('client::edit');
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,16 +28,16 @@ class PlanController extends Controller
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$plans = Plan::query()
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
// ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) {
|
||||
// $corporatePlan->where('corporate_id', $corporate_id);
|
||||
// })
|
||||
// ->with('corporatePlan')
|
||||
->orderBy('corporate_plan_id', 'ASC')
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
->filter($request->all())
|
||||
->where('corporate_id', $corporate_id)
|
||||
// ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) {
|
||||
// $corporatePlan->where('corporate_id', $corporate_id);
|
||||
// })
|
||||
// ->with('corporatePlan')
|
||||
->orderBy('corporate_plan_id', 'ASC')
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
return $plans;
|
||||
}
|
||||
|
||||
@@ -105,14 +105,14 @@ class PlanController extends Controller
|
||||
{
|
||||
$request->validate([
|
||||
'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);
|
||||
$corporate = Corporate::findOrFail($corporate_id);
|
||||
|
||||
|
||||
$import = $this->importService;
|
||||
$import->read(Storage::path('temp/'.$file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
||||
$import->read(Storage::path('temp/' . $file_name));
|
||||
$import->write(Storage::disk('public')->path('temp/result-' . $file_name), 'xsls');
|
||||
|
||||
$headers_map_to_table_fields = Plan::$doc_headers_to_field_map;
|
||||
|
||||
@@ -142,7 +142,7 @@ class PlanController extends Controller
|
||||
// Create Directly
|
||||
try {
|
||||
$rowResponse = $this->corporateService->handlePlanRow($corporate, $plan_row);
|
||||
|
||||
|
||||
// Write Success Result to File
|
||||
array_push($plan_row, 'SUCCESS');
|
||||
$import->addArrayToRow($plan_row);
|
||||
@@ -160,11 +160,11 @@ class PlanController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break; //only read first sheet
|
||||
}
|
||||
$import->reader->close();
|
||||
Storage::delete('temp/'.$file_name);
|
||||
Storage::delete('temp/' . $file_name);
|
||||
$import->writer->close();
|
||||
// throw(404);
|
||||
|
||||
@@ -173,8 +173,8 @@ class PlanController extends Controller
|
||||
'total_failed_row' => count($failed_plan_data),
|
||||
'failed_row' => $failed_plan_data,
|
||||
'result_file' => [
|
||||
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
||||
'name' => 'result-'.$file_name,
|
||||
'url' => Storage::disk('public')->url('temp/result-' . $file_name),
|
||||
'name' => 'result-' . $file_name,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Speciality;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class SpecialityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$specialiy = Speciality::get();
|
||||
return response()->json($specialiy);
|
||||
}
|
||||
|
||||
public function searchSpeciality(Request $request)
|
||||
{
|
||||
$specialiy = Speciality::get();
|
||||
return response()->json($specialiy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
37
Modules/Internal/Listeners/SendVerifyEmail.php
Normal file
37
Modules/Internal/Listeners/SendVerifyEmail.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Listeners;
|
||||
|
||||
use App\Models\User;
|
||||
use Modules\Internal\Events\ForgetPassword;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Modules\Internal\Notifications\NotifyVerifyEmail;
|
||||
|
||||
class SendVerifyEmail
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param ForgetPassword $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(ForgetPassword $event)
|
||||
{
|
||||
User::where('email', $event->data['email'])
|
||||
->each(function ($user) use ($event) {
|
||||
$user->notify(new NotifyVerifyEmail($event->data));
|
||||
});
|
||||
}
|
||||
}
|
||||
70
Modules/Internal/Notifications/NotifyVerifyEmail.php
Normal file
70
Modules/Internal/Notifications/NotifyVerifyEmail.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Notifications;
|
||||
|
||||
use Crypt;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class NotifyVerifyEmail extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
protected $data;
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
|
||||
$token = Crypt::encryptString($this->data['email'] . '|' . now());
|
||||
|
||||
$url = env('INTERNAL_URL', 'https://aso.linksehat.com') . '/auth/forget-password?token=' . $token;
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('Verify Email')
|
||||
->markdown('verify_email', ['url' => $url]);
|
||||
// return (new MailMessage)
|
||||
// ->line('The introduction to the notification.')
|
||||
// ->action('Notification Action', 'https://laravel.com')
|
||||
// ->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
50
Modules/Internal/Providers/EventServiceProvider.php
Normal file
50
Modules/Internal/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Internal\Events\ForgetPassword;
|
||||
use Modules\Internal\Listeners\SendVerifyEmail;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
// protected $listen = [
|
||||
// ForgetPassword::class => [
|
||||
// SendVerifyEmail::class,
|
||||
// ],
|
||||
// ];
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Event::listen(
|
||||
ForgetPassword::class,
|
||||
[SendVerifyEmail::class, 'handle']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,11 @@ use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class InternalServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $listen = [
|
||||
ForgetPassword::class => [
|
||||
SendVerifyEmail::class,
|
||||
],
|
||||
];
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
@@ -51,7 +56,8 @@ class InternalServiceProvider extends ServiceProvider
|
||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||
module_path($this->moduleName, 'Config/config.php'),
|
||||
$this->moduleNameLower
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,13 @@ use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
|
||||
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
|
||||
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
|
||||
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\FormulariumController;
|
||||
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\SpecialityController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -36,14 +39,16 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('login', [AuthController::class, 'login'])->name('login');
|
||||
Route::post('forget-password', [AuthController::class, 'forgetPassword'])->name('forget-password');
|
||||
Route::post('verify-email', [AuthController::class, 'verifyEmail'])->name('verify-email');
|
||||
|
||||
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
|
||||
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
Route::put('reset-password', [AuthController::class, 'resetPassword'])->name('resetPassword');
|
||||
|
||||
|
||||
Route::resource('corporates', CorporateController::class);
|
||||
Route::put('corporates/{corporate_id}/activation', [CorporateController::class, 'activation']);
|
||||
@@ -53,14 +58,16 @@ Route::prefix('internal')->group(function () {
|
||||
Route::post('corporates/{corporate_id}/corporate-plans', [CorporatePlanController::class, 'store']);
|
||||
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('plans/{plan_id}/activation', [CorporatePlanController::class, 'activation']);
|
||||
|
||||
Route::get('corporates/{corporate_id}/plans', [PlanController::class, 'index']);
|
||||
Route::post('corporates/{corporate_id}/plans/import', [PlanController::class, 'planImport']);
|
||||
|
||||
|
||||
Route::get('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'index']);
|
||||
Route::post('corporates/{corporate_id}/corporate-benefits', [CorporateBenefitController::class, 'store']);
|
||||
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('benefits/{benefit_id}/activation', [CorporateBenefitController::class, 'activation']);
|
||||
|
||||
Route::get('corporates/{corporate_id}/benefits', [BenefitController::class, 'index']);
|
||||
Route::post('corporates/{corporate_id}/benefits/import', [BenefitController::class, 'memberBenefitImport']);
|
||||
@@ -72,8 +79,12 @@ Route::prefix('internal')->group(function () {
|
||||
|
||||
Route::get('corporates/{corporate_id}/members', [CorporateMemberController::class, 'index']);
|
||||
Route::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::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::get('corporates/{corporate_id}/services', [CorporateServiceController::class, 'index']);
|
||||
@@ -81,6 +92,7 @@ Route::prefix('internal')->group(function () {
|
||||
Route::get('corporates/{corporate_id}/services/{service_code}', [CorporateServiceController::class, 'corporateServiceIndex']);
|
||||
Route::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/exclusion', [CorporateServiceController::class, 'storeExclusion']);
|
||||
|
||||
Route::get('corporates/{corporate_id}/formulariums', [CorporateFormulariumController::class, 'index']);
|
||||
Route::put('corporates/{corporate_id}/formulariums/{formularium_id}/{action}', [CorporateFormulariumController::class, 'updateStatus']);
|
||||
@@ -97,12 +109,20 @@ Route::prefix('internal')->group(function () {
|
||||
|
||||
Route::get('members', [MemberController::class, 'index']);
|
||||
Route::get('members/{member_id}/benefits', [MemberController::class, 'benefits']);
|
||||
|
||||
|
||||
Route::get('claims', [ClaimController::class, 'index']);
|
||||
Route::post('claims', [ClaimController::class, 'store']);
|
||||
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||
Route::post('check-limit', [ClaimController::class, 'checkLimit']);
|
||||
|
||||
|
||||
Route::get('search-organizations', [OrganizationController::class, 'searchOrganization']);
|
||||
Route::get('search-specialities', [SpecialityController::class, 'searchSpeciality']);
|
||||
Route::resource('organizations', OrganizationController::class);
|
||||
Route::resource('doctors', DoctorController::class);
|
||||
});
|
||||
|
||||
// Route::resource('organizations', OrganizationController::class);
|
||||
// Route::resource('doctors', DoctorController::class);
|
||||
|
||||
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
|
||||
});
|
||||
|
||||
@@ -7,109 +7,5 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ClaimService
|
||||
{
|
||||
public static function checkMemberEligibility($member, $benefit, $diagnosis, $totalClaim = 0)
|
||||
{
|
||||
$currentPlan = $member->currentPlan;
|
||||
$policy = $member->currentPolicy;
|
||||
$corporate = $policy->corporate;
|
||||
|
||||
|
||||
$isEligible = true;
|
||||
$validationErrors = [];
|
||||
|
||||
// Eligibility Validation
|
||||
|
||||
if (!in_array($member->marital_status, explode(',', $benefit->msc))) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'msc',
|
||||
'message' => 'Only '.$benefit->msc
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (!in_array($member->gender_code, explode(',', $benefit->genders))) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'genders',
|
||||
'message' => 'Only '.$benefit->genders
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (!empty($benefit->min_age) && $member->age < $benefit->min_age) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'min_age',
|
||||
'message' => 'Minimum Age is '.$benefit->min_age
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (!empty($benefit->max_age) && $member->age > $benefit->max_age) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'max_age',
|
||||
'message' => 'Maximum Age is '.$benefit->min_age
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
// TODO complete validations
|
||||
|
||||
// Limit Validation
|
||||
if ($totalClaim > 0) {
|
||||
if (bcsub($corporate->limit_balance, $totalClaim) < 0) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'corporate_limit',
|
||||
'message' => 'Corporate Limit cannot cover this'
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (bcsub($benefit->limit_amount, $totalClaim) < 0) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'benefit_limit',
|
||||
'message' => 'Benefit Limit cannot cover this'
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
// TODO complete validations
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
'isEligible' => $isEligible,
|
||||
'errors' => $validationErrors
|
||||
];
|
||||
}
|
||||
|
||||
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$claim = Claim::create([
|
||||
'member_id' => $member->id,
|
||||
'diagnosis_id' => $diagnosis->id,
|
||||
'total_claim' => $totalClaim,
|
||||
'currency' => 'IDR',
|
||||
'plan_id' => $member->currentPlan->id,
|
||||
'benefit_id' => $benefit->id,
|
||||
]);
|
||||
|
||||
$policy = $member->currentPolicy;
|
||||
$policy->limitJournals()->create([
|
||||
'previous_balance' => $policy->limit_balance,
|
||||
'total_credit' => $totalClaim,
|
||||
'type' => 'credit',
|
||||
'balance' => bcsub($policy->limit_balance, $totalClaim),
|
||||
'description' => 'Log for Claim #'. $claim->code,
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
return $claim;
|
||||
} catch (\Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,12 @@ namespace Modules\Internal\Services;
|
||||
use App\Exceptions\ImportRowException;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\CorporateBenefit;
|
||||
use App\Models\Plan;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
|
||||
class CorporateService
|
||||
{
|
||||
{
|
||||
protected function validatePlanRow($row)
|
||||
{
|
||||
if (empty($row['service_code'])) {
|
||||
@@ -61,10 +62,10 @@ class CorporateService
|
||||
if (empty($row['plan_code'])) {
|
||||
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);
|
||||
}
|
||||
if (empty($row['code'])) {
|
||||
if (empty($row['corporate_benefit_code'])) {
|
||||
throw new ImportRowException(__('benefit.CUSTOMER_BENEFIT_CODE_REQUIRED'), 0, null, $row);
|
||||
}
|
||||
if (empty($row['description'])) {
|
||||
@@ -83,21 +84,35 @@ class CorporateService
|
||||
|
||||
public function handleBenefitRow(Corporate $corporate, $row)
|
||||
{
|
||||
|
||||
try {
|
||||
$benefit_data = $row;
|
||||
$benefit_data["corporate_id"] = $corporate->id;
|
||||
|
||||
$this->validateBenefitRow($benefit_data);
|
||||
|
||||
$plan = Benefit::updateOrCreate([
|
||||
'service_code' => $benefit_data['service_code'],
|
||||
'plan_code' => $benefit_data['plan_code'],
|
||||
'corporate_id' => $corporate->id,
|
||||
|
||||
$plan = Plan::where('corporate_plan_id', $benefit_data['plan_code'])->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'],
|
||||
'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);
|
||||
|
||||
return $plan;
|
||||
return $corporateBenefit;
|
||||
} catch (\Exception $e) {
|
||||
// dd($e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ class ExclusionService
|
||||
'service_code' => 'OP',
|
||||
'type' => 'diagnosis'
|
||||
]);
|
||||
|
||||
|
||||
if (!empty($excl_array[1])) { //msc
|
||||
$msc = explode(',', $excl_array[1]);
|
||||
collect($msc)->each(function($m) use ($exclusion) {
|
||||
collect($msc)->each(function ($m) use ($exclusion) {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'msc',
|
||||
'values' => $m
|
||||
@@ -44,11 +44,18 @@ class ExclusionService
|
||||
}
|
||||
if (!empty($excl_array[2])) { //genders
|
||||
$genders = explode(',', $excl_array[2]);
|
||||
collect($genders)->each(function($gender) use ($exclusion) {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => $gender
|
||||
]);
|
||||
collect($genders)->each(function ($gender) use ($exclusion) {
|
||||
if ($gender == 'M') {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => 'male'
|
||||
]);
|
||||
} else if ($gender == 'F') {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => 'female'
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!empty($excl_array[3])) { //min_age
|
||||
@@ -84,10 +91,10 @@ class ExclusionService
|
||||
'service_code' => 'OP',
|
||||
'type' => 'diagnosis'
|
||||
]);
|
||||
|
||||
|
||||
if (!empty($excl_array[1])) { //msc
|
||||
$msc = explode(',', $excl_array[1]);
|
||||
collect($msc)->each(function($m) use ($exclusion) {
|
||||
collect($msc)->each(function ($m) use ($exclusion) {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'msc',
|
||||
'values' => $m
|
||||
@@ -96,11 +103,18 @@ class ExclusionService
|
||||
}
|
||||
if (!empty($excl_array[2])) { //genders
|
||||
$genders = explode(',', $excl_array[2]);
|
||||
collect($genders)->each(function($gender) use ($exclusion) {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => $gender
|
||||
]);
|
||||
collect($genders)->each(function ($gender) use ($exclusion) {
|
||||
if ($gender == 'M') {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => 'male'
|
||||
]);
|
||||
} else if ($gender == 'F') {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => 'female'
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!empty($excl_array[3])) { //min_age
|
||||
@@ -133,10 +147,10 @@ class ExclusionService
|
||||
'service_code' => 'OP',
|
||||
'type' => 'diagnosis'
|
||||
]);
|
||||
|
||||
|
||||
if (!empty($excl_array[1])) { //msc
|
||||
$msc = explode(',', $excl_array[1]);
|
||||
collect($msc)->each(function($m) use ($exclusion) {
|
||||
collect($msc)->each(function ($m) use ($exclusion) {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'msc',
|
||||
'values' => $m
|
||||
@@ -145,11 +159,18 @@ class ExclusionService
|
||||
}
|
||||
if (!empty($excl_array[2])) { //genders
|
||||
$genders = explode(',', $excl_array[2]);
|
||||
collect($genders)->each(function($gender) use ($exclusion) {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => $gender
|
||||
]);
|
||||
collect($genders)->each(function ($gender) use ($exclusion) {
|
||||
if ($gender == 'M') {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => 'male'
|
||||
]);
|
||||
} else if ($gender == 'F') {
|
||||
$exclusion->rules()->create([
|
||||
'name' => 'gender',
|
||||
'values' => 'female'
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!empty($excl_array[3])) { //min_age
|
||||
@@ -177,7 +198,6 @@ class ExclusionService
|
||||
$excl_array = explode('|', $row['ma_exclusion']);
|
||||
dd($excl_array);
|
||||
if ($excl_array[0]) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +205,6 @@ class ExclusionService
|
||||
$excl_array = explode('|', $row['sp_exclusion']);
|
||||
dd($excl_array);
|
||||
if ($excl_array[0]) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +212,6 @@ class ExclusionService
|
||||
$excl_array = explode('|', $row['pre_exist_exclusion']);
|
||||
dd($excl_array);
|
||||
if ($excl_array[0]) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +219,6 @@ class ExclusionService
|
||||
$excl_array = explode('|', $row['op_de_exclusion']);
|
||||
dd($excl_array);
|
||||
if ($excl_array[0]) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +226,6 @@ class ExclusionService
|
||||
$excl_array = explode('|', $row['maternity_waiting']);
|
||||
dd($excl_array);
|
||||
if ($excl_array[0]) {
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\CorporateDivision;
|
||||
use App\Models\CorporatePlan;
|
||||
use App\Models\Member;
|
||||
use App\Models\MemberPolicy;
|
||||
use App\Models\Person;
|
||||
use App\Models\Plan;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Common\Entity\Row;
|
||||
@@ -361,8 +362,8 @@ class MemberEnrollmentService
|
||||
"nik" => $row['nik'] ?? null,
|
||||
"birth_date" => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||
"gender" => Helper::genderNormalization($row['sex']),
|
||||
"language" => $row['language'] ?? null,
|
||||
"race" => $row['race'] ?? null,
|
||||
// "language" => $row['language'] ?? null,
|
||||
// "race" => $row['race'] ?? null,
|
||||
"marital_status" => $row['marital_status'] ?? null,
|
||||
"record_type" => $row['record_type'] ?? null,
|
||||
"principal_id" => $row['principal_id'] ?? null,
|
||||
@@ -408,6 +409,20 @@ class MemberEnrollmentService
|
||||
|
||||
// Validate If Exist Member
|
||||
if ($member) {
|
||||
$person = Person::updateOrCreate(
|
||||
[
|
||||
'id' => $member->person_id
|
||||
],
|
||||
[
|
||||
'name' => $row['name'] ?? null,
|
||||
'birth_date' => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||
'gender' => Helper::genderPerson($row['sex']),
|
||||
'language' => $row['language'] ?? null,
|
||||
'race' => $row['race'] ?? null,
|
||||
]
|
||||
);
|
||||
$member->person_id = $person->id;
|
||||
$member->save();
|
||||
throw new ImportRowException(__('enrollment.MEMBER_UNIQUE', [
|
||||
'member_id' => $row['member_id'],
|
||||
'policy_id' => $row['policy_number']
|
||||
@@ -439,10 +454,22 @@ class MemberEnrollmentService
|
||||
|
||||
$this->validateRow($row);
|
||||
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$member->fill($member_data);
|
||||
if ($member->save()) {
|
||||
|
||||
$person = Person::create([
|
||||
'name' => $row['name'],
|
||||
'birth_date' => Carbon::parse(strtotime($row['date_of_birth'])),
|
||||
'gender' => Helper::genderPerson($row['sex']),
|
||||
'language' => $row['language'] ?? null,
|
||||
'race' => $row['race'] ?? null,
|
||||
]);
|
||||
$member->person_id = $person->id;
|
||||
$member->save();
|
||||
|
||||
$memberPolicy = new MemberPolicy();
|
||||
$memberPolicy->fill([
|
||||
'member_id' => $member->member_id,
|
||||
@@ -457,20 +484,10 @@ class MemberEnrollmentService
|
||||
$division_id = CorporateDivision::query()->where('code', $row['division_name'])->pluck('id')->first();
|
||||
|
||||
if (empty($division_id)) {
|
||||
$corporateCodeArray = explode(' ', $row['division_name']);
|
||||
|
||||
if (!empty($corporateCodeArray[1])) {
|
||||
$corporateCode = substr($corporateCodeArray[0], 0, 1) . substr($corporateCodeArray[1], 0, 1);
|
||||
} elseif (!empty($corporateCodeArray[2])) {
|
||||
$corporateCode = substr($corporateCodeArray[0], 0, 1) . substr($corporateCodeArray[1], 0, 1);
|
||||
} else {
|
||||
$corporateCode = substr($row['division_name'], 0, 1);
|
||||
}
|
||||
|
||||
$division = CorporateDivision::query()->create([
|
||||
$division = CorporateDivision::query()->updateOrCreate(['name' => $row['division_name'], 'code' => $row['division_name']], [
|
||||
'corporate_id' => $corporate->id,
|
||||
'name' => $row['division_name'],
|
||||
'code' => $corporateCode,
|
||||
'code' => $row['division_name'],
|
||||
]);
|
||||
|
||||
$division_id = $division->id;
|
||||
|
||||
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,7 +15,7 @@ class CorporateServiceConfigResource extends JsonResource
|
||||
public function toArray($request)
|
||||
{
|
||||
|
||||
return [
|
||||
$data = [
|
||||
'id' => $this->id,
|
||||
'corporate_id' => $this->corporate_id,
|
||||
'service_code' => $this->service_code,
|
||||
@@ -23,7 +23,75 @@ class CorporateServiceConfigResource extends JsonResource
|
||||
'name' => $this->service->name,
|
||||
'description' => $this->service->description,
|
||||
'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)
|
||||
{
|
||||
return [
|
||||
$data = [
|
||||
'id' => $this->id,
|
||||
'code' => $this->exclusionable->code,
|
||||
'name' => $this->exclusionable->name,
|
||||
@@ -25,5 +25,36 @@ class DiagnosisExclusionResource extends JsonResource
|
||||
return [$item['name'] => $item['values']];
|
||||
})
|
||||
];
|
||||
|
||||
$msc = explode(',', $this->rules->where('name', 'msc')->first()->values ?? '');
|
||||
$list_msc = [
|
||||
'm' => in_array('m', $msc),
|
||||
's' => in_array('s', $msc),
|
||||
'c' => in_array('c', $msc),
|
||||
];
|
||||
|
||||
$gender = explode(',', $this->rules->where('name', 'gender')->first()->values ?? '');
|
||||
$list_gender = [
|
||||
'male' => in_array('male', $gender),
|
||||
'female' => in_array('female', $gender),
|
||||
];
|
||||
|
||||
$min_age = $this->rules->where('name', 'min_age')->first()->values ?? '';
|
||||
$max_age = $this->rules->where('name', 'max_age')->first()->values ?? '';
|
||||
$plan = $this->rules->where('name', 'plan')->first()->values ?? '';
|
||||
|
||||
$value_plan = [
|
||||
'plan' => $plan,
|
||||
'gender' => $list_gender,
|
||||
'msc' => $list_msc,
|
||||
'min_age' => $min_age,
|
||||
'max_age' => $max_age,
|
||||
];
|
||||
|
||||
$data['value_rules'] = $value_plan;
|
||||
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
53
Modules/Internal/Transformers/DoctorResource.php
Normal file
53
Modules/Internal/Transformers/DoctorResource.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DoctorResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$doctor = [
|
||||
'id' => $this->id,
|
||||
// 'his_dokter_id' => $this->practitionerRoles->meta,
|
||||
'name' => $this->person->name,
|
||||
'person_id' => $this->person->id,
|
||||
'phone' => $this->person->phone,
|
||||
'email' => $this->person->email,
|
||||
'gender' => $this->person->gender == "L" ? 'Laki-laki' : 'Perempuan',
|
||||
'address' => $this->person->currentAddress->text,
|
||||
'organizations' => $this->practitionerRoles->unique('organization_id')->map(function ($practitionerRole) {
|
||||
return [
|
||||
'organization_id' => $practitionerRole->organization->id,
|
||||
'organization_name' => $practitionerRole->organization->name,
|
||||
];
|
||||
}),
|
||||
"specialties" => $this->practitionerRoles->unique('speciality_id')->map(function ($practitionerRole) {
|
||||
return [
|
||||
'specialty_id' => $practitionerRole->speciality->id,
|
||||
'specialty_name' => $practitionerRole->speciality->name,
|
||||
];
|
||||
}),
|
||||
"departemen" => $this->practitionerRoles->map(function ($practitionerRole) {
|
||||
return [
|
||||
'departemen_id' => $practitionerRole->meta->DepartemenID,
|
||||
];
|
||||
}),
|
||||
'education' => $this->meta->education,
|
||||
'experience' => $this->meta->work_experience,
|
||||
'award' => $this->meta->award,
|
||||
'keilmuan' => $this->meta->Keilmuan,
|
||||
'tipe_dokter' => $this->meta->tipeDokter,
|
||||
|
||||
];
|
||||
|
||||
return $doctor;
|
||||
}
|
||||
}
|
||||
32
Modules/Internal/Transformers/OrganizationResource.php
Normal file
32
Modules/Internal/Transformers/OrganizationResource.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class OrganizationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$organization = [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'code' => $this->code,
|
||||
'description' => $this->description,
|
||||
'kodeRs' => $this->meta->kodeRs ?? null,
|
||||
'phone' => $this->meta->phone ?? null,
|
||||
'lat' => $this->currentAddress->lat ?? null,
|
||||
'lng' => $this->currentAddress->lng ?? null,
|
||||
'address' => $this->currentAddress ?? null,
|
||||
];
|
||||
|
||||
return $organization;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Internal\\Providers\\InternalServiceProvider"
|
||||
"Modules\\Internal\\Providers\\InternalServiceProvider",
|
||||
"Modules\\Internal\\Providers\\EventServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"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
|
||||
{
|
||||
protected $data = null;
|
||||
|
||||
|
||||
public function __construct($message, $code = 0, Throwable $previous = null, $data)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
parent::__construct($message, (int)$code, $previous);
|
||||
$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)
|
||||
{
|
||||
return [
|
||||
@@ -35,6 +50,8 @@ class Helper
|
||||
'last_page_url' => '',
|
||||
'links' => $resource->links(null, $resource->items()),
|
||||
'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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
49
app/Http/Controllers/Api/OLDLMS/ClaimController.php
Normal file
49
app/Http/Controllers/Api/OLDLMS/ClaimController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\OLDLMS;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Member;
|
||||
use App\Services\ClaimService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'member_id' => 'required',
|
||||
'user_id' => 'required',
|
||||
'type' => 'required|in:consultation-gp,consultation-specialist,medicine',
|
||||
'total_claim' => 'required',
|
||||
'detail' => 'required',
|
||||
]);
|
||||
|
||||
if ($request->type == 'consultation-gp') {
|
||||
$benefitCode = 'OPCONS1';
|
||||
}
|
||||
if ($request->type == 'consultation-specialist') {
|
||||
$benefitCode = 'OPCONS2';
|
||||
}
|
||||
if ($request->type == 'medicine') {
|
||||
$benefitCode = 'OPMEDI1';
|
||||
}
|
||||
|
||||
$member = Member::query()
|
||||
->where('member_id', $request->member_id)
|
||||
->with([
|
||||
'currentPlan',
|
||||
])
|
||||
->firstOrFail();
|
||||
$benefit = $member->currentPlan->benefits()->where('code', $benefitCode)->first();
|
||||
// $diagnosis = Icd::first();
|
||||
|
||||
$claim = ClaimService::storeClaim($member, null, $request->total_claim, $benefit, 'requested');
|
||||
$claim->status = 'approved';
|
||||
$claim->save();
|
||||
|
||||
return Helper::responseJson($claim);
|
||||
}
|
||||
}
|
||||
219
app/Http/Controllers/Api/OLDLMS/MembershipController.php
Normal file
219
app/Http/Controllers/Api/OLDLMS/MembershipController.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\OLDLMS;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Member;
|
||||
use App\Services\ClaimService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MembershipController extends Controller
|
||||
{
|
||||
//
|
||||
public function check(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'member_id' => 'required',
|
||||
// 'birth_date' => 'required',
|
||||
]);
|
||||
|
||||
$member = Member::where('member_id', $request->member_id)->first();
|
||||
|
||||
if (!$member) {
|
||||
return Helper::responseJson(statusCode: 404, message: 'Member not found.', status: 'error');
|
||||
}
|
||||
|
||||
if (!$member->active) {
|
||||
return Helper::responseJson(statusCode: 406, message: 'The Member '.$request->member_id.' is Inactive.', status: 'error');
|
||||
}
|
||||
|
||||
return Helper::responseJson(data: $member, message: 'Member Found');
|
||||
}
|
||||
|
||||
public function checkLimit(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'member_id' => 'required',
|
||||
'type' => 'required|in:consultation-gp,consultation-specialist,medicine',
|
||||
// 'speciality_code' => 'sometimes'
|
||||
]);
|
||||
|
||||
if ($request->type == 'consultation-gp') {
|
||||
$benefitCode = 'OPCONS1';
|
||||
}
|
||||
if ($request->type == 'consultation-specialist') {
|
||||
$benefitCode = 'OPCONS2';
|
||||
}
|
||||
if ($request->type == 'medicine') {
|
||||
$benefitCode = 'OPMEDI1';
|
||||
}
|
||||
|
||||
$member = Member::where('member_id', $request->member_id)->with(['currentCorporate', 'currentPolicy', 'currentPlan', 'postponedClaims'])->first();
|
||||
|
||||
$limits = ClaimService::showMemberBenefitLimit($member, $benefitCode);
|
||||
$limits['postponed_claims'] = $member->postponedClaims;
|
||||
$limits['postponed_claims_payment_url'] = "http://google.com";
|
||||
$limits['postponed_claims_unpaid_total'] = $member->postponedClaims->sum('total_claim');
|
||||
|
||||
if ($request->has('speciality_code') && !empty($request->speciality_code)) {
|
||||
$corporateService = $member->currentCorporate
|
||||
->corporateServices()
|
||||
->active()
|
||||
->where('service_code', 'OP')
|
||||
->with([
|
||||
'specialities' => function ($speciality) use ($request) {
|
||||
$speciality->where('code', $request->speciality_code)
|
||||
->wherePivot('active', 1);
|
||||
}])
|
||||
->first();
|
||||
|
||||
// $rules = $corporateServiceConfigs->
|
||||
// dd($corporateServiceConfigs->toArray());
|
||||
if (empty($corporateService)) {
|
||||
$limit['coverage'] = [
|
||||
'benefit' => false,
|
||||
'admin_fee' => false,
|
||||
'delivery_fee' => false
|
||||
];
|
||||
|
||||
return Helper::responseJson(data: $limits);
|
||||
}
|
||||
|
||||
if (empty($corporateService->specialities)) {
|
||||
$limit['coverage'] = [
|
||||
'benefit' => false,
|
||||
'admin_fee' => false,
|
||||
'delivery_fee' => false
|
||||
];
|
||||
|
||||
return Helper::responseJson(data: $limits);
|
||||
}
|
||||
|
||||
$currentSpeciality = $corporateService->specialities->first();
|
||||
|
||||
// Load the Relation Data after speciality check is supported
|
||||
$corporateService->load([
|
||||
'configs',
|
||||
// 'configs.exclusions.rules',
|
||||
'corporateServiceSpecialities' => function ($corporateServiceSpeciality) use ($currentSpeciality) {
|
||||
$corporateServiceSpeciality->where('speciality_id', $currentSpeciality->id);
|
||||
},
|
||||
'corporateServiceSpecialities.exclusions' => function ($exclusion) {
|
||||
$exclusion->where('service_code', 'OP');
|
||||
},
|
||||
'corporateServiceSpecialities.exclusions.rules'
|
||||
]);
|
||||
|
||||
$configs = $corporateService->configs->mapWithKeys(function ($config) {
|
||||
return [$config->name => $config];
|
||||
});
|
||||
|
||||
$serviceSpeciality = $corporateService->corporateServiceSpecialities->first() ?? null;
|
||||
$serviceSpecialityRules = $serviceSpeciality->exclusions->first()->rules ?? collect([]);
|
||||
$serviceSpecialityRules = $serviceSpecialityRules->mapWithKeys(function ($rule) {
|
||||
return [$rule->name => $rule];
|
||||
});
|
||||
|
||||
$gpSpecialityName = config('aso.general_practitioner_speciality_name', 'Umum');
|
||||
// dd($serviceSpecialityRules->toArray());
|
||||
|
||||
$coverage = [
|
||||
'benefit' => false,
|
||||
'admin_fee' => false,
|
||||
'delivery_fee' => false
|
||||
];
|
||||
|
||||
// dd($configs->toArray());
|
||||
// dd($gpSpecialityName, $currentSpeciality->name);
|
||||
|
||||
if ($gpSpecialityName == $currentSpeciality->name) {
|
||||
// To General Practitioner
|
||||
if (($configs['gp_internal_doctor_online']['value'] ?? 1) == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
|
||||
if (($configs['general_practitioner_fee']['value'] ?? 1) == 1) {
|
||||
$coverage['admin_fee'] = true;
|
||||
}
|
||||
|
||||
if ($serviceSpeciality->active == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
// To Specialist
|
||||
if (($configs['sp_internal_doctor_online']['value'] ?? 1) == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
// dd($configs['specialist_practitioner_fee']['value'], $configs['specialist_practitioner_fee']['value'] ?? 1, ($configs['specialist_practitioner_fee']['value'] ?? 1) == 1);
|
||||
|
||||
if (($configs['specialist_practitioner_fee']['value'] ?? 1) == 1) {
|
||||
$coverage['admin_fee'] = true;
|
||||
}
|
||||
|
||||
if ($serviceSpeciality->active == 1) {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO THIS EXCLUSION IS USED AS INCLUSION NOW, MUST BE CHANGE TO USED AS EXCLUSION AND MAYBE MOVE THE TABLE
|
||||
$excluded = [];
|
||||
foreach ($serviceSpecialityRules as $ruleName => $rule) {
|
||||
if ($ruleName == 'msc') {
|
||||
$values = explode(',', $rule->values);
|
||||
if (!in_array(strtolower($member->marital_status), $values)) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'gender') {
|
||||
$values = explode(',', $rule->values);
|
||||
if (!in_array(strtolower($member->gender), $values)) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'min_age') {
|
||||
if (!empty($rule->values) && $member->age < $rule->values) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'max_age') {
|
||||
if (!empty($rule->values) && $member->age > $rule->values) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ruleName == 'plan') {
|
||||
$values = explode(',', $rule->values);
|
||||
if (!in_array($member->currentPlan->code, $values)) {
|
||||
$excluded[] = $rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($excluded) ) {
|
||||
$coverage['benefit'] = false;
|
||||
$coverage['benefit_exclusion'] = $excluded;
|
||||
} else {
|
||||
$coverage['benefit'] = true;
|
||||
}
|
||||
|
||||
|
||||
$limits['coverage'] = $coverage;
|
||||
} else {
|
||||
|
||||
$limits['coverage'] = [
|
||||
'benefit' => true,
|
||||
'admin_fee' => true,
|
||||
'delivery_fee' => true
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
return Helper::responseJson(data: $limits);
|
||||
}
|
||||
}
|
||||
@@ -64,5 +64,6 @@ class Kernel extends HttpKernel
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
'linksehat.old.auth' => \App\Http\Middleware\LinksehatOldAuthMiddleware::class,
|
||||
];
|
||||
}
|
||||
|
||||
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_end',
|
||||
];
|
||||
|
||||
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function addressable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
|
||||
@@ -12,141 +12,12 @@ class Benefit extends Model
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'service_code',
|
||||
'plan_code',
|
||||
'benefit_code',
|
||||
'code',
|
||||
'description',
|
||||
'budget',
|
||||
'budget_conditions',
|
||||
'budget_code',
|
||||
'primary_benefit_code',
|
||||
'benefit_mode',
|
||||
'room_class_coverage',
|
||||
'max_bed_coverage',
|
||||
'tolerance_parameter',
|
||||
'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'
|
||||
];
|
||||
|
||||
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)
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
@@ -159,13 +30,17 @@ class Benefit extends Model
|
||||
});
|
||||
}
|
||||
|
||||
public function benefit()
|
||||
{
|
||||
return $this->belongsTo(Benefit::class, 'benefit_code', 'code');
|
||||
}
|
||||
// public function benefit()
|
||||
// {
|
||||
// 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,30 @@
|
||||
|
||||
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\Model;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Claim extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'code',
|
||||
'member_id',
|
||||
'diagnosis_id',
|
||||
'total_claim',
|
||||
'currency',
|
||||
'plan_id',
|
||||
'benefit_id',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -34,6 +42,7 @@ class Claim extends Model
|
||||
'requested' => 'Requested',
|
||||
'received' => 'Received',
|
||||
'approved' => 'Approved',
|
||||
'postpone' => 'Postpone',
|
||||
'paid' => 'Paid',
|
||||
'declined' => 'Declined'
|
||||
];
|
||||
@@ -49,6 +58,55 @@ class Claim extends Model
|
||||
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()
|
||||
@@ -56,9 +114,19 @@ class Claim extends Model
|
||||
return $this->belongsTo(Member::class, 'member_id');
|
||||
}
|
||||
|
||||
public function diagnoses()
|
||||
{
|
||||
return $this->hasMany(ClaimDiagnosis::class, 'claim_id');
|
||||
}
|
||||
|
||||
// TODO Remove this !, Sementara
|
||||
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()
|
||||
@@ -71,11 +139,16 @@ class Claim extends Model
|
||||
return $this->belongsTo(Benefit::class, 'benefit_id');
|
||||
}
|
||||
|
||||
public function statusHistories()
|
||||
{
|
||||
return $this->morphMany(StatusHistory::class, 'statusable');
|
||||
}
|
||||
|
||||
public function scopeUsed($query, $startDate, $endDate)
|
||||
{
|
||||
return $query
|
||||
->whereIn('status', ['approved', 'paid'])
|
||||
->whereBetween('requested_at', $startDate, $endDate);
|
||||
->whereIn('status', ['approved', 'paid']);
|
||||
// ->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',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'avatar_url',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function imports()
|
||||
{
|
||||
return $this->morphMany(ImportLog::class, 'importable');
|
||||
@@ -36,6 +49,21 @@ class Corporate extends Model
|
||||
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()
|
||||
{
|
||||
return $this->hasMany(CorporatePolicy::class);
|
||||
@@ -77,6 +105,8 @@ class Corporate extends Model
|
||||
]);
|
||||
}
|
||||
|
||||
// public function
|
||||
|
||||
public function importLogs()
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
// public function claims()
|
||||
// {
|
||||
// return $this->hasManyThrough()
|
||||
// }
|
||||
|
||||
public function corporateServices()
|
||||
{
|
||||
return $this->hasMany(CorporateService::class, 'corporate_id');
|
||||
|
||||
@@ -13,23 +13,220 @@ class CorporateBenefit extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'code',
|
||||
'name',
|
||||
'description',
|
||||
'plan_id',
|
||||
'benefit_id',
|
||||
'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',
|
||||
];
|
||||
|
||||
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()
|
||||
{
|
||||
return $this->belongsTo(Corporate::class);
|
||||
}
|
||||
|
||||
public function plan()
|
||||
{
|
||||
return $this->belongsTo(Plan::class);
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
return $query
|
||||
->where('code', 'like', "%" . $search . "%")
|
||||
->orWhere('name', 'like', "%" . $search . "%");
|
||||
->whereHas('benefit', function ($query) use ($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 . "%");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ class CorporatePlan extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes, Blameable;
|
||||
|
||||
protected $table = 'plans';
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'code',
|
||||
@@ -28,8 +30,8 @@ class CorporatePlan extends Model
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
return $query
|
||||
->where('code', 'like', "%" . $search . "%")
|
||||
->orWhere('name', 'like', "%" . $search . "%");
|
||||
->where('code', 'like', "%" . $search . "%")
|
||||
->orWhere('name', 'like', "%" . $search . "%");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,15 @@ class CorporatePolicy extends Model
|
||||
'end',
|
||||
'active',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'latestLimitJournal'
|
||||
|
||||
@@ -17,6 +17,15 @@ class CorporateService extends Model
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function corporate()
|
||||
{
|
||||
return $this->belongsTo(Corporate::class);
|
||||
@@ -33,10 +42,20 @@ class CorporateService extends Model
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
public function scopeActive($query) {
|
||||
$query->where('status', 'active');
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
{
|
||||
if (!empty($filters['search'])) {
|
||||
|
||||
@@ -16,9 +16,23 @@ class CorporateServiceConfig extends Model
|
||||
'name',
|
||||
'value'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function corporateService()
|
||||
{
|
||||
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 = [
|
||||
'corporate_service_id',
|
||||
'speciality_id',
|
||||
'status'
|
||||
'active'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function corporateService()
|
||||
@@ -31,4 +40,9 @@ class CorporateServiceSpeciality extends Model
|
||||
{
|
||||
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_type',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,15 @@ class ExclusionRules extends Model
|
||||
'name',
|
||||
'values',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function exclusion()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,15 @@ class LimitJournal extends Model
|
||||
'balance',
|
||||
'description',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function journalable()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ class Member extends Model
|
||||
|
||||
protected $fillable = [
|
||||
"id",
|
||||
"person_id",
|
||||
"member_id",
|
||||
"record_type",
|
||||
"payor_id",
|
||||
@@ -61,7 +62,6 @@ class Member extends Model
|
||||
'full_name',
|
||||
'age',
|
||||
'gender_code',
|
||||
''
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@@ -78,6 +78,16 @@ class Member extends Model
|
||||
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()
|
||||
{
|
||||
return $this->hasMany(CorporateEmployee::class, 'member_id');
|
||||
@@ -99,17 +109,24 @@ class Member extends Model
|
||||
|
||||
public function currentCorporate()
|
||||
{
|
||||
return $this->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
|
||||
// ->withPivot([
|
||||
// 'branch_code',
|
||||
// 'divison_id',
|
||||
// 'nik',
|
||||
// 'status',
|
||||
// 'start',
|
||||
// 'end'
|
||||
// ])
|
||||
->where('start', '<', now())
|
||||
->where('end', '>', now());
|
||||
// return $this->belongsToMany(Corporate::class, 'corporate_employees', 'corporate_id', 'member_id')
|
||||
// // ->withPivot([
|
||||
// // 'branch_code',
|
||||
// // 'divison_id',
|
||||
// // 'nik',
|
||||
// // 'status',
|
||||
// // 'start',
|
||||
// // 'end'
|
||||
// // ])
|
||||
// ->where('start', '<', now())
|
||||
// ->where('end', '>', now());
|
||||
|
||||
|
||||
return $this->hasOneThrough(Corporate::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'corporate_id');
|
||||
// ->where('corporate_policies.start', '<', now())
|
||||
// ->where('corporate_policies.end', '>', now())
|
||||
// ->where('member_policies.start', '<', now())
|
||||
// ->where('member_policies.end', '>', now());
|
||||
}
|
||||
|
||||
public function memberPlans()
|
||||
@@ -153,13 +170,16 @@ class Member extends Model
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
$arr = [];
|
||||
if (!empty($this->name_prefix)) {
|
||||
$arr[] = $this->name_prefix;
|
||||
if (!$this->person) {
|
||||
return null;
|
||||
}
|
||||
$arr[] = $this->name;
|
||||
if (!empty($this->name_suffix)) {
|
||||
$arr[] = $this->name_suffix;
|
||||
$arr = [];
|
||||
if (!empty($this->person->name_prefix)) {
|
||||
$arr[] = $this->person->name_prefix;
|
||||
}
|
||||
$arr[] = $this->person->name;
|
||||
if (!empty($this->person->name_suffix)) {
|
||||
$arr[] = $this->person->name_suffix;
|
||||
}
|
||||
|
||||
return implode(' ', $arr);
|
||||
@@ -170,24 +190,41 @@ class Member extends Model
|
||||
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)
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
return $query
|
||||
->where('member_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) {
|
||||
// $query->where('code', 'like', "%" . $search . "%");
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
// public function corporateEmployee()
|
||||
// {
|
||||
// return $this->hasOne(CorporateEmployee::class, 'member_id');
|
||||
// }
|
||||
|
||||
public function division()
|
||||
{
|
||||
return $this->hasOneThrough(CorporateDivision::class, CorporateEmployee::class, 'member_id', 'id', 'id', 'division_id');
|
||||
|
||||
25
app/Models/OLDLMS/Appointment.php
Normal file
25
app/Models/OLDLMS/Appointment.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Appointment extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_appointment';
|
||||
|
||||
public function detail()
|
||||
{
|
||||
return $this->hasOne(AppointmentDetail::class, '');
|
||||
}
|
||||
}
|
||||
11
app/Models/OLDLMS/AppointmentDetail.php
Normal file
11
app/Models/OLDLMS/AppointmentDetail.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AppointmentDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/OLDLMS/Healthcare.php
Normal file
11
app/Models/OLDLMS/Healthcare.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Healthcare extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/OLDLMS/Insurance.php
Normal file
11
app/Models/OLDLMS/Insurance.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Insurance extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/OLDLMS/User.php
Normal file
11
app/Models/OLDLMS/User.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/OLDLMS/UserDetail.php
Normal file
11
app/Models/OLDLMS/UserDetail.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/OLDLMS/UserInsurance.php
Normal file
11
app/Models/OLDLMS/UserInsurance.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserInsurance extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
11
app/Models/OLDLMS/UserInsuranceDetail.php
Normal file
11
app/Models/OLDLMS/UserInsuranceDetail.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserInsuranceDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -24,9 +24,18 @@ class Organization extends Model
|
||||
// 'metas'
|
||||
// ];
|
||||
|
||||
// public $appends = [
|
||||
// 'meta'
|
||||
// ];
|
||||
public $appends = [
|
||||
'meta'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* Scope a query to only include active data.
|
||||
|
||||
@@ -22,6 +22,8 @@ class Person extends Model
|
||||
'gender',
|
||||
'birth_date',
|
||||
'birth_place',
|
||||
'language',
|
||||
'race',
|
||||
'citizenship',
|
||||
'current_employment',
|
||||
'last_education',
|
||||
@@ -38,6 +40,15 @@ class Person extends Model
|
||||
'updated_by',
|
||||
'deleted_by'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
@@ -107,4 +118,27 @@ class Person extends Model
|
||||
{
|
||||
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;
|
||||
|
||||
protected $table = "plans";
|
||||
|
||||
protected $fillable = [
|
||||
"service_code",
|
||||
"corporate_id",
|
||||
@@ -62,6 +64,15 @@ class Plan extends Model
|
||||
"max_surgery_reinstatement_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 = [
|
||||
"Service" => "service_code",
|
||||
@@ -138,7 +149,7 @@ class Plan extends Model
|
||||
{
|
||||
$this->attributes['max_surgery_reinstatement_days'] = empty($value) ? null : $value;
|
||||
}
|
||||
|
||||
|
||||
public function setMaxSurgeryPeriodeDaysAttribute($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) {
|
||||
return $query
|
||||
->where('service_code', 'like', "%" . $search . "%")
|
||||
->orWhere('code', 'like', "%" . $search . "%")
|
||||
->orWhereHas('corporatePlan', function ($query) use ($search) {
|
||||
$query->where('code', 'like', "%" . $search . "%");
|
||||
});
|
||||
->where('service_code', 'like', "%" . $search . "%")
|
||||
->orWhere('code', 'like', "%" . $search . "%")
|
||||
->orWhereHas('corporatePlan', function ($query) use ($search) {
|
||||
$query->where('code', 'like', "%" . $search . "%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,6 +179,15 @@ class Plan extends Model
|
||||
|
||||
public function benefits()
|
||||
{
|
||||
return $this->hasMany(Benefit::class, 'plan_code', 'id');
|
||||
return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'plan_id', 'id')
|
||||
->withTimestamps()
|
||||
->withPivot([
|
||||
// TODO corporate_benefits pivot
|
||||
]);
|
||||
}
|
||||
|
||||
public function corporateBenefits()
|
||||
{
|
||||
return $this->hasMany(CorporateBenefit::class, 'plan_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,21 @@ class PractitionerRole extends Model
|
||||
'active',
|
||||
];
|
||||
|
||||
public $appends = [
|
||||
'meta'
|
||||
];
|
||||
|
||||
public function getMetaAttribute()
|
||||
{
|
||||
$orgMeta = [];
|
||||
foreach ($this->metas as $meta) {
|
||||
$orgMeta[$meta->type] = $meta->value;
|
||||
}
|
||||
|
||||
return (object) $orgMeta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scope a query to only include active data.
|
||||
*
|
||||
|
||||
16
app/Models/StatusHistory.php
Normal file
16
app/Models/StatusHistory.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class StatusHistory extends Model
|
||||
{
|
||||
use HasFactory, Blameable;
|
||||
|
||||
protected $fillable = [
|
||||
'status'
|
||||
];
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Str;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -25,5 +26,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
Str::macro('initials', fn($value, $sep = ' ', $glue = '') => trim(collect(explode($sep, $value))->map(function ($segment) {
|
||||
return $segment[0] ?? '';
|
||||
})->join($glue)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Events\ClaimApproved;
|
||||
use App\Listeners\LogClaimJournal;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
@@ -18,6 +20,10 @@ class EventServiceProvider extends ServiceProvider
|
||||
Registered::class => [
|
||||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
|
||||
ClaimApproved::class => [
|
||||
LogClaimJournal::class,
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,31 +2,16 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Events\ClaimApproved;
|
||||
use App\Models\Claim;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Member;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Str;
|
||||
|
||||
class ClaimService{
|
||||
|
||||
public function storeClaim($member, $icd, $benefit, $totalClaim)
|
||||
{
|
||||
$claim = Claim::create([
|
||||
'code' => Str::random('16'),
|
||||
'member_id' => $member->id,
|
||||
'diagnosis_id' => $icd,
|
||||
'total_claim' => $totalClaim,
|
||||
'currency' => 'IDR',
|
||||
'plan_id' => $member->currentPlan->id,
|
||||
'benefit_id' => $benefit->id,
|
||||
]);
|
||||
|
||||
$corporate = $member->asd;
|
||||
|
||||
return $claim;
|
||||
}
|
||||
|
||||
public static function getMemberTotalUsage(Member $member, $startDate = null, $endDate = null)
|
||||
{
|
||||
$startDate = empty($startDate) ? Carbon::now()->startOfMonth() : $startDate;
|
||||
@@ -41,4 +26,182 @@ class ClaimService{
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public static function checkMemberEligibility($member, $benefit, $diagnosis, $totalClaim = 0)
|
||||
{
|
||||
$currentPlan = $member->currentPlan;
|
||||
$policy = $member->currentPolicy;
|
||||
$corporate = $policy->corporate;
|
||||
|
||||
|
||||
$isEligible = true;
|
||||
$validationErrors = [];
|
||||
|
||||
// Eligibility Validation
|
||||
|
||||
if (!in_array($member->marital_status, explode(',', $benefit->msc))) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'msc',
|
||||
'message' => 'Only '.$benefit->msc
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (!in_array($member->gender_code, explode(',', $benefit->genders))) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'genders',
|
||||
'message' => 'Only '.$benefit->genders
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (!empty($benefit->min_age) && $member->age < $benefit->min_age) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'min_age',
|
||||
'message' => 'Minimum Age is '.$benefit->min_age
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (!empty($benefit->max_age) && $member->age > $benefit->max_age) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'max_age',
|
||||
'message' => 'Maximum Age is '.$benefit->min_age
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
// TODO complete validations
|
||||
|
||||
// Limit Validation
|
||||
if ($totalClaim > 0) {
|
||||
if (bcsub($corporate->limit_balance, $totalClaim) < 0) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'corporate_limit',
|
||||
'message' => 'Corporate Limit cannot cover this'
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
if (bcsub($benefit->limit_amount, $totalClaim) < 0) {
|
||||
$validationErrors[] = [
|
||||
'error' => 'benefit_limit',
|
||||
'message' => 'Benefit Limit cannot cover this'
|
||||
];
|
||||
$isEligible = false;
|
||||
}
|
||||
|
||||
// TODO complete validations
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
'isEligible' => $isEligible,
|
||||
'errors' => $validationErrors
|
||||
];
|
||||
}
|
||||
|
||||
public static function getMemberUsageByBenefitLimit($member, $benefit)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function showMemberBenefitLimit($member, $benefit_code)
|
||||
{
|
||||
// $plan = $member->currentPlan;
|
||||
// $policy = $member->currentPolicy;
|
||||
// $corporate = $member->currentCorporate;
|
||||
$benefit = $member->currentPlan->benefits()->where('code', $benefit_code)->first();
|
||||
$corporateBenefit = $member->currentPlan->corporateBenefits()->where('benefit_id', $benefit->id)->first();
|
||||
|
||||
// dd($benefit->toArray());
|
||||
// dd(compact(['plan', 'policy', 'corporate', 'benefit']));
|
||||
$limits = [
|
||||
'total_limit' => $corporateBenefit ? $corporateBenefit->limit_amount : 0,
|
||||
'frequency_limit_name' => $corporateBenefit ? $corporateBenefit->max_frequency_period_name : null,
|
||||
'frequency_limit' => $corporateBenefit ? $corporateBenefit->max_frequency : 0,
|
||||
'total_claim' => 0,
|
||||
'remaining_limit' => $corporateBenefit ? $corporateBenefit->limit_amount : 0,
|
||||
'usage_daily' => null,
|
||||
'usage_weekly' => null,
|
||||
'usage_monthly' => null,
|
||||
'usage_yearly' => null
|
||||
];
|
||||
|
||||
switch ($corporateBenefit->max_frequency_period) {
|
||||
case(0) :
|
||||
$limits['usage_yearly'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->count();
|
||||
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->sum('total_claim');
|
||||
break;
|
||||
case(1) :
|
||||
$limits['usage_daily'] = $member->claims()->used(now()->format('Y-m-d'), now()->addDay(1)->format('Y-m-d'))->count();
|
||||
$limits['total_claim'] = $member->claims()->used(now()->format('Y-m-d'), now()->addDay(1)->format('Y-m-d'))->sum('total_claim');
|
||||
break;
|
||||
case(2) :
|
||||
$limits['usage_weekly'] = $member->claims()->used(Carbon::parse('Previous Sunday'), now())->count();
|
||||
$limits['total_claim'] = $member->claims()->used(Carbon::parse('Previous Sunday'), now())->sum('total_claim');
|
||||
break;
|
||||
case(3) :
|
||||
$limits['usage_monthly'] = $member->claims()->used(Carbon::now()->firstOfMonth(), now())->count();
|
||||
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfMonth(), now())->sum('total_claim');
|
||||
break;
|
||||
case(4) :
|
||||
$limits['usage_yearly'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->count();
|
||||
$limits['total_claim'] = $member->claims()->used(Carbon::now()->firstOfYear(), now())->sum('total_claim');
|
||||
break;
|
||||
default :
|
||||
// return null;
|
||||
break;
|
||||
}
|
||||
$limits['remaining_limit'] = $corporateBenefit->limit_amount - $limits['total_claim'];
|
||||
|
||||
return $limits;
|
||||
}
|
||||
|
||||
public static function storeClaim($member, $diagnosis, $totalClaim, $benefit, $status)
|
||||
{
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$claimData = [
|
||||
'member_id' => $member->id,
|
||||
'diagnosis_id' => $diagnosis->id ?? null,
|
||||
'total_claim' => $totalClaim,
|
||||
'currency' => 'IDR',
|
||||
'plan_id' => $member->currentPlan->id,
|
||||
'benefit_id' => $benefit->id,
|
||||
'status' => $status
|
||||
];
|
||||
// $claimData[$status.'_at'] = now();
|
||||
// $claimData[$status.'_by'] = auth()->user()->id ?? null;
|
||||
|
||||
$claim = Claim::create($claimData);
|
||||
|
||||
DB::commit();
|
||||
return $claim;
|
||||
} catch (\Exception $error) {
|
||||
DB::rollBack();
|
||||
|
||||
throw new \Exception($error);
|
||||
}
|
||||
}
|
||||
|
||||
// public static function claimApprove(Claim $claim)
|
||||
// {
|
||||
// if (!in_array($claim->status, ['approved', 'paid', 'declined'])) {
|
||||
|
||||
// // Only Update Claim is not approved yet
|
||||
// if (empty($claim->approved_at)) {
|
||||
// $claim->approved_at = now();
|
||||
// $claim->status = 'approved';
|
||||
|
||||
// $claim->save();
|
||||
|
||||
// ClaimApproved::dispatch($claim);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
222
app/Services/DoctorService.php
Normal file
222
app/Services/DoctorService.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Person;
|
||||
use App\Models\Practitioner;
|
||||
use App\Models\PractitionerRole;
|
||||
use App\Models\Speciality;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
|
||||
class DoctorService
|
||||
{
|
||||
public function getData()
|
||||
{
|
||||
$mapSpecialities = [
|
||||
'Akupunktur' => 'SP027',
|
||||
'Anak' => 'SP001',
|
||||
'Andrologi' => 'SP029',
|
||||
'Anastesia' => 'SP015',
|
||||
'Bedah Anak' => '',
|
||||
'Bedah Digestif' => '',
|
||||
'Bedah Mulut' => '',
|
||||
'Bedah Onkologi' => '',
|
||||
'Bedah Orthopedi' => 'SP007',
|
||||
'Bedah Plastik & Rekonstruksi' => 'SP005',
|
||||
'Bedah Saraf' => '',
|
||||
'Bedah Thorak & Kardiovaskuler' => '',
|
||||
'Bedah Umum' => 'SP004',
|
||||
'Bedah Vaskuler' => '',
|
||||
'Dokter Gigi' => 'SP026',
|
||||
'Fisik & Rehabilitasi' => 'SP014',
|
||||
'Gastroenterologi Hepatologi' => '',
|
||||
'Ginjal Hipertensi' => '',
|
||||
'Gizi Klinik' => 'SP019',
|
||||
'Hematologi Onkologi' => '',
|
||||
'Jantung & Pembuluh Darah' => 'SP008',
|
||||
'Kardio Vaskuler' => '',
|
||||
'Kebidanan & Kandungan' => 'SP003',
|
||||
'Kesehatan Jiwa' => 'SP018',
|
||||
'Kulit & Kelamin' => 'SP013',
|
||||
'Laboratorium' => '',
|
||||
'Mata' => 'SP011',
|
||||
'Okupasi' => 'SP016',
|
||||
'Paru' => 'SP009',
|
||||
'Patologi Klinik' => 'SP021',
|
||||
'Penyakit Dalam' => 'SP002',
|
||||
'Psikologi' => 'SP042',
|
||||
'Radiologi' => 'SP020',
|
||||
'Rehabilitasi Medik' => 'SP039',
|
||||
'Rheumatologi' => '',
|
||||
'Saraf' => 'SP012',
|
||||
'THT' => 'SP010',
|
||||
'Umum' => 'SP025',
|
||||
'Urologi' => 'SP006',
|
||||
'Lain-Lain' => '',
|
||||
];
|
||||
|
||||
$organizations = Organization::query()
|
||||
->whereHas('metas', function ($meta) {
|
||||
$meta->where('type', 'KodeRS');
|
||||
})
|
||||
->with('metas')
|
||||
->get();
|
||||
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||
foreach ($organizations as $organization) {
|
||||
|
||||
$hisOrganizationCode = $organization->meta->KodeRS ?? null;
|
||||
|
||||
if (empty($hisOrganizationCode)) {
|
||||
$this->command->warn('NO ORGANIZATION CODE' . $organization->name);
|
||||
continue;
|
||||
}
|
||||
$primayaApiService = new PrimayaApi($hisOrganizationCode);
|
||||
|
||||
$this->command->info('Getting RS ' . $hisOrganizationCode . '-' . $organization->name . ' PractitionerRole');
|
||||
|
||||
try {
|
||||
$doctors = $primayaApiService->doctors();
|
||||
$this->processDoctors($doctors, $mapSpecialities, $organization, $specialities);
|
||||
} catch (Exception $e) {
|
||||
$this->command->warn('Something Went Wrong :' . $hisOrganizationCode . ' - ' . $organization->name . ' - ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function processDoctors($doctors, $mapSpecialities, $organization, $specialities)
|
||||
{
|
||||
// foreach ($doctors['data'] as $doctor) {
|
||||
|
||||
// }
|
||||
|
||||
$organizations = Organization::query()
|
||||
->whereHas('metas', function ($meta) {
|
||||
$meta->where('type', 'KodeRS');
|
||||
})
|
||||
->with('metas')
|
||||
->get();
|
||||
$specialities = Speciality::pluck('id', 'name')->toArray();
|
||||
|
||||
foreach ($organizations as $organization) {
|
||||
$response = Http::get('https://app.primaya.id/temp/practitioners?code=' . $organization->meta->KodeRS);
|
||||
|
||||
foreach ($response->json()['practitioners'] as $practitioner) {
|
||||
$practitioner = json_decode(json_encode($practitioner));
|
||||
|
||||
dd($practitioner);
|
||||
if (!empty($practitioner->meta->NIK)) {
|
||||
$newPerson = Person::updateOrCreate([
|
||||
'nik' => $practitioner->meta->NIK
|
||||
], [
|
||||
'nik' => $practitioner->meta->NIK,
|
||||
'name' => $practitioner->doctor->name,
|
||||
'gender' => $practitioner->doctor->gender,
|
||||
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||
]);
|
||||
} else {
|
||||
$newPerson = Person::create([
|
||||
'name' => $practitioner->doctor->name,
|
||||
'gender' => $practitioner->doctor->gender,
|
||||
'birth_date' => !empty($practitioner->meta->TanggalLahir) && $practitioner->meta->TanggalLahir != '0000-00-00' ? $practitioner->meta->TanggalLahir : null,
|
||||
]);
|
||||
}
|
||||
$newPerson->addresses()->create([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $practitioner->doctor->address,
|
||||
]);
|
||||
|
||||
$newPractitioner = Practitioner::updateOrCreate([
|
||||
'person_id' => $newPerson->id
|
||||
], [
|
||||
'person_id' => $newPerson->id
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'medical_treatment',
|
||||
'value' => $practitioner->doctor->meta->MedicalTreatment ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'education',
|
||||
'value' => $practitioner->doctor->meta->Education ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'award',
|
||||
'value' => $practitioner->doctor->meta->Award ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'work_experience',
|
||||
'value' => $practitioner->doctor->meta->WorkExperience ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'alias',
|
||||
'value' => $practitioner->meta->Sapaan ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'Keilmuan',
|
||||
'value' => $practitioner->meta->Keilmuan ?? null,
|
||||
]);
|
||||
$newPractitioner->metas()->create([
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'description',
|
||||
'value' => $practitioner->doctor->description ?? null,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
$newPractitionerRole = PractitionerRole::create([
|
||||
'practitioner_id' => $newPractitioner->id,
|
||||
'organization_id' => $organization->id,
|
||||
'speciality_id' => $practitioner->speciality ? ($specialities[$practitioner->speciality->name] ?? null) : null,
|
||||
'active' => 1,
|
||||
]);
|
||||
|
||||
if (empty($newPractitionerRole->speciality_id)) {
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_code',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality_code',
|
||||
'value' => $practitioner->speciality->code ?? null,
|
||||
]);
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality',
|
||||
'value' => $practitioner->speciality->name ?? null,
|
||||
]);
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'speciality_image',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'speciality_image',
|
||||
'value' => $practitioner->speciality->name ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
$newPractitionerRole->metas()->updateOrCreate([
|
||||
'type' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
], [
|
||||
'system' => 'primaya-his',
|
||||
'type' => 'DokterID',
|
||||
'value' => $practitioner->meta->DokterID ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
app/Services/PrimayaApi.php
Normal file
123
app/Services/PrimayaApi.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Mockery\Generator\Parameter;
|
||||
use Psy\CodeCleaner\FunctionContextPass;
|
||||
use Termwind\Components\Dd;
|
||||
|
||||
class PrimayaApi
|
||||
{
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
* @param string $KodeRS C,DE,...
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $KodeRS)
|
||||
{
|
||||
// TODO Feels Wrong
|
||||
$endpointMaps = [
|
||||
"C" => [
|
||||
"base_url" => "http://tgr.primaya.id:1234",
|
||||
"token" => "1|QGYpSbyi9snAj1bHl1lP6apLJxbl20gsAoPmu1oh",
|
||||
],
|
||||
"D" => [
|
||||
"base_url" => "http://primaya-hospital.com:38588",
|
||||
"token" => "1|nbVbBmNmm967qYs9dNA0JvFNGvArGFGwFHJ8C9nK",
|
||||
],
|
||||
"E" => [
|
||||
"base_url" => "http://evasari.fortiddns.com:9280",
|
||||
"token" => "1|qb17AM6BB5sw1a3vZ2BTfIHXbPisqLSBdhwZKGJv",
|
||||
],
|
||||
"F" => [
|
||||
"base_url" => "http://mks.primaya.id:2588",
|
||||
"token" => null,
|
||||
],
|
||||
"M" => [ // Bektim
|
||||
"base_url" => 'http://101.255.124.84',
|
||||
"token" => null,
|
||||
],
|
||||
"O" => [
|
||||
"base_url" => "http://rsinco.fortiddns.com:88",
|
||||
"token" => "1|7e64N6gfSxsBic7DgwVec6EKQAIAx9Dd7is7K5Db",
|
||||
],
|
||||
"P" => [
|
||||
"base_url" => "http://bekut.primaya.id:88",
|
||||
"token" => "1|N5s4oKJNRnrpA2lneFI5LBhGNq6xwioY6PKDIA10",
|
||||
],
|
||||
"Q" => [
|
||||
"base_url" => "http://krw.primaya.id:4040",
|
||||
"token" => "1|zyS7AbeqzwKavfXFu0ReQOn5npIjdzVqA0pMqaMt",
|
||||
],
|
||||
"N" => [
|
||||
"base_url" => "http://pky.primaya.id:88",
|
||||
"token" => "1|yiajZEyu7pBkJNacv60tmb6McimbakG5lGzhm1Oy",
|
||||
],
|
||||
"SG" => [
|
||||
"base_url" => "http://smg.primaya.id:4040",
|
||||
"token" => "1|2lXZqpzhofXA2IjPdL7z52iBRiqrK5Eio924hMxi",
|
||||
],
|
||||
"BW" => [
|
||||
"base_url" => "http://bwp.primaya.id:4040",
|
||||
"token" => "1|8I6mdDxSUO0019GbbVx6olcACjaklxLUgmg0zUKh",
|
||||
],
|
||||
"SK" => [
|
||||
"base_url" => "http://skb.primaya.id:4040",
|
||||
"token" => "1|nYXzAvDbTceumUIDCr9sqXzj2Hq1kvfjYWeVg60P",
|
||||
],
|
||||
"PK" => [
|
||||
"base_url" => "http://pkt.primaya.id:4040",
|
||||
"token" => "2|nvIdQ7gzJnB7xQhfdjxlkr3oRSqBIvBOunjj72QO",
|
||||
],
|
||||
"CK" => [
|
||||
"base_url" => "http://103.154.92.150:4040",
|
||||
"token" => "1|BEKJwPhrmyjGwYVbl6xARV2auLSMtgYJyP4E3Kgd",
|
||||
],
|
||||
"DE" => [
|
||||
"base_url" => "http://202.148.23.68:38807",
|
||||
"token" => "1|DgEL6wte9vmg5X74AUBPVlbMtTIbDqrrp990Kqrt",
|
||||
],
|
||||
];
|
||||
|
||||
$config = $endpointMaps[$KodeRS];
|
||||
$this->base_url = !empty($config['base_url']) ? ($config['base_url'] . '/api') : null;
|
||||
|
||||
$this->headers = [
|
||||
'Authorization' => 'Bearer ' . ($config['token'] ?? null)
|
||||
];
|
||||
}
|
||||
|
||||
public static function getBaseUrl()
|
||||
{
|
||||
return config('lms-api.base_url');
|
||||
}
|
||||
|
||||
public static function getDefaultHeaders()
|
||||
{
|
||||
return ['id' => config('lms-api.auth_id')];
|
||||
}
|
||||
|
||||
public function consultationPrice($LayananKodes = [], $timeout = 30)
|
||||
{
|
||||
$response = Http::timeout($timeout)
|
||||
->withHeaders($this->headers)
|
||||
->post(
|
||||
$this->base_url . '/consultation-price',
|
||||
empty($LayananKodes) ? null : $LayananKodes
|
||||
)->json();
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function doctors($page = 1)
|
||||
{
|
||||
$response = Http::withHeaders($this->headers)
|
||||
->get($this->base_url . '/doctors' . '?page=' . $page)
|
||||
->json();
|
||||
|
||||
return $response;
|
||||
}
|
||||
};
|
||||
@@ -7,6 +7,7 @@ trait Blameable {
|
||||
public static function bootBlameable() {
|
||||
static::creating(function ($model) {
|
||||
$model->created_by = auth()->id() ?? NULL;
|
||||
$model->updated_by = auth()->id() ?? NULL;
|
||||
});
|
||||
|
||||
static::updating(function ($model) {
|
||||
|
||||
5
config/aso.php
Normal file
5
config/aso.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'general_practitioner_speciality_name' => 'Umum'
|
||||
];
|
||||
@@ -63,6 +63,26 @@ return [
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'oldlms' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('OLDLMS_DATABASE_URL'),
|
||||
'host' => env('OLDLMS_DB_HOST', '127.0.0.1'),
|
||||
'port' => env('OLDLMS_DB_PORT', '3306'),
|
||||
'database' => env('OLDLMS_DB_DATABASE', 'forge'),
|
||||
'username' => env('OLDLMS_DB_USERNAME', 'forge'),
|
||||
'password' => env('OLDLMS_DB_PASSWORD', ''),
|
||||
'unix_socket' => env('OLDLMS_DB_SOCKET', ''),
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DATABASE_URL'),
|
||||
|
||||
@@ -15,64 +15,66 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('benefits', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('corporate_id')->index()->nullable();
|
||||
// $table->foreignId('corporate_id')->index()->nullable();
|
||||
$table->string('service_code')->index()->nullable();
|
||||
$table->string('plan_code')->index()->nullable();
|
||||
$table->string('benefit_code')->index()->nullable();
|
||||
$table->string('code')->index()->nullable();
|
||||
// $table->string('plan_code')->index()->nullable();
|
||||
// $table->string('benefit_code')->index()->nullable();
|
||||
$table->string('code')->index();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('budget')->nullable();
|
||||
$table->string('budget_conditions')->nullable();
|
||||
$table->string('budget_code')->nullable();
|
||||
$table->string('primary_benefit_code')->index()->nullable();
|
||||
$table->string('benefit_mode')->nullable();
|
||||
$table->string('room_class_coverage')->nullable();
|
||||
$table->string('max_bed_coverage')->nullable();
|
||||
$table->string('tolerance_parameter')->nullable();
|
||||
$table->string('max_room_class')->nullable();
|
||||
$table->string('limit_amount', 30)->nullable();
|
||||
$table->boolean('area_limit')->default(false)->nullable();
|
||||
$table->string('shared_benefit')->nullable();
|
||||
$table->string('shared_benefit_type')->nullable();
|
||||
$table->string('msc')->nullable();
|
||||
$table->string('genders')->nullable();
|
||||
$table->string('min_age')->nullable();
|
||||
$table->string('max_age')->nullable();
|
||||
$table->string('max_frequency_period')->nullable();
|
||||
$table->string('daily_frequency')->nullable();
|
||||
$table->string('weekly_frequency')->nullable();
|
||||
$table->string('monthly_frequency')->nullable();
|
||||
$table->string('yearly_frequency')->nullable();
|
||||
$table->string('custom_frequency_days')->nullable();
|
||||
$table->string('custom_duration_value')->nullable();
|
||||
$table->string('allowed_transaction_types')->nullable();
|
||||
$table->string('high_plan_factor')->nullable();
|
||||
$table->boolean('pre_post_treatment')->nullable();
|
||||
$table->string('pre_treatment_days')->nullable();
|
||||
$table->string('post_treatment_days')->nullable();
|
||||
$table->string('layer_type_1')->nullable();
|
||||
$table->string('layer_value_1')->nullable();
|
||||
$table->string('layer_type_2')->nullable();
|
||||
$table->string('layer_value_2')->nullable();
|
||||
$table->string('cashless_percentage')->default(100)->nullable();
|
||||
$table->string('reimbursement_percentage')->default(100)->nullable();
|
||||
$table->string('digital_percentage')->default(100)->nullable();
|
||||
$table->string('co_share_m_percentage')->default(100)->nullable();
|
||||
$table->string('co_share_s_percentage')->default(100)->nullable();
|
||||
$table->string('co_share_c_percentage')->default(100)->nullable();
|
||||
$table->string('cashless_deductible', 30)->nullable();
|
||||
$table->string('reimbursement_deductible', 30)->nullable();
|
||||
$table->string('digital_deductible', 30)->nullable();
|
||||
$table->string('co_share_m_deductible', 30)->nullable();
|
||||
$table->string('co_share_s_deductible', 30)->nullable();
|
||||
$table->string('co_share_c_deductible', 30)->nullable();
|
||||
$table->string('prorate_type')->nullable();
|
||||
$table->string('prorate_lookup')->nullable();
|
||||
$table->string('max_days_for_disability')->nullable();
|
||||
$table->string('max_period_for_disability')->nullable();
|
||||
$table->string('currency')->nullable();
|
||||
$table->string('show_benefit_item')->nullable();
|
||||
$table->string('show_benefit_value')->nullable();
|
||||
// $table->string('budget')->nullable();
|
||||
// $table->string('budget_conditions')->nullable();
|
||||
// $table->string('budget_code')->nullable();
|
||||
// $table->string('primary_benefit_code')->index()->nullable();
|
||||
// $table->string('benefit_mode')->nullable();
|
||||
// $table->string('room_class_coverage')->nullable();
|
||||
// $table->string('max_bed_coverage')->nullable();
|
||||
// $table->string('tolerance_parameter')->nullable();
|
||||
// $table->string('max_room_class')->nullable();
|
||||
// $table->string('limit_amount', 30)->nullable();
|
||||
// $table->boolean('area_limit')->default(false)->nullable();
|
||||
// $table->string('shared_benefit')->nullable();
|
||||
// $table->string('shared_benefit_type')->nullable();
|
||||
// $table->string('msc')->nullable();
|
||||
// $table->string('genders')->nullable();
|
||||
// $table->string('min_age')->nullable();
|
||||
// $table->string('max_age')->nullable();
|
||||
// $table->string('max_frequency_period')->nullable();
|
||||
// $table->string('daily_frequency')->nullable();
|
||||
// $table->string('weekly_frequency')->nullable();
|
||||
// $table->string('monthly_frequency')->nullable();
|
||||
// $table->string('yearly_frequency')->nullable();
|
||||
// $table->string('custom_frequency_days')->nullable();
|
||||
// $table->string('custom_duration_value')->nullable();
|
||||
// $table->string('allowed_transaction_types')->nullable();
|
||||
// $table->string('high_plan_factor')->nullable();
|
||||
// $table->boolean('pre_post_treatment')->nullable();
|
||||
// $table->string('pre_treatment_days')->nullable();
|
||||
// $table->string('post_treatment_days')->nullable();
|
||||
// $table->string('layer_type_1')->nullable();
|
||||
// $table->string('layer_value_1')->nullable();
|
||||
// $table->string('layer_type_2')->nullable();
|
||||
// $table->string('layer_value_2')->nullable();
|
||||
// $table->string('cashless_percentage')->default(100)->nullable();
|
||||
// $table->string('reimbursement_percentage')->default(100)->nullable();
|
||||
// $table->string('digital_percentage')->default(100)->nullable();
|
||||
// $table->string('co_share_m_percentage')->default(100)->nullable();
|
||||
// $table->string('co_share_s_percentage')->default(100)->nullable();
|
||||
// $table->string('co_share_c_percentage')->default(100)->nullable();
|
||||
// $table->string('cashless_deductible', 30)->nullable();
|
||||
// $table->string('reimbursement_deductible', 30)->nullable();
|
||||
// $table->string('digital_deductible', 30)->nullable();
|
||||
// $table->string('co_share_m_deductible', 30)->nullable();
|
||||
// $table->string('co_share_s_deductible', 30)->nullable();
|
||||
// $table->string('co_share_c_deductible', 30)->nullable();
|
||||
// $table->string('prorate_type')->nullable();
|
||||
// $table->string('prorate_lookup')->nullable();
|
||||
// $table->string('max_days_for_disability')->nullable();
|
||||
// $table->string('max_period_for_disability')->nullable();
|
||||
// $table->string('currency')->nullable();
|
||||
// $table->string('show_benefit_item')->nullable();
|
||||
// $table->string('show_benefit_value')->nullable();
|
||||
|
||||
$table->boolean('active')->default(true);
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
@@ -16,9 +16,63 @@ return new class extends Migration
|
||||
Schema::create('corporate_benefits', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('corporate_id')->index();
|
||||
$table->string('code')->index();
|
||||
$table->string('name')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->foreignId('plan_id')->index();
|
||||
$table->foreignId('benefit_id')->index();
|
||||
|
||||
$table->string('corporate_benefit_code')->nullable();
|
||||
$table->string('budget')->nullable();
|
||||
$table->string('budget_conditions')->nullable();
|
||||
$table->string('budget_code')->nullable();
|
||||
$table->string('primary_benefit_code')->index()->nullable();
|
||||
$table->string('benefit_mode')->nullable();
|
||||
$table->string('room_class_coverage')->nullable();
|
||||
$table->string('max_bed_coverage')->nullable();
|
||||
$table->string('tolerance_parameter')->nullable();
|
||||
$table->string('max_room_class')->nullable();
|
||||
$table->string('limit_amount', 30)->nullable();
|
||||
$table->boolean('area_limit')->default(false)->nullable();
|
||||
$table->string('shared_benefit')->nullable();
|
||||
$table->string('shared_benefit_type')->nullable();
|
||||
$table->string('msc')->nullable();
|
||||
$table->string('genders')->nullable();
|
||||
$table->string('min_age')->nullable();
|
||||
$table->string('max_age')->nullable();
|
||||
$table->string('max_frequency_period')->nullable();
|
||||
$table->string('daily_frequency')->nullable();
|
||||
$table->string('weekly_frequency')->nullable();
|
||||
$table->string('monthly_frequency')->nullable();
|
||||
$table->string('yearly_frequency')->nullable();
|
||||
$table->string('custom_frequency_days')->nullable();
|
||||
$table->string('custom_duration_value')->nullable();
|
||||
$table->string('allowed_transaction_types')->nullable();
|
||||
$table->string('high_plan_factor')->nullable();
|
||||
$table->boolean('pre_post_treatment')->nullable();
|
||||
$table->string('pre_treatment_days')->nullable();
|
||||
$table->string('post_treatment_days')->nullable();
|
||||
$table->string('layer_type_1')->nullable();
|
||||
$table->string('layer_value_1')->nullable();
|
||||
$table->string('layer_type_2')->nullable();
|
||||
$table->string('layer_value_2')->nullable();
|
||||
$table->string('cashless_percentage')->default(100)->nullable();
|
||||
$table->string('reimbursement_percentage')->default(100)->nullable();
|
||||
$table->string('digital_percentage')->default(100)->nullable();
|
||||
$table->string('co_share_m_percentage')->default(100)->nullable();
|
||||
$table->string('co_share_s_percentage')->default(100)->nullable();
|
||||
$table->string('co_share_c_percentage')->default(100)->nullable();
|
||||
$table->string('cashless_deductible', 30)->nullable();
|
||||
$table->string('reimbursement_deductible', 30)->nullable();
|
||||
$table->string('digital_deductible', 30)->nullable();
|
||||
$table->string('co_share_m_deductible', 30)->nullable();
|
||||
$table->string('co_share_s_deductible', 30)->nullable();
|
||||
$table->string('co_share_c_deductible', 30)->nullable();
|
||||
$table->string('prorate_type')->nullable();
|
||||
$table->string('prorate_lookup')->nullable();
|
||||
$table->string('max_days_for_disability')->nullable();
|
||||
$table->string('max_period_for_disability')->nullable();
|
||||
$table->string('currency')->nullable();
|
||||
$table->string('show_benefit_item')->nullable();
|
||||
$table->string('show_benefit_value')->nullable();
|
||||
|
||||
$table->boolean('active')->default(true);
|
||||
|
||||
$table->timestamps();
|
||||
@@ -28,7 +82,7 @@ return new class extends Migration
|
||||
$table->foreignId('updated_by')->nullable()->index();
|
||||
$table->foreignId('deleted_by')->nullable()->index();
|
||||
|
||||
$table->unique(['corporate_id', 'code']);
|
||||
$table->unique(['corporate_id', 'plan_id', 'benefit_id']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('corporate_service_id');
|
||||
$table->foreignId('speciality_id');
|
||||
$table->string('status')->default('active');
|
||||
$table->boolean('active');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreignId('created_by')->nullable();
|
||||
$table->foreignId('updated_by')->nullable();
|
||||
$table->foreignId('deleted_by')->nullable();
|
||||
|
||||
@@ -17,23 +17,28 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->string('code')->index();
|
||||
$table->foreignId('member_id')->index();
|
||||
$table->foreignId('diagnosis_id')->index();
|
||||
$table->string('total_claim');
|
||||
// $table->foreignId('diagnosis_id')->index()->nullable();
|
||||
$table->string('currency');
|
||||
$table->foreignId('plan_id')->index();
|
||||
$table->foreignId('benefit_id')->index();
|
||||
$table->string('total_claim')->nullable();
|
||||
$table->foreignId('plan_id')->index()->nullable();
|
||||
$table->foreignId('benefit_id')->index()->nullable();
|
||||
|
||||
$table->dateTime('requested_at')->nullable();
|
||||
$table->unsignedBigInteger('requested_by')->nullable()->index();
|
||||
$table->string('status');
|
||||
|
||||
$table->dateTime('received_at')->nullable();
|
||||
$table->unsignedBigInteger('received_by')->nullable()->index();
|
||||
// $table->dateTime('requested_at')->nullable();
|
||||
// $table->unsignedBigInteger('requested_by')->nullable()->index();
|
||||
|
||||
$table->dateTime('declined')->nullable();
|
||||
$table->unsignedBigInteger('declined_by')->nullable()->index();
|
||||
// $table->dateTime('received_at')->nullable();
|
||||
// $table->unsignedBigInteger('received_by')->nullable()->index();
|
||||
|
||||
$table->dateTime('paid_at')->nullable();
|
||||
$table->unsignedBigInteger('paid_by')->nullable()->index();
|
||||
// $table->dateTime('approved_at')->nullable();
|
||||
// $table->unsignedBigInteger('approved_by')->nullable()->index();
|
||||
|
||||
// $table->dateTime('declined')->nullable();
|
||||
// $table->unsignedBigInteger('declined_by')->nullable()->index();
|
||||
|
||||
// $table->dateTime('paid_at')->nullable();
|
||||
// $table->unsignedBigInteger('paid_by')->nullable()->index();
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('plans', function (Blueprint $table) {
|
||||
$table->boolean('active')->after('max_surgery_periode_days')->default(true);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('plans', function (Blueprint $table) {
|
||||
$table->dropColumn('active');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('members', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('person_id')->after('id')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('members', function (Blueprint $table) {
|
||||
$table->dropColumn('person_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('persons', function (Blueprint $table) {
|
||||
$table->string('language')->after('birth_place')->nullable();
|
||||
$table->string('race')->after('language')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('persons', function (Blueprint $table) {
|
||||
$table->dropColumn('language');
|
||||
$table->dropColumn('race');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('status_histories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('statusable');
|
||||
$table->string('status');
|
||||
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('created_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('status_histories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('claim_diagnosis', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('claim_id');
|
||||
$table->string('type')->comment('primary, secondary');
|
||||
$table->foreignId('diagnosis_id')->nullable();
|
||||
$table->string('note')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
$table->unsignedBigInteger('created_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('updated_by')->nullable()->index();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('claim_diagnosis');
|
||||
}
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user