3 Commits

Author SHA1 Message Date
R
d706bf0623 [WIP] Add Approve Button 2023-02-14 13:07:17 +07:00
R
13542cd3c0 [WIP] Add Claim Request 2023-02-14 12:39:51 +07:00
pajri
a7e688a52c hospital portal 2023-02-01 16:22:03 +07:00
628 changed files with 50180 additions and 4880 deletions

View 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' => 4444, //rand(1000, 9999),
'otp' => rand(1000, 9999),
'otp_created_at' => now()
]);
} else {
User::query()->find($user->id)->update([
'phone' => $request->phoneOrEmail,
'otp' => 4444,//rand(1000, 9999),
'otp' => rand(1000, 9999),
'otp_created_at' => now()
]);
}

View File

@@ -26,7 +26,7 @@ class DashboardResources extends JsonResource
'myLimit' => [
'balance' => $myLimitBalance,
'total' => $myLimitTotal,
'percentage' => $myLimitTotal ? (($myLimitBalance / $myLimitTotal) * 100) : 0,
'percentage' => ($myLimitBalance / $myLimitTotal) * 100,
],
'lockLimit' => [
'balance' => $lockBalance,

View File

View File

@@ -0,0 +1,5 @@
<?php
return [
'name' => 'HospitalPortal'
];

View File

View File

@@ -0,0 +1,21 @@
<?php
namespace Modules\HospitalPortal\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class HospitalPortalDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}

View File

View File

@@ -0,0 +1,128 @@
<?php
namespace Modules\HospitalPortal\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\User;
use Crypt;
use Error;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use Modules\Internal\Emails\SendVerifyEmail;
use Modules\Internal\Events\ForgetPassword;
class AuthController extends Controller
{
public function login(Request $request)
{
$request->validate([
'email' => 'required|email',
'password' => 'required'
]);
$user = User::query()
->where('email', $request->email)
->first();
if (!$user) {
return response(['message' => 'User Tidak Ditemukan'], 404);
}
if (!Hash::check($request->password, $user->password)) {
return response(['message' => 'Password Salah'], 403);
}
return response([
'message' => 'Selamat Datang',
'user' => $user,
'token' => $user->createToken('app')->plainTextToken
]);
}
public function logout(Request $request)
{
$token = $request->bearerToken();
Auth::user()->tokens()->where('id', $token)->delete();
return response(['message' => 'Berhasil Logout.']);
}
public function resetPassword(Request $request)
{
$user = Auth::user();
$request->validate([
'old_password' => 'required',
'new_password' => 'required',
'confirm_new_password' => 'required'
]);
if (!Hash::check($request['old_password'], $user->password)) {
return response(['message' => 'Password Salah'], 403);
}
if ($request["new_password"] != $request["confirm_new_password"]) {
return response([
'message' => "Password Tidak Sama"
]);
}
$user->update([
'password' => Hash::make($request->confirm_new_password),
]);
return response()->json($user);
}
public function verifyEmail(Request $request)
{
$request->validate([
'email' => 'required|email',
]);
$user = User::query()
->where('email', $request->email)
->first();
if (!$user) {
return response(['message' => 'User Tidak Ditemukan'], 404);
}
Event(new ForgetPassword($user));
// Mail::to($user->email)->send(new SendVerifyEmail($user));
return response()->json($user);
}
public function forgetPassword(Request $request)
{
$request->validate([
'new_password' => 'required',
'confirm_new_password' => 'required'
]);
$token = Crypt::decryptString($request->token);
$email = explode('|', $token)[0];
$user = User::query()
->where('email', $email)
->first();
if (!$user) {
return response(['message' => 'User Tidak Ditemukan'], 404);
}
if ($request["new_password"] != $request["confirm_new_password"]) {
return response([
'message' => "Password Tidak Sama"
], 404);
}
$user->update([
'password' => Hash::make($request->confirm_new_password),
]);
return response()->json($user);
}
}

View File

@@ -1,15 +1,14 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
namespace Modules\HospitalPortal\Http\Controllers\Api;
use App\Helpers\Helper;
use App\Models\OLDLMS\Appointment;
use App\Models\ClaimRequest;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\Internal\Transformers\AppointmentResource;
class AppointmentController extends Controller
class ClaimRequestController extends Controller
{
/**
* Display a listing of the resource.
@@ -17,19 +16,20 @@ class AppointmentController extends Controller
*/
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)));
$claimRequests = ClaimRequest::query()
->with(['member'])
->paginate();
return Helper::responseJson($claimRequests);
}
/**
* Show the form for creating a new resource.
* @return Renderable
*/
public function create()
{
return view('internal::create');
return view('hospitalportal::create');
}
/**
@@ -39,7 +39,19 @@ class AppointmentController extends Controller
*/
public function store(Request $request)
{
//
$request->validate([
// 'submission_date' => 'required',
'member_id' => 'required',
// 'files' => ''
]);
$newClaimRequest = ClaimRequest::create([
'member_id' => $request->member_id,
'submission_date' => now(),
'status' => 'requested'
]);
return Helper::responseJson(data: $newClaimRequest, message: 'Claim Request berhasil ajukan!');
}
/**
@@ -49,11 +61,7 @@ class AppointmentController extends Controller
*/
public function show($id)
{
$appointments = Appointment::query()
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare')
->where('nID', $id)
->first();
return response()->json(new AppointmentResource($appointments));
return view('hospitalportal::show');
}
/**
@@ -63,7 +71,7 @@ class AppointmentController extends Controller
*/
public function edit($id)
{
return view('internal::edit');
return view('hospitalportal::edit');
}
/**

View File

@@ -0,0 +1,41 @@
<?php
namespace Modules\HospitalPortal\Http\Controllers\Api;
use App\Helpers\Helper;
use App\Models\Member;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class MemberController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function search(Request $request)
{
$request->validate([
'no_polis' => 'required',
'birth_date' => 'required'
]);
$member = Member::query()
->where('member_id', $request->no_polis)
->where('birth_date', $request->birth_date)
->with(['person', 'currentCorporate',
// 'currentCorporate.corporateServices' => function ($corporateService) {
// $corporateService->where('status', 'active');
// },
// 'currentCorporate.corporateServices.service'
// 'currentPlan.benefits',
// 'currentPlan.corporateBenefit.plan',
'currentPlan.corporateBenefits.benefit'
])
->firstOrFail();
return Helper::responseJson($member);
}
}

View File

@@ -1,27 +1,24 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
namespace Modules\HospitalPortal\Http\Controllers;
use App\Models\Province;
use App\Helpers\Helper;
use App\Models\Claim;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class ProvinceController extends Controller
class ClaimController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request)
public function index()
{
$province = Province::orderBy('name', 'ASC')->get();
$claims = Claim::where('deleted_at', 'ASD')->paginate(5);
if (empty($province)) {
return response(['message' => 'Tidak ada data'], 404);
} else {
return response(['message' => 'Data ditemukan', 'data' => $province]);
}
return Helper::responseJson($claims);
}
/**
@@ -30,7 +27,7 @@ class ProvinceController extends Controller
*/
public function create()
{
return view('internal::create');
return view('hospitalportal::create');
}
/**
@@ -50,7 +47,7 @@ class ProvinceController extends Controller
*/
public function show($id)
{
return view('internal::show');
return view('hospitalportal::show');
}
/**
@@ -60,7 +57,7 @@ class ProvinceController extends Controller
*/
public function edit($id)
{
return view('internal::edit');
return view('hospitalportal::edit');
}
/**

View File

@@ -1,27 +1,20 @@
<?php
namespace Modules\Internal\Http\Controllers\Api;
namespace Modules\HospitalPortal\Http\Controllers;
use App\Models\City;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class CityController extends Controller
class HospitalPortalController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request)
public function index()
{
$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]);
}
return view('hospitalportal::index');
}
/**
@@ -30,7 +23,7 @@ class CityController extends Controller
*/
public function create()
{
return view('internal::create');
return view('hospitalportal::create');
}
/**
@@ -50,7 +43,7 @@ class CityController extends Controller
*/
public function show($id)
{
return view('internal::show');
return view('hospitalportal::show');
}
/**
@@ -60,7 +53,7 @@ class CityController extends Controller
*/
public function edit($id)
{
return view('internal::edit');
return view('hospitalportal::edit');
}
/**

View File

@@ -0,0 +1,112 @@
<?php
namespace Modules\HospitalPortal\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
class HospitalPortalServiceProvider extends ServiceProvider
{
/**
* @var string $moduleName
*/
protected $moduleName = 'HospitalPortal';
/**
* @var string $moduleNameLower
*/
protected $moduleNameLower = 'hospitalportal';
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}
/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
], 'config');
$this->mergeConfigFrom(
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'Resources/views');
$this->publishes([
$sourcePath => $viewPath
], ['views', $this->moduleNameLower . '-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
}
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (\Config::get('view.paths') as $path) {
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
$paths[] = $path . '/modules/' . $this->moduleNameLower;
}
}
return $paths;
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace Modules\HospitalPortal\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* The module namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $moduleNamespace = 'Modules\HospitalPortal\Http\Controllers';
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function boot()
{
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->moduleNamespace)
->group(module_path('HospitalPortal', '/Routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->group(module_path('HospitalPortal', '/Routes/api.php'));
}
}

View File

@@ -0,0 +1,9 @@
@extends('hospitalportal::layouts.master')
@section('content')
<h1>Hello World</h1>
<p>
This view is loaded from module: {!! config('hospitalportal.name') !!}
</p>
@endsection

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Module HospitalPortal</title>
{{-- Laravel Mix - CSS File --}}
{{-- <link rel="stylesheet" href="{{ mix('css/hospitalportal.css') }}"> --}}
</head>
<body>
@yield('content')
{{-- Laravel Mix - JS File --}}
{{-- <script src="{{ mix('js/hospitalportal.js') }}"></script> --}}
</body>
</html>

View File

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Http\Request;
use Modules\HospitalPortal\Http\Controllers\Api\AuthController;
use Modules\HospitalPortal\Http\Controllers\Api\ClaimRequestController;
use Modules\HospitalPortal\Http\Controllers\Api\MemberController;
use Modules\HospitalPortal\Http\Controllers\ClaimController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::prefix('hospitalportal')->group(function () {
Route::post('login', [AuthController::class, 'login'])->name('login');
Route::post('forget-password', [AuthController::class, 'forgetPassword'])->name('forget-password');
Route::post('verify-email', [AuthController::class, 'verifyEmail'])->name('verify-email');
Route::middleware('auth:sanctum')->group(function () {
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
Route::get('/user', function (Request $request) {
return $request->user();
});
Route::put('reset-password', [AuthController::class, 'resetPassword'])->name('resetPassword');
Route::get('claims', [ClaimController::class, 'index']);
Route::post('search-member', [MemberController::class, 'search']);
Route::get('claim-requests', [ClaimRequestController::class, 'index'])->name('claim-requests.index');
Route::post('claim-requests', [ClaimRequestController::class, 'store'])->name('claim-requests.store');
});
});

View File

@@ -0,0 +1,16 @@
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::prefix('hospitalportal')->group(function() {
Route::get('/', 'HospitalPortalController@index');
});

View File

@@ -0,0 +1,23 @@
{
"name": "nwidart/hospitalportal",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\HospitalPortal\\": ""
}
}
}

View File

@@ -0,0 +1,13 @@
{
"name": "HospitalPortal",
"alias": "hospitalportal",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\HospitalPortal\\Providers\\HospitalPortalServiceProvider"
],
"aliases": {},
"files": [],
"requires": []
}

View File

@@ -0,0 +1,21 @@
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"axios": "^0.21.4",
"dotenv": "^10.0.0",
"dotenv-expand": "^5.1.0",
"laravel-mix": "^6.0.31",
"laravel-mix-merge-manifest": "^2.0.0",
"lodash": "^4.17.21",
"postcss": "^8.3.7"
}
}

View File

@@ -0,0 +1,14 @@
const dotenvExpand = require('dotenv-expand');
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));
const mix = require('laravel-mix');
require('laravel-mix-merge-manifest');
mix.setPublicPath('../../public').mergeManifest();
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/hospitalportal.js')
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/hospitalportal.css');
if (mix.inProduction()) {
mix.version();
}

View File

@@ -2,26 +2,25 @@
namespace Modules\Internal\Http\Controllers\Api;
use App\Models\Village;
use App\Helpers\Helper;
use App\Models\ClaimRequest;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class VillageController extends Controller
class ClaimRequestController extends Controller
{
/**
* Display a listing of the resource.
* @return Renderable
*/
public function index(Request $request)
public function index()
{
$villages = Village::where('district_id', $request->district_id)->orderBy('name', 'asc')->get();
$claimRequests = ClaimRequest::query()
->with(['member'])
->paginate();
if (!$villages) {
return response(['message' => 'Tidak ada data'], 404);
} else {
return response(['message' => 'Data ditemukan', 'data' => $villages]);
}
return $claimRequests;
}
/**
@@ -83,4 +82,16 @@ class VillageController extends Controller
{
//
}
public function approve($id)
{
$claimRequest = ClaimRequest::findOrFail($id);
$claimRequest->status = 'approved';
$claimRequest->save();
// Generate LOG
return $claimRequest;
}
}

View File

@@ -15,7 +15,6 @@ use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Storage;
use Modules\Internal\Services\MemberEnrollmentService;
use PDF;
class CorporateMemberController extends Controller
{
@@ -229,25 +228,4 @@ class CorporateMemberController extends Controller
]
];
}
public function generateLog($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'));
return $pdf->download('Guaranted Letter - '.$member->full_name.'.pdf');
}
}

View File

@@ -1,85 +0,0 @@
<?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)
{
//
}
}

View File

@@ -3,7 +3,6 @@
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;
@@ -19,6 +18,12 @@ 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) {
@@ -26,9 +31,6 @@ 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);
@@ -63,58 +65,7 @@ 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',
]);
//
}
/**
@@ -124,8 +75,7 @@ class DoctorController extends Controller
*/
public function show($id)
{
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
return response()->json(DoctorResource::make($practitioner));
return view('internal::show');
}
/**
@@ -135,8 +85,7 @@ class DoctorController extends Controller
*/
public function edit($id)
{
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
return response()->json(DoctorResource::make($practitioner));
return view('internal::edit');
}
/**
@@ -147,81 +96,7 @@ 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',
]);
//
}
/**
@@ -231,14 +106,6 @@ 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',
]);
//
}
}

View File

@@ -1,90 +0,0 @@
<?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)
{
//
}
}

View File

@@ -47,44 +47,7 @@ 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)
]);
//
}
/**
@@ -94,7 +57,7 @@ class OrganizationController extends Controller
*/
public function show($id)
{
return response()->json(OrganizationResource::make(Organization::find($id)));
return view('internal::show');
}
/**
@@ -104,7 +67,7 @@ class OrganizationController extends Controller
*/
public function edit($id)
{
return response()->json(OrganizationResource::make(Organization::find($id)));
return view('internal::edit');
}
/**
@@ -115,46 +78,7 @@ 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)
]);
//
}
/**
@@ -164,12 +88,6 @@ 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)
]);
//
}
}

View File

@@ -3,10 +3,9 @@
use App\Http\Controllers\Api\MemberController as ApiMemberController;
use Modules\Internal\Http\Controllers\Api\AuthController;
use Illuminate\Http\Request;
use Modules\Internal\Http\Controllers\Api\AppointmentController;
use Modules\Internal\Http\Controllers\Api\BenefitController;
use Modules\Internal\Http\Controllers\Api\CityController;
use Modules\Internal\Http\Controllers\Api\ClaimController;
use Modules\Internal\Http\Controllers\Api\ClaimRequestController;
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
use Modules\Internal\Http\Controllers\Api\CorporateController;
use Modules\Internal\Http\Controllers\Api\CorporateFormulariumController;
@@ -15,18 +14,14 @@ use Modules\Internal\Http\Controllers\Api\CorporatePlanController;
use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
use Modules\Internal\Http\Controllers\Api\DistrictController;
use Modules\Internal\Http\Controllers\Api\DivisionController;
use Modules\Internal\Http\Controllers\Api\DoctorController;
use Modules\Internal\Http\Controllers\Api\DrugController;
use Modules\Internal\Http\Controllers\Api\FormulariumController;
use Modules\Internal\Http\Controllers\Api\LivechatController;
use Modules\Internal\Http\Controllers\Api\MemberController;
use Modules\Internal\Http\Controllers\Api\OrganizationController;
use Modules\Internal\Http\Controllers\Api\PlanController;
use Modules\Internal\Http\Controllers\Api\ProvinceController;
use Modules\Internal\Http\Controllers\Api\SpecialityController;
use Modules\Internal\Http\Controllers\Api\VillageController;
/*
|--------------------------------------------------------------------------
@@ -125,17 +120,14 @@ Route::prefix('internal')->group(function () {
Route::get('search-organizations', [OrganizationController::class, 'searchOrganization']);
Route::get('search-specialities', [SpecialityController::class, 'searchSpeciality']);
Route::resource('organizations', OrganizationController::class);
Route::resource('appointments', AppointmentController::class);
Route::resource('live-chat', LivechatController::class);
Route::resource('doctors', DoctorController::class);
Route::get('generate-log/{member_id}', [CorporateMemberController::class, 'generateLog']);
Route::get('claim-requests', [ClaimRequestController::class, 'index'])->name('claim-requests.index');
Route::post('claim-requests/{id}/approve', [ClaimRequestController::class, 'approve'])->name('claim-requests.approve');
});
Route::get('province', [ProvinceController::class, 'index']);
Route::get('city', [CityController::class, 'index']);
Route::get('district', [DistrictController::class, 'index']);
Route::get('village', [VillageController::class, 'index']);
// Route::resource('organizations', OrganizationController::class);
// Route::resource('doctors', DoctorController::class);
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
});

View File

@@ -11,8 +11,6 @@
|
*/
use Modules\Internal\Http\Controllers\Api\CorporateMemberController;
Route::prefix('internal')->group(function() {
Route::get('/', 'InternalController@index');
});
});

View File

@@ -42,8 +42,10 @@ class CorporateService
$this->validatePlanRow($plan_data);
$plan = $corporate->plans()->updateOrCreate([
$plan = Plan::updateOrCreate([
'service_code' => $plan_data['service_code'],
'corporate_id' => $corporate->id,
'code' => $plan_data['code'],
], $plan_data);
return $plan;

View File

@@ -1,53 +0,0 @@
<?php
namespace Modules\Internal\Transformers;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
class AppointmentResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$appointment = [
'id' => $this->nID,
'patient_name' => $this->user ? $this->user->full_name : '',
'doctor_name' => $this->doctor ? $this->doctor->user?->full_name : '',
'speciality' => $this->doctor->speciality->sKeterangan,
'date_appointment' => Carbon::parse($this->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointmentDetail->tTimeAppointment,
'date_created' => Carbon::parse($this->dCreateOn)->format('d-m-Y H:i:s') ?? null,
'appointment_media' => $this->sMedia,
'status' => $this->status_name,
'health_care' => $this->healthCare->sHealthCare ?? null,
'payment_method' => $this->payment_method ?? null,
'patient' => $this->user,
'booking_code' => $this->sBookingCode,
'his_detail' => [
'RegID' => $this->sRegID,
'Medrec' => $this->sNomorRekamMedis
],
'type' => $this->type
];
$payment_detail = null;
if ($this->appointmentDetail->sPaymentDetails != null) {
$payment_detail = [
'payment_type' => $this->appointmentDetail->sPaymentDetails['payment_type'] ?? '',
'transaction_time' => $this->appointmentDetail->sPaymentDetails['transaction_time'] ?? '',
'gross_amount' => $this->appointmentDetail->sPaymentDetails['gross_amount'] ?? '',
'currency' => $this->appointmentDetail->sPaymentDetails['currency'] ?? '',
'status_message' => $this->appointmentDetail->sPaymentDetails['status_message'] ?? '',
];
}
$appointment['payment_detail'] = $payment_detail;
return $appointment;
}
}

View File

@@ -4,8 +4,6 @@ namespace Modules\Internal\Transformers;
use Illuminate\Http\Resources\Json\JsonResource;
use function PHPSTORM_META\map;
class DoctorResource extends JsonResource
{
/**
@@ -21,51 +19,35 @@ class DoctorResource extends JsonResource
// 'his_dokter_id' => $this->practitionerRoles->meta,
'name' => $this->person->name,
'person_id' => $this->person->id,
'phone' => $this->person->phone ?? null,
'email' => $this->person->email ?? null,
'birth_date' => $this->person->birth_date ?? null,
'birth_place' => $this->person->birth_place ?? null,
'gender' => $this->person->gender == "L" || $this->person->gender == "male" ? 'male' : 'female',
'address' => $this->person->currentAddress->text ?? null,
'phone' => $this->person->phone,
'email' => $this->person->email,
'gender' => $this->person->gender == "L" ? 'Laki-laki' : 'Perempuan',
'address' => $this->person->currentAddress->text,
'organizations' => $this->practitionerRoles->unique('organization_id')->map(function ($practitionerRole) {
return [
'organization_id' => $practitionerRole->organization->id,
'organization_name' => $practitionerRole->organization->name,
];
})->values(),
}),
"specialties" => $this->practitionerRoles->unique('speciality_id')->map(function ($practitionerRole) {
return [
'specialty_id' => $practitionerRole->speciality->id,
'specialty_name' => $practitionerRole->speciality->name,
];
}),
// "departemen" => $this->practitionerRoles->map(function ($practitionerRole) {
// return [
// 'departemen_id' => $practitionerRole->meta->DepartemenID ?? null,
// ];
// }) ?? null,
'education' => $this->meta->education ?? null,
'experience' => $this->meta->work_experience ?? null,
'award' => $this->meta->award ?? null,
'keilmuan' => $this->meta->Keilmuan ?? null,
'tipe_dokter' => $this->meta->tipeDokter ?? null,
"departemen" => $this->practitionerRoles->map(function ($practitionerRole) {
return [
'departemen_id' => $practitionerRole->meta->DepartemenID,
];
}),
'education' => $this->meta->education,
'experience' => $this->meta->work_experience,
'award' => $this->meta->award,
'keilmuan' => $this->meta->Keilmuan,
'tipe_dokter' => $this->meta->tipeDokter,
];
$grouped = $this->collection($this->practitionerRoles)->groupBy('organization_id');
$grouped->transform(function ($items, $key) {
return [
'organization_id' => $key,
'specialities' => $items->map(function ($item) {
return [
'speciality_id' => $item->speciality->id,
];
}),
];
});
$doctor['practices'] = $grouped->toArray();
return $doctor;
}
}

View File

@@ -1,62 +0,0 @@
<?php
namespace Modules\Internal\Transformers;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
class LivechatResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$livechat = [
'id' => $this->nID,
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
'speciality' => $this->doctor->speciality->sKeterangan ?? null,
'health_care' => $this->healthCare->sHealthCare ?? null,
'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y')
. ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null,
'status_appointment' => $this->appointment->status_name ?? null,
'date_created' => Carbon::parse($this->appointment->dCreateOn)->format('d-m-Y H:i:s') ?? null,
'patient_media' => $this->sMedia ?? null,
'doctor_media' => $this->sMediaDokter ?? null,
'appointment_media' => $this->appointment->sMedia ?? null,
'status_chat' => $this->status_name ?? null,
'payment_method' => $this->appointment->payment_method ?? null,
];
$start_time = $this->dStartTime;
$end_time = $this->dEndTime;
$data_duration = 0 . ' jam ' . 0 . ' menit ' . 0 . ' detik';
if ($start_time != null && $end_time != null) {
$duration = Carbon::parse($start_time)->diffInMinutes(Carbon::parse($end_time));
$hours = floor($duration / 60);
$minutes = $duration % 60;
$seconds = ($duration - ($hours * 60) - $minutes) * 60;
$data_duration = $hours . ' jam ' . $minutes . ' menit ' . $seconds . ' detik';
}
$livechat['duration'] = $data_duration;
$payment_detail = null;
if ($this->appointment->appointmentDetail->sPaymentDetails != null) {
$payment_detail = [
'payment_type' => $this->appointment->appointmentDetail->sPaymentDetails['payment_type'],
'transaction_time' => $this->appointment->appointmentDetail->sPaymentDetails['transaction_time'],
'gross_amount' => $this->appointment->appointmentDetail->sPaymentDetails['gross_amount'],
'currency' => $this->appointment->appointmentDetail->sPaymentDetails['currency'],
'status_message' => $this->appointment->appointmentDetail->sPaymentDetails['status_message'],
];
}
$livechat['payment_detail'] = $payment_detail;
return $livechat;
}
}

View File

@@ -14,24 +14,17 @@ class OrganizationResource extends JsonResource
*/
public function toArray($request)
{
$organization = [
'id' => $this->id,
'name' => $this->name,
'type' => $this->type,
'code' => $this->code,
'description' => $this->description,
'kodeRs' => $this->meta->KodeRS ?? null,
'kodeRs' => $this->meta->kodeRs ?? null,
'phone' => $this->meta->phone ?? null,
'lat' => $this->currentAddress->lat ?? null,
'lng' => $this->currentAddress->lng ?? null,
'address' => $this->currentAddress->text ?? null,
'province_id' => $this->currentAddress->province_id ?? null,
'city_id' => $this->currentAddress->city_id ?? null,
'district_id' => $this->currentAddress->district_id ?? null,
'village_id' => $this->currentAddress->village_id ?? null,
'postal_code' => $this->currentAddress->postal_code ?? null,
'active' => $this->status == 'active' ? 1 : 0,
'address' => $this->currentAddress ?? null,
];
return $organization;

View File

@@ -4,10 +4,7 @@ namespace App\Http\Controllers\Api\OLDLMS;
use App\Helpers\Helper;
use App\Http\Controllers\Controller;
use App\Http\Resources\OLDLMS\MemberResource;
use App\Models\Corporate;
use App\Models\Member;
use App\Rules\NikRule;
use App\Services\ClaimService;
use Illuminate\Http\Request;
@@ -172,91 +169,4 @@ class MembershipController extends Controller
return Helper::responseJson(data: $limits);
}
public function linkingRules(Request $request)
{
$corporates = Corporate::query()
->when($request->search, function ($q, $search) {
$q->where('name', 'LIKE', '%'.$search.'%');
})
->get();
return Helper::responseJson(data: $corporates);
}
public function linkingValidate(Request $request)
{
$request->validate([
'corporate_id' => 'required'
]);
$corporate = Corporate::findOrFail($request->corporate_id);
// Make Validation from Linking Rules
$linkingRulesArr = $corporate->linking_rules->toArray();
$validationRules = [];
foreach ($linkingRulesArr as $field) {
$rules = ['required']; // Default is required if in the linking_rules
if ($field == 'email') {
$rules[] = 'email';
}
if ($field == 'nric') {
$rules[] = new NikRule;
}
$validationRules[$field] = $rules;
}
$request->validate($validationRules);
$member = Member::query()
->when(in_array('nric', $linkingRulesArr), function($q) use ($request) {
$q->where('nric', $request->nric);
})
->when(in_array('member_id', $linkingRulesArr), function($q) use ($request) {
$q->where('member_id', $request->member_id);
})
->when(in_array('name', $linkingRulesArr), function($q) use ($request) {
$q->where('name', $request->name);
})
->when(in_array('dob', $linkingRulesArr), function($q) use ($request) {
$q->where('birth_date', $request->dob);
})
->when(in_array('phone', $linkingRulesArr), function($q) use ($request) {
$q->whereHas('person', function ($person) use ($request) {
$person->where('phone', $request->phone);
});
})
->when(in_array('email', $linkingRulesArr), function($q) use ($request) {
$q->where('email', $request->email);
})
->when(in_array('nik', $linkingRulesArr), function($q) use ($request) {
$q->whereHas('employeds', function ($employed) use ($request) {
$employed->where('corporate_id', $request->corporate_id)
->where('nik', $request->nik);
});
})
->with([
'memberPlans' => function ($memberPlan) {
$memberPlan->latest();
},
])
->first();
if ($member) {
return Helper::responseJson(data: MemberResource::make($member), message: 'Data Member ditemukan!');
}
return Helper::responseJson(data: [], message: 'Member Tidak ditemukan', statusCode: 404, status: 'error');
}
public function show($member_id)
{
$member = Member::where('member_id', $member_id)->firstOrFail();
$member->load(['currentPlan', 'memberPlans']);
return Helper::responseJson(data: MemberResource::make($member));
}
}

View File

@@ -14,30 +14,6 @@ class MemberResource extends JsonResource
*/
public function toArray($request)
{
// $data = parent::toArray($request);
$currentMemberPlan = $this->memberPlans?->first();
$data = [
'member_id' => $this->member_id,
'birth_date' => $this->birth_date,
'email' => $this->email,
'phone' => $this->person->phone ?? null,
'full_name' => $this->full_name,
'nric' => $this->nric,
'plan' => $currentMemberPlan ? [
'code' => $currentMemberPlan->plan->code ?? null,
'start' => $currentMemberPlan->start,
'end' => $currentMemberPlan->end
] : null,
'policy_code' => $this->currentPolicy->code,
'corporate' => [
'code' => $this->currentPolicy->corporate->code,
'name' => $this->currentPolicy->corporate->name,
'welcome_message' => $this->currentPolicy->corporate->welcome_message,
'help_text' => $this->currentPolicy->corporate->help_text,
'avatar_url' => $this->currentpolicy->corporate->avatar_url
]
];
return $data;
return parent::toArray($request);
}
}

View File

@@ -18,6 +18,15 @@ class Benefit extends Model
'active'
];
protected $hidden = [
"created_at",
"updated_at",
"deleted_at",
"created_by",
"updated_by",
"deleted_by",
];
public function scopeFilter($query, array $filters)
{
$query->when($filters['search'] ?? false, function ($query, $search) {

View File

@@ -0,0 +1,52 @@
<?php
namespace App\Models;
use App\Traits\Blameable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class ClaimRequest extends Model
{
use HasFactory, SoftDeletes, Blameable;
protected static $code_prefix = 'CRQ';
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
try {
$model->code = self::getNextCode();
} catch (\Exception $e) {
abort(500, $e->getMessage());
}
});
}
public static function getNextCode()
{
$last_number = self::withTrashed()->max('code');
$next_number = empty($last_number) ? 1 : ((int) explode('-', $last_number)[1] + 1);
return self::makeCode($next_number);
}
public static function makeCode($next_number)
{
return (string) self::$code_prefix .'-'. str_pad($next_number, 5, 0, STR_PAD_LEFT);
}
public $fillable = [
'submission_date',
'member_id',
'status'
];
public function member()
{
return $this->belongsTo(Member::class, 'member_id', 'id');
}
}

View File

@@ -3,7 +3,6 @@
namespace App\Models;
use App\Traits\Blameable;
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -24,7 +23,7 @@ class Corporate extends Model
];
protected $casts = [
'linking_rules' => AsArrayObject::class,
'linking_rules' => 'array',
];
protected $appends = [

View File

@@ -4,11 +4,10 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class CorporateManager extends Model
{
use HasFactory, SoftDeletes;
use HasFactory;
protected $table = 'corporate_manager';
}

View File

@@ -141,8 +141,7 @@ class Member extends Model
public function currentPlan()
{
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')
->latest(); // TODO Fix This
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')->latest();
}
public function policies()
@@ -193,12 +192,13 @@ class Member extends Model
public function getNameAttribute()
{
return $this->person->name ?? null;
return $this->person->name ?? ($this->name ?? null);
}
public function getBirthDateAttribute()
{
return Carbon::parse($this->person->birth_date ?? null)->format('Y-m-d') ?? null;
$date = $this->person->birth_date ?? ($this->birth_date ?? null);
return !empty($date) ? Carbon::parse($date)->format('Y-m-d') : null;
}
public function getGenderAttribute()

View File

@@ -31,17 +31,4 @@ class MemberPlan extends Model
{
return $this->belongsTo(CorporatePlan::class, 'plan_id', 'code');
}
public function plan()
{
return $this->belongsTo(Plan::class, 'plan_id');
}
public function scopeActive($q)
{
return $q
->where('start', '<', now())
->where('end', '>', now())
->latest();
}
}

View File

@@ -2,7 +2,6 @@
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -15,99 +14,12 @@ class Appointment extends Model
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
public $sStatusNames = [
0 => 'Menunggu Pembayaran',
1 => 'Pembayaran Terkonfirmasi', // Pembayaran Diterima
2 => 'Ditolak',
3 => 'Dibatalkan', // Canceled
4 => 'Expired',
];
public $sPaymentMethodName = [
1 => 'Pribadi',
2 => 'On-Site Payment',
3 => 'OVO',
4 => 'Asuransi',
5 => 'Voucher',
];
public $nIDJenisBookingNames = [
1 => 'Rawat Jalan',
2 => 'Telekonsultasi',
3 => 'Chat Sekarang'
];
protected $connection = 'oldlms';
protected $table = 'tx_appointment';
protected $primaryKey = 'nID';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'nID',
'nIDDokter',
'nIDUser',
'sStatus',
'dCreateOn',
'dUpdateOn',
'dDeleteOn',
];
protected $appends = [
'status_name',
'payment_method',
'type'
];
protected function statusName(): Attribute
public function detail()
{
return Attribute::make(
get: function ($value) {
return $this->sStatusNames[$this->sStatus] ?? '-';
},
);
}
protected function paymentMethod(): Attribute
{
return Attribute::make(
get: function ($value) {
return $this->sPaymentMethodName[$this->sPaymentMethod] ?? '-';
},
);
}
protected function type(): Attribute
{
return Attribute::make(
get: function($value) {
return $this->nIDJenisBookingNames[$this->nIDJenisBooking] ?? '-';
}
);
}
public function appointmentDetail()
{
return $this->hasOne(AppointmentDetail::class, 'nIDAppointment', 'nID');
}
public function doctor()
{
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nID');
}
public function user()
{
return $this->belongsTo(User::class, 'nIDUser', 'nID');
}
public function healthCare()
{
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
return $this->hasOne(AppointmentDetail::class, '');
}
}

View File

@@ -8,19 +8,4 @@ use Illuminate\Database\Eloquent\Model;
class AppointmentDetail extends Model
{
use HasFactory;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tx_appointment_detail';
protected $casts = [
'sPaymentDetails' => 'array',
];
public function appointment()
{
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
}
}

View File

@@ -24,14 +24,4 @@ class Dokter extends Model
{
return $this->hasMany(JadwalDokter::class, 'nIDDokter', 'nID');
}
public function user()
{
return $this->belongsTo(User::class, 'nIDUser', 'nID');
}
public function speciality()
{
return $this->belongsTo(Speciality::class, 'nIDSpesialis', 'nID');
}
}

View File

@@ -1,64 +0,0 @@
<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
class Livechat extends Model
{
use HasFactory;
public $sStatusNames = [
0 => 'Menunggu Konfirmasi',
1 => 'Diterima',
2 => 'Ditolak',
3 => 'Selesai',
4 => 'Expired',
];
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tx_livechat';
protected $appends = [
'status_name',
];
protected function statusName(): Attribute
{
return Attribute::make(
get: function ($value) {
return $this->sStatusNames[$this->sStatus] ?? '-';
},
);
}
public function user()
{
return $this->belongsTo(User::class, 'nIDUser', 'nID');
}
public function doctor()
{
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nID');
}
public function appointment()
{
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
}
public function healthCare()
{
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
}
}

View File

@@ -1,26 +0,0 @@
<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Speciality extends Model
{
use HasFactory;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tm_spesialis';
protected $primaryKey = 'nID';
public function dokter()
{
return $this->hasMany(Dokter::class, 'nIDSpesialis', 'nID');
}
}

View File

@@ -2,46 +2,10 @@
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model
{
use HasFactory, SoftDeletes;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tm_users';
protected $appends = [
'full_name',
];
protected function fullName(): Attribute
{
return Attribute::make(
get: function ($value) {
$names = [];
if (!empty($this->sFirstName)) {
array_push($names, $this->sFirstName);
}
if (!empty($this->sLastName)) {
array_push($names, $this->sLastName);
}
return implode(' ', $names);
}
);
}
public function detail()
{
return $this->hasOne(UserDetail::class, 'nIDUser', 'nID');
}
use HasFactory;
}

View File

@@ -8,13 +8,4 @@ use Illuminate\Database\Eloquent\Model;
class UserDetail extends Model
{
use HasFactory;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tm_users_detail';
}

View File

@@ -114,11 +114,6 @@ class Person extends Model
return $this->hasOne(User::class, 'person_id');
}
public function practitioner()
{
return $this->hasOne(Practitioner::class, 'person_id');
}
public function appointmentParticipantables()
{
return $this->morphMany(AppointmentParticipant::class, 'participantable');

View File

@@ -182,7 +182,63 @@ class Plan extends Model
return $this->belongsToMany(Benefit::class, 'corporate_benefits', 'plan_id', 'benefit_id')
->withTimestamps()
->withPivot([
// TODO corporate_benefits pivot
'corporate_id',
'plan_id',
'benefit_id',
'corporate_benefit_code',
'budget',
'budget_conditions',
'budget_code',
'primary_benefit_code',
'benefit_mode',
'room_class_coverage',
'max_bed_coverage',
'tolerance_parameter',
'max_room_class',
'limit_amount',
'area_limit',
'shared_benefit',
'shared_benefit_type',
'msc',
'genders',
'min_age',
'max_age',
'max_frequency_period',
'daily_frequency',
'weekly_frequency',
'monthly_frequency',
'yearly_frequency',
'custom_frequency_days',
'custom_duration_value',
'allowed_transaction_types',
'high_plan_factor',
'pre_post_treatment',
'pre_treatment_days',
'post_treatment_days',
'layer_type_1',
'layer_value_1',
'layer_type_2',
'layer_value_2',
'cashless_percentage',
'reimbursement_percentage',
'digital_percentage',
'co_share_m_percentage',
'co_share_s_percentage',
'co_share_c_percentage',
'cashless_deductible',
'reimbursement_deductible',
'digital_deductible',
'co_share_m_deductible',
'co_share_s_deductible',
'co_share_c_deductible',
'prorate_type',
'prorate_lookup',
'max_days_for_disability',
'max_period_for_disability',
'currency',
'show_benefit_item',
'show_benefit_value',
'active'
]);
}
@@ -190,4 +246,9 @@ class Plan extends Model
{
return $this->hasMany(CorporateBenefit::class, 'plan_id', 'id');
}
public function service()
{
return $this->belongsTo(Service::class, 'service_code', 'code');
}
}

View File

@@ -14,4 +14,9 @@ class Service extends Model
'name',
'description',
];
public function corporateService()
{
return $this->hasMany(CorporateService::class, 'service_code', 'code');
}
}

View File

@@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasApiTokens, HasFactory, Notifiable, HasRoles;
/**
* The attributes that are mass assignable.
@@ -48,26 +49,13 @@ class User extends Authenticatable
];
public $with = [
'metas',
'person'
'metas'
];
public $appends = [
'meta',
'avatar_url',
'full_name'
'meta'
];
public function getAvatarUrlAttribute()
{
return asset('images/specialities/anak.png');
}
public function getFullNameAttribute()
{
return $this->person?->full_name;
}
public function getMetaAttribute()
{
$orgMeta = [];

View File

@@ -2,9 +2,7 @@
namespace App\Providers;
use App\Rules\NikRule;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use Str;

View File

@@ -1,66 +0,0 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class NikRule implements Rule
{
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
// The NIK is a 16-digit number
if (!preg_match('/^[0-9]{16}$/', $value)) {
return false;
}
// // The first 6 digits represent the person's birth date in the format of YYMMDD
// $year = substr($value, 6, 2);
// $month = substr($value, 8, 2);
// $day = substr($value, 10, 2);
// // dd($year, $month, $day);
// // dd(checkdate($month, $day, "19{$year}"));
// if (!checkdate($month, $day, "19{$year}")) {
// return false;
// }
// // The next 2 digits represent the place of birth (province/city code)
// $provinceCode = substr($value, 6, 2);
// // The next 2 digits represent the person's gender (odd for male, even for female)
// $genderCode = substr($value, 14, 1);
// // The last 4 digits represent the sequence number of the person's birth in that day
// $sequenceNumber = substr($value, 12, 4);
return true;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return ':attribute bukan valid NIK Indonesia.';
}
}

View File

@@ -6,11 +6,9 @@
"license": "MIT",
"require": {
"php": "^8.0.2",
"barryvdh/laravel-snappy": "^1.0",
"box/spout": "^3.3",
"duitkupg/duitku-php": "dev-master",
"guzzlehttp/guzzle": "^7.2",
"h4cc/wkhtmltopdf-amd64": "0.12.x",
"laravel/framework": "^9.11",
"laravel/sanctum": "^2.15",
"laravel/socialite": "^5.5",
@@ -18,7 +16,8 @@
"maatwebsite/excel": "^3.1",
"nwidart/laravel-modules": "^9.0",
"psr/simple-cache": "^1.0",
"pusher/pusher-php-server": "^7.2"
"pusher/pusher-php-server": "^7.2",
"spatie/laravel-permission": "^5.9"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.7",

285
composer.lock generated
View File

@@ -4,86 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "001e5beb4f35e725aaab5763c69eaeed",
"content-hash": "fba5a398ed86e2a1809183198ce640f5",
"packages": [
{
"name": "barryvdh/laravel-snappy",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-snappy.git",
"reference": "2c18a3602981bc6f25b32908cf8aaa05952ab2f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-snappy/zipball/2c18a3602981bc6f25b32908cf8aaa05952ab2f7",
"reference": "2c18a3602981bc6f25b32908cf8aaa05952ab2f7",
"shasum": ""
},
"require": {
"illuminate/filesystem": "^6|^7|^8|^9",
"illuminate/support": "^6|^7|^8|^9",
"knplabs/knp-snappy": "^1",
"php": ">=7.2"
},
"require-dev": {
"orchestra/testbench": "^4|^5|^6|^7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"laravel": {
"providers": [
"Barryvdh\\Snappy\\ServiceProvider"
],
"aliases": {
"PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf",
"SnappyImage": "Barryvdh\\Snappy\\Facades\\SnappyImage"
}
}
},
"autoload": {
"psr-4": {
"Barryvdh\\Snappy\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Snappy PDF/Image for Laravel",
"keywords": [
"image",
"laravel",
"pdf",
"snappy",
"wkhtmltoimage",
"wkhtmltopdf"
],
"support": {
"issues": "https://github.com/barryvdh/laravel-snappy/issues",
"source": "https://github.com/barryvdh/laravel-snappy/tree/v1.0.0"
},
"funding": [
{
"url": "https://fruitcake.nl",
"type": "custom"
},
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2022-01-29T19:36:49+00:00"
},
{
"name": "box/spout",
"version": "v3.3.0",
@@ -1277,129 +1199,6 @@
],
"time": "2022-10-26T14:07:24+00:00"
},
{
"name": "h4cc/wkhtmltopdf-amd64",
"version": "0.12.4",
"source": {
"type": "git",
"url": "https://github.com/h4cc/wkhtmltopdf-amd64.git",
"reference": "4e2ab2d032a5d7fbe2a741de8b10b8989523c95b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/h4cc/wkhtmltopdf-amd64/zipball/4e2ab2d032a5d7fbe2a741de8b10b8989523c95b",
"reference": "4e2ab2d032a5d7fbe2a741de8b10b8989523c95b",
"shasum": ""
},
"bin": [
"bin/wkhtmltopdf-amd64"
],
"type": "library",
"autoload": {
"psr-4": {
"h4cc\\WKHTMLToPDF\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL Version 3"
],
"authors": [
{
"name": "Julius Beckmann",
"email": "github@h4cc.de"
}
],
"description": "Convert html to pdf using webkit (qtwebkit). Static linked linux binary for amd64 systems.",
"homepage": "http://wkhtmltopdf.org/",
"keywords": [
"binary",
"convert",
"pdf",
"snapshot",
"thumbnail",
"wkhtmltopdf"
],
"support": {
"issues": "https://github.com/h4cc/wkhtmltopdf-amd64/issues",
"source": "https://github.com/h4cc/wkhtmltopdf-amd64/tree/master"
},
"time": "2018-01-15T06:57:33+00:00"
},
{
"name": "knplabs/knp-snappy",
"version": "v1.4.1",
"source": {
"type": "git",
"url": "https://github.com/KnpLabs/snappy.git",
"reference": "5126fb5b335ec929a226314d40cd8dad497c3d67"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/KnpLabs/snappy/zipball/5126fb5b335ec929a226314d40cd8dad497c3d67",
"reference": "5126fb5b335ec929a226314d40cd8dad497c3d67",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/log": "^1.0||^2.0||^3.0",
"symfony/process": "~3.4||~4.3||~5.0||~6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16||^3.0",
"pedrotroller/php-cs-custom-fixer": "^2.19",
"phpstan/phpstan": "^0.12.7",
"phpstan/phpstan-phpunit": "^0.12.6",
"phpunit/phpunit": "~7.4||~8.5"
},
"suggest": {
"h4cc/wkhtmltoimage-amd64": "Provides wkhtmltoimage-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency",
"h4cc/wkhtmltoimage-i386": "Provides wkhtmltoimage-i386 binary for Linux-compatible machines, use version `~0.12` as dependency",
"h4cc/wkhtmltopdf-amd64": "Provides wkhtmltopdf-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency",
"h4cc/wkhtmltopdf-i386": "Provides wkhtmltopdf-i386 binary for Linux-compatible machines, use version `~0.12` as dependency",
"wemersonjanuario/wkhtmltopdf-windows": "Provides wkhtmltopdf executable for Windows, use version `~0.12` as dependency"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Knp\\Snappy\\": "src/Knp/Snappy"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "KNP Labs Team",
"homepage": "http://knplabs.com"
},
{
"name": "Symfony Community",
"homepage": "http://github.com/KnpLabs/snappy/contributors"
}
],
"description": "PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.",
"homepage": "http://github.com/KnpLabs/snappy",
"keywords": [
"knp",
"knplabs",
"pdf",
"snapshot",
"thumbnail",
"wkhtmltopdf"
],
"support": {
"issues": "https://github.com/KnpLabs/snappy/issues",
"source": "https://github.com/KnpLabs/snappy/tree/v1.4.1"
},
"time": "2022-01-07T13:03:38+00:00"
},
{
"name": "laravel/framework",
"version": "v9.47.0",
@@ -4204,6 +4003,88 @@
],
"time": "2022-12-31T22:20:34+00:00"
},
{
"name": "spatie/laravel-permission",
"version": "5.9.1",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-permission.git",
"reference": "a88ed98c8937442737e0c50163682e832d608f13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-permission/zipball/a88ed98c8937442737e0c50163682e832d608f13",
"reference": "a88ed98c8937442737e0c50163682e832d608f13",
"shasum": ""
},
"require": {
"illuminate/auth": "^7.0|^8.0|^9.0|^10.0",
"illuminate/container": "^7.0|^8.0|^9.0|^10.0",
"illuminate/contracts": "^7.0|^8.0|^9.0|^10.0",
"illuminate/database": "^7.0|^8.0|^9.0|^10.0",
"php": "^7.3|^8.0"
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
"phpunit/phpunit": "^9.4",
"predis/predis": "^1.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "5.x-dev",
"dev-master": "5.x-dev"
},
"laravel": {
"providers": [
"Spatie\\Permission\\PermissionServiceProvider"
]
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Spatie\\Permission\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Permission handling for Laravel 6.0 and up",
"homepage": "https://github.com/spatie/laravel-permission",
"keywords": [
"acl",
"laravel",
"permission",
"permissions",
"rbac",
"roles",
"security",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-permission/issues",
"source": "https://github.com/spatie/laravel-permission/tree/5.9.1"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2023-02-06T21:37:02+00:00"
},
{
"name": "symfony/console",
"version": "v6.2.3",

View File

@@ -187,7 +187,7 @@ return [
*/
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Barryvdh\Snappy\ServiceProvider::class,
Spatie\Permission\PermissionServiceProvider::class,
/*
* Application Service Providers...
@@ -219,8 +219,6 @@ return [
'Duitku' => App\Services\Duitku::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'LmsApi' => App\Services\LmsApi::class,
'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
'SnappyImage' => Barryvdh\Snappy\Facades\SnappyImage::class,
])->toArray(),
];

161
config/permission.php Normal file
View File

@@ -0,0 +1,161 @@
<?php
return [
'models' => [
/*
* When using the "HasPermissions" trait from this package, we need to know which
* Eloquent model should be used to retrieve your permissions. Of course, it
* is often just the "Permission" model but you may use whatever you like.
*
* The model you want to use as a Permission model needs to implement the
* `Spatie\Permission\Contracts\Permission` contract.
*/
'permission' => Spatie\Permission\Models\Permission::class,
/*
* When using the "HasRoles" trait from this package, we need to know which
* Eloquent model should be used to retrieve your roles. Of course, it
* is often just the "Role" model but you may use whatever you like.
*
* The model you want to use as a Role model needs to implement the
* `Spatie\Permission\Contracts\Role` contract.
*/
'role' => Spatie\Permission\Models\Role::class,
],
'table_names' => [
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'roles' => 'roles',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your permissions. We have chosen a basic
* default value but you may easily change it to any table you like.
*/
'permissions' => 'permissions',
/*
* When using the "HasPermissions" trait from this package, we need to know which
* table should be used to retrieve your models permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_permissions' => 'model_has_permissions',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your models roles. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'model_has_roles' => 'model_has_roles',
/*
* When using the "HasRoles" trait from this package, we need to know which
* table should be used to retrieve your roles permissions. We have chosen a
* basic default value but you may easily change it to any table you like.
*/
'role_has_permissions' => 'role_has_permissions',
],
'column_names' => [
/*
* Change this if you want to name the related pivots other than defaults
*/
'role_pivot_key' => null, //default 'role_id',
'permission_pivot_key' => null, //default 'permission_id',
/*
* Change this if you want to name the related model primary key other than
* `model_id`.
*
* For example, this would be nice if your primary keys are all UUIDs. In
* that case, name this `model_uuid`.
*/
'model_morph_key' => 'model_id',
/*
* Change this if you want to use the teams feature and your related model's
* foreign key is other than `team_id`.
*/
'team_foreign_key' => 'team_id',
],
/*
* When set to true, the method for checking permissions will be registered on the gate.
* Set this to false, if you want to implement custom logic for checking permissions.
*/
'register_permission_check_method' => true,
/*
* When set to true the package implements teams using the 'team_foreign_key'. If you want
* the migrations to register the 'team_foreign_key', you must set this to true
* before doing the migration. If you already did the migration then you must make a new
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
* 'model_has_permissions'(view the latest version of package's migration file)
*/
'teams' => false,
/*
* When set to true, the required permission names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_permission_in_exception' => false,
/*
* When set to true, the required role names are added to the exception
* message. This could be considered an information leak in some contexts, so
* the default setting is false here for optimum safety.
*/
'display_role_in_exception' => false,
/*
* By default wildcard permission lookups are disabled.
*/
'enable_wildcard_permission' => false,
'cache' => [
/*
* By default all permissions are cached for 24 hours to speed up performance.
* When permissions or roles are updated the cache is flushed automatically.
*/
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
/*
* The cache key used to store all permissions.
*/
'key' => 'spatie.permission.cache',
/*
* You may optionally indicate a specific cache driver to use for permission and
* role caching using any of the `store` drivers listed in the cache.php config
* file. Using 'default' here means to use the `default` set in cache.php.
*/
'store' => 'default',
],
];

View File

@@ -1,52 +0,0 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Snappy PDF / Image Configuration
|--------------------------------------------------------------------------
|
| This option contains settings for PDF generation.
|
| Enabled:
|
| Whether to load PDF / Image generation.
|
| Binary:
|
| The file path of the wkhtmltopdf / wkhtmltoimage executable.
|
| Timout:
|
| The amount of time to wait (in seconds) before PDF / Image generation is stopped.
| Setting this to false disables the timeout (unlimited processing time).
|
| Options:
|
| The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
| See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
|
| Env:
|
| The environment variables to set while running the wkhtmltopdf process.
|
*/
'pdf' => [
'enabled' => true,
'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
'timeout' => false,
'options' => [],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'),
'timeout' => false,
'options' => [],
'env' => [],
],
];

View File

@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('claim_requests', function (Blueprint $table) {
$table->id();
$table->string('code')->index();
$table->dateTime('submission_date')->nullable();
$table->foreignId('member_id');
$table->string('status')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable()->index();
$table->unsignedBigInteger('updated_by')->nullable()->index();
$table->unsignedBigInteger('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('claim_requests');
}
};

View File

@@ -0,0 +1,141 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Spatie\Permission\PermissionRegistrar;
class CreatePermissionTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = config('permission.table_names');
$columnNames = config('permission.column_names');
$teams = config('permission.teams');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
if ($teams && empty($columnNames['team_foreign_key'] ?? null)) {
throw new \Exception('Error: team_foreign_key on config/permission.php not loaded. Run [php artisan config:clear] and try again.');
}
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->bigIncrements('id'); // permission id
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
$table->unique(['name', 'guard_name']);
});
Schema::create($tableNames['roles'], function (Blueprint $table) use ($teams, $columnNames) {
$table->bigIncrements('id'); // role id
if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing
$table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable();
$table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index');
}
$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);
$table->timestamps();
if ($teams || config('permission.testing')) {
$table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']);
} else {
$table->unique(['name', 'guard_name']);
}
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotPermission, $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
}
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames, $teams) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->string('model_type');
$table->unsignedBigInteger($columnNames['model_morph_key']);
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
if ($teams) {
$table->unsignedBigInteger($columnNames['team_foreign_key']);
$table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index');
$table->primary([$columnNames['team_foreign_key'], PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
} else {
$table->primary([PermissionRegistrar::$pivotRole, $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
}
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedBigInteger(PermissionRegistrar::$pivotPermission);
$table->unsignedBigInteger(PermissionRegistrar::$pivotRole);
$table->foreign(PermissionRegistrar::$pivotPermission)
->references('id') // permission id
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign(PermissionRegistrar::$pivotRole)
->references('id') // role id
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary([PermissionRegistrar::$pivotPermission, PermissionRegistrar::$pivotRole], 'role_has_permissions_permission_id_role_id_primary');
});
app('cache')
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
->forget(config('permission.cache.key'));
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$tableNames = config('permission.table_names');
if (empty($tableNames)) {
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
}
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
}

View File

@@ -17,18 +17,23 @@ class DummyMemberSeeder extends Seeder
public function run()
{
$userEmails = [
'admin@linksehat.dev',
'manager+one@gmail.com',
'manager+two@gmail.com'
'admin@linksehat.dev' => ['administrator'],
'manager+one@gmail.com' => ['corporate-manager'],
'manager+two@gmail.com' => ['corporate-manager'],
'hospitaladmin@gmail.com' => ['hospital-admin']
];
foreach ($userEmails as $email) {
User::updateOrCreate([
foreach ($userEmails as $email => $roles) {
$user = User::updateOrCreate([
'email' => $email
], [
'email' => $email,
'password' => Hash::make('password')
]);
if (isset($roles) && count($roles)) {
$user->syncRoles($roles);
}
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$roles = [
'administrator',
'corporate-manager',
'hospital-admin'
];
foreach ($roles as $name) {
Role::create([
'name' => $name
]);
}
}
}

View File

@@ -32,7 +32,7 @@ const MENU_OPTIONS = [
export default function AccountPopover() {
const [open, setOpen] = useState<HTMLElement | null>(null);
const navigate = useNavigate();
const { logout, user } = useAuth();
const { logout } = useAuth();
const handleOpen = (event: React.MouseEvent<HTMLElement>) => {
setOpen(event.currentTarget);
@@ -67,10 +67,10 @@ export default function AccountPopover() {
}),
}}
>
{user && user.user.avatar_url && (<Avatar
src={user ? user.user.avatar_url : ''}
alt={user ? user.user.full_name : ''}
/>)}
<Avatar
src="https://minimal-assets-api.vercel.app/assets/images/avatars/avatar_5.jpg"
alt="Rayan Moran"
/>
</IconButtonAnimate>
<MenuPopover
@@ -89,16 +89,16 @@ export default function AccountPopover() {
>
<Box sx={{ my: 1.5, px: 2.5 }}>
<Typography variant="subtitle2" noWrap>
{ user ? user.user.full_name ?? 'Hi, ' : 'Hi, '}
Rayan Moran
</Typography>
<Typography variant="body2" sx={{ color: 'text.secondary' }} noWrap>
{ user ? user.user.email : 'Please Wait'}
rayan.moran@gmail.com
</Typography>
</Box>
<Divider sx={{ borderStyle: 'dashed' }} />
{/* <Stack sx={{ p: 1 }}>
<Stack sx={{ p: 1 }}>
{MENU_OPTIONS.map((option) => (
<MenuItem key={option.label} onClick={handleClose}>
{option.label}
@@ -106,7 +106,7 @@ export default function AccountPopover() {
))}
</Stack>
<Divider sx={{ borderStyle: 'dashed' }} /> */}
<Divider sx={{ borderStyle: 'dashed' }} />
<MenuItem sx={{ m: 1 }} onClick={handleLogout}>
Logout

View File

@@ -1,7 +1,6 @@
// @mui
import { styled } from '@mui/material/styles';
import { Box, Link, Typography, Avatar } from '@mui/material';
import useAuth from '../../../hooks/useAuth';
// ----------------------------------------------------------------------
@@ -23,10 +22,6 @@ type Props = {
};
export default function NavbarAccount({ isCollapse }: Props) {
const { user } = useAuth();
console.log('current user is ', user)
return (
<Link underline="none" color="inherit">
<RootStyle
@@ -36,10 +31,10 @@ export default function NavbarAccount({ isCollapse }: Props) {
}),
}}
>
{user && user.user.avatar_url && (<Avatar
src={user ? user.user.avatar_url : ''}
alt={user ? user.user.full_name : ''}
/>)}
<Avatar
src="https://minimal-assets-api.vercel.app/assets/images/avatars/avatar_5.jpg"
alt="Rayan Moran"
/>
<Box
sx={{
@@ -55,10 +50,10 @@ export default function NavbarAccount({ isCollapse }: Props) {
}}
>
<Typography variant="subtitle2" noWrap>
{ user ? user.user.full_name ?? 'Hi, ' : 'Hi, '}
Rayan Moran
</Typography>
<Typography variant="body2" noWrap sx={{ color: 'text.secondary', fontSize: '11px' }}>
{ user ? user.user.email : 'Please Wait'}
<Typography variant="body2" noWrap sx={{ color: 'text.secondary' }}>
user
</Typography>
</Box>
</RootStyle>

View File

@@ -134,7 +134,7 @@ export default function DialogClaimSubmitMember({
params: { ...appliedParams, claimMember: true },
});
setData(response.data.data);
setData(response.data);
}
})();
}, [corporateValue, openDialog, appliedParams]);

View File

@@ -409,11 +409,11 @@ export default function TableList(props: any) {
</Button>
)}
</TableCell>
{/* <TableCell align="right">
<TableCell align="right">
<IconButton>
<Iconify icon="ic:baseline-more-vert" />
</IconButton>
</TableCell> */}
</TableCell>
</TableRow>
))
) : (

View File

@@ -1,7 +0,0 @@
GENERATE_SOURCEMAP=false
PORT=8083
REACT_APP_HOST_API_URL="http://localhost:8000"
VITE_API_URL="http://localhost:8000/api/internal"

View File

@@ -58,6 +58,13 @@ const navConfig = [
{ title: 'Hospitals', path: '/hospitals' },
],
},
{
title: 'LOG REQUEST',
path: '/claim-requests',
// children: [
// { title: 'Request', path: '/case-request' },
// ],
},
{
title: 'CASE MANAGEMENT',
path: '/claims',
@@ -69,13 +76,6 @@ const navConfig = [
title: 'CUSTOMER SERVICES',
children: [{ title: 'Request', path: '/cs-request' }],
},
{
title: 'REPORT',
children: [
{ title: 'Appointment', path: '/report/appointments' },
{ title: 'Live Chat', path: '/report/live-chat' },
],
},
{
title: 'USER MANAGEMENT',
path: '/users',

View File

@@ -0,0 +1,64 @@
import * as Yup from 'yup';
import { yupResolver } from '@hookform/resolvers/yup';
import { Autocomplete, Button, Card, Collapse, Container, Divider, Grid, Stack, Table, TableBody, TableCell, TableRow, TextField, Typography } from '@mui/material';
import { Controller, useForm } from 'react-hook-form';
import { useParams, useNavigate } from 'react-router-dom';
import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs';
import { FormProvider, RHFCheckbox, RHFSelect, RHFTextField } from '../../components/hook-form';
import Page from '../../components/Page';
import useSettings from '../../hooks/useSettings';
import { useEffect, useMemo, useRef, useState } from 'react';
import MemberSelectDialog from '../../components/dialogs/MemberSelectDialog';
import { styled } from '@mui/system';
import axios from '../../utils/axios';
import { enqueueSnackbar } from 'notistack';
import { LoadingButton } from '@mui/lab';
import { fCurrency } from '../../utils/formatNumber';
import Iconify from '../../components/Iconify';
import Form from './Form';
export default function ClaimsCreateUpdate() {
const { themeStretch } = useSettings();
const { id } = useParams();
const isEdit = id ? true : false;
const [currentClaim, setCurrentClaim] = useState();
useEffect(() => {
if (isEdit) {
axios.get('/claims/' + id).then((res) => {
// console.log('Yeet', res.data);
setCurrentClaim(res.data);
});
}
}, [id]);
return (
<Page title={isEdit ? `Edit Claim : ${currentClaim?.id}` : "Create New Claim"}>
<Container maxWidth={themeStretch ? false : 'xl'}>
<Stack direction="row" alignItems="center">
<HeaderBreadcrumbs
heading={
!isEdit
? 'Create New Claim'
: `Edit Claim : ${currentClaim?.code}`
}
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Claim',
href: '/claims',
},
{ name: !isEdit ? 'Create' : currentClaim?.id ?? '' },
]}
/>
</Stack>
<Form isEdit={isEdit} currentClaim={currentClaim} />
</Container>
</Page>
);
}

View File

@@ -0,0 +1,596 @@
import * as Yup from 'yup';
import { useSnackbar } from 'notistack';
import { useNavigate } from 'react-router-dom';
import { yupResolver } from '@hookform/resolvers/yup';
import { Controller, useForm } from 'react-hook-form';
import React, { useEffect, useMemo, useState } from 'react';
import axios from '../../utils/axios';
import { FormProvider, RHFTextField } from '../../components/hook-form';
import {
Autocomplete,
Button,
Grid,
Stack,
Table,
TableBody,
TableCell,
TableRow,
TextField,
Typography,
useTheme,
List,
ListItem,
IconButton,
ListItemAvatar,
Avatar,
ListItemText,
} from '@mui/material';
import Iconify from '../../components/Iconify';
import { LoadingButton } from '@mui/lab';
import { fCurrency } from '../../utils/formatNumber';
import MemberSelectDialog from '../../components/dialogs/MemberSelectDialog';
import { Add, DeleteOutline } from '@mui/icons-material';
type Props = {
isEdit: boolean;
currentClaim?: any;
};
export default function ClaimForm({ isEdit, currentClaim }: Props) {
const navigate = useNavigate();
const { enqueueSnackbar } = useSnackbar();
const NewCorporateSchema = Yup.object().shape({
name: Yup.string().required('Name is required'),
code: Yup.string().required('Corporate Code is required'),
active: Yup.boolean().required('Corporate Status is required'),
// file: Yup.boolean().required('Corporate Status is required'),
});
const defaultValues = useMemo(
() => ({
member: currentClaim?.member || {},
member_id: currentClaim?.member_id || null,
diagnosis_id: currentClaim?.diagnosis_id || null,
total_claim: currentClaim?.total_claim || 0,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[currentClaim]
);
const methods = useForm<any>({
resolver: yupResolver(NewCorporateSchema),
defaultValues,
});
const {
reset,
watch,
control,
setValue,
getValues,
setError,
handleSubmit,
formState: { isSubmitting },
} = methods;
const values = watch();
const [isCheckingLimit, setIsCheckingLimit] = useState(false);
const [isEligible, setIsEligible] = useState(false);
const [memberBenefits, setMemberBenefits] = useState([]);
const [diagnosisOption, setDiagnosisOption] = useState([]);
const [isMemberDialogOpen, setIsMemberDialogOpen] = useState(false);
const [member, setMember] = useState({})
useEffect(() => {
console.log('defaultValues', defaultValues);
if (isEdit && currentClaim) {
reset(defaultValues);
setMember(defaultValues.member)
}
if (!isEdit) {
reset(defaultValues);
setMember(defaultValues.member)
}
}, [isEdit, currentClaim]);
const fileSelected = (event, type) => {
const files = event.target.files;
const currentFiles = getValues(`uploaded_files.${type}`) ?? [];
setValue(`uploaded_files.${type}`, [...currentFiles, ...files]);
console.log('currentFiles', getValues('uploaded_files'));
};
const memberSelected = (member) => {
setMember(member)
};
const checkLimit = async () => {
console.log('CHECKING LIMIT');
};
const onSubmit = async (data: any) => {
try {
if (!isEdit) {
const response = await axios.post('/claims', data);
} else {
const response = await axios.put('/claims/' + currentClaim?.id ?? '', data);
}
reset();
enqueueSnackbar(
!isEdit ? 'Organizations Created Successfully!' : 'Organizations Udpated Successfully!',
{ variant: 'success' }
);
navigate('/claims');
} catch (error: any) {
if (error && error.response.status === 422) {
for (const [key, value] of Object.entries(error.response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
}
} else {
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
}
}
const ascent = document?.querySelector('ascent');
if (ascent != null) {
ascent.innerHTML = '';
}
};
function generate(files, element: React.ReactElement) {
return files.map((value) =>
React.cloneElement(element, {
key: value,
})
);
}
const headStyle = {};
return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<Stack spacing={3}>
<Typography variant="h6">Member</Typography>
<Stack spacing={2} direction="row">
<Grid item xs={12}>
<RHFTextField
name="member_id"
label="Member"
variant="outlined"
fullWidth
value={member?.name || ''}
InputProps={{
readOnly: true,
}}
onClick={() => {
if (!isEdit) setIsMemberDialogOpen(true);
if (isEdit) enqueueSnackbar('Cannot Change Member', { variant: 'error' });
}}
/>
</Grid>
{/* <Grid item xs={2}>
<Button variant="outlined" fullWidth sx={{ p: 1.8 }} onClick={() => {
setIsMemberDialogOpen(true)
}}>
{member ? 'Change' : 'Search'}
</Button>
</Grid> */}
</Stack>
{member?.id && (
<Stack>
<Grid container spacing={2}>
<Grid item xs={12} md={6}>
<Table border="light-700">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left">
Name
</TableCell>
<TableCell align="left">{member?.full_name}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
DOB
</TableCell>
<TableCell align="left">
{member?.birth_date} ({member?.age + ' years'})
</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Marital Status
</TableCell>
<TableCell align="left">{member?.marital_status}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Record Type
</TableCell>
<TableCell align="left">{member?.record_type}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Principal ID
</TableCell>
<TableCell align="left">
{member?.principal_id} (
{member?.relation_with_principal})
</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
<Grid item xs={12} md={6}>
<Table border="light-700">
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left">
Plan
</TableCell>
<TableCell align="left">{member?.current_plan?.code}</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Active
</TableCell>
<TableCell align="left">
{member?.current_plan?.start} -{' '}
{member?.current_plan?.end} (Active)
</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Corporate Limit
</TableCell>
<TableCell align="left">
{fCurrency(0)} / {fCurrency(member?.current_plan?.limit_rules)}
</TableCell>
</TableRow>
<TableRow>
<TableCell style={headStyle} align="left">
Plan Usage
</TableCell>
<TableCell align="left">
{fCurrency(0)} / {fCurrency(member?.current_plan?.limit_rules)}
</TableCell>
</TableRow>
</TableBody>
</Table>
</Grid>
</Grid>
</Stack>
)}
<Controller
name="benefit"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
options={memberBenefits}
getOptionLabel={(option) =>
option ? `#${option.id} (${option.code}) ${option.description}` : ''
}
value={value || ''}
onChange={(event: any, newValue: any) => {
setValue('benefit_id', newValue?.id);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
name="benefit"
{...params}
label="Benefit"
variant="outlined"
fullWidth
// onKeyPress={(event) => {
// if (event.key === 'Enter')
// searchDiagnosis(event.target.value)
// }}
/>
)}
/>
)}
/>
<Controller
name="diagnosis"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
options={diagnosisOption}
getOptionLabel={(option) => (option ? `(${option.code}) ${option.name}` : '')}
value={value || ''}
onChange={(event: any, newValue: any) => {
setValue('diagnosis_id', newValue?.id);
// setValue('diagnosis', newValue)
onChange(newValue);
}}
renderInput={(params) => (
<TextField
name="diagnosis"
{...params}
label="Diagnosis"
variant="outlined"
fullWidth
onKeyPress={(event) => {
if (event.key === 'Enter') searchDiagnosis(event.target.value);
}}
/>
)}
/>
)}
/>
{isCheckingLimit && (
<Stack
sx={{
backgroundColor: 'gray',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* Checking */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:info-circle"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Please Wait, Checking Eligibilty
</Typography>
</Typography>
</Stack>
)}
{false && isCheckingLimit == false && isEligible == null && (
<Stack
sx={{
backgroundColor: 'gray',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* No Data Selected */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:info-circle"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Please Select Diagnosis !
</Typography>
</Typography>
</Stack>
)}
{!isCheckingLimit && isEligible !== null && isEligible && (
<Stack
sx={{
backgroundColor: '#B2E8E8',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* Eligible */}
<Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:lock-alt"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Diagnosis is Eligible
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
125.000.000 / 125.000.000
</Typography>
</Stack>
)}
{!isCheckingLimit && isEligible !== null && !isEligible && (
<Stack
sx={{
backgroundColor: '#B2E8E8',
paddingY: 1,
paddingX: 1.5,
mb: 2,
borderRadius: '3-xl',
}}
>
{/* Not Eligible */}
{/* <Typography sx={{ typography: 'caption', display: 'flex', alignItems: 'center' }}>
<Iconify
icon="bxs:lock-alt"
width={12}
height={13}
sx={{ color: '#424242', marginRight: '6px' }}
/>
<Typography variant="caption" component="span">
Not Eligible
</Typography>
</Typography>
<Typography sx={{ typography: 'caption', color: '#637381' }}>
125.000.000 / 125.000.000
</Typography> */}
</Stack>
)}
<RHFTextField type="number" name="total_claim" label="Total Claim" />
{isEdit && (
<React.Fragment>
<Typography variant="h6">Documents</Typography>
<List>
{(getValues('uploaded_files.invoice') && getValues('uploaded_files.invoice').length
? getValues('uploaded_files.invoice')
: []
).map((file, index) => (
<ListItem
secondaryAction={
<IconButton edge="end" aria-label="delete">
<DeleteOutline />
</IconButton>
}
>
<ListItemAvatar>
<Avatar>
{/* <FileIcon /> */}
I
</Avatar>
</ListItemAvatar>
<ListItemText primary={file.name} secondary={file.type} />
</ListItem>
))}
</List>
<Button
variant="outlined"
startIcon={<Add />}
component="label"
sx={{ paddingY: 2, width: '100%', ':hover': { border: 'none' } }}
>
Invoice
<input
name="invoice"
hidden
accept="image/*,application/pdf"
multiple
type="file"
onChange={(event) => {
fileSelected(event, 'invoice');
}}
/>
</Button>
<List>
{(getValues('uploaded_files.prescription') && getValues('uploaded_files.prescription').length
? getValues('uploaded_files.prescription')
: []
).map((file, index) => (
<ListItem
secondaryAction={
<IconButton edge="end" aria-label="delete">
<DeleteOutline />
</IconButton>
}
>
<ListItemAvatar>
<Avatar>
{/* <FileIcon /> */}
P
</Avatar>
</ListItemAvatar>
<ListItemText primary={file.name} secondary={file.type} />
</ListItem>
))}
</List>
<Button
variant="outlined"
startIcon={<Add />}
component="label"
sx={{ paddingY: 2, width: '100%', ':hover': { border: 'none' } }}
>
Prescription
<input
name="prescription"
hidden
accept="image/*,application/pdf"
multiple
type="file"
onChange={(event) => {
fileSelected(event, 'prescription');
}}
/>
</Button>
<List>
{(getValues('uploaded_files.diagnosis') && getValues('uploaded_files.diagnosis').length
? getValues('uploaded_files.diagnosis')
: []
).map((file, index) => (
<ListItem
secondaryAction={
<IconButton edge="end" aria-label="delete">
<DeleteOutline />
</IconButton>
}
>
<ListItemAvatar>
<Avatar>
{/* <FileIcon /> */}
DR
</Avatar>
</ListItemAvatar>
<ListItemText primary={file.name} secondary={file.type} />
</ListItem>
))}
</List>
<Button
variant="outlined"
startIcon={<Add />}
component="label"
sx={{ paddingY: 2, width: '100%', ':hover': { border: 'none' } }}
>
Doctor Result
<input
name="invoice"
hidden
accept="image/*,application/pdf"
multiple
type="file"
onChange={(event) => {
fileSelected(event, 'diagnosis');
}}
/>
</Button>
</React.Fragment>
)}
{isEligible === true ? (
<LoadingButton
onClick={handleSubmit(onSubmit)}
variant="contained"
color="success"
style={{ color: '#ffffff' }}
size="large"
fullWidth={true}
loading={isCheckingLimit}
>
Create Claim
</LoadingButton>
) : (
<LoadingButton
onClick={checkLimit}
variant="outlined"
size="large"
fullWidth={true}
loading={isCheckingLimit}
>
Check Limit
</LoadingButton>
)}
</Stack>
<MemberSelectDialog
openDialog={isMemberDialogOpen}
setOpenDialog={setIsMemberDialogOpen}
onSelect={memberSelected}
></MemberSelectDialog>
</FormProvider>
);
}

View File

@@ -0,0 +1,30 @@
import { Card, Stack } from "@mui/material";
import HeaderBreadcrumbs from "../../components/HeaderBreadcrumbs";
import Page from "../../components/Page";
import List from "./List";
export default function Claims() {
const pageTitle = 'Claim Request';
return (
<Page title={ pageTitle } sx={{ mx: 2}}>
<HeaderBreadcrumbs
heading={ pageTitle }
links={[
{ name: 'Dashboard', href: '/dashboard' },
{
name: 'Claim Request',
href: '/claim-requests',
},
]}
/>
{/* <Stack> */}
<List />
{/* </Stack> */}
</Page>
);
}

View File

@@ -0,0 +1,272 @@
// @mui
import {
Box,
Button,
Card,
Collapse,
IconButton,
MenuItem,
Table,
TableBody,
TableCell,
TableRow,
TextField,
Typography,
Stack,
Menu,
ButtonGroup,
Link,
Chip,
} from '@mui/material';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel';
// hooks
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
import { Navigate, useNavigate, useSearchParams } from 'react-router-dom';
// components
import axios from '../../utils/axios';
import { LaravelPaginatedData, LaravelPaginatedDataDefault } from '../../@types/paginated-data';
import DataTable from '../../components/LaravelTable';
import { fCurrency } from '../../utils/formatNumber';
import EditRoundedIcon from '@mui/icons-material/EditRounded';
import { LoadingButton } from '@mui/lab';
import { enqueueSnackbar } from 'notistack';
// import LoadingButton from '@/theme/overrides/LoadingButton';
export default function List() {
const [searchParams, setSearchParams] = useSearchParams();
const [importResult, setImportResult] = useState(null);
const navigate = useNavigate();
function SearchInput(props: any) {
// SEARCH
const searchInput = useRef<HTMLInputElement>(null);
const [searchText, setSearchText] = useState('');
const handleSearchChange = (event: any) => {
const newSearchText = event.target.value ?? '';
setSearchText(newSearchText);
};
const handleSearchSubmit = (event: any) => {
event.preventDefault();
props.onSearch({ search: searchText }); // Trigger to Parent
};
useEffect(() => {
// Trigger First Search
setSearchText(searchParams.get('search') ?? '');
}, []);
return (
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}>
<TextField
id="search-input"
ref={searchInput}
label="Search"
variant="outlined"
fullWidth
onChange={handleSearchChange}
value={searchText}
/>
</form>
);
}
function ImportForm(props: any) {
// IMPORT
// Create Button Menu
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const createMenu = Boolean(anchorEl);
const importForm = useRef<HTMLInputElement>(null);
const [currentImportFileName, setCurrentImportFileName] = useState(null);
const handleClose = () => {
setAnchorEl(null);
};
return (
<div>
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter} />
{/* <Button
variant="outlined"
startIcon={<AddIcon />}
sx={{ p: 1.8 }}
onClick={() => {
navigate('/claims/create');
}}
>
Create
</Button> */}
</Stack>
</div>
);
}
// Dummy Default Data
const [dataTableIsLoading, setDataTableLoading] = useState(true);
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>(
LaravelPaginatedDataDefault
);
const loadDataTableData = async (appliedFilter: any | null = null) => {
setDataTableLoading(true);
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
const response = await axios.get('/claim-requests', { params: filter });
// console.log(response.data);
setDataTableLoading(false);
setDataTableData(response.data);
};
const applyFilter = async (searchFilter: { search: string }) => {
await loadDataTableData(searchFilter);
setSearchParams(searchFilter);
};
const handlePageChange = (event: ChangeEvent, value: number): void => {
const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
loadDataTableData(filter);
setSearchParams(filter);
};
const handleApprove = (claimRequest) => {
axios.post(`claim-requests/${claimRequest.id}/approve`)
.then((response) => {
enqueueSnackbar('Success Approve', {variant: 'success'})
loadDataTableData()
})
.catch(({response}) => {
enqueueSnackbar(response.data.message ?? 'Something went wrong!', {variant : "error"})
})
}
useEffect(() => {
loadDataTableData();
}, []);
const headStyle = {
fontWeight: 'bold',
};
// Called on every row to map the data to the columns
function createData(data: any): any {
return {
...data,
};
}
{
/* ------------------ TABLE ROW ------------------ */
}
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
const [loadingApprove, setLoadingApprove] = React.useState(false);
return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell>
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
</IconButton>
</TableCell>
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left">{row.submission_date}</TableCell>
<TableCell align="right"><Chip label={row.status}/></TableCell>
<TableCell align="right">{ row.status == 'requested' && (<LoadingButton loading={loadingApprove} variant="outlined" onClick={() => {handleApprove(row)}}>Approve</LoadingButton> )}</TableCell>
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Box sx={{ borderBottom: 1 }}>
<Typography variant="body2" gutterBottom component="div">
Description : {row.description}
</Typography>
</Box>
</Collapse>
</TableCell>
</TableRow>
</React.Fragment>
);
}
{
/* ------------------ END TABLE ROW ------------------ */
}
function TableContent() {
return (
<Table aria-label="collapsible table">
{/* ------------------ TABLE HEADER ------------------ */}
<TableBody>
<TableRow>
<TableCell style={headStyle} align="left" />
<TableCell style={headStyle} align="left">
Code
</TableCell>
<TableCell style={headStyle} align="left">
Member Name
</TableCell>
<TableCell style={headStyle} align="left">
Submission Date
</TableCell>
<TableCell style={headStyle} align="left">
Status
</TableCell>
<TableCell style={headStyle} align="right">
Action
</TableCell>
</TableRow>
</TableBody>
{/* ------------------ END TABLE HEADER ------------------ */}
{/* ------------------ TABLE ROW ------------------ */}
{dataTableIsLoading ? (
<TableBody>
<TableRow>
<TableCell colSpan={8} align="center">
Loading
</TableCell>
</TableRow>
</TableBody>
) : dataTableData.data.length === 0 ? (
<TableBody>
<TableRow>
<TableCell colSpan={8} align="center">
No Data
</TableCell>
</TableRow>
</TableBody>
) : (
<TableBody>
{dataTableData.data.map((row) => (
<Row key={row.id} row={row} />
))}
</TableBody>
)}
{/* ------------------ END TABLE ROW ------------------ */}
</Table>
);
}
return (
<Card>
<ImportForm />
<DataTable
isLoading={dataTableIsLoading}
lastRequest={0}
data={dataTableData}
handlePageChange={handlePageChange}
TableContent={<TableContent />}
/>
</Card>
);
}

View File

@@ -100,7 +100,7 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
policy_stop_service_net: currentCorporate?.current_policy?.minimal_stop_service_net || 0,
policy_start: currentCorporate?.current_policy?.start || '',
policy_end: currentCorporate?.current_policy?.end || '',
linking_rules: currentCorporate?.linking_rules || ['nric', 'nik', 'member_id'],
linking_rules: currentCorporate?.linking_rules || ['nrik', 'nik', 'member_id'],
type: currentCorporate?.type || 'corporate',
logo: currentCorporate?.logo || '',
}),
@@ -174,8 +174,6 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
formData.append('policy_end', data.policy_end);
formData.append('linking_rules', data.linking_rules);
console.log('MOTHERFUCKER', data.linking_rules)
if (!isEdit) {
const response = await axios.post('/corporates', formData);
} else {
@@ -271,7 +269,7 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
const linking_rules_checkbox_name = 'linking_rules';
const linking_tools = [
{
value: 'nric',
value: 'nrik',
label: 'No. KTP',
},
{
@@ -427,7 +425,6 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
Linking Rules
</Typography>
<Stack>
{JSON.stringify(getValues('linking_rules'))}
<RHFCustomMultiCheckbox name="linking_rules" options={linking_tools} />
</Stack>
</Stack>

View File

@@ -33,7 +33,6 @@ import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
import UploadIcon from '@mui/icons-material/Upload';
import CancelIcon from '@mui/icons-material/Cancel';
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
// hooks
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
import useSettings from '../../../hooks/useSettings';
@@ -328,7 +327,6 @@ export default function CorporatePlanList() {
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
const [loadingLog, setLoadingLog] = React.useState(false);
const handleActivate = (model: any, status: string) => {
axios
.put(`/members/${row.id}/activation`, {
@@ -355,33 +353,6 @@ export default function CorporatePlanList() {
);
});
};
const handleDownloadLog = (row: ReturnType<typeof createData>) => {
setLoadingLog(true);
axios.get(`generate-log/${row.id}`, {
responseType: 'blob'
})
.then((response) => {
window.open(URL.createObjectURL(response.data));
// const content = response.headers['content-type'];
// download(response.data, file.file_name, content);
// const link = document.createElement('a');
// console.log(response.data);
// link.href = response.data.data.file_url;
// link.setAttribute('download', response.data.data.file_name);
// document.body.appendChild(link);
// link.click();
setLoadingLog(false);
})
// .then((blobFile) => {
// new File([blobFile], 'asdads.pdf', { type: blobFile.type })
// setLoadingLog(false);
// })
.catch((response) => {
enqueueSnackbar(response.message, {variant: 'error'})
setLoadingLog(false);
})
}
return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
@@ -545,19 +516,6 @@ export default function CorporatePlanList() {
</Grid>
</Grid>
<Grid>
<LoadingButton
id="upload-button"
variant="outlined"
startIcon={<InsertDriveFileIcon />}
// sx={{ p: 1.8 }}
onClick={() => {handleDownloadLog(row)}}
loading={loadingLog}
>
Download LOG
</LoadingButton>
</Grid>
{/* <Typography sx={{ fontWeight: '600', mb: 1, mt: 2 }}>Sub Corporate</Typography>
<Grid container>
<Grid item xs={12}>

View File

@@ -9,6 +9,7 @@ import Form from './Form';
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
import axios from '../../../utils/axios';
import { Practitioner } from '../../../@types/doctor';
import ButtonBack from '../../../components/ButtonBack';
export default function Create() {
const { themeStretch } = useSettings();
@@ -30,6 +31,7 @@ export default function Create() {
<Page title="Membership: Create a new Dokter">
<Container maxWidth={themeStretch ? false : 'xl'}>
<Stack direction="row" alignItems="center">
<ButtonBack />
<HeaderBreadcrumbs
heading={!isEdit ? 'Manage a new Dokter' : 'Manage Dokter'}
links={[
@@ -52,3 +54,40 @@ export default function Create() {
</Page>
);
}
// const pageTitle = 'Create Data Dokter';
// return (
// <Page title={pageTitle}>
// <Container maxWidth={themeStretch ? false : 'xl'}>
// <HeaderBreadcrumbs
// heading={pageTitle}
// links={[
// {
// name: 'Master',
// href: '/master',
// },
// {
// name: 'Dokter',
// href: '/master/organizations/',
// },
// {
// name: 'Create',
// href: '/master/organizations/create/',
// },
// ]}
// />
// <Grid container spacing={2}>
// <Grid item xs={12}>
// <Card sx={{ p: 2 }}>
// <Form
// isSubmitting={isSubmitting}
// isEdit={isEdit}
// currentOrganizations={currentOrganizations}
// />
// </Card>
// </Grid>
// </Grid>
// </Container>
// </Page>
// );
// }

View File

@@ -8,7 +8,7 @@ import Select, { SelectChangeEvent } from '@mui/material/Select';
import * as React from 'react';
// form
import { useForm, Controller } from 'react-hook-form';
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
// @mui
import { styled } from '@mui/material/styles';
@@ -25,7 +25,6 @@ import {
Typography,
TextField,
Chip,
Autocomplete,
} from '@mui/material';
import CancelIcon from '@mui/icons-material/Cancel';
@@ -42,20 +41,17 @@ import {
RHFMultiCheckbox,
RHFCheckbox,
RHFCustomMultiCheckbox,
RHFSelect,
} from '../../../components/hook-form';
import axios from '../../../utils/axios';
import { fCurrency } from '../../../utils/formatNumber';
import { Practitioner } from '../../../@types/doctor';
import AddIcon from '@mui/icons-material/Add';
import { Label, Rowing } from '@mui/icons-material';
import { email } from '../../../_mock/email';
const LabelStyle = styled(Typography)(({ theme }) => ({
...theme.typography.h6,
marginBottom: theme.spacing(2),
marginTop: theme.spacing(2),
...theme.typography.subtitle2,
color: theme.palette.text.secondary,
marginBottom: theme.spacing(1),
}));
const HeaderStyle = styled('header')(({ theme }) => ({
@@ -70,6 +66,7 @@ const Title = styled(Typography)(({ theme }) => ({
boxShadow: 'none',
// paddingBottom: theme.spacing(3),
fontWeight: 700,
color: '#005B7F',
}));
interface FormValuesProps extends Partial<Practitioner> {
@@ -109,8 +106,6 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
() => ({
id: currentPractitioner?.id,
name: currentPractitioner?.name || '',
email: currentPractitioner?.email || '',
phone: currentPractitioner?.phone || '',
address: currentPractitioner?.address || '',
birth_date: currentPractitioner?.birth_date || '',
gender: currentPractitioner?.gender || '',
@@ -126,8 +121,6 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
[currentPractitioner]
);
console.log('currentPractitioner', currentPractitioner);
console.log('defaultValues', defaultValues);
function StatusLabel({ value }: { value: boolean }) {
@@ -175,391 +168,91 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isEdit, currentPractitioner]);
const onSubmit = async (data: FormValuesProps) => {
try {
const formData = new FormData();
formData.append('name', data.name);
formData.append('gender', data.gender);
formData.append('address', data.address);
formData.append('birth_place', data.birth_place);
formData.append('birth_date', data.birth_date);
formData.append('email', data.email);
formData.append('phone', data.phone);
// formData.append('active', data.active ? '1' : '0');
forms.forEach((form, index) => {
formData.append(`practices[${index}][organization_id]`, form.organizationId);
form.specialities.forEach((speciality, i) => {
formData.append(`practices[${index}][specialities][${i}][speciality_id]`, speciality);
});
});
const handleActivate = (event: React.ChangeEvent<HTMLInputElement>) => {
setValue('active', event.target.checked);
if (!isEdit) {
console.log('formData', formData);
const response = await axios.post('/doctors', formData);
} else {
formData.append('_method', 'PUT');
const response = await axios.post('/doctors/' + currentPractitioner?.id ?? '', formData);
}
reset();
enqueueSnackbar(!isEdit ? 'Doctors Created Successfully!' : 'Doctors Udpated Successfully!', {
variant: 'success',
});
navigate('/master/doctors');
} catch (error: any) {
if (error && error.response.status === 422) {
console.log('error', error.response.data.errors);
for (const [key, value] of Object.entries(error.response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
}
} else {
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
}
}
console.log('event.target.checked', event.target.checked);
const ascent = document?.querySelector('ascent');
if (ascent != null) {
ascent.innerHTML = '';
}
};
const formData = new FormData();
formData.append('active', event.target.checked ? '1' : '0');
formData.append('_method', 'PUT');
axios.post('/doctors/' + currentPractitioner?.id ?? '', formData);
const [organizations, setOrganizations] = useState<any>([]);
const [specialities, setSpecialities] = useState<any>([]);
useEffect(() => {
axios.get(`/search-organizations`).then((response) => {
setOrganizations(
response.data.map((item: any) => ({ ...item, name: item.name, value: item.id }))
);
});
axios.get(`/search-specialities`).then((response) => {
setSpecialities(
response.data.map((item: any) => ({ ...item, name: item.name, value: item.id }))
);
});
}, []);
// const specialities = [
// { name: 'Dentistry', id: 1 },
// { name: 'Dermatology', id: 2 },
// { name: 'General Medicine', id: 3 },
// { name: 'Pediatrics', id: 4 },
// { name: 'Surgery', id: 5 },
// ];
const practices = currentPractitioner?.practices || [];
// const practices = [
// {
// organization_id: 187,
// specialities: [
// {
// speciality_id: 7,
// },
// {
// speciality_id: 6,
// },
// ],
// },
// {
// organization_id: 181,
// specialities: [
// {
// speciality_id: 2,
// },
// ],
// },
// ];
const [forms, setForms] = useState<any>([]);
useEffect(() => {
if (practices.length > 0) {
const newForms = practices.map((practice: any) => {
return {
organizationId: practice.organization_id,
specialities: practice.specialities.map((s) => s.speciality_id),
};
});
setForms(newForms);
} else {
setForms([
{
organizationId: '',
specialities: [],
},
]);
}
}, [practices && practices.length]);
// }, []);
console.log('forms', forms);
const findValueOrganization = (organizationId) => {
if (organizationId === '' || organizationId === null) {
return { name: '', value: '' };
} else {
const organization = organizations.find((o) => o.id === organizationId);
return { name: organization?.name, value: organizationId };
}
};
// console.log('findValueOrganization', findValueOrganization(187));
// const findValueSpeciality = (specialityIds: number[]) => {
// if (specialityIds.length === 0) {
// return [];
// } else {
// const data = specialities.filter((s) => specialityIds.includes(s.id));
// return data.map((d) => ({ name: d.name, value: d.id }));
// }
// };
const findValueSpeciality = (values: any) => {
return specialities.filter((s) => values.includes(s.value));
};
// const [forms, setForms] = useState([
// {
// organizationId: '',
// specialities: [],
// },
// ]);
const addForm = () => {
setForms([
...forms,
{
organizationId: '',
specialities: [],
},
]);
};
console.log('forms', forms);
const gender = [
{
value: 'male',
label: 'Laki-Laki',
},
{
value: 'female',
label: 'Perempuan',
},
];
console.log('forms', forms);
// const handleSpecialitiesChange = (index: number, value: any) => {
// const newForms = [...forms];
// newForms[index].specialities = value.map((v: any) => ({ speciality_id: v.id }));
// setForms(newForms);
// };
// const handleSpecialitiesChange = (index: number, value: any) => {
// const updatedForms = [...forms];
// updatedForms[index].specialities = value.map((v: any) => v.speciality_id);
// setForms(updatedForms);
// };
const handleOrganizationIdChange = (index, value) => {
const updatedForms = [...forms];
updatedForms[index].organizationId = value.id;
setForms(updatedForms);
};
const handleSpecialitiesChange = (index: number, value: any) => {
setForms((forms) => {
forms[index].specialities = value.map((v: any) => v.value);
return [...forms];
});
};
// const availableOrganizations = organizations.filter(
// (org) =>
// !forms.some((f) => f.organization && f.organization.id === org.id) ||
// forms.findIndex((f) => f.organization && f.organization.id === org.id) === editIndex
// );
const availableOrganizations =
practices.length > 0
? organizations.filter(
(org) => !practices.some((practice) => practice.organization_id === org.id)
)
: organizations.filter((org) => !forms.some((f) => f.organizationId === org.id));
// const availableOrganizations = organizations.filter(
// (org) => !practices.some((p) => p.organization_id === org.id)
// );
const handleDeleteForm = (index) => {
const updatedForms = [...forms];
updatedForms.splice(index, 1);
setForms(updatedForms);
enqueueSnackbar('active Updated Successfully!', { variant: 'success' });
};
return (
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
<FormProvider methods={methods}>
<Stack spacing={3}>
<Box sx={{ width: '100%' }}>
{/* <Stack spacing={3}> */}
<Card sx={{ p: 5 }}>
{/* <HeaderStyle>
<HeaderStyle>
<Grid item xs={6} md={6}>
<Title>Data Dokter</Title>
</Grid>
<Grid item xs={6} md={6}>
<RHFSwitch name="active" label="" />
{/* <Typography>Status Rumah Sakit</Typography> */}
<RHFSwitch name="active" label="" onClick={handleActivate} />
<StatusLabel value={values.active} />
</Grid>
</HeaderStyle> */}
</HeaderStyle>
<Title variant="h5">Informasi Umum</Title>
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }} sx={{ mt: 2 }}>
<Grid item xs={12}>
<LabelStyle>Nama Dokter</LabelStyle>
<RHFTextField name="name" placeholder="Tuliskan Nama Dokter" />
</Grid>
<Avatar
alt="Remy Sharp"
src={currentPractitioner?.avatar_url}
sx={{ width: 120, height: 120, marginBottom: 2 }}
/>
<Grid item xs={6}>
<LabelStyle>Jenis Kelamin</LabelStyle>
<RHFSelect name="gender" label="Pilih Jenis Kelamin">
<option value="" />
{gender.map((option, index) => (
<option key={index} value={option.value}>
{option.label}
</option>
))}
</RHFSelect>
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={7}>
<Span style={{ fontWeight: 'bold' }}>Nama Dokter</Span>
<Text>{currentPractitioner?.name ? currentPractitioner?.name : '-'}</Text>
<Span style={{ fontWeight: 'bold' }}>No Telp</Span>
<Text>{currentPractitioner?.phone ? currentPractitioner?.phone : '-'}</Text>
<Span style={{ fontWeight: 'bold' }}>Tempat Lahir</Span>
<Text>
{currentPractitioner?.birth_place ? currentPractitioner?.birth_place : '-'}
</Text>
<Span style={{ fontWeight: 'bold' }}>Alamat</Span>
<Text>{currentPractitioner?.address ? currentPractitioner?.address : '-'}</Text>
</Grid>
<Grid item xs={6}>
<LabelStyle>Alamat</LabelStyle>
<RHFTextField name="address" placeholder="Tuliskan Alamat" />
</Grid>
<Grid item xs={6}>
<LabelStyle>Tempat Lahir</LabelStyle>
<RHFTextField name="birth_place" placeholder="Tuliskan Tempat Lahir" />
</Grid>
<Grid item xs={6}>
<LabelStyle>Tanggal Lahir</LabelStyle>
<RHFDatepicker name="birth_date" placeholder="Silahkan Pilih Tanggal Lahir" />
</Grid>
<Grid item xs={6}>
<LabelStyle>Email</LabelStyle>
<RHFTextField name="email" placeholder="Tuliskan Email" type="email" />
</Grid>
<Grid item xs={6}>
<LabelStyle>No. Telp</LabelStyle>
<RHFTextField name="phone" placeholder="Tuliskan Nomor Telepon" />
<Grid item xs={5} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Span style={{ fontWeight: 'bold' }}>Jenis Kelamin</Span>
<Text>{currentPractitioner?.gender ? currentPractitioner?.gender : '-'}</Text>
<Span style={{ fontWeight: 'bold' }}>Email</Span>
<Text>{currentPractitioner?.email ? currentPractitioner?.email : '-'}</Text>
<Span style={{ fontWeight: 'bold' }}>Tanggal Lahir</Span>
<Text>
{currentPractitioner?.birth_date ? currentPractitioner?.birth_date : '-'}
</Text>
</Grid>
</Grid>
</Card>
<Card sx={{ p: 5, marginTop: 2 }}>
<Stack spacing={3} direction="row" justifyContent="space-between">
<Title variant="h5">Tempat Praktik</Title>
<Button
variant="contained"
color="primary"
size="small"
sx={{ boxShadow: 'none' }}
onClick={addForm}
startIcon={<AddIcon />}
>
Tambah Tempat Praktik
</Button>
</Stack>
{forms.map((form, index) => (
<div key={index}>
<Box sx={{ mt: 3 }}>
<Stack spacing={3} direction="row" justifyContent="space-between">
<LabelStyle></LabelStyle>
{index !== 0 && (
<Button
sx={{ color: 'red', m: 1 }}
aria-label="close"
onClick={() => handleDeleteForm(index)}
>
Delete
</Button>
// <Button onClick={() => handleDeleteForm(index)}>Delete</Button>
)}
</Stack>
{/* <h1>{form.organizationId}</h1> */}
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={6}>
<Autocomplete
options={availableOrganizations}
value={findValueOrganization(form.organizationId) ?? ''}
getOptionLabel={(option) => option.name}
isOptionEqualToValue={(option, value) => option.value === value.value}
onChange={(event, value) => handleOrganizationIdChange(index, value)}
renderInput={(params) => (
<TextField {...params} label="Rumah Sakit" variant="outlined" />
)}
/>
{/* <Autocomplete
options={organizations}
value={findValueOrganization(form.organizationId)}
getOptionLabel={(option) =>
option.name ?? findValueOrganization(form.organizationId).name ?? ''
}
onChange={(event, value) => handleOrganizationIdChange(index, value)}
renderInput={(params) => (
<TextField {...params} label="Rumah Sakit" variant="outlined" />
)}
/> */}
</Grid>
<Grid item xs={6}>
{form.specialities && (
// <Autocomplete
// multiple
// // options={specialities}
// options={specialities}
// value={findValueSpeciality(form.specialities) ?? ''}
// getOptionLabel={(option) => option.name}
// isOptionEqualToValue={(option, value) => option.value === value.value}
// onChange={(event, value) => handleSpecialitiesChange(index, value)}
// renderInput={(params) => (
// <TextField {...params} label="Spesialis" variant="outlined" />
// )}
// />
<Autocomplete
multiple
options={specialities}
value={findValueSpeciality(form.specialities)}
getOptionLabel={(option) => option.name}
onChange={(event, value) => handleSpecialitiesChange(index, value)}
renderInput={(params) => (
<TextField {...params} label="Spesialis" variant="outlined" />
)}
/>
)}
</Grid>
<Title variant="h5">Tempat Praktik</Title>
{currentPractitioner?.organizations?.map((item, index) => (
<Box key={index} sx={{ mt: 3 }}>
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={7}>
<Text>{item.name}</Text>
</Grid>
</Box>
</div>
</Grid>
</Box>
))}
</Card>
<Card sx={{ p: 5, marginTop: 2 }}>
<Title variant="h5">Spesialisasi</Title>
{currentPractitioner?.specialities?.map((item, index) => (
<Box key={index} sx={{ mt: 3 }}>
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={7}>
<Text>{item.name}</Text>
</Grid>
</Grid>
</Box>
))}
</Card>
<Box sx={{ width: '100%', mt: 5 }}>
<Stack
alignItems="center"
justifyContent="end"
direction={{ xs: 'column', md: 'row' }}
sx={{ width: 1, textAlign: { xs: 'center', md: 'left' } }}
>
<Grid item xs={12} md={4}>
<LoadingButton
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)' }}
type="submit"
variant="contained"
size="large"
// fullWidth={true}
loading={isSubmitting}
>
{!isEdit ? 'Simpan' : 'Simpan Perubahan'}
</LoadingButton>
</Grid>
</Stack>
</Box>
</Box>
</Stack>
</FormProvider>

View File

@@ -57,7 +57,6 @@ import { Search } from '@mui/icons-material';
import { Icon } from '@iconify/react';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
import AddIcon from '@mui/icons-material/Add';
// ----------------------------------------------------------------------
@@ -206,16 +205,9 @@ export default function List() {
spacing={2}
sx={{ p: 2, justifyContent: 'space-between', alignItems: 'center' }}
>
<Grid item xs={12} md={10} lg={10}>
<Grid item xs={12} md={12} lg={12}>
<Filter onSearch={applyItems} />
</Grid>
<Grid item xs={12} md={2} lg={2} sx={{ textAlign: 'right' }}>
<Link to="/master/doctors/create" style={{ textDecoration: 'none' }}>
<Button variant="outlined" startIcon={<AddIcon />} sx={{ p: 1.8 }}>
Create
</Button>
</Link>
</Grid>
</Grid>
);
}
@@ -305,22 +297,15 @@ export default function List() {
<CheckStatus row={row} />
</TableCell> */}
<TableCell align="center">
{/* <TableCell align="center">
<ButtonGroup variant="text" aria-label="text button group">
<Link to={'/master/doctors/' + row.id + '/edit'}>
<Link to={'/master/doctors/' + row.id}>
<Button>
<Icon icon="ph:pencil-simple-fill" style={{ width: '24px', height: '24px' }} />
<Icon icon="ph:eye-bold" style={{ width: '24px', height: '24px' }} />
</Button>
</Link>
<Button
onClick={() => {
setOpenDialog(true);
}}
>
<Icon icon="eva:trash-2-outline" style={{ width: '24px', height: '24px' }} />
</Button>
</ButtonGroup>
</TableCell>
</TableCell> */}
</TableRow>
{/* COLLAPSIBLE ROW */}
<TableRow>
@@ -351,12 +336,7 @@ export default function List() {
Jenis Kelamin
</Grid>
<Grid item xs={6}>
:{' '}
{row.gender == 'male'
? 'Laki-Laki'
: row.gender == 'female'
? 'Perempuan'
: '-'}
: {row.gender ? row.gender : '-'}
</Grid>
</Grid>
</Grid>

View File

@@ -154,7 +154,7 @@ export default function FormulariumForm({ isEdit, currentFormularium }: Props) {
const linking_rules_checkbox_name = "linking_rules"
const linking_tools = [
{
"value" : "nric",
"value" : "nrik",
"label" : "No. KTP"
},
{

View File

@@ -9,6 +9,7 @@ import Form from './Form';
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
import axios from '../../../utils/axios';
import { Organizations } from '../../../@types/organization';
import ButtonBack from '../../../components/ButtonBack';
export default function Create() {
const { themeStretch } = useSettings();
@@ -30,20 +31,25 @@ export default function Create() {
<Page title="Membership: Create a new Rumah Sakit">
<Container maxWidth={themeStretch ? false : 'xl'}>
<Stack direction="row" alignItems="center">
<ButtonBack />
<HeaderBreadcrumbs
heading={!isEdit ? 'Create a new Rumah Sakit' : 'Edit Rumah Sakit'}
links={[
{ name: 'Master', href: '/master' },
{
name: 'Organizations',
href: '/master/hospitals',
href: '/master/organizations',
},
{ name: !isEdit ? 'Create' : currentOrganizations?.name ?? '' },
]}
/>
</Stack>
<Form isEdit={isEdit} currentOrganizations={currentOrganizations} />
<Form
// isSubmitting={isSubmitting}
isEdit={isEdit}
currentOrganizations={currentOrganizations}
/>
</Container>
</Page>
);

View File

@@ -65,6 +65,7 @@ const LabelStyle = styled(Typography)(({ theme }) => ({
}));
const HeaderStyle = styled('header')(({ theme }) => ({
padding: theme.spacing(5),
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
@@ -75,6 +76,7 @@ const Title = styled(Typography)(({ theme }) => ({
boxShadow: 'none',
// paddingBottom: theme.spacing(3),
fontWeight: 700,
color: '#005B7F',
}));
// const [timezone, setTimezone] = React.useState('');
@@ -108,6 +110,10 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
const NewCorporateSchema = Yup.object().shape({
name: Yup.string().required('Name is required'),
code: Yup.string().required('Corporate Code is required'),
active: Yup.boolean().required('Corporate Status is required'),
lat: Yup.string().required('Latitude is required'),
lng: Yup.string().required('Longitude is required'),
timezone: Yup.string().required('Timezone is required'),
// file: Yup.boolean().required('Corporate Status is required'),
});
@@ -127,6 +133,12 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
village_id: currentOrganizations?.village_id || '',
postal_code: currentOrganizations?.postal_code || '',
description: currentOrganizations?.description || '',
technology: currentOrganizations?.technology || '',
support_services: currentOrganizations?.support_services || '',
merchant_code: currentOrganizations?.merchant_code || '',
merchant_key: currentOrganizations?.merchant_key || '',
image_url: currentOrganizations?.image_url || '',
region_groups: currentOrganizations?.region_groups || '',
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[currentOrganizations]
@@ -180,15 +192,25 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isEdit, currentOrganizations]);
const currentImage = currentOrganizations?.image_url;
console.log('currentImage', currentImage);
console.log('current_image', currentImage);
const [file, setFile] = useState(null);
console.log('file', file);
const onSubmit = async (data: FormValuesProps) => {
try {
const formData = new FormData();
console.log('data', data);
formData.append('name', data.name);
formData.append('code', data.code);
formData.append('phone', data.phone);
formData.append('lat', data.lat);
formData.append('lng', data.lng);
formData.append('address', data.address);
formData.append('timezone', data.timezone);
formData.append('active', data.active ? '1' : '0');
if (data.province_id === currentOrganizations?.province_id) {
formData.append('province_id', data.province_id);
@@ -213,12 +235,21 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
} else {
formData.append('village_id', data.village_id?.value ?? '');
}
if (data.region_groups === currentOrganizations?.region_groups) {
formData.append('region_groups', data.region_groups);
} else {
formData.append('region_groups', data.region_groups?.value ?? '');
}
formData.append('postal_code', data.postal_code);
formData.append('description', data.description);
formData.append('technology', data.technology);
formData.append('support_services', data.support_services);
formData.append('merchant_code', data.merchant_code);
formData.append('merchant_key', data.merchant_key);
formData.append('image', file);
if (!isEdit) {
console.log('formData', formData);
const response = await axios.post('/organizations', formData);
} else {
formData.append('_method', 'PUT');
@@ -232,10 +263,9 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
!isEdit ? 'Organizations Created Successfully!' : 'Organizations Udpated Successfully!',
{ variant: 'success' }
);
navigate('/master/hospitals');
navigate('/master/organizations');
} catch (error: any) {
if (error && error.response.status === 422) {
console.log('error', error.response.data.errors);
for (const [key, value] of Object.entries(error.response.data.errors)) {
setError(key, { message: value[0] });
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
@@ -251,10 +281,34 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
}
};
const [valueTab, setValueTab] = React.useState('1');
const handleChangeTab = (event: React.SyntheticEvent, newValueTab: string) => {
setValueTab(newValueTab);
};
const handleDrop = useCallback(
(acceptedFiles) => {
setValue(
'logo',
acceptedFiles.map((file: Blob | MediaSource) =>
Object.assign(file, {
preview: URL.createObjectURL(file),
})
)
);
},
[setValue]
);
const handleRemove = (file: File | string) => {
setValue('logo', null);
};
const [province, setProvince] = useState<any>([]);
const [city, setCity] = useState<any>([]);
const [district, setDistrict] = useState<any>([]);
const [village, setVillage] = useState<any>([]);
// const [village, setVillage] = useState<any>([]);
useEffect(() => {
axios.get('/province').then((res) => {
@@ -281,15 +335,17 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
}
};
const loadVillage = async () => {
if (values.district_id == currentOrganizations?.district_id) {
const res = await axios.get('/village?district_id=' + values.district_id);
setVillage(res.data.data.map((item: any) => ({ value: item.id, label: item.name })));
} else {
const res = await axios.get('/village?district_id=' + values.district_id?.value);
setVillage(res.data.data.map((item: any) => ({ value: item.id, label: item.name })));
}
};
// if (values.province_id) {
// if (values.city_id) {
// loadDistrict();
// } else {
// loadCity();
// }
// } else {
// axios.get('/province').then((res) => {
// setProvince(res.data.data.map((item: any) => ({ value: item.id, label: item.name })));
// });
// }
if (values.province_id) {
loadCity();
@@ -298,11 +354,12 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
if (values.city_id) {
loadDistrict();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [values.province_id, values.city_id, values.district_id]);
if (values.district_id) {
loadVillage();
}
}, [values.province_id, values.city_id, values.district_id, values.village_id]);
console.log('province', values.province_id);
console.log('city', values.city_id);
console.log('district', values.district_id);
const findValueProvince = province.find(
(item: any) => item.value === currentOrganizations?.province_id
@@ -311,8 +368,53 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
const findValueDistrict = district.find(
(item: any) => item.value === currentOrganizations?.district_id
);
const findValueVillage = village.find(
(item: any) => item.value === currentOrganizations?.village_id
console.log('findValueProvince', findValueProvince);
console.log('findValueCity', findValueCity);
console.log('findValueDistrict', findValueDistrict);
const timezone = [
{
value: 'WIB',
label: 'WIB',
},
{
value: 'WITA',
label: 'WITA',
},
{
value: 'WIT',
label: 'WIT',
},
];
const region_groups = [
{
value: 'Jabodetabek',
label: 'Jabodetabek',
},
{
value: 'Jawa',
label: 'Jawa',
},
{
value: 'Kalimantan',
label: 'Kalimantan',
},
{
value: 'Papua',
label: 'Papua',
},
{
value: 'Sulawesi',
label: 'Sulawesi',
},
{
value: 'Sumatera',
label: 'Sumatera',
},
];
const findVaalueGroupWilayah = region_groups.find(
(item: any) => item.value === currentOrganizations?.region_groups
);
return (
@@ -329,147 +431,326 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
<StatusLabel value={values.active} />
</Grid>
</HeaderStyle>
<Box sx={{ width: '100%', typography: 'body1', mt: 2 }}>
<Grid container rowSpacing={4} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={12}>
<LabelStyle>Nama Rumah Sakit</LabelStyle>
<RHFTextField name="name" placeholder="Tuliskan Nama Rumah Sakit" />
</Grid>
<Box sx={{ width: '100%', typography: 'body1' }}>
<TabContext value={valueTab}>
<Box
sx={{
borderBottom: 1,
borderColor: 'divider',
backgroundColor: '#F4F6F8',
pl: 5,
pr: 5,
}}
>
<TabList onChange={handleChangeTab} aria-label="lab API tabs example">
<Tab label="Rumah Sakit" value="1" sx={{ pr: 5, pl: 5 }} />
<Tab label="Informasi" value="2" sx={{ pr: 5, pl: 5 }} />
<Tab label="Duitku Setting" value="3" sx={{ pr: 5, pl: 5 }} />
</TabList>
</Box>
<TabPanel value="1">
<Box sx={{ width: '100%', p: 5 }}>
<Grid container rowSpacing={4} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={12}>
<LabelStyle>Nama Rumah Sakit</LabelStyle>
<RHFTextField name="name" placeholder="Tuliskan Nama Rumah Sakit" />
</Grid>
<Grid item xs={12} md={12}>
<LabelStyle>Pilih Foto Rumah Sakit</LabelStyle>
<Box sx={{ width: '100%' }}>
<MyDropzone setFile={setFile} currentImage={currentImage} />
</Box>
</Grid>
<Grid item xs={12}>
<LabelStyle>Nomor IGD</LabelStyle>
<RHFTextField name="phone" placeholder="Tuliskan No IGD" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Code Rumah Sakit</LabelStyle>
<RHFTextField name="code" placeholder="Tuliskan Code Rumah Sakit" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Group Wilayah</LabelStyle>
<Controller
name="region_groups"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={region_groups}
getOptionLabel={(option) =>
option.label ?? findVaalueGroupWilayah?.label ?? ''
}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('region_groups', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
{...params}
label="Group Wilayah"
variant="outlined"
fullWidth
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={12}>
<LabelStyle>Alamat</LabelStyle>
<RHFTextField name="address" placeholder="Tuliskan Alamat" />
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Provinsi</LabelStyle>
{/*
<Controller
name="province_id"
control={control}
render={({ field: { onChange, value } }) => (
<Select
className="input-container"
size="medium"
disabled={!province?.length}
value={value}
onChange={(e: any) => {
onChange(e);
}}
fullWidth
MenuProps={{
PaperProps: {
sx: {
maxHeight: 224,
width: 250,
p: 1,
},
},
}}
>
{province?.map((item: any) => (
<MenuItem key={item.value} value={item.value}>
{item.label}
</MenuItem>
))}
</Select>
)}
/> */}
<Grid item xs={12} md={6}>
<LabelStyle>Code Rumah Sakit</LabelStyle>
<RHFTextField name="code" placeholder="Tuliskan Code Rumah Sakit" />
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Nomor IGD</LabelStyle>
<RHFTextField name="phone" placeholder="Tuliskan No IGD" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Alamat</LabelStyle>
<RHFTextField name="address" placeholder="Tuliskan Alamat" />
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Provinsi</LabelStyle>
<Controller
name="province_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={province}
getOptionLabel={(option) =>
option.label ?? findValueProvince?.label ?? ''
}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('province_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
{...params}
label="Provinsi"
variant="outlined"
fullWidth
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Kabupaten / Kota</LabelStyle>
{/* <Controller
name="city_id"
control={control}
render={({ field: { onChange, value } }) => (
<Select
className="input-container"
size="medium"
disabled={!city?.length}
value={value}
onChange={(e: any) => {
onChange(e);
}}
fullWidth
MenuProps={{
PaperProps: {
sx: {
maxHeight: 224,
width: 250,
p: 1,
},
},
}}
>
{city?.map((item: any) => (
<MenuItem key={item.value} value={item.value}>
{item.label}
</MenuItem>
))}
</Select>
)}
/> */}
<Controller
name="city_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={city}
getOptionLabel={(option) => option.label ?? findValueCity?.label ?? ''}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('city_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
{...params}
label="Kabupaten / Kota"
variant="outlined"
fullWidth
/>
)}
/>
)}
/>
</Grid>
<Controller
name="province_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={province}
getOptionLabel={(option) => option.label ?? findValueProvince?.label ?? ''}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('province_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField {...params} label="Provinsi" variant="outlined" fullWidth />
)}
/>
)}
/>
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Kabupaten / Kota</LabelStyle>
<Grid item xs={12} md={6}>
<LabelStyle>Kecamatan</LabelStyle>
<Controller
name="city_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={city}
getOptionLabel={(option) => option.label ?? findValueCity?.label ?? ''}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('city_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
{...params}
label="Kabupaten / Kota"
variant="outlined"
fullWidth
/>
)}
/>
)}
/>
</Grid>
{/* <Controller
name="district_id"
control={control}
render={({ field: { onChange, value } }) => (
<Select
className="input-container"
size="medium"
disabled={!district?.length}
value={value}
onChange={(e: any) => {
onChange(e);
}}
fullWidth
MenuProps={{
PaperProps: {
sx: {
maxHeight: 224,
width: 250,
p: 1,
},
},
}}
>
{district?.map((item: any) => (
<MenuItem key={item.value} value={item.value}>
{item.label}
</MenuItem>
))}
</Select>
)}
/> */}
<Grid item xs={12} md={6}>
<LabelStyle>Kecamatan</LabelStyle>
<Controller
name="district_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={district}
getOptionLabel={(option) => option.label ?? findValueDistrict?.label ?? ''}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('district_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField {...params} label="Kecamatan" variant="outlined" fullWidth />
)}
/>
)}
/>
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Desa</LabelStyle>
<Controller
name="village_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={village}
getOptionLabel={(option) => option.label ?? findValueVillage?.label ?? ''}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('village_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField {...params} label="Desa" variant="outlined" fullWidth />
)}
/>
)}
/>
</Grid>
<Grid item xs={12} md={4}>
<LabelStyle>Kode Pos</LabelStyle>
<RHFTextField name="postal_code" placeholder="Tuliskan Kode Pos" />
</Grid>
<Grid item xs={12} md={4}>
<LabelStyle>Latitude</LabelStyle>
<RHFTextField name="lat" placeholder="Tuliskan Lattitude" />
</Grid>
<Grid item xs={12} md={4}>
<LabelStyle>Longitude</LabelStyle>
<RHFTextField name="lng" placeholder="Tuliskan Longitude" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Deskripsi</LabelStyle>
<RHFEditor name="description" placeholder="Tuliskan Deskripsi" />
</Grid>
</Grid>
<Controller
name="district_id"
control={control}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="combo-box-demo"
options={district}
getOptionLabel={(option) =>
option.label ?? findValueDistrict?.label ?? ''
}
value={value}
onChange={(event: any, newValue: any) => {
console.log('newValue', newValue);
setValue('district_id', newValue?.value);
onChange(newValue);
}}
renderInput={(params) => (
<TextField
{...params}
label="Kecamatan"
variant="outlined"
fullWidth
/>
)}
/>
)}
/>
</Grid>
<Grid item xs={12} md={6}>
<LabelStyle>Kode Pos</LabelStyle>
<RHFTextField name="postal_code" placeholder="Tuliskan Kode Pos" />
</Grid>
<Grid item xs={12} md={4}>
<LabelStyle>Latitude</LabelStyle>
<RHFTextField name="lat" placeholder="Tuliskan Lattitude" />
</Grid>
<Grid item xs={12} md={4}>
<LabelStyle>Longitude</LabelStyle>
<RHFTextField name="lng" placeholder="Tuliskan Longitude" />
</Grid>
<Grid item xs={12} md={4}>
<LabelStyle>Timezone</LabelStyle>
{/* <RHFTextField name="timezone" /> */}
<RHFSelect name="timezone" label="Pilih Timezone">
<option value="" />
{timezone.map((option, index) => (
<option key={index} value={option.value}>
{option.label}
</option>
))}
</RHFSelect>
</Grid>
</Grid>
</Box>
</TabPanel>
<TabPanel value="2">
<Box sx={{ width: '100%', p: 5 }}>
<Grid container rowSpacing={4} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={12}>
<LabelStyle>Deskripsi</LabelStyle>
<RHFEditor name="description" placeholder="Tuliskan Deskripsi" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Teknologi</LabelStyle>
<RHFEditor name="technology" placeholder="Tuliskan Teknologi" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Layanan Penunjang</LabelStyle>
<RHFEditor name="support_services" placeholder="Tuliskan Layanan Penunjang" />
</Grid>
</Grid>
</Box>
</TabPanel>
<TabPanel value="3">
<Box sx={{ width: '100%', p: 5 }}>
<Grid container rowSpacing={4} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
<Grid item xs={12}>
<LabelStyle>Merchant Code</LabelStyle>
<RHFTextField name="merchant_code" placeholder="Tuliskan Merchant Code" />
</Grid>
<Grid item xs={12}>
<LabelStyle>Merchant Key</LabelStyle>
<RHFTextField name="merchant_key" placeholder="Tuliskan Merchant Key" />
</Grid>
</Grid>
</Box>
</TabPanel>
</TabContext>
</Box>
<Box sx={{ width: '100%', mt: 5 }}>
<Box sx={{ width: '100%', p: 5 }}>
<Stack
alignItems="center"
justifyContent="end"

View File

@@ -23,7 +23,7 @@ export default function Organizations() {
},
{
name: 'Rumah Sakit',
href: '/master/hospitals',
href: '/master/organizations',
},
]}
/>

View File

@@ -147,11 +147,9 @@ export default function List() {
>
<SearchInput onSearch={applyFilter} />
<Link to="/master/hospitals/create" style={{ textDecoration: 'none' }}>
<Button variant="outlined" startIcon={<AddIcon />} sx={{ p: 1.8 }}>
Create
</Button>
</Link>
{/* <Link to="/master/organizations/create/" style={{ textDecoration: 'none' }}>
<ButtonCreate />
</Link> */}
</Stack>
);
}
@@ -261,26 +259,26 @@ export default function List() {
</TableCell>
<TableCell align="left">{row.name}</TableCell>
<TableCell align="left">{row.phone}</TableCell>
<TableCell align="left">{row.address}</TableCell>
<TableCell align="left">{row.address?.text}</TableCell>
<TableCell align="right">
{/* <Stack direction="row"> */}
<ButtonGroup variant="text" aria-label="text button group">
<Link to={'/master/hospitals/' + row.id + '/edit'}>
<Button>
<Icon icon="ph:pencil-simple-fill" style={{ width: '24px', height: '24px' }} />
{/* <TableCell align="left">
<Stack direction="row">
<ButtonGroup variant="text" aria-label="text button group">
<Link to={'/master/organizations/' + row.id + '/edit'}>
<Button>
<Icon icon="ph:pencil-simple-fill" style={{ width: '24px', height: '24px' }} />
</Button>
</Link>
<Button
onClick={() => {
setOpenDialog(true);
}}
>
<Icon icon="eva:trash-2-outline" style={{ width: '24px', height: '24px' }} />
</Button>
</Link>
<Button
onClick={() => {
setOpenDialog(true);
}}
>
<Icon icon="eva:trash-2-outline" style={{ width: '24px', height: '24px' }} />
</Button>
</ButtonGroup>
{/* </Stack> */}
</TableCell>
</ButtonGroup>
</Stack>
</TableCell> */}
</TableRow>
{/* COLLAPSIBLE ROW */}

Some files were not shown because too many files have changed in this diff Show More