Compare commits
130 Commits
feature/ho
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 5042cd7800 | |||
| 70b0d880fc | |||
| 6c65b58481 | |||
| 6a94e46f52 | |||
| b3e78850d3 | |||
| 5df1a85e7c | |||
|
|
c8b06f67d1 | ||
|
|
49f3a8558d | ||
| 12fbef2a12 | |||
| e455fbfbea | |||
| a55b7f4148 | |||
| 4f8745d726 | |||
| f5de316768 | |||
|
|
d22fa1848f | ||
|
|
cc5201ca3e | ||
| bb925503f0 | |||
| be5e8950c1 | |||
|
|
aefddcbff2 | ||
| 5333a65495 | |||
| 91be43263a | |||
| 947952340d | |||
| affb54b62d | |||
| 67cd7cdce0 | |||
| 27c1bfd6e3 | |||
| 5c6e7f3122 | |||
|
|
83e3ff6345 | ||
| 3e2c9015ed | |||
| 3a5fd67778 | |||
| 0d73222a04 | |||
| 85f7eeda18 | |||
| e91304bb4b | |||
| da87a53623 | |||
|
|
70a2cbff9e | ||
|
|
85039893a8 | ||
| 7d198583a4 | |||
| 3ff0cc1b29 | |||
| 97486da90f | |||
| 53075d0ce8 | |||
| a2cbc0a270 | |||
| cca2310f54 | |||
| d54288106b | |||
|
|
4a7c3ebdda | ||
|
|
59e7394d13 | ||
|
|
127cdf8708 | ||
| c2d084b4ea | |||
| 7b9a341ccd | |||
|
|
606b3c871a | ||
|
|
5fd33b3784 | ||
|
|
588b66c050 | ||
|
|
86bb5860f3 | ||
|
|
677a349d4c | ||
|
|
3c5f06ef26 | ||
|
|
d5dfc7d36c | ||
| 229908e492 | |||
| f65b28107c | |||
| e06447bf00 | |||
| c35442e652 | |||
| 26290912ef | |||
| 53b35e86c2 | |||
| 254420bdae | |||
| 8c86794340 | |||
| 2b1f5c97df | |||
| b587178c85 | |||
| ed96878dda | |||
| 35119ee8ec | |||
| 91ba718a50 | |||
| 9e322c4ee5 | |||
| 5741789ddb | |||
| d0ee09a6e4 | |||
| 89cd2a9d37 | |||
| ce0fde18dc | |||
| acf9fa348e | |||
| 74dd65efde | |||
| edc5ba9822 | |||
| 8902718523 | |||
| 1c4f03ea83 | |||
| 627904abba | |||
| bd3f53b596 | |||
| 69919878fa | |||
| f3bdf12bc4 | |||
| eb1211cde7 | |||
|
|
b8ed27f2ff | ||
| 74cfcfa16b | |||
| 9f95e89a9a | |||
| e51068b0a6 | |||
| 5cd23ff343 | |||
| 615330bb46 | |||
| bcf6662db6 | |||
| be43f8a4a4 | |||
| dba421ad0b | |||
| c3a78f8a40 | |||
| 6c6a7c3919 | |||
| 5c71b556a0 | |||
| 63c53d18d1 | |||
| a5db01bd25 | |||
| 5d4033a9ca | |||
| 912edcdae7 | |||
| 5a7695b404 | |||
| 5f05f191c6 | |||
| 46af57b17c | |||
| 016bd3f605 | |||
| 093f8160d2 | |||
| d8f493103c | |||
| 7f77deb09e | |||
| d38bc8dbfc | |||
| b225084991 | |||
| d8a98f4648 | |||
| 27523b8cce | |||
| f6117743ad | |||
| 8c97df9fc4 | |||
| 4f2bb19d8a | |||
| 13764a3766 | |||
| ed273fdafa | |||
|
|
f309f4039c | ||
|
|
387658a992 | ||
| 6491f4d3e3 | |||
| 5028b2d82b | |||
| 5d56434aa2 | |||
| 8e05280b7d | |||
| e3de0a3c04 | |||
| c3a425c93d | |||
| 431070efc3 | |||
| e8c3decf85 | |||
| 99c488baf3 | |||
| 0b50e4c980 | |||
| ba310a21c1 | |||
| 5a0136acf8 | |||
| 75c9781a22 | |||
| 2a1f0c854a | |||
| f0c787fede |
0
.editorconfig
Executable file → Normal file
0
.editorconfig
Executable file → Normal file
0
.env.example
Executable file → Normal file
0
.env.example
Executable file → Normal file
0
.gitattributes
vendored
Executable file → Normal file
0
.gitattributes
vendored
Executable file → Normal file
3
.gitignore
vendored
Executable file → Normal file
3
.gitignore
vendored
Executable file → Normal file
@@ -12,3 +12,6 @@ npm-debug.log
|
||||
yarn-error.log
|
||||
/.idea
|
||||
/.vscode
|
||||
|
||||
/public/dashboard
|
||||
/public/dashboard-staging
|
||||
|
||||
0
.styleci.yml
Executable file → Normal file
0
.styleci.yml
Executable file → Normal file
0
Modules/Client/Config/.gitkeep
Executable file → Normal file
0
Modules/Client/Config/.gitkeep
Executable file → Normal file
0
Modules/Client/Config/config.php
Executable file → Normal file
0
Modules/Client/Config/config.php
Executable file → Normal file
0
Modules/Client/Console/.gitkeep
Executable file → Normal file
0
Modules/Client/Console/.gitkeep
Executable file → Normal file
0
Modules/Client/Database/Migrations/.gitkeep
Executable file → Normal file
0
Modules/Client/Database/Migrations/.gitkeep
Executable file → Normal file
0
Modules/Client/Database/Seeders/.gitkeep
Executable file → Normal file
0
Modules/Client/Database/Seeders/.gitkeep
Executable file → Normal file
0
Modules/Client/Database/Seeders/ClientDatabaseSeeder.php
Executable file → Normal file
0
Modules/Client/Database/Seeders/ClientDatabaseSeeder.php
Executable file → Normal file
0
Modules/Client/Database/factories/.gitkeep
Executable file → Normal file
0
Modules/Client/Database/factories/.gitkeep
Executable file → Normal file
0
Modules/Client/Entities/.gitkeep
Executable file → Normal file
0
Modules/Client/Entities/.gitkeep
Executable file → Normal file
0
Modules/Client/Http/Controllers/.gitkeep
Executable file → Normal file
0
Modules/Client/Http/Controllers/.gitkeep
Executable file → Normal file
4
Modules/Client/Http/Controllers/Api/AuthController.php
Executable file → Normal file
4
Modules/Client/Http/Controllers/Api/AuthController.php
Executable file → Normal file
@@ -35,13 +35,13 @@ class AuthController extends Controller
|
||||
if (filter_var($request->phoneOrEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
User::query()->find($user->id)->update([
|
||||
'email' => $request->phoneOrEmail,
|
||||
'otp' => rand(1000, 9999),
|
||||
'otp' => 4444, //rand(1000, 9999),
|
||||
'otp_created_at' => now()
|
||||
]);
|
||||
} else {
|
||||
User::query()->find($user->id)->update([
|
||||
'phone' => $request->phoneOrEmail,
|
||||
'otp' => rand(1000, 9999),
|
||||
'otp' => 4444,//rand(1000, 9999),
|
||||
'otp_created_at' => now()
|
||||
]);
|
||||
}
|
||||
|
||||
136
Modules/Client/Http/Controllers/Api/ClaimController.php
Normal file
136
Modules/Client/Http/Controllers/Api/ClaimController.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Claim;
|
||||
use App\Services\ClaimService;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Client\Transformers\ClaimShowResource;
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
public function __construct(public ClaimService $claimService)
|
||||
{
|
||||
}
|
||||
|
||||
public function status($corporate_id)
|
||||
{
|
||||
$claims = $this->claimService->getCountClaimRequestPerStatus($corporate_id);
|
||||
|
||||
dd($claims);
|
||||
|
||||
return Helper::responseJson([
|
||||
'count_requested' => 0,
|
||||
'count_approval' => 0,
|
||||
'count_disbrushment' => 0,
|
||||
'count_rejected' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request, $corporate_id)
|
||||
{
|
||||
$claims = Claim::query()
|
||||
->when($request->search ?? null, function ($query, $search) {
|
||||
$query->where('code', 'LIKE', '%' . $search . '%');
|
||||
})
|
||||
->with([
|
||||
'member',
|
||||
'diagnoses' => function ($diagnosis) {
|
||||
return $diagnosis->where('type', 'primary');
|
||||
},
|
||||
'diagnoses.icd',
|
||||
'plan',
|
||||
'benefit',
|
||||
'claimRequest',
|
||||
'claimRequest.service'
|
||||
])
|
||||
->paginate(10);
|
||||
|
||||
return Helper::responseJson($claims);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$claim = Claim::query()
|
||||
->with([
|
||||
'member',
|
||||
'member.currentPlan',
|
||||
'member.currentPlan.benefits',
|
||||
'member.currentCorporate',
|
||||
'member.currentPolicy',
|
||||
'diagnosis',
|
||||
'diagnoses',
|
||||
'benefit',
|
||||
'files',
|
||||
'claimRequest',
|
||||
'claimRequest.files',
|
||||
'items',
|
||||
'items.claim_itemable',
|
||||
])
|
||||
->findOrFail($id);
|
||||
|
||||
return Helper::responseJson(ClaimShowResource::make($claim));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
0
Modules/Client/Http/Controllers/Api/CorporateDivisionController.php
Executable file → Normal file
0
Modules/Client/Http/Controllers/Api/CorporateDivisionController.php
Executable file → Normal file
0
Modules/Client/Http/Controllers/Api/CorporateManageController.php
Executable file → Normal file
0
Modules/Client/Http/Controllers/Api/CorporateManageController.php
Executable file → Normal file
115
Modules/Client/Http/Controllers/Api/CorporateMemberController.php
Executable file → Normal file
115
Modules/Client/Http/Controllers/Api/CorporateMemberController.php
Executable file → Normal file
@@ -3,110 +3,39 @@
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Member;
|
||||
use App\Services\CorporateMemberService;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Client\Transformers\MemberResources;
|
||||
use Modules\Client\Transformers\ClaimReport\MemberResources as ClaimReportMemberResources;
|
||||
use Modules\Client\Transformers\Dashboard\MemberResources as DashboardMemberResources;
|
||||
use Modules\Client\Transformers\Dashboard\MemberAlarmCenterResources as DashboardMemberAlarmResources;
|
||||
|
||||
class CorporateMemberController extends Controller
|
||||
{
|
||||
public function __construct(public CorporateMemberService $corporateMemberService)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
switch ($request->input('type')) {
|
||||
case 'claim-report':
|
||||
$members = $this->corporateMemberService->getAllMemberClaimReports($corporate_id, $request);
|
||||
return response()->json(Helper::paginateResources(ClaimReportMemberResources::collection($members)));
|
||||
case 'claim-submit':
|
||||
$members = $this->corporateMemberService->getAllMemberClaimReports($corporate_id, $request);
|
||||
return response()->json(Helper::paginateResources(ClaimReportMemberResources::collection($members)));
|
||||
case 'alarm-center':
|
||||
$members = $this->corporateMemberService->getAllMemberAlarmCenter($corporate_id, $request);
|
||||
return response()->json(Helper::paginateResources(DashboardMemberAlarmResources::collection($members)));
|
||||
default:
|
||||
$members = $this->corporateMemberService->getAllMemberDashboards($corporate_id, $request);
|
||||
return response()->json(Helper::paginateResources(DashboardMemberResources::collection($members)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
Modules/Client/Http/Controllers/Api/CorporatePolicyController.php
Executable file → Normal file
21
Modules/Client/Http/Controllers/Api/CorporatePolicyController.php
Executable file → Normal file
@@ -2,11 +2,12 @@
|
||||
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Client\Transformers\DashboardResources;
|
||||
use Modules\Client\Transformers\Dashboard\LimitResources;
|
||||
|
||||
class CorporatePolicyController extends Controller
|
||||
{
|
||||
@@ -14,25 +15,15 @@ class CorporatePolicyController extends Controller
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request, $corporate_id)
|
||||
public function index($corporate_id)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$currentCorporate = $user->managedCorporates()
|
||||
$currentCorporate = Auth::user()->managedCorporates()
|
||||
->with(['currentPolicy', 'employees'])
|
||||
->find($corporate_id);
|
||||
|
||||
$data = DashboardResources::make($currentCorporate);
|
||||
$data = LimitResources::make($currentCorporate);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('client::create');
|
||||
return Helper::responseJson($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
71
Modules/Client/Http/Controllers/Api/TopUpController.php
Normal file
71
Modules/Client/Http/Controllers/Api/TopUpController.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Client\Transformers\Dashboard\TopUpLimitResources;
|
||||
|
||||
class TopUpController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index($corporate_id)
|
||||
{
|
||||
$data = Auth::user()
|
||||
->managedCorporates()
|
||||
->with(['currentPolicy', 'employees'])
|
||||
->withCount(['employees', 'claims' => function ($query) {
|
||||
$query->where('claims.status', 'paid');
|
||||
}])
|
||||
->find($corporate_id);
|
||||
|
||||
return Helper::responseJson(TopUpLimitResources::make($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
0
Modules/Client/Http/Controllers/Api/UserController.php
Executable file → Normal file
0
Modules/Client/Http/Controllers/Api/UserController.php
Executable file → Normal file
0
Modules/Client/Http/Controllers/ClientController.php
Executable file → Normal file
0
Modules/Client/Http/Controllers/ClientController.php
Executable file → Normal file
0
Modules/Client/Http/Middleware/.gitkeep
Executable file → Normal file
0
Modules/Client/Http/Middleware/.gitkeep
Executable file → Normal file
0
Modules/Client/Http/Requests/.gitkeep
Executable file → Normal file
0
Modules/Client/Http/Requests/.gitkeep
Executable file → Normal file
0
Modules/Client/Providers/.gitkeep
Executable file → Normal file
0
Modules/Client/Providers/.gitkeep
Executable file → Normal file
0
Modules/Client/Providers/ClientServiceProvider.php
Executable file → Normal file
0
Modules/Client/Providers/ClientServiceProvider.php
Executable file → Normal file
0
Modules/Client/Providers/RouteServiceProvider.php
Executable file → Normal file
0
Modules/Client/Providers/RouteServiceProvider.php
Executable file → Normal file
0
Modules/Client/Resources/assets/.gitkeep
Executable file → Normal file
0
Modules/Client/Resources/assets/.gitkeep
Executable file → Normal file
0
Modules/Client/Resources/assets/js/app.js
Executable file → Normal file
0
Modules/Client/Resources/assets/js/app.js
Executable file → Normal file
0
Modules/Client/Resources/assets/sass/app.scss
Executable file → Normal file
0
Modules/Client/Resources/assets/sass/app.scss
Executable file → Normal file
0
Modules/Client/Resources/lang/.gitkeep
Executable file → Normal file
0
Modules/Client/Resources/lang/.gitkeep
Executable file → Normal file
0
Modules/Client/Resources/views/.gitkeep
Executable file → Normal file
0
Modules/Client/Resources/views/.gitkeep
Executable file → Normal file
0
Modules/Client/Resources/views/index.blade.php
Executable file → Normal file
0
Modules/Client/Resources/views/index.blade.php
Executable file → Normal file
0
Modules/Client/Resources/views/layouts/master.blade.php
Executable file → Normal file
0
Modules/Client/Resources/views/layouts/master.blade.php
Executable file → Normal file
0
Modules/Client/Routes/.gitkeep
Executable file → Normal file
0
Modules/Client/Routes/.gitkeep
Executable file → Normal file
11
Modules/Client/Routes/api.php
Executable file → Normal file
11
Modules/Client/Routes/api.php
Executable file → Normal file
@@ -6,6 +6,8 @@ use Modules\Client\Http\Controllers\Api\CorporateManageController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporateMemberController;
|
||||
use Modules\Client\Http\Controllers\Api\CorporatePolicyController;
|
||||
use Modules\Client\Http\Controllers\Api\UserController;
|
||||
use Modules\Client\Http\Controllers\Api\ClaimController;
|
||||
use Modules\Client\Http\Controllers\Api\TopUpController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -34,6 +36,13 @@ Route::prefix('client')->group(function () {
|
||||
Route::get('policy', [CorporatePolicyController::class, 'index']);
|
||||
Route::get('division', [CorporateDivisionController::class, 'index']);
|
||||
Route::get('members', [CorporateMemberController::class, 'index']);
|
||||
});
|
||||
Route::get('claims/status', [ClaimController::class, 'status']);
|
||||
Route::get('claims', [ClaimController::class, 'index']);
|
||||
|
||||
Route::get('topup', [TopUpController::class, 'index']);
|
||||
Route::post('topup', [TopUpController::class, 'store']);
|
||||
});
|
||||
|
||||
Route::get('claims/{id}', [ClaimController::class, 'show']);
|
||||
});
|
||||
});
|
||||
|
||||
0
Modules/Client/Routes/web.php
Executable file → Normal file
0
Modules/Client/Routes/web.php
Executable file → Normal file
0
Modules/Client/Tests/Feature/.gitkeep
Executable file → Normal file
0
Modules/Client/Tests/Feature/.gitkeep
Executable file → Normal file
0
Modules/Client/Tests/Unit/.gitkeep
Executable file → Normal file
0
Modules/Client/Tests/Unit/.gitkeep
Executable file → Normal file
26
Modules/Client/Transformers/ClaimReport/MemberResources.php
Normal file
26
Modules/Client/Transformers/ClaimReport/MemberResources.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Transformers\ClaimReport;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class MemberResources extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'memberId' => $this->member_id,
|
||||
'fullName' => $this->full_name,
|
||||
'division' => $this->division_name ?? '',
|
||||
'submission_date' => '',
|
||||
'status' => $this->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
41
Modules/Client/Transformers/ClaimShowResource.php
Normal file
41
Modules/Client/Transformers/ClaimShowResource.php
Normal file
@@ -0,0 +1,41 @@
|
||||
c<?php
|
||||
|
||||
namespace Modules\Client\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ClaimShowResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$data = parent::toArray($request);
|
||||
// $data['']
|
||||
$data['benefit_items'] = $this->items
|
||||
->filter(function ($item) {
|
||||
return $item->claim_itemable_type == Benefit::class;
|
||||
})
|
||||
->map(function ($item) {
|
||||
$itemData = $item->claim_itemable->toArray();
|
||||
$itemData['nominal_dicover'] = $item['nominal_dicover'] ?? 0;
|
||||
$itemData['nominal_ditagihkan'] = $item['nominal_ditagihkan'] ?? 0;
|
||||
$itemData['nominal_total'] = $item['nominal_total'] ?? 0;
|
||||
|
||||
// For React Frotnend
|
||||
$itemData['biaya_diajukan'] = $itemData['nominal_ditagihkan'];
|
||||
$itemData['biaya_disetujui'] = $itemData['nominal_dicover'];
|
||||
|
||||
return $itemData;
|
||||
});
|
||||
|
||||
$data['primary_diagnosis'] = $this->diagnoses->filter(function($diagnosis){ return $diagnosis->type == 'primary';})->values();
|
||||
$data['secondary_diagnosis'] = $this->diagnoses->filter(function($diagnosis){ return $diagnosis->type == 'secondary';})->values();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Transformers;
|
||||
namespace Modules\Client\Transformers\Dashboard;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DashboardResources extends JsonResource
|
||||
class LimitResources extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
@@ -22,17 +21,15 @@ class DashboardResources extends JsonResource
|
||||
$lockPercentage = (int)$this->currentPolicy->minimal_stop_service_percentage;
|
||||
|
||||
return [
|
||||
'policy' => [
|
||||
'myLimit' => [
|
||||
'balance' => $myLimitBalance,
|
||||
'total' => $myLimitTotal,
|
||||
'percentage' => ($myLimitBalance / $myLimitTotal) * 100,
|
||||
'percentage' => $myLimitTotal ? round(($myLimitBalance / $myLimitTotal) * 100, 2) : 0,
|
||||
],
|
||||
'lockLimit' => [
|
||||
'balance' => $lockBalance,
|
||||
'percentage' => $lockPercentage
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Modules\Client\Transformers\Dashboard;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class MemberAlarmCenterResources extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'memberId' => $this->member_id,
|
||||
'fullName' => $this->full_name,
|
||||
'service' => $this->service_code,
|
||||
'start_date' => $this->start_date,
|
||||
'end_date' => $this->end_date,
|
||||
'status' => $this->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Transformers;
|
||||
namespace Modules\Client\Transformers\Dashboard;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
@@ -18,15 +18,13 @@ class MemberResources extends JsonResource
|
||||
'id' => $this->id,
|
||||
'memberId' => $this->member_id,
|
||||
'fullName' => $this->full_name,
|
||||
$this->mergeWhen($request->input('claimMember') === 'false', [
|
||||
'division' => $this->division->name ?? '',
|
||||
'status' => $this->active
|
||||
]),
|
||||
'division' => $this->division_name ?? '',
|
||||
'limit' => [
|
||||
'current' => $this->claims_sum_total_claim,
|
||||
'current' => $this->claims_sum_total_claim ?? 0,
|
||||
'total' => $this->currentPlan->limit_rules ?? 0,
|
||||
'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->claims_sum_total_claim / $this->currentPlan->limit_rules) * 100) : 0
|
||||
],
|
||||
'status' => $this->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Client\Transformers\Dashboard;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TopUpLimitResources extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$myLimitBalance = (int)$this->currentPolicy->limit_balance;
|
||||
$myLimitTotal = (int)$this->currentPolicy->total_premi;
|
||||
|
||||
return [
|
||||
'companyName' => $this->name,
|
||||
'policyNumber' => $this->currentPolicy->code,
|
||||
'totalMembers' => $this->employees_count,
|
||||
'totalCases' => $this->claims_count,
|
||||
'myLimit' => [
|
||||
'balance' => $myLimitBalance,
|
||||
'total' => $myLimitTotal,
|
||||
'percentage' => $myLimitTotal ? round(($myLimitBalance / $myLimitTotal) * 100, 2) : 0,
|
||||
],
|
||||
'maxTopUp' => ($myLimitTotal - $myLimitBalance)
|
||||
];
|
||||
}
|
||||
}
|
||||
0
Modules/Client/composer.json
Executable file → Normal file
0
Modules/Client/composer.json
Executable file → Normal file
0
Modules/Client/module.json
Executable file → Normal file
0
Modules/Client/module.json
Executable file → Normal file
0
Modules/Client/package.json
Executable file → Normal file
0
Modules/Client/package.json
Executable file → Normal file
0
Modules/Client/webpack.mix.js
Executable file → Normal file
0
Modules/Client/webpack.mix.js
Executable file → Normal file
0
Modules/HospitalPortal/Http/Controllers/Api/AuthController.php
Executable file → Normal file
0
Modules/HospitalPortal/Http/Controllers/Api/AuthController.php
Executable file → Normal file
@@ -2,11 +2,20 @@
|
||||
|
||||
namespace Modules\HospitalPortal\Http\Controllers\Api;
|
||||
|
||||
use App\Events\ClaimRequested;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\ClaimRequest;
|
||||
use App\Models\File;
|
||||
use App\Models\Member;
|
||||
use App\Services\ClaimRequestService;
|
||||
use App\Services\ClaimService;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\HospitalPortal\Transformers\ClaimRequestResource;
|
||||
use Modules\HospitalPortal\Transformers\ClaimRequestShowResource;
|
||||
use PDF;
|
||||
|
||||
class ClaimRequestController extends Controller
|
||||
{
|
||||
@@ -14,10 +23,22 @@ class ClaimRequestController extends Controller
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
public function index(request $request)
|
||||
{
|
||||
$claimRequests = ClaimRequest::query()
|
||||
->when($request->search, function ($q, $search) {
|
||||
$q->where('code', 'LIKE', "%".$search."%");
|
||||
})
|
||||
->when($request->orderBy, function ($q, $orderBy) use ($request) {
|
||||
if (in_array($orderBy, ['submission_date', 'code'])) {
|
||||
$q->orderBy($orderBy, $request->order);
|
||||
}
|
||||
})
|
||||
->when($request->status, function($q, $status) {
|
||||
$q->where('status', $status);
|
||||
})
|
||||
->with(['member'])
|
||||
->orderBy('created_at', 'DESC')
|
||||
->paginate();
|
||||
|
||||
return Helper::responseJson($claimRequests);
|
||||
@@ -40,18 +61,69 @@ class ClaimRequestController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
// 'submission_date' => 'required',
|
||||
'member_id' => 'required',
|
||||
// 'files' => ''
|
||||
'service_code' => 'required|in:OP,IP'
|
||||
]);
|
||||
|
||||
$newClaimRequest = ClaimRequest::create([
|
||||
'member_id' => $request->member_id,
|
||||
'submission_date' => now(),
|
||||
'status' => 'requested'
|
||||
$member = Member::find($request->member_id);
|
||||
$newClaimRequest = ClaimRequestService::storeClaimRequest(member: $member, paymentType: 'reimbursement', serviceCode: $request->service_code);
|
||||
|
||||
ClaimRequested::dispatch($newClaimRequest);
|
||||
|
||||
// Log History
|
||||
$newClaimRequest->histories()->create([
|
||||
'title' => 'New Claim Requested',
|
||||
'description' => "Claim Requested for Member : {$member->member_id} - ({$member->full_name})",
|
||||
'type' => 'info',
|
||||
'system_origin' => 'hospital-portal'
|
||||
]);
|
||||
|
||||
return Helper::responseJson(data: $newClaimRequest, message: 'Claim Request berhasil ajukan!');
|
||||
if ($request->hasFile('result_files')) {
|
||||
foreach ($request->result_files as $file) {
|
||||
$pathFile = File::storeFile('claim-result', $newClaimRequest->id, $file);
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-result',
|
||||
'name' => File::getFileName('claim-result', $newClaimRequest->id, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('diagnosa_files')) {
|
||||
foreach ($request->diagnosa_files as $file) {
|
||||
$pathFile = File::storeFile('claim-diagnosis', $newClaimRequest->id, $file);
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-diagnosis',
|
||||
'name' => File::getFileName('claim-diagnosis', $newClaimRequest->id, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('result_files')) {
|
||||
foreach ($request->result_files as $file) {
|
||||
$pathFile = File::storeFile('claim-kondisi', $newClaimRequest->id, $file);
|
||||
$newClaimRequest->files()->updateOrCreate([
|
||||
'type' => 'claim-kondisi',
|
||||
'name' => File::getFileName('claim-kondisi', $newClaimRequest->id, $file),
|
||||
'original_name' => $file->getClientOriginalName(),
|
||||
'extension' => $file->getClientOriginalExtension(),
|
||||
'path' => $pathFile,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return Helper::responseJson(data: $request->toArray(), message: 'Claim Request berhasil ajukan!');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +133,14 @@ class ClaimRequestController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('hospitalportal::show');
|
||||
$claimRequest = ClaimRequest::findOrFail($id);
|
||||
$claimRequest->load([
|
||||
'histories' => function ($history) {
|
||||
$history->latest();
|
||||
}
|
||||
]);
|
||||
|
||||
return Helper::responseJson(data: ClaimRequestShowResource::make($claimRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,4 +173,21 @@ class ClaimRequestController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function generateLog($claim_request_id)
|
||||
{
|
||||
$claimRequest = ClaimRequest::findOrFail($claim_request_id);
|
||||
|
||||
if ($claimRequest->status != 'approved') {
|
||||
throw new Exception("Belum Teverifikasi", 1);
|
||||
}
|
||||
|
||||
$member = Member::findOrFail($claimRequest->member_id)
|
||||
->load(['currentPlan', 'currentPolicy', 'currentPlan.corporateBenefits', 'currentPlan.corporateBenefits.benefit']);
|
||||
|
||||
$pdf = PDF::loadView('pdf.guaranted_leter', compact('member', 'claimRequest'));
|
||||
return $pdf->download('Guaranted Letter - '.$member->full_name.'.pdf');
|
||||
|
||||
return $claimRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,5 +38,7 @@ Route::prefix('hospitalportal')->group(function () {
|
||||
|
||||
Route::get('claim-requests', [ClaimRequestController::class, 'index'])->name('claim-requests.index');
|
||||
Route::post('claim-requests', [ClaimRequestController::class, 'store'])->name('claim-requests.store');
|
||||
Route::get('claim-requests/{claim_request_id}/log', [ClaimRequestController::class, 'generateLog'])->name('claim-requests.generate-log');
|
||||
Route::get('claim-requests/{id}', [ClaimRequestController::class, 'show'])->name('claim-requests.show');
|
||||
});
|
||||
});
|
||||
|
||||
31
Modules/HospitalPortal/Transformers/ClaimRequestResource.php
Normal file
31
Modules/HospitalPortal/Transformers/ClaimRequestResource.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\HospitalPortal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ClaimRequestResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$data = parent::toArray($request);
|
||||
$historiesGroupByDate = $this->histories->mapToGroups(function($history) {
|
||||
return [$history->created_at->format('Y-m-d') => $history];
|
||||
});
|
||||
$data['histories_by_date'] = [];
|
||||
foreach ($historiesGroupByDate as $date => $histories) {
|
||||
$data['histories_by_date'][] = [
|
||||
'date' => $date,
|
||||
'histories' => $histories
|
||||
];
|
||||
}
|
||||
|
||||
return $data; //parent::toArray($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\HospitalPortal\Transformers;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ClaimRequestShowResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$data = parent::toArray($request);
|
||||
$historiesGroupByDate = $this->histories->mapToGroups(function($history) {
|
||||
return [$history->created_at->format('Y-m-d') => $history];
|
||||
});
|
||||
$data['histories_by_date'] = [];
|
||||
foreach ($historiesGroupByDate as $date => $histories) {
|
||||
$data['histories_by_date'][] = [
|
||||
'date' => $date,
|
||||
'histories' => $histories
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
0
Modules/Internal/Config/.gitkeep
Executable file → Normal file
0
Modules/Internal/Config/.gitkeep
Executable file → Normal file
0
Modules/Internal/Config/config.php
Executable file → Normal file
0
Modules/Internal/Config/config.php
Executable file → Normal file
0
Modules/Internal/Console/.gitkeep
Executable file → Normal file
0
Modules/Internal/Console/.gitkeep
Executable file → Normal file
0
Modules/Internal/Database/Migrations/.gitkeep
Executable file → Normal file
0
Modules/Internal/Database/Migrations/.gitkeep
Executable file → Normal file
0
Modules/Internal/Database/Seeders/.gitkeep
Executable file → Normal file
0
Modules/Internal/Database/Seeders/.gitkeep
Executable file → Normal file
0
Modules/Internal/Database/Seeders/InternalDatabaseSeeder.php
Executable file → Normal file
0
Modules/Internal/Database/Seeders/InternalDatabaseSeeder.php
Executable file → Normal file
0
Modules/Internal/Database/factories/.gitkeep
Executable file → Normal file
0
Modules/Internal/Database/factories/.gitkeep
Executable file → Normal file
0
Modules/Internal/Entities/.gitkeep
Executable file → Normal file
0
Modules/Internal/Entities/.gitkeep
Executable file → Normal file
0
Modules/Internal/Http/Controllers/.gitkeep
Executable file → Normal file
0
Modules/Internal/Http/Controllers/.gitkeep
Executable file → Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\AppointmentResource;
|
||||
|
||||
class AppointmentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$appointments = Appointment::query()
|
||||
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare', 'user', 'user.detail')
|
||||
->latest()
|
||||
->paginate(15);
|
||||
return response()->json(Helper::paginateResources(AppointmentResource::collection($appointments)));
|
||||
}
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$appointments = Appointment::query()
|
||||
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare')
|
||||
->where('nID', $id)
|
||||
->first();
|
||||
return response()->json(new AppointmentResource($appointments));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
0
Modules/Internal/Http/Controllers/Api/AuthController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/AuthController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/BenefitController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/BenefitController.php
Executable file → Normal file
86
Modules/Internal/Http/Controllers/Api/CityController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/CityController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\City;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class CityController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$city = City::where('province_id', $request->province_id)->orderBy('name', 'asc')->get();
|
||||
|
||||
if (!$city) {
|
||||
return response(['message' => 'Tidak ada data'], 404);
|
||||
} else {
|
||||
return response(['message' => 'Data ditemukan', 'data' => $city]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,18 @@
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Benefit;
|
||||
use App\Models\Claim;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Services\ClaimService;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\ClaimShowResource;
|
||||
use PDF;
|
||||
|
||||
class ClaimController extends Controller
|
||||
{
|
||||
@@ -21,9 +25,14 @@ class ClaimController extends Controller
|
||||
{
|
||||
$claims = Claim::with([
|
||||
'member',
|
||||
'diagnosis',
|
||||
'diagnoses' => function ($diagnosis) {
|
||||
return $diagnosis->where('type', 'primary');
|
||||
},
|
||||
'diagnoses.icd',
|
||||
'plan',
|
||||
'benefit'
|
||||
'benefit',
|
||||
'claimRequest',
|
||||
'claimRequest.service'
|
||||
])
|
||||
->latest()
|
||||
->paginate(10);
|
||||
@@ -87,13 +96,27 @@ class ClaimController extends Controller
|
||||
->with([
|
||||
'member',
|
||||
'member.currentPlan',
|
||||
'diagnosis',
|
||||
'member.currentPlan.benefits',
|
||||
'member.currentCorporate',
|
||||
'member.currentPolicy',
|
||||
// 'diagnosis',
|
||||
'diagnoses',
|
||||
'diagnoses.icd',
|
||||
'benefit',
|
||||
'files'
|
||||
'files',
|
||||
'claimRequest',
|
||||
'claimRequest.files',
|
||||
'items',
|
||||
'items.claim_itemable',
|
||||
'encounters',
|
||||
'encounters.doctors',
|
||||
'encounters.primaryDiagnoses',
|
||||
'encounters.primaryDiagnoses.diagnosis',
|
||||
'encounters.healthcare'
|
||||
])
|
||||
->findOrFail($id);
|
||||
|
||||
return response()->json($claim);
|
||||
return Helper::responseJson(ClaimShowResource::make($claim));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,4 +154,135 @@ class ClaimController extends Controller
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateDetails(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'healthcare_id' => 'required',
|
||||
'doctor_id' => 'required',
|
||||
'start' => 'required',
|
||||
'end' => 'required'
|
||||
]);
|
||||
|
||||
$claim = Claim::findOrFail($id);
|
||||
|
||||
return $claim;
|
||||
}
|
||||
|
||||
public function updateItems(Request $request, $id)
|
||||
{
|
||||
$request->validate([]);
|
||||
$claim = Claim::findOrFail($id);
|
||||
|
||||
$order = 1;
|
||||
$data = [];
|
||||
$claim->items()->forceDelete();
|
||||
foreach ($request->benefit_items as $benefitItem) {
|
||||
$benefit = Benefit::find($benefitItem['id']);
|
||||
if ($benefit) {
|
||||
$benefit->claimItem()->create([
|
||||
'claim_id' => $claim->id,
|
||||
'order' => $order,
|
||||
'name' => $benefit->code,
|
||||
'currency' => 'IDR',
|
||||
'nominal_ditagihkan' => $benefitItem['biaya_diajukan'] ?? 0,
|
||||
'nominal_dicover' => $benefitItem['biaya_disetujui'] ?? 0,
|
||||
'nominal_total' => $benefitItem['biaya_disetujui'] ?? 0,
|
||||
]);
|
||||
}
|
||||
|
||||
$order++;
|
||||
}
|
||||
return Helper::responseJson([], message: "Item Claim berhasil di update");
|
||||
}
|
||||
|
||||
public function updateDiagnosis(Request $request, $id)
|
||||
{
|
||||
$request->validate([]);
|
||||
$claim = Claim::findOrFail($id);
|
||||
|
||||
$claim->diagnoses()->forceDelete();
|
||||
if ($request->primary) {
|
||||
foreach ($request->primary as $diagnosisId) {
|
||||
$claim->diagnoses()->create([
|
||||
'claim_id' => $claim->id,
|
||||
'type' => 'primary',
|
||||
'diagnosis_id' => $diagnosisId,
|
||||
'note' => '',
|
||||
'description' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->secondary) {
|
||||
foreach ($request->secondary as $diagnosisId) {
|
||||
$claim->diagnoses()->create([
|
||||
'claim_id' => $claim->id,
|
||||
'type' => 'secondary',
|
||||
'diagnosis_id' => $diagnosisId,
|
||||
'note' => '',
|
||||
'description' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return Helper::responseJson([], message: "Diagnosis berhasil di update");
|
||||
}
|
||||
|
||||
public function decline($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
$claim->status = 'declined';
|
||||
$claim->save();
|
||||
|
||||
return Helper::responseJson($claim, message: "Claim berhasil di decline");
|
||||
}
|
||||
|
||||
public function approve($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
$claim->status = 'approved';
|
||||
$claim->save();
|
||||
|
||||
return Helper::responseJson($claim, message: "Claim berhasil di approve");
|
||||
}
|
||||
|
||||
public function reOpen($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
$claim->status = 'received';
|
||||
$claim->save();
|
||||
|
||||
return Helper::responseJson($claim, message: "Claim berhasil di approve");
|
||||
}
|
||||
|
||||
public function downloadFinalLog($id)
|
||||
{
|
||||
$claim = Claim::findOrFail($id);
|
||||
|
||||
$hospital = $claim->finalEncounter->healthcare ?? null;
|
||||
|
||||
// TODO Fix this tipu tipu
|
||||
$inpationBenefit = $claim->member->currentPlan->benefits()->first();
|
||||
|
||||
$pdf = PDF::loadView('pdf.final_log', [
|
||||
'claim' => $claim,
|
||||
'member' => $claim->member,
|
||||
'dateOfAdmission' => $claim->start,
|
||||
'hospital' => $hospital,
|
||||
'inpationBenefit' => $inpationBenefit
|
||||
]);
|
||||
|
||||
return $pdf->download('Final LOG '.$claim->code.'.pdf');
|
||||
|
||||
$view = view('pdf.final_log', [
|
||||
'claim' => $claim,
|
||||
'member' => $claim->member,
|
||||
'dateOfAdmission' => $claim->start,
|
||||
'hospital' => $hospital,
|
||||
'inpationBenefit' => $inpationBenefit
|
||||
]);
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\ClaimRequest;
|
||||
use App\Services\ClaimService;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\ClaimRequestResource;
|
||||
use Modules\Internal\Transformers\ClaimRequestShowResource;
|
||||
|
||||
class ClaimRequestController extends Controller
|
||||
{
|
||||
@@ -14,13 +17,27 @@ class ClaimRequestController extends Controller
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
public function index(Request $request)
|
||||
{
|
||||
$claimRequests = ClaimRequest::query()
|
||||
->with(['member'])
|
||||
->when($request->search, function ($q, $search) {
|
||||
$q->where('code', 'LIKE', "%".$search."%");
|
||||
})
|
||||
->when($request->orderBy, function ($q, $orderBy) use ($request) {
|
||||
if (in_array($orderBy, ['submission_date', 'code'])) {
|
||||
$q->orderBy($orderBy, $request->order);
|
||||
}
|
||||
})
|
||||
->when(empty($request->orderBy), function ($q) {
|
||||
$q->orderBy('created_at', 'desc');
|
||||
})
|
||||
->when($request->status, function($q, $status) {
|
||||
$q->where('status', $status);
|
||||
})
|
||||
->with(['member', 'files', 'service'])
|
||||
->paginate();
|
||||
|
||||
return $claimRequests;
|
||||
return Helper::paginateResources(ClaimRequestResource::collection($claimRequests));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +66,15 @@ class ClaimRequestController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
$claimRequest = ClaimRequest::findOrFail($id);
|
||||
$claimRequest->load([
|
||||
'histories' => function ($history) {
|
||||
$history->latest();
|
||||
},
|
||||
'files'
|
||||
]);
|
||||
|
||||
return Helper::responseJson(data: ClaimRequestShowResource::make($claimRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,12 +111,33 @@ class ClaimRequestController extends Controller
|
||||
public function approve($id)
|
||||
{
|
||||
$claimRequest = ClaimRequest::findOrFail($id);
|
||||
$member = $claimRequest->member;
|
||||
|
||||
try {
|
||||
|
||||
// Create New Claim
|
||||
$newClaim = ClaimService::storeClaim(member: $member, status: 'received', claimRequest: $claimRequest);
|
||||
|
||||
// Update Claim Request Status & Link with Claim
|
||||
$claimRequest->status = 'approved';
|
||||
$claimRequest->claim_id = $newClaim->id;
|
||||
$claimRequest->save();
|
||||
|
||||
// Generate LOG
|
||||
// Store Generated Documents LOG
|
||||
$logContent = view('pdf.guaranted_leter', compact('member', 'claimRequest'));
|
||||
$claimRequest->generatedDocuments()->create([
|
||||
'type' => 'guarantee_letter',
|
||||
'title' => 'Guarantee Letter for '. $member->full_name,
|
||||
'document_type' => 'type',
|
||||
'html_content' => $logContent,
|
||||
'system_origin' => 'primecenter'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return $claimRequest;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
0
Modules/Internal/Http/Controllers/Api/CorporateBenefitController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/CorporateBenefitController.php
Executable file → Normal file
5
Modules/Internal/Http/Controllers/Api/CorporateController.php
Executable file → Normal file
5
Modules/Internal/Http/Controllers/Api/CorporateController.php
Executable file → Normal file
@@ -77,6 +77,7 @@ class CorporateController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'code' => 'required|regex:/^[a-zA-Z0-9]+$/',
|
||||
'name' => 'required',
|
||||
@@ -90,7 +91,6 @@ class CorporateController extends Controller
|
||||
'policy_stop_service_percentage' => 'required_with:policy_code',
|
||||
'policy_stop_service_net' => 'required_with:policy_code',
|
||||
]);
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
$corporate_data = $request->all();
|
||||
@@ -98,7 +98,6 @@ class CorporateController extends Controller
|
||||
|
||||
$newCorporate = Corporate::create($request->all());
|
||||
if ($request->has('policy_code') && !empty($request->policy_code)) {
|
||||
// dd($request->policy_code, 'fuck you');
|
||||
$newCorporate->policies()->create([
|
||||
'code' => $request->policy_code ?? NULL,
|
||||
'total_premi' => $request->policy_total_premi ?? NULL,
|
||||
@@ -397,7 +396,6 @@ class CorporateController extends Controller
|
||||
$request->validate([
|
||||
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||
]);
|
||||
// dd($request->toArray());
|
||||
$file_name = now()->getPreciseTimestamp(3) . '-' . $request->file('file')->getClientOriginalName();
|
||||
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||
$corporate = Corporate::with(['plans'])->findOrFail($corporate_id);
|
||||
@@ -521,4 +519,5 @@ class CorporateController extends Controller
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
0
Modules/Internal/Http/Controllers/Api/CorporateFormulariumController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/CorporateFormulariumController.php
Executable file → Normal file
31
Modules/Internal/Http/Controllers/Api/CorporateMemberController.php
Executable file → Normal file
31
Modules/Internal/Http/Controllers/Api/CorporateMemberController.php
Executable file → Normal file
@@ -10,11 +10,13 @@ use App\Models\Member;
|
||||
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||
use Box\Spout\Common\Entity\Row;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Internal\Services\MemberEnrollmentService;
|
||||
use PDF;
|
||||
|
||||
class CorporateMemberController extends Controller
|
||||
{
|
||||
@@ -41,10 +43,10 @@ class CorporateMemberController extends Controller
|
||||
'claims' => function ($claim) {
|
||||
// return $claim->whereBetween('requested_at', [now()->startOfYear(), now()->endOfYear()]);
|
||||
// return $claim->used(now()->startOfYear(), now()->endOfYear());
|
||||
}
|
||||
},
|
||||
'currentPlan',
|
||||
'currentPlan.benefits'
|
||||
])
|
||||
->with('currentPlan')
|
||||
// ->with
|
||||
->paginate()
|
||||
->appends($request->all());
|
||||
|
||||
@@ -179,7 +181,7 @@ class CorporateMemberController extends Controller
|
||||
}
|
||||
|
||||
try {
|
||||
// dd($new_member_data);
|
||||
|
||||
$rowResponse = $this->memberEnrollmentService->handleImportRow($corporate, $new_member_data);
|
||||
|
||||
// Write Success Result to File
|
||||
@@ -228,4 +230,25 @@ class CorporateMemberController extends Controller
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function generateLog(Request $request, $member_id)
|
||||
{
|
||||
$member = Member::findOrFail($member_id)
|
||||
->load([
|
||||
'currentPlan',
|
||||
'currentPolicy',
|
||||
'currentPlan.corporateBenefits' => function ($benefit) use ($request) {
|
||||
return $benefit->when($request->benefit_ids, function ($q, $ids) {
|
||||
return $q->whereIn('benefit_id', $ids);
|
||||
});
|
||||
},
|
||||
'currentPlan.corporateBenefits.benefit']);
|
||||
|
||||
$dateOfAdmission = $request->date_of_admission ? Carbon::parse($request->date_of_admission) : now();
|
||||
|
||||
// return view('pdf.guaranted_leter', compact('member'));
|
||||
$pdf = PDF::loadView('pdf.guaranted_leter', compact(['member', 'dateOfAdmission']));
|
||||
return $pdf->download('Guaranted Letter - '.$member->full_name.'.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
0
Modules/Internal/Http/Controllers/Api/CorporatePlanController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/CorporatePlanController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/CorporateServiceController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/CorporateServiceController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/DiagnosisController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/DiagnosisController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/DiagnosisExclusionController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/DiagnosisExclusionController.php
Executable file → Normal file
85
Modules/Internal/Http/Controllers/Api/DistrictController.php
Normal file
85
Modules/Internal/Http/Controllers/Api/DistrictController.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\District;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class DistrictController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$district = District::where('city_id', $request->city_id)->orderBy('name', 'asc')->get();
|
||||
|
||||
if (!$district) {
|
||||
return response(['message' => 'Tidak ada data'], 404);
|
||||
} else {
|
||||
return response(['message' => 'Data ditemukan', 'data' => $district]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
3
Modules/Internal/Http/Controllers/Api/DivisionController.php
Executable file → Normal file
3
Modules/Internal/Http/Controllers/Api/DivisionController.php
Executable file → Normal file
@@ -91,7 +91,8 @@ class DivisionController extends Controller
|
||||
$request->validate([
|
||||
'code' => [
|
||||
'required',
|
||||
Rule::unique('corporate_plans')->where('corporate_id', $corporate_id)->ignore($corporatePlan->id)
|
||||
// Rule::unique('corporate_plans')->where('corporate_id', $corporate_id)->ignore($corporatePlan->id)
|
||||
Rule::unique('corporate_divisions')->where('corporate_id', $corporate_id)
|
||||
],
|
||||
'name' => 'required'
|
||||
]);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Person;
|
||||
use App\Models\Practitioner;
|
||||
use App\Models\PractitionerRole;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
@@ -18,12 +19,6 @@ class DoctorController extends Controller
|
||||
*/
|
||||
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) {
|
||||
@@ -31,6 +26,9 @@ class DoctorController extends Controller
|
||||
$person->where('name', 'LIKE', '%' . $search . '%');
|
||||
});
|
||||
})
|
||||
->when($request->id ?? null, function ($query, $id) {
|
||||
$query->where('id', $id);
|
||||
})
|
||||
->when($request->organization_id ?? null, function ($query, $organization_id) {
|
||||
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($organization_id) {
|
||||
$practitionerRole->where('organization_id', $organization_id);
|
||||
@@ -65,7 +63,58 @@ class DoctorController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$data_person = [
|
||||
'name' => $request->name,
|
||||
'gender' => $request->gender,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'email' => $request->email,
|
||||
'birth_date' => date('Y-m-d', strtotime($request->birth_date)),
|
||||
'birth_place' => $request->birth_place,
|
||||
];
|
||||
|
||||
$person = Person::create($data_person);
|
||||
$address = $person->addresses()->create([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $request->address,
|
||||
]);
|
||||
|
||||
$person->main_address_id = $address->id;
|
||||
$person->save();
|
||||
|
||||
$practitioner = $person->practitioner()->create();
|
||||
|
||||
$practices = $request->practices;
|
||||
if ($practices[0]['organization_id'] !== null) {
|
||||
foreach ($practices as $key => $practice) {
|
||||
if (isset($practice['specialities'])) {
|
||||
//jika input spesialis
|
||||
foreach ($practice['specialities'] as $key => $speciality) {
|
||||
$speciality_id = $speciality['speciality_id'];
|
||||
$organization_id = $practice['organization_id'];
|
||||
$practitionerRole = $practitioner->practitionerRoles()->create([
|
||||
'organization_id' => $organization_id,
|
||||
'speciality_id' => $speciality_id,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
//jika tidak input spesialis
|
||||
$speciality_id = null;
|
||||
$organization_id = $practice['organization_id'];
|
||||
|
||||
$practitionerRole = $practitioner->practitionerRoles()->create([
|
||||
'organization_id' => $organization_id,
|
||||
'speciality_id' => $speciality_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Data berhasil disimpan',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +124,8 @@ class DoctorController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
|
||||
return response()->json(DoctorResource::make($practitioner));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +135,8 @@ class DoctorController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
|
||||
return response()->json(DoctorResource::make($practitioner));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +147,81 @@ class DoctorController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
$practitioner = Practitioner::find($id);
|
||||
$data_person = [
|
||||
'name' => $request->name,
|
||||
'gender' => $request->gender,
|
||||
'address' => $request->address,
|
||||
'phone' => $request->phone,
|
||||
'email' => $request->email,
|
||||
'birth_date' => date('Y-m-d', strtotime($request->birth_date)),
|
||||
'birth_place' => $request->birth_place,
|
||||
];
|
||||
|
||||
$person = $practitioner->person;
|
||||
$person->update($data_person);
|
||||
$address = $practitioner->person->addresses()->updateOrCreate([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $request->address,
|
||||
]);
|
||||
$practitioner->person->main_address_id = $address->id;
|
||||
$practitioner->person->save();
|
||||
|
||||
$practices = $request->practices;
|
||||
$practitionerRole = $practitioner->practitionerRoles()->get() ?? null;
|
||||
|
||||
foreach ($practices as $practice) {
|
||||
$organization_id = $practice['organization_id'];
|
||||
foreach ($practice['specialities'] as $speciality) {
|
||||
$speciality_id = $speciality['speciality_id'];
|
||||
$cek = $practitionerRole->where('organization_id', $organization_id)
|
||||
->where('speciality_id', $speciality_id)->first() ?? null;
|
||||
if (!$cek || $practitionerRole->isEmpty()) {
|
||||
// Create new practitioner role if not found
|
||||
$practitioner->practitionerRoles()->create([
|
||||
'organization_id' => $organization_id,
|
||||
'speciality_id' => $speciality_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($practitionerRole) {
|
||||
// Remove practitioner roles that are no longer exists
|
||||
$currentRoleIds = $practitionerRole->pluck('id')->toArray();
|
||||
$newRoleIds = [];
|
||||
|
||||
foreach ($practices as $practice) {
|
||||
$organization_id = $practice['organization_id'];
|
||||
foreach ($practice['specialities'] as $speciality) {
|
||||
$speciality_id = $speciality['speciality_id'];
|
||||
$newPractitionerRole = $practitionerRole->where('organization_id', $organization_id)
|
||||
->where('speciality_id', $speciality_id)
|
||||
->first();
|
||||
|
||||
if ($newPractitionerRole) {
|
||||
$newRoleIds[] = $newPractitionerRole->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$deletedRoleIds = array_diff($currentRoleIds, $newRoleIds);
|
||||
|
||||
if (count($deletedRoleIds) > 0) {
|
||||
// Delete practitioner roles that are no longer exists
|
||||
$data = $practitionerRole->whereIn('id', $deletedRoleIds);
|
||||
$data->each(function ($item) {
|
||||
$item->delete();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Data berhasil disimpan',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,6 +231,14 @@ class DoctorController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
$practitioner = Practitioner::find($id);
|
||||
$person = $practitioner->person->delete();
|
||||
$address = $practitioner->person->addresses()->delete();
|
||||
$practitionerRole = $practitioner->practitionerRoles()->delete();
|
||||
$practitioner->delete();
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Data berhasil dihapus',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
0
Modules/Internal/Http/Controllers/Api/DrugController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/DrugController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/FormulariumController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/FormulariumController.php
Executable file → Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api\Linksehat;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\LinksehatPaymentResource;
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
// return $request->toArray();
|
||||
$appointments = Appointment::query()
|
||||
->where('sPaymentStatus', 'settlement')
|
||||
->with(['healthCare', 'healthCare.commission', 'detail', 'user', 'doctor', 'doctor.user']);
|
||||
|
||||
if ($request->has('search')) {
|
||||
$appointments->where(function ($query) use ($request) {
|
||||
$query->where('nID', $request->search)
|
||||
->orWhere('sBookingCode', $request->search)
|
||||
->orWhereHas('detail', function (Builder $detail) use ($request) {
|
||||
$detail->where('sPaymentDetails', 'LIKE', '%' . $request->search . "%");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (($request->has('appointment_start') || $request->has('appointment_end'))
|
||||
&& !empty($request->appointment_start)
|
||||
&& !empty($request->appointment_end)
|
||||
) {
|
||||
// $appointments = $appointments->whereHas('detail', function (Builder $detail) use ($request) {
|
||||
|
||||
// // Appointment Start
|
||||
// // if ($request->has('appointment_start')) {
|
||||
// $detail->where('dTanggalAppointment', '>=', $request->appointment_start);
|
||||
// // } else {
|
||||
// // $detail->where('dTanggalAppointment', '>', now()->format('Y-m-d'));
|
||||
// // }
|
||||
|
||||
// // if ($request->has('appointment_end')) {
|
||||
// $detail->where('dTanggalAppointment', '<=', $request->appointment_end);
|
||||
// // } else {
|
||||
// // $detail->where('dTanggalAppointment', '<', now()->addDay(1)->format('Y-m-d'));
|
||||
// // }
|
||||
|
||||
// });
|
||||
|
||||
$appointments = $appointments->where(function($q) use ($request) {
|
||||
$q->where('dAgreeOn', '>=', $request->appointment_start)
|
||||
->where('dAgreeOn', '<=', $request->appointment_end);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('payment_status') && $request->payment_status != 'semua') {
|
||||
$appointments->where('sPaymentStatus', $request->payment_status);
|
||||
}
|
||||
|
||||
if ($request->has('healthcare_id') && !empty($request->healthcare_id)) {
|
||||
$appointments->where('nIDHealthCare', $request->healthcare_id);
|
||||
}
|
||||
|
||||
$appointments = $appointments->orderBy('dUpdateOn', 'DESC')
|
||||
->paginate();
|
||||
|
||||
return Helper::responseJson(Helper::paginateResources(LinksehatPaymentResource::collection($appointments)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
90
Modules/Internal/Http/Controllers/Api/LivechatController.php
Normal file
90
Modules/Internal/Http/Controllers/Api/LivechatController.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\LivechatResource;
|
||||
|
||||
class LivechatController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||
->latest()
|
||||
->paginate(15);
|
||||
|
||||
return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||
->where('nID', $id)
|
||||
->first();
|
||||
return response()->json(new LivechatResource($livechat));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
141
Modules/Internal/Http/Controllers/Api/OptionController.php
Normal file
141
Modules/Internal/Http/Controllers/Api/OptionController.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Icd;
|
||||
use App\Models\OLDLMS\Healthcare;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Practitioner;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class OptionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'type' => 'required',
|
||||
'search' => 'required'
|
||||
]);
|
||||
|
||||
switch ($request->type) {
|
||||
case 'diagnosis':
|
||||
$icds = Icd::query()
|
||||
->where('code', 'LIKE', '%'.$request->search.'%')
|
||||
->orWhere('name', 'LIKE', '%'.$request->search.'%')
|
||||
->limit('10')
|
||||
->get();
|
||||
|
||||
return $icds;
|
||||
break;
|
||||
case 'doctors':
|
||||
$doctors = Practitioner::query()
|
||||
->whereHas('person', function ($person) use ($request) {
|
||||
$person->where('name', 'LIKE', '%'.$request->search.'%');
|
||||
})
|
||||
->limit('10')
|
||||
->get();
|
||||
|
||||
$doctors = $doctors->map(function($doctor) {
|
||||
$doctorDetail = $doctor->person->toArray();
|
||||
unset($doctorDetail['id']);
|
||||
|
||||
return array_merge([
|
||||
'id' => $doctor->id,
|
||||
'code' => $doctor->code
|
||||
], $doctorDetail);
|
||||
});
|
||||
|
||||
return $doctors;
|
||||
break;
|
||||
case 'healthcares':
|
||||
$healthcares = Organization::query()
|
||||
->hospital()
|
||||
->where('name', 'LIKE', '%'.$request->search.'%')
|
||||
->limit('10')
|
||||
->get();
|
||||
|
||||
return $healthcares;
|
||||
break;
|
||||
case 'linksehat-healthcares':
|
||||
$healthcares = Healthcare::query()
|
||||
->where('sHealthCare', 'LIKE', '%'.$request->search.'%')
|
||||
->limit('10')
|
||||
->get();
|
||||
|
||||
return $healthcares;
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
return view('internal::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,44 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$organization = [
|
||||
'code' => $request->code,
|
||||
'name' => $request->name,
|
||||
'type' => 'hospital',
|
||||
'status' => $request->active == 1 ? 'active' : 'inactive',
|
||||
'description' => $request->description,
|
||||
];
|
||||
|
||||
$create_organization = Organization::create($organization);
|
||||
|
||||
if ($request->phone != null) {
|
||||
$create_organization->metas()->create([
|
||||
'system' => 'default',
|
||||
'type' => 'phone',
|
||||
'value' => $request->phone,
|
||||
]);
|
||||
}
|
||||
|
||||
$address = $create_organization->addresses()->create([
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $request->address,
|
||||
'province_id' => $request->province_id,
|
||||
'city_id' => $request->city_id,
|
||||
'district_id' => $request->district_id,
|
||||
'village_id' => $request->village_id,
|
||||
'postal_code' => $request->postal_code,
|
||||
'lat' => $request->lat,
|
||||
'lng' => $request->lng,
|
||||
]);
|
||||
|
||||
$create_organization->main_address_id = $address->id;
|
||||
$create_organization->save();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Data berhasil disimpan',
|
||||
'data' => new OrganizationResource($create_organization)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +94,7 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
return response()->json(OrganizationResource::make(Organization::find($id)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +104,7 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
return response()->json(OrganizationResource::make(Organization::find($id)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +115,46 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
$update_organization = Organization::find($id);
|
||||
|
||||
$update_organization->update([
|
||||
'code' => $request->code,
|
||||
'name' => $request->name,
|
||||
'type' => 'hospital',
|
||||
'status' => $request->active == 1 ? 'active' : 'inactive',
|
||||
'description' => $request->description,
|
||||
]);
|
||||
|
||||
if ($request->phone != null) {
|
||||
$update_organization->metas()->updateOrCreate([
|
||||
'system' => 'default',
|
||||
'type' => 'phone',
|
||||
], [
|
||||
'system' => 'default',
|
||||
'type' => 'phone',
|
||||
'value' => $request->phone,
|
||||
]);
|
||||
}
|
||||
|
||||
$update_organization->addresses()->updateOrCreate([
|
||||
'id' => $update_organization->main_address_id
|
||||
], [
|
||||
'use' => 'both',
|
||||
'type' => 'physical',
|
||||
'text' => $request->address,
|
||||
'province_id' => $request->province_id,
|
||||
'city_id' => $request->city_id,
|
||||
'district_id' => $request->district_id,
|
||||
'village_id' => $request->village_id,
|
||||
'postal_code' => $request->postal_code,
|
||||
'lat' => $request->lat,
|
||||
'lng' => $request->lng,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Data berhasil diubah',
|
||||
'data' => new OrganizationResource($update_organization)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,6 +164,12 @@ class OrganizationController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
$delete_organization = Organization::find($id);
|
||||
$delete_organization->addresses()->delete();
|
||||
$delete_organization->delete();
|
||||
return response()->json([
|
||||
'message' => 'Data berhasil dihapus',
|
||||
'data' => new OrganizationResource($delete_organization)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
0
Modules/Internal/Http/Controllers/Api/PlanController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/Api/PlanController.php
Executable file → Normal file
86
Modules/Internal/Http/Controllers/Api/ProvinceController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/ProvinceController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Province;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class ProvinceController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$province = Province::orderBy('name', 'ASC')->get();
|
||||
|
||||
if (empty($province)) {
|
||||
return response(['message' => 'Tidak ada data'], 404);
|
||||
} else {
|
||||
return response(['message' => 'Data ditemukan', 'data' => $province]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
86
Modules/Internal/Http/Controllers/Api/VillageController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/VillageController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Village;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class VillageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$villages = Village::where('district_id', $request->district_id)->orderBy('name', 'asc')->get();
|
||||
|
||||
if (!$villages) {
|
||||
return response(['message' => 'Tidak ada data'], 404);
|
||||
} else {
|
||||
return response(['message' => 'Data ditemukan', 'data' => $villages]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('internal::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
281
Modules/Internal/Http/Controllers/ClaimEncounterController.php
Normal file
281
Modules/Internal/Http/Controllers/ClaimEncounterController.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Claim;
|
||||
use App\Models\Encounter;
|
||||
use App\Models\Practitioner;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Internal\Transformers\EncounterResource;
|
||||
|
||||
class ClaimEncounterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('internal::index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, $claim_id)
|
||||
{
|
||||
$request->validate([
|
||||
'service_code' => 'required',
|
||||
'tanggal_masuk' => 'required',
|
||||
'tanggal_keluar' => 'required'
|
||||
]);
|
||||
$claim = Claim::findOrFail($claim_id);
|
||||
|
||||
// return ($request->primary_diagnosis['id']);
|
||||
// die;
|
||||
// return $request->toArray();
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$newEncounterData = [
|
||||
'status' => 'completed',
|
||||
'class' => $request->service_code,
|
||||
'type' => 'Consultation',
|
||||
'patient_id' => $claim->member->person_id,
|
||||
'start' => $request->tanggal_masuk,
|
||||
'end' => $request->tanggal_keluar,
|
||||
'number_of_bed' => $request->number_of_bed,
|
||||
'duration_day' => $request->duration_day
|
||||
];
|
||||
|
||||
if ($request->has('healthcare')) {
|
||||
$newEncounterData['healthcare_id'] = $request->healthcare['id'];
|
||||
}
|
||||
|
||||
// Create New Encounter
|
||||
$newEncounter = $claim->encounters()->create($newEncounterData);
|
||||
|
||||
|
||||
// --------------------------------------------
|
||||
// Meta
|
||||
// TODO Handle if healthcare not primaya
|
||||
$newEncounter->metas()->updateOrCreate([
|
||||
'type' => 'MEDRECID',
|
||||
'system' => 'primaya-his'
|
||||
], [
|
||||
'type' => 'MEDRECID',
|
||||
'system' => 'primaya-his',
|
||||
'value' => $request->medical_record_number
|
||||
]);
|
||||
|
||||
// ---------------------------------------------
|
||||
// Handle Diagnosis
|
||||
if ($request->has('primary_diagnosis') && $request->primary_diagnosis) {
|
||||
$newEncounter->diagnoses()->create([
|
||||
'diagnosis_id' => $request->primary_diagnosis['id'],
|
||||
'type' => 'primary',
|
||||
'use' => 'discharge',
|
||||
'source' => 'primecenter',
|
||||
'description' => 'Batching',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($request->has('secondary_diagnoses')) {
|
||||
foreach ($request->secondary_diagnoses as $diagnosis) {
|
||||
if (!isset($diagnosis['id'])) { // Handle Null Values
|
||||
continue;
|
||||
}
|
||||
$newEncounter->diagnoses()->create([
|
||||
'diagnosis_id' => $diagnosis['id'],
|
||||
'type' => 'secondary',
|
||||
'use' => 'discharge',
|
||||
'source' => 'primecenter',
|
||||
'description' => 'Batching',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
// Handle Doctors as primary Doctor
|
||||
if ($request->has('doctor')) {
|
||||
$newEncounter->participants()->create([
|
||||
'type' => 'Doctor',
|
||||
'participantable_type' => Practitioner::class,
|
||||
'participantable_id' => $request->doctor['id'],
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
|
||||
$newEncounter->load(['diagnoses', 'doctors', 'healthcare']);
|
||||
|
||||
return Helper::responseJson(data: EncounterResource::make($newEncounter), message: 'Encounter berhasil ditambahkan');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, $claim_id, $encounter_id)
|
||||
{
|
||||
$request->validate([
|
||||
'service_code' => 'required',
|
||||
'tanggal_masuk' => 'required',
|
||||
'tanggal_keluar' => 'required'
|
||||
]);
|
||||
// $claim = Claim::findOrFail($claim_id);
|
||||
|
||||
// return ($request->primary_diagnosis['id']);
|
||||
// die;
|
||||
// return $request->toArray();
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$encounter = Encounter::findOrFail($encounter_id);
|
||||
|
||||
$encounterData = [
|
||||
'status' => 'completed',
|
||||
'class' => $request->service_code,
|
||||
'type' => 'Consultation',
|
||||
'start' => $request->tanggal_masuk,
|
||||
'end' => $request->tanggal_keluar,
|
||||
'number_of_bed' => $request->number_of_bed,
|
||||
'duration_day' => $request->duration_day
|
||||
];
|
||||
|
||||
if ($request->has('healthcare')) {
|
||||
$encounterData['healthcare_id'] = $request->healthcare['id'];
|
||||
}
|
||||
|
||||
// Update The Encounter
|
||||
$encounter->fill($encounterData);
|
||||
$encounter->save();
|
||||
|
||||
|
||||
// --------------------------------------------
|
||||
// Meta
|
||||
// TODO Handle if healthcare not primaya
|
||||
$encounter->metas()->updateOrCreate([
|
||||
'type' => 'MEDRECID',
|
||||
'system' => 'primaya-his'
|
||||
], [
|
||||
'type' => 'MEDRECID',
|
||||
'system' => 'primaya-his',
|
||||
'value' => $request->medical_record_number
|
||||
]);
|
||||
|
||||
// ---------------------------------------------
|
||||
// Handle Diagnosis
|
||||
if ($request->has('primary_diagnosis')) {
|
||||
$encounter->diagnoses()->where('type', 'primary')->delete();
|
||||
$encounter->diagnoses()->create([
|
||||
'diagnosis_id' => $request->primary_diagnosis['id'],
|
||||
'type' => 'primary',
|
||||
'use' => 'discharge',
|
||||
'source' => 'primecenter',
|
||||
'description' => 'Batching',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($request->has('secondary_diagnoses')) {
|
||||
$encounter->diagnoses()->where('type', 'secondary')->delete();
|
||||
foreach ($request->secondary_diagnoses as $diagnosis) {
|
||||
if (!isset($diagnosis['id'])) { // Handle Null Values
|
||||
continue;
|
||||
}
|
||||
$encounter->diagnoses()->create([
|
||||
'diagnosis_id' => $diagnosis['id'],
|
||||
'type' => 'secondary',
|
||||
'use' => 'discharge',
|
||||
'source' => 'primecenter',
|
||||
'description' => 'Batching',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
// Handle Doctors as primary Doctor
|
||||
// if ($request->has('doctor')) {
|
||||
// $encounter->participants()->create([
|
||||
// 'type' => 'Doctor',
|
||||
// 'participantable_type' => Practitioner::class,
|
||||
// 'participantable_id' => $request->doctor['id'],
|
||||
// ]);
|
||||
// }
|
||||
DB::commit();
|
||||
|
||||
$encounter->load(['diagnoses', 'doctors', 'healthcare']);
|
||||
|
||||
return Helper::responseJson(data: EncounterResource::make($encounter), message: 'Encounter berhasil ditambahkan');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function setFinalEncounter(Request $request, $claim_id)
|
||||
{
|
||||
$request->validate([
|
||||
'encounter_id' => 'required'
|
||||
]);
|
||||
|
||||
$claim = Claim::findOrFail($claim_id);
|
||||
|
||||
$claim->final_encounter_id = $request->encounter_id;
|
||||
$claim->save();
|
||||
|
||||
return Helper::responseJson(data: $claim, message: "Success Update Final Encounter");
|
||||
}
|
||||
}
|
||||
0
Modules/Internal/Http/Controllers/InternalController.php
Executable file → Normal file
0
Modules/Internal/Http/Controllers/InternalController.php
Executable file → Normal file
0
Modules/Internal/Http/Middleware/.gitkeep
Executable file → Normal file
0
Modules/Internal/Http/Middleware/.gitkeep
Executable file → Normal file
0
Modules/Internal/Http/Requests/.gitkeep
Executable file → Normal file
0
Modules/Internal/Http/Requests/.gitkeep
Executable file → Normal file
0
Modules/Internal/Providers/.gitkeep
Executable file → Normal file
0
Modules/Internal/Providers/.gitkeep
Executable file → Normal file
0
Modules/Internal/Providers/InternalServiceProvider.php
Executable file → Normal file
0
Modules/Internal/Providers/InternalServiceProvider.php
Executable file → Normal file
0
Modules/Internal/Providers/RouteServiceProvider.php
Executable file → Normal file
0
Modules/Internal/Providers/RouteServiceProvider.php
Executable file → Normal file
0
Modules/Internal/Resources/assets/.gitkeep
Executable file → Normal file
0
Modules/Internal/Resources/assets/.gitkeep
Executable file → Normal file
0
Modules/Internal/Resources/assets/js/app.js
Executable file → Normal file
0
Modules/Internal/Resources/assets/js/app.js
Executable file → Normal file
0
Modules/Internal/Resources/assets/sass/app.scss
Executable file → Normal file
0
Modules/Internal/Resources/assets/sass/app.scss
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user