From 6a4447a549623bc31e4005f436fc87973fa9abac Mon Sep 17 00:00:00 2001 From: R Date: Tue, 13 Dec 2022 12:47:12 +0700 Subject: [PATCH] [WIP] Claims --- .../Controllers/Api/CorporateController.php | 2 + .../Api/OLDLMS/ClaimController.php | 47 +++++++++++++++++++ .../Api/{ => OLDLMS}/MembershipController.php | 2 +- app/Models/Corporate.php | 5 ++ app/Models/OLDLMS/Appointment.php | 25 ++++++++++ app/Models/OLDLMS/AppointmentDetail.php | 11 +++++ app/Models/OLDLMS/Healthcare.php | 11 +++++ app/Models/OLDLMS/Insurance.php | 11 +++++ app/Models/OLDLMS/User.php | 11 +++++ app/Models/OLDLMS/UserDetail.php | 11 +++++ app/Models/OLDLMS/UserInsurance.php | 11 +++++ app/Models/OLDLMS/UserInsuranceDetail.php | 11 +++++ app/Services/ClaimService.php | 3 +- config/database.php | 20 ++++++++ .../2022_11_22_135948_create_claims_table.php | 11 +++-- frontend/dashboard/src/pages/Claims/Form.tsx | 4 +- routes/api.php | 5 +- 17 files changed, 192 insertions(+), 9 deletions(-) create mode 100644 app/Http/Controllers/Api/OLDLMS/ClaimController.php rename app/Http/Controllers/Api/{ => OLDLMS}/MembershipController.php (97%) create mode 100644 app/Models/OLDLMS/Appointment.php create mode 100644 app/Models/OLDLMS/AppointmentDetail.php create mode 100644 app/Models/OLDLMS/Healthcare.php create mode 100644 app/Models/OLDLMS/Insurance.php create mode 100644 app/Models/OLDLMS/User.php create mode 100644 app/Models/OLDLMS/UserDetail.php create mode 100644 app/Models/OLDLMS/UserInsurance.php create mode 100644 app/Models/OLDLMS/UserInsuranceDetail.php diff --git a/Modules/Internal/Http/Controllers/Api/CorporateController.php b/Modules/Internal/Http/Controllers/Api/CorporateController.php index 978bef4e..b6ac62fb 100755 --- a/Modules/Internal/Http/Controllers/Api/CorporateController.php +++ b/Modules/Internal/Http/Controllers/Api/CorporateController.php @@ -5,6 +5,7 @@ namespace Modules\Internal\Http\Controllers\Api; use App\Exceptions\ImportRowException; use App\Imports\PlansImport; use App\Models\Benefit; +use App\Models\Claim; use App\Models\Corporate; use App\Models\Plan; use App\Services\ImportService; @@ -34,6 +35,7 @@ class CorporateController extends Controller ->withCount([ 'employees', 'corporateBenefits', + // 'claims' ]) ->where('type', 'corporate') ->paginate(10); diff --git a/app/Http/Controllers/Api/OLDLMS/ClaimController.php b/app/Http/Controllers/Api/OLDLMS/ClaimController.php new file mode 100644 index 00000000..4fc9d108 --- /dev/null +++ b/app/Http/Controllers/Api/OLDLMS/ClaimController.php @@ -0,0 +1,47 @@ +validate([ + 'member_id' => 'required', + 'user_id' => 'required', + 'type' => 'required|in:consultation-gp,consultation-specialist,medicine', + 'total_claim' => 'required', + 'detail' => 'required', + ]); + + if ($request->type == 'consultation-gp') { + $benefitCode = 'OPCONS1'; + } + if ($request->type == 'consultation-specialist') { + $benefitCode = 'OPCONS2'; + } + if ($request->type == 'medicine') { + $benefitCode = 'OPMEDI1'; + } + + $member = Member::query() + ->where('member_id', $request->member_id) + ->with([ + 'currentPlan', + ]) + ->firstOrFail(); + $benefit = $member->currentPlan->benefits()->where('benefit_code', $benefitCode)->first(); + // $diagnosis = Icd::first(); + + $claim = ClaimService::storeClaim($member, null, $request->total_claim, $benefit, 'approved'); + + return Helper::responseJson($claim); + } +} diff --git a/app/Http/Controllers/Api/MembershipController.php b/app/Http/Controllers/Api/OLDLMS/MembershipController.php similarity index 97% rename from app/Http/Controllers/Api/MembershipController.php rename to app/Http/Controllers/Api/OLDLMS/MembershipController.php index 23232ca0..176561dc 100644 --- a/app/Http/Controllers/Api/MembershipController.php +++ b/app/Http/Controllers/Api/OLDLMS/MembershipController.php @@ -1,6 +1,6 @@ hasManyThrough(CorporateService::class, Service::class, 'corporate_id', 'service_code', 'id', 'service_code'); } + // public function claims() + // { + // return $this->hasManyThrough() + // } + public function corporateServices() { return $this->hasMany(CorporateService::class, 'corporate_id'); diff --git a/app/Models/OLDLMS/Appointment.php b/app/Models/OLDLMS/Appointment.php new file mode 100644 index 00000000..030ad6a6 --- /dev/null +++ b/app/Models/OLDLMS/Appointment.php @@ -0,0 +1,25 @@ +hasOne(AppointmentDetail::class, ''); + } +} diff --git a/app/Models/OLDLMS/AppointmentDetail.php b/app/Models/OLDLMS/AppointmentDetail.php new file mode 100644 index 00000000..98212e1f --- /dev/null +++ b/app/Models/OLDLMS/AppointmentDetail.php @@ -0,0 +1,11 @@ + $member->id, - 'diagnosis_id' => $diagnosis->id, + 'diagnosis_id' => $diagnosis->id ?? null, 'total_claim' => $totalClaim, 'currency' => 'IDR', 'plan_id' => $member->currentPlan->id, diff --git a/config/database.php b/config/database.php index 137ad18c..6b3c0fc2 100755 --- a/config/database.php +++ b/config/database.php @@ -63,6 +63,26 @@ return [ ]) : [], ], + 'oldlms' => [ + 'driver' => 'mysql', + 'url' => env('OLDLMS_DATABASE_URL'), + 'host' => env('OLDLMS_DB_HOST', '127.0.0.1'), + 'port' => env('OLDLMS_DB_PORT', '3306'), + 'database' => env('OLDLMS_DB_DATABASE', 'forge'), + 'username' => env('OLDLMS_DB_USERNAME', 'forge'), + 'password' => env('OLDLMS_DB_PASSWORD', ''), + 'unix_socket' => env('OLDLMS_DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), diff --git a/database/migrations/2022_11_22_135948_create_claims_table.php b/database/migrations/2022_11_22_135948_create_claims_table.php index 786a4a12..2a750d68 100644 --- a/database/migrations/2022_11_22_135948_create_claims_table.php +++ b/database/migrations/2022_11_22_135948_create_claims_table.php @@ -17,11 +17,11 @@ return new class extends Migration $table->id(); $table->string('code')->index(); $table->foreignId('member_id')->index(); - $table->foreignId('diagnosis_id')->index(); - $table->string('total_claim'); + $table->foreignId('diagnosis_id')->index()->nullable(); + $table->string('total_claim')->nullable(); $table->string('currency'); - $table->foreignId('plan_id')->index(); - $table->foreignId('benefit_id')->index(); + $table->foreignId('plan_id')->index()->nullable(); + $table->foreignId('benefit_id')->index()->nullable(); $table->string('status'); @@ -31,6 +31,9 @@ return new class extends Migration $table->dateTime('received_at')->nullable(); $table->unsignedBigInteger('received_by')->nullable()->index(); + $table->dateTime('approved_at')->nullable(); + $table->unsignedBigInteger('approved_by')->nullable()->index(); + $table->dateTime('declined')->nullable(); $table->unsignedBigInteger('declined_by')->nullable()->index(); diff --git a/frontend/dashboard/src/pages/Claims/Form.tsx b/frontend/dashboard/src/pages/Claims/Form.tsx index 0da987d1..a4898695 100644 --- a/frontend/dashboard/src/pages/Claims/Form.tsx +++ b/frontend/dashboard/src/pages/Claims/Form.tsx @@ -414,7 +414,7 @@ export default function ClaimForm({ isEdit, currentClaim }: Props) { }} > {/* Not Eligible */} - + {/* 125.000.000 / 125.000.000 - + */} )} diff --git a/routes/api.php b/routes/api.php index c33577fd..b969597c 100755 --- a/routes/api.php +++ b/routes/api.php @@ -1,7 +1,8 @@ group(function() { Route::post('check-membership', [MembershipController::class, 'check']); Route::post('check-limit', [MembershipController::class, 'checkLimit']); + + Route::post('claim-create', [ClaimController::class, 'store']); }); \ No newline at end of file