CRUD Doctor Hospital
This commit is contained in:
86
Modules/Internal/Http/Controllers/Api/CityController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/CityController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\City;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class CityController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$city = City::where('province_id', $request->province_id)->orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if (!$city) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $city]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('internal::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('internal::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
85
Modules/Internal/Http/Controllers/Api/DistrictController.php
Normal file
85
Modules/Internal/Http/Controllers/Api/DistrictController.php
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\District;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class DistrictController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$district = District::where('city_id', $request->city_id)->orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if (!$district) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $district]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('internal::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('internal::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Modules\Internal\Http\Controllers\Api;
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\Person;
|
||||||
use App\Models\Practitioner;
|
use App\Models\Practitioner;
|
||||||
use App\Models\PractitionerRole;
|
use App\Models\PractitionerRole;
|
||||||
use Illuminate\Contracts\Support\Renderable;
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
@@ -18,12 +19,6 @@ class DoctorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
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')
|
$doctors = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')
|
||||||
->when($request->search ?? null, function ($query, $search) {
|
->when($request->search ?? null, function ($query, $search) {
|
||||||
@@ -31,6 +26,9 @@ class DoctorController extends Controller
|
|||||||
$person->where('name', 'LIKE', '%' . $search . '%');
|
$person->where('name', 'LIKE', '%' . $search . '%');
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
->when($request->id ?? null, function ($query, $id) {
|
||||||
|
$query->where('id', $id);
|
||||||
|
})
|
||||||
->when($request->organization_id ?? null, function ($query, $organization_id) {
|
->when($request->organization_id ?? null, function ($query, $organization_id) {
|
||||||
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($organization_id) {
|
$query->whereHas('practitionerRoles', function ($practitionerRole) use ($organization_id) {
|
||||||
$practitionerRole->where('organization_id', $organization_id);
|
$practitionerRole->where('organization_id', $organization_id);
|
||||||
@@ -65,7 +63,58 @@ class DoctorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
//
|
$data_person = [
|
||||||
|
'name' => $request->name,
|
||||||
|
'gender' => $request->gender,
|
||||||
|
'address' => $request->address,
|
||||||
|
'phone' => $request->phone,
|
||||||
|
'email' => $request->email,
|
||||||
|
'birth_date' => date('Y-m-d', strtotime($request->birth_date)),
|
||||||
|
'birth_place' => $request->birth_place,
|
||||||
|
];
|
||||||
|
|
||||||
|
$person = Person::create($data_person);
|
||||||
|
$address = $person->addresses()->create([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$person->main_address_id = $address->id;
|
||||||
|
$person->save();
|
||||||
|
|
||||||
|
$practitioner = $person->practitioner()->create();
|
||||||
|
|
||||||
|
$practices = $request->practices;
|
||||||
|
if ($practices[0]['organization_id'] !== null) {
|
||||||
|
foreach ($practices as $key => $practice) {
|
||||||
|
if (isset($practice['specialities'])) {
|
||||||
|
//jika input spesialis
|
||||||
|
foreach ($practice['specialities'] as $key => $speciality) {
|
||||||
|
$speciality_id = $speciality['speciality_id'];
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->create([
|
||||||
|
'organization_id' => $organization_id,
|
||||||
|
'speciality_id' => $speciality_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//jika tidak input spesialis
|
||||||
|
$speciality_id = null;
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->create([
|
||||||
|
'organization_id' => $organization_id,
|
||||||
|
'speciality_id' => $speciality_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,7 +124,8 @@ class DoctorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('internal::show');
|
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
|
||||||
|
return response()->json(DoctorResource::make($practitioner));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,7 +135,8 @@ class DoctorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
return view('internal::edit');
|
$practitioner = Practitioner::with('person', 'practitionerRoles.organization', 'practitionerRoles.speciality')->find($id);
|
||||||
|
return response()->json(DoctorResource::make($practitioner));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +147,81 @@ class DoctorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
//
|
$practitioner = Practitioner::find($id);
|
||||||
|
$data_person = [
|
||||||
|
'name' => $request->name,
|
||||||
|
'gender' => $request->gender,
|
||||||
|
'address' => $request->address,
|
||||||
|
'phone' => $request->phone,
|
||||||
|
'email' => $request->email,
|
||||||
|
'birth_date' => date('Y-m-d', strtotime($request->birth_date)),
|
||||||
|
'birth_place' => $request->birth_place,
|
||||||
|
];
|
||||||
|
|
||||||
|
$person = $practitioner->person;
|
||||||
|
$person->update($data_person);
|
||||||
|
$address = $practitioner->person->addresses()->updateOrCreate([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
]);
|
||||||
|
$practitioner->person->main_address_id = $address->id;
|
||||||
|
$practitioner->person->save();
|
||||||
|
|
||||||
|
$practices = $request->practices;
|
||||||
|
$practitionerRole = $practitioner->practitionerRoles()->get() ?? null;
|
||||||
|
|
||||||
|
foreach ($practices as $practice) {
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
foreach ($practice['specialities'] as $speciality) {
|
||||||
|
$speciality_id = $speciality['speciality_id'];
|
||||||
|
$cek = $practitionerRole->where('organization_id', $organization_id)
|
||||||
|
->where('speciality_id', $speciality_id)->first() ?? null;
|
||||||
|
if (!$cek || $practitionerRole->isEmpty()) {
|
||||||
|
// Create new practitioner role if not found
|
||||||
|
$practitioner->practitionerRoles()->create([
|
||||||
|
'organization_id' => $organization_id,
|
||||||
|
'speciality_id' => $speciality_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($practitionerRole) {
|
||||||
|
// Remove practitioner roles that are no longer exists
|
||||||
|
$currentRoleIds = $practitionerRole->pluck('id')->toArray();
|
||||||
|
$newRoleIds = [];
|
||||||
|
|
||||||
|
foreach ($practices as $practice) {
|
||||||
|
$organization_id = $practice['organization_id'];
|
||||||
|
foreach ($practice['specialities'] as $speciality) {
|
||||||
|
$speciality_id = $speciality['speciality_id'];
|
||||||
|
$newPractitionerRole = $practitionerRole->where('organization_id', $organization_id)
|
||||||
|
->where('speciality_id', $speciality_id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($newPractitionerRole) {
|
||||||
|
$newRoleIds[] = $newPractitionerRole->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$deletedRoleIds = array_diff($currentRoleIds, $newRoleIds);
|
||||||
|
|
||||||
|
if (count($deletedRoleIds) > 0) {
|
||||||
|
// Delete practitioner roles that are no longer exists
|
||||||
|
$data = $practitionerRole->whereIn('id', $deletedRoleIds);
|
||||||
|
$data->each(function ($item) {
|
||||||
|
$item->delete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'success',
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,6 +231,14 @@ class DoctorController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy($id)
|
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',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,44 @@ class OrganizationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
//
|
$organization = [
|
||||||
|
'code' => $request->code,
|
||||||
|
'name' => $request->name,
|
||||||
|
'type' => 'hospital',
|
||||||
|
'status' => $request->active == 1 ? 'active' : 'inactive',
|
||||||
|
'description' => $request->description,
|
||||||
|
];
|
||||||
|
|
||||||
|
$create_organization = Organization::create($organization);
|
||||||
|
|
||||||
|
if ($request->phone != null) {
|
||||||
|
$create_organization->metas()->create([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'phone',
|
||||||
|
'value' => $request->phone,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$address = $create_organization->addresses()->create([
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
'province_id' => $request->province_id,
|
||||||
|
'city_id' => $request->city_id,
|
||||||
|
'district_id' => $request->district_id,
|
||||||
|
'village_id' => $request->village_id,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lng' => $request->lng,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$create_organization->main_address_id = $address->id;
|
||||||
|
$create_organization->save();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Data berhasil disimpan',
|
||||||
|
'data' => new OrganizationResource($create_organization)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,7 +94,7 @@ class OrganizationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
return view('internal::show');
|
return response()->json(OrganizationResource::make(Organization::find($id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +104,7 @@ class OrganizationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
return view('internal::edit');
|
return response()->json(OrganizationResource::make(Organization::find($id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +115,46 @@ class OrganizationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function update(Request $request, $id)
|
public function update(Request $request, $id)
|
||||||
{
|
{
|
||||||
//
|
$update_organization = Organization::find($id);
|
||||||
|
|
||||||
|
$update_organization->update([
|
||||||
|
'code' => $request->code,
|
||||||
|
'name' => $request->name,
|
||||||
|
'type' => 'hospital',
|
||||||
|
'status' => $request->active == 1 ? 'active' : 'inactive',
|
||||||
|
'description' => $request->description,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($request->phone != null) {
|
||||||
|
$update_organization->metas()->updateOrCreate([
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'phone',
|
||||||
|
], [
|
||||||
|
'system' => 'default',
|
||||||
|
'type' => 'phone',
|
||||||
|
'value' => $request->phone,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$update_organization->addresses()->updateOrCreate([
|
||||||
|
'id' => $update_organization->main_address_id
|
||||||
|
], [
|
||||||
|
'use' => 'both',
|
||||||
|
'type' => 'physical',
|
||||||
|
'text' => $request->address,
|
||||||
|
'province_id' => $request->province_id,
|
||||||
|
'city_id' => $request->city_id,
|
||||||
|
'district_id' => $request->district_id,
|
||||||
|
'village_id' => $request->village_id,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'lat' => $request->lat,
|
||||||
|
'lng' => $request->lng,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Data berhasil diubah',
|
||||||
|
'data' => new OrganizationResource($update_organization)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,6 +164,12 @@ class OrganizationController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy($id)
|
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)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
86
Modules/Internal/Http/Controllers/Api/ProvinceController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/ProvinceController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Province;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class ProvinceController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$province = Province::orderBy('name', 'ASC')->get();
|
||||||
|
|
||||||
|
if (empty($province)) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $province]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('internal::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('internal::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
86
Modules/Internal/Http/Controllers/Api/VillageController.php
Normal file
86
Modules/Internal/Http/Controllers/Api/VillageController.php
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Village;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class VillageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$villages = Village::where('district_id', $request->district_id)->orderBy('name', 'asc')->get();
|
||||||
|
|
||||||
|
if (!$villages) {
|
||||||
|
return response(['message' => 'Tidak ada data'], 404);
|
||||||
|
} else {
|
||||||
|
return response(['message' => 'Data ditemukan', 'data' => $villages]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('internal::create');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
return view('internal::show');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
return view('internal::edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
* @param Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
* @param int $id
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ use App\Http\Controllers\Api\MemberController as ApiMemberController;
|
|||||||
use Modules\Internal\Http\Controllers\Api\AuthController;
|
use Modules\Internal\Http\Controllers\Api\AuthController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\CityController;
|
||||||
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
||||||
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
|
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
|
||||||
use Modules\Internal\Http\Controllers\Api\CorporateController;
|
use Modules\Internal\Http\Controllers\Api\CorporateController;
|
||||||
@@ -13,6 +14,7 @@ use Modules\Internal\Http\Controllers\Api\CorporatePlanController;
|
|||||||
use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
|
use Modules\Internal\Http\Controllers\Api\CorporateServiceController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
|
use Modules\Internal\Http\Controllers\Api\DiagnosisController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
|
use Modules\Internal\Http\Controllers\Api\DiagnosisExclusionController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\DistrictController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DivisionController;
|
use Modules\Internal\Http\Controllers\Api\DivisionController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DoctorController;
|
use Modules\Internal\Http\Controllers\Api\DoctorController;
|
||||||
use Modules\Internal\Http\Controllers\Api\DrugController;
|
use Modules\Internal\Http\Controllers\Api\DrugController;
|
||||||
@@ -20,7 +22,9 @@ use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
|||||||
use Modules\Internal\Http\Controllers\Api\MemberController;
|
use Modules\Internal\Http\Controllers\Api\MemberController;
|
||||||
use Modules\Internal\Http\Controllers\Api\OrganizationController;
|
use Modules\Internal\Http\Controllers\Api\OrganizationController;
|
||||||
use Modules\Internal\Http\Controllers\Api\PlanController;
|
use Modules\Internal\Http\Controllers\Api\PlanController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\ProvinceController;
|
||||||
use Modules\Internal\Http\Controllers\Api\SpecialityController;
|
use Modules\Internal\Http\Controllers\Api\SpecialityController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\VillageController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -125,8 +129,8 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::get('generate-log/{member_id}', [CorporateMemberController::class, 'generateLog']);
|
Route::get('generate-log/{member_id}', [CorporateMemberController::class, 'generateLog']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route::resource('organizations', OrganizationController::class);
|
Route::get('province', [ProvinceController::class, 'index']);
|
||||||
// Route::resource('doctors', DoctorController::class);
|
Route::get('city', [CityController::class, 'index']);
|
||||||
|
Route::get('district', [DistrictController::class, 'index']);
|
||||||
// Route::get('something', [DiagnosisExclusionController::class, 'index']);
|
Route::get('village', [VillageController::class, 'index']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ namespace Modules\Internal\Transformers;
|
|||||||
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
use function PHPSTORM_META\map;
|
||||||
|
|
||||||
class DoctorResource extends JsonResource
|
class DoctorResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -19,35 +21,51 @@ class DoctorResource extends JsonResource
|
|||||||
// 'his_dokter_id' => $this->practitionerRoles->meta,
|
// 'his_dokter_id' => $this->practitionerRoles->meta,
|
||||||
'name' => $this->person->name,
|
'name' => $this->person->name,
|
||||||
'person_id' => $this->person->id,
|
'person_id' => $this->person->id,
|
||||||
'phone' => $this->person->phone,
|
'phone' => $this->person->phone ?? null,
|
||||||
'email' => $this->person->email,
|
'email' => $this->person->email ?? null,
|
||||||
'gender' => $this->person->gender == "L" ? 'Laki-laki' : 'Perempuan',
|
'birth_date' => $this->person->birth_date ?? null,
|
||||||
'address' => $this->person->currentAddress->text,
|
'birth_place' => $this->person->birth_place ?? null,
|
||||||
|
'gender' => $this->person->gender == "L" || $this->person->gender == "male" ? 'male' : 'female',
|
||||||
|
'address' => $this->person->currentAddress->text ?? null,
|
||||||
'organizations' => $this->practitionerRoles->unique('organization_id')->map(function ($practitionerRole) {
|
'organizations' => $this->practitionerRoles->unique('organization_id')->map(function ($practitionerRole) {
|
||||||
return [
|
return [
|
||||||
'organization_id' => $practitionerRole->organization->id,
|
'organization_id' => $practitionerRole->organization->id,
|
||||||
'organization_name' => $practitionerRole->organization->name,
|
'organization_name' => $practitionerRole->organization->name,
|
||||||
];
|
];
|
||||||
}),
|
})->values(),
|
||||||
"specialties" => $this->practitionerRoles->unique('speciality_id')->map(function ($practitionerRole) {
|
"specialties" => $this->practitionerRoles->unique('speciality_id')->map(function ($practitionerRole) {
|
||||||
return [
|
return [
|
||||||
'specialty_id' => $practitionerRole->speciality->id,
|
'specialty_id' => $practitionerRole->speciality->id,
|
||||||
'specialty_name' => $practitionerRole->speciality->name,
|
'specialty_name' => $practitionerRole->speciality->name,
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
"departemen" => $this->practitionerRoles->map(function ($practitionerRole) {
|
// "departemen" => $this->practitionerRoles->map(function ($practitionerRole) {
|
||||||
return [
|
// return [
|
||||||
'departemen_id' => $practitionerRole->meta->DepartemenID,
|
// 'departemen_id' => $practitionerRole->meta->DepartemenID ?? null,
|
||||||
];
|
// ];
|
||||||
}),
|
// }) ?? null,
|
||||||
'education' => $this->meta->education,
|
'education' => $this->meta->education ?? null,
|
||||||
'experience' => $this->meta->work_experience,
|
'experience' => $this->meta->work_experience ?? null,
|
||||||
'award' => $this->meta->award,
|
'award' => $this->meta->award ?? null,
|
||||||
'keilmuan' => $this->meta->Keilmuan,
|
'keilmuan' => $this->meta->Keilmuan ?? null,
|
||||||
'tipe_dokter' => $this->meta->tipeDokter,
|
'tipe_dokter' => $this->meta->tipeDokter ?? null,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$grouped = $this->collection($this->practitionerRoles)->groupBy('organization_id');
|
||||||
|
$grouped->transform(function ($items, $key) {
|
||||||
|
return [
|
||||||
|
'organization_id' => $key,
|
||||||
|
'specialities' => $items->map(function ($item) {
|
||||||
|
return [
|
||||||
|
'speciality_id' => $item->speciality->id,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
$doctor['practices'] = $grouped->toArray();
|
||||||
|
|
||||||
return $doctor;
|
return $doctor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,17 +14,24 @@ class OrganizationResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$organization = [
|
$organization = [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'type' => $this->type,
|
'type' => $this->type,
|
||||||
'code' => $this->code,
|
'code' => $this->code,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'kodeRs' => $this->meta->kodeRs ?? null,
|
'kodeRs' => $this->meta->KodeRS ?? null,
|
||||||
'phone' => $this->meta->phone ?? null,
|
'phone' => $this->meta->phone ?? null,
|
||||||
'lat' => $this->currentAddress->lat ?? null,
|
'lat' => $this->currentAddress->lat ?? null,
|
||||||
'lng' => $this->currentAddress->lng ?? null,
|
'lng' => $this->currentAddress->lng ?? null,
|
||||||
'address' => $this->currentAddress ?? null,
|
'address' => $this->currentAddress->text ?? null,
|
||||||
|
'province_id' => $this->currentAddress->province_id ?? null,
|
||||||
|
'city_id' => $this->currentAddress->city_id ?? null,
|
||||||
|
'district_id' => $this->currentAddress->district_id ?? null,
|
||||||
|
'village_id' => $this->currentAddress->village_id ?? null,
|
||||||
|
'postal_code' => $this->currentAddress->postal_code ?? null,
|
||||||
|
'active' => $this->status == 'active' ? 1 : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $organization;
|
return $organization;
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ class Person extends Model
|
|||||||
return $this->hasOne(User::class, 'person_id');
|
return $this->hasOne(User::class, 'person_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function practitioner()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Practitioner::class, 'person_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function appointmentParticipantables()
|
public function appointmentParticipantables()
|
||||||
{
|
{
|
||||||
return $this->morphMany(AppointmentParticipant::class, 'participantable');
|
return $this->morphMany(AppointmentParticipant::class, 'participantable');
|
||||||
|
|||||||
7
frontend/dashboard/.env.development
Executable file
7
frontend/dashboard/.env.development
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
GENERATE_SOURCEMAP=false
|
||||||
|
|
||||||
|
PORT=8083
|
||||||
|
|
||||||
|
REACT_APP_HOST_API_URL="http://localhost:8000"
|
||||||
|
|
||||||
|
VITE_API_URL="http://localhost:8000/api/internal"
|
||||||
@@ -9,7 +9,6 @@ import Form from './Form';
|
|||||||
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
||||||
import axios from '../../../utils/axios';
|
import axios from '../../../utils/axios';
|
||||||
import { Practitioner } from '../../../@types/doctor';
|
import { Practitioner } from '../../../@types/doctor';
|
||||||
import ButtonBack from '../../../components/ButtonBack';
|
|
||||||
|
|
||||||
export default function Create() {
|
export default function Create() {
|
||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
@@ -31,7 +30,6 @@ export default function Create() {
|
|||||||
<Page title="Membership: Create a new Dokter">
|
<Page title="Membership: Create a new Dokter">
|
||||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||||
<Stack direction="row" alignItems="center">
|
<Stack direction="row" alignItems="center">
|
||||||
<ButtonBack />
|
|
||||||
<HeaderBreadcrumbs
|
<HeaderBreadcrumbs
|
||||||
heading={!isEdit ? 'Manage a new Dokter' : 'Manage Dokter'}
|
heading={!isEdit ? 'Manage a new Dokter' : 'Manage Dokter'}
|
||||||
links={[
|
links={[
|
||||||
@@ -54,40 +52,3 @@ export default function Create() {
|
|||||||
</Page>
|
</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>
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import Select, { SelectChangeEvent } from '@mui/material/Select';
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
// form
|
// form
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm, Controller } from 'react-hook-form';
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
// @mui
|
// @mui
|
||||||
import { styled } from '@mui/material/styles';
|
import { styled } from '@mui/material/styles';
|
||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
Typography,
|
Typography,
|
||||||
TextField,
|
TextField,
|
||||||
Chip,
|
Chip,
|
||||||
|
Autocomplete,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
@@ -41,17 +42,20 @@ import {
|
|||||||
RHFMultiCheckbox,
|
RHFMultiCheckbox,
|
||||||
RHFCheckbox,
|
RHFCheckbox,
|
||||||
RHFCustomMultiCheckbox,
|
RHFCustomMultiCheckbox,
|
||||||
|
RHFSelect,
|
||||||
} from '../../../components/hook-form';
|
} from '../../../components/hook-form';
|
||||||
import axios from '../../../utils/axios';
|
import axios from '../../../utils/axios';
|
||||||
import { fCurrency } from '../../../utils/formatNumber';
|
import { fCurrency } from '../../../utils/formatNumber';
|
||||||
import { Practitioner } from '../../../@types/doctor';
|
import { Practitioner } from '../../../@types/doctor';
|
||||||
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
|
||||||
import { Label, Rowing } from '@mui/icons-material';
|
import { Label, Rowing } from '@mui/icons-material';
|
||||||
|
import { email } from '../../../_mock/email';
|
||||||
|
|
||||||
const LabelStyle = styled(Typography)(({ theme }) => ({
|
const LabelStyle = styled(Typography)(({ theme }) => ({
|
||||||
...theme.typography.subtitle2,
|
...theme.typography.h6,
|
||||||
color: theme.palette.text.secondary,
|
marginBottom: theme.spacing(2),
|
||||||
marginBottom: theme.spacing(1),
|
marginTop: theme.spacing(2),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const HeaderStyle = styled('header')(({ theme }) => ({
|
const HeaderStyle = styled('header')(({ theme }) => ({
|
||||||
@@ -66,7 +70,6 @@ const Title = styled(Typography)(({ theme }) => ({
|
|||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
// paddingBottom: theme.spacing(3),
|
// paddingBottom: theme.spacing(3),
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
color: '#005B7F',
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
interface FormValuesProps extends Partial<Practitioner> {
|
interface FormValuesProps extends Partial<Practitioner> {
|
||||||
@@ -106,6 +109,8 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
|||||||
() => ({
|
() => ({
|
||||||
id: currentPractitioner?.id,
|
id: currentPractitioner?.id,
|
||||||
name: currentPractitioner?.name || '',
|
name: currentPractitioner?.name || '',
|
||||||
|
email: currentPractitioner?.email || '',
|
||||||
|
phone: currentPractitioner?.phone || '',
|
||||||
address: currentPractitioner?.address || '',
|
address: currentPractitioner?.address || '',
|
||||||
birth_date: currentPractitioner?.birth_date || '',
|
birth_date: currentPractitioner?.birth_date || '',
|
||||||
gender: currentPractitioner?.gender || '',
|
gender: currentPractitioner?.gender || '',
|
||||||
@@ -121,6 +126,8 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
|||||||
[currentPractitioner]
|
[currentPractitioner]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('currentPractitioner', currentPractitioner);
|
||||||
|
|
||||||
console.log('defaultValues', defaultValues);
|
console.log('defaultValues', defaultValues);
|
||||||
|
|
||||||
function StatusLabel({ value }: { value: boolean }) {
|
function StatusLabel({ value }: { value: boolean }) {
|
||||||
@@ -168,91 +175,391 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isEdit, currentPractitioner]);
|
}, [isEdit, currentPractitioner]);
|
||||||
|
|
||||||
const handleActivate = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const onSubmit = async (data: FormValuesProps) => {
|
||||||
setValue('active', event.target.checked);
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
console.log('event.target.checked', 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' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const formData = new FormData();
|
const ascent = document?.querySelector('ascent');
|
||||||
formData.append('active', event.target.checked ? '1' : '0');
|
if (ascent != null) {
|
||||||
formData.append('_method', 'PUT');
|
ascent.innerHTML = '';
|
||||||
axios.post('/doctors/' + currentPractitioner?.id ?? '', formData);
|
}
|
||||||
|
};
|
||||||
|
|
||||||
enqueueSnackbar('active Updated Successfully!', { variant: 'success' });
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormProvider methods={methods}>
|
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||||
<Stack spacing={3}>
|
<Stack spacing={3}>
|
||||||
<Box sx={{ width: '100%' }}>
|
<Box sx={{ width: '100%' }}>
|
||||||
{/* <Stack spacing={3}> */}
|
{/* <Stack spacing={3}> */}
|
||||||
<Card sx={{ p: 5 }}>
|
<Card sx={{ p: 5 }}>
|
||||||
<HeaderStyle>
|
{/* <HeaderStyle>
|
||||||
<Grid item xs={6} md={6}>
|
<Grid item xs={6} md={6}>
|
||||||
<Title>Data Dokter</Title>
|
<Title>Data Dokter</Title>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={6} md={6}>
|
<Grid item xs={6} md={6}>
|
||||||
{/* <Typography>Status Rumah Sakit</Typography> */}
|
<RHFSwitch name="active" label="" />
|
||||||
<RHFSwitch name="active" label="" onClick={handleActivate} />
|
|
||||||
<StatusLabel value={values.active} />
|
<StatusLabel value={values.active} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</HeaderStyle>
|
</HeaderStyle> */}
|
||||||
<Title variant="h5">Informasi Umum</Title>
|
<Title variant="h5">Informasi Umum</Title>
|
||||||
<Avatar
|
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }} sx={{ mt: 2 }}>
|
||||||
alt="Remy Sharp"
|
<Grid item xs={12}>
|
||||||
src={currentPractitioner?.avatar_url}
|
<LabelStyle>Nama Dokter</LabelStyle>
|
||||||
sx={{ width: 120, height: 120, marginBottom: 2 }}
|
<RHFTextField name="name" placeholder="Tuliskan Nama Dokter" />
|
||||||
/>
|
|
||||||
|
|
||||||
<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>
|
||||||
<Grid item xs={5} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
|
||||||
<Span style={{ fontWeight: 'bold' }}>Jenis Kelamin</Span>
|
<Grid item xs={6}>
|
||||||
<Text>{currentPractitioner?.gender ? currentPractitioner?.gender : '-'}</Text>
|
<LabelStyle>Jenis Kelamin</LabelStyle>
|
||||||
<Span style={{ fontWeight: 'bold' }}>Email</Span>
|
<RHFSelect name="gender" label="Pilih Jenis Kelamin">
|
||||||
<Text>{currentPractitioner?.email ? currentPractitioner?.email : '-'}</Text>
|
<option value="" />
|
||||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Lahir</Span>
|
{gender.map((option, index) => (
|
||||||
<Text>
|
<option key={index} value={option.value}>
|
||||||
{currentPractitioner?.birth_date ? currentPractitioner?.birth_date : '-'}
|
{option.label}
|
||||||
</Text>
|
</option>
|
||||||
|
))}
|
||||||
|
</RHFSelect>
|
||||||
|
</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>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Card>
|
</Card>
|
||||||
<Card sx={{ p: 5, marginTop: 2 }}>
|
<Card sx={{ p: 5, marginTop: 2 }}>
|
||||||
<Title variant="h5">Tempat Praktik</Title>
|
<Stack spacing={3} direction="row" justifyContent="space-between">
|
||||||
{currentPractitioner?.organizations?.map((item, index) => (
|
<Title variant="h5">Tempat Praktik</Title>
|
||||||
<Box key={index} sx={{ mt: 3 }}>
|
<Button
|
||||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
variant="contained"
|
||||||
<Grid item xs={7}>
|
color="primary"
|
||||||
<Text>{item.name}</Text>
|
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>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Box>
|
||||||
</Box>
|
</div>
|
||||||
))}
|
|
||||||
</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>
|
</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>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ import { Search } from '@mui/icons-material';
|
|||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||||
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||||
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -205,9 +206,16 @@ export default function List() {
|
|||||||
spacing={2}
|
spacing={2}
|
||||||
sx={{ p: 2, justifyContent: 'space-between', alignItems: 'center' }}
|
sx={{ p: 2, justifyContent: 'space-between', alignItems: 'center' }}
|
||||||
>
|
>
|
||||||
<Grid item xs={12} md={12} lg={12}>
|
<Grid item xs={12} md={10} lg={10}>
|
||||||
<Filter onSearch={applyItems} />
|
<Filter onSearch={applyItems} />
|
||||||
</Grid>
|
</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>
|
</Grid>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -297,15 +305,22 @@ export default function List() {
|
|||||||
<CheckStatus row={row} />
|
<CheckStatus row={row} />
|
||||||
</TableCell> */}
|
</TableCell> */}
|
||||||
|
|
||||||
{/* <TableCell align="center">
|
<TableCell align="center">
|
||||||
<ButtonGroup variant="text" aria-label="text button group">
|
<ButtonGroup variant="text" aria-label="text button group">
|
||||||
<Link to={'/master/doctors/' + row.id}>
|
<Link to={'/master/doctors/' + row.id + '/edit'}>
|
||||||
<Button>
|
<Button>
|
||||||
<Icon icon="ph:eye-bold" style={{ width: '24px', height: '24px' }} />
|
<Icon icon="ph:pencil-simple-fill" style={{ width: '24px', height: '24px' }} />
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setOpenDialog(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon icon="eva:trash-2-outline" style={{ width: '24px', height: '24px' }} />
|
||||||
|
</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</TableCell> */}
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
{/* COLLAPSIBLE ROW */}
|
{/* COLLAPSIBLE ROW */}
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -336,7 +351,12 @@ export default function List() {
|
|||||||
Jenis Kelamin
|
Jenis Kelamin
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={6}>
|
<Grid item xs={6}>
|
||||||
: {row.gender ? row.gender : '-'}
|
:{' '}
|
||||||
|
{row.gender == 'male'
|
||||||
|
? 'Laki-Laki'
|
||||||
|
: row.gender == 'female'
|
||||||
|
? 'Perempuan'
|
||||||
|
: '-'}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import Form from './Form';
|
|||||||
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
||||||
import axios from '../../../utils/axios';
|
import axios from '../../../utils/axios';
|
||||||
import { Organizations } from '../../../@types/organization';
|
import { Organizations } from '../../../@types/organization';
|
||||||
import ButtonBack from '../../../components/ButtonBack';
|
|
||||||
|
|
||||||
export default function Create() {
|
export default function Create() {
|
||||||
const { themeStretch } = useSettings();
|
const { themeStretch } = useSettings();
|
||||||
@@ -31,25 +30,20 @@ export default function Create() {
|
|||||||
<Page title="Membership: Create a new Rumah Sakit">
|
<Page title="Membership: Create a new Rumah Sakit">
|
||||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||||
<Stack direction="row" alignItems="center">
|
<Stack direction="row" alignItems="center">
|
||||||
<ButtonBack />
|
|
||||||
<HeaderBreadcrumbs
|
<HeaderBreadcrumbs
|
||||||
heading={!isEdit ? 'Create a new Rumah Sakit' : 'Edit Rumah Sakit'}
|
heading={!isEdit ? 'Create a new Rumah Sakit' : 'Edit Rumah Sakit'}
|
||||||
links={[
|
links={[
|
||||||
{ name: 'Master', href: '/master' },
|
{ name: 'Master', href: '/master' },
|
||||||
{
|
{
|
||||||
name: 'Organizations',
|
name: 'Organizations',
|
||||||
href: '/master/organizations',
|
href: '/master/hospitals',
|
||||||
},
|
},
|
||||||
{ name: !isEdit ? 'Create' : currentOrganizations?.name ?? '' },
|
{ name: !isEdit ? 'Create' : currentOrganizations?.name ?? '' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Form
|
<Form isEdit={isEdit} currentOrganizations={currentOrganizations} />
|
||||||
// isSubmitting={isSubmitting}
|
|
||||||
isEdit={isEdit}
|
|
||||||
currentOrganizations={currentOrganizations}
|
|
||||||
/>
|
|
||||||
</Container>
|
</Container>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ const LabelStyle = styled(Typography)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const HeaderStyle = styled('header')(({ theme }) => ({
|
const HeaderStyle = styled('header')(({ theme }) => ({
|
||||||
padding: theme.spacing(5),
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
@@ -76,7 +75,6 @@ const Title = styled(Typography)(({ theme }) => ({
|
|||||||
boxShadow: 'none',
|
boxShadow: 'none',
|
||||||
// paddingBottom: theme.spacing(3),
|
// paddingBottom: theme.spacing(3),
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
color: '#005B7F',
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// const [timezone, setTimezone] = React.useState('');
|
// const [timezone, setTimezone] = React.useState('');
|
||||||
@@ -110,10 +108,6 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
const NewCorporateSchema = Yup.object().shape({
|
const NewCorporateSchema = Yup.object().shape({
|
||||||
name: Yup.string().required('Name is required'),
|
name: Yup.string().required('Name is required'),
|
||||||
code: Yup.string().required('Corporate Code 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'),
|
// file: Yup.boolean().required('Corporate Status is required'),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -133,12 +127,6 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
village_id: currentOrganizations?.village_id || '',
|
village_id: currentOrganizations?.village_id || '',
|
||||||
postal_code: currentOrganizations?.postal_code || '',
|
postal_code: currentOrganizations?.postal_code || '',
|
||||||
description: currentOrganizations?.description || '',
|
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
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[currentOrganizations]
|
[currentOrganizations]
|
||||||
@@ -192,25 +180,15 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isEdit, currentOrganizations]);
|
}, [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) => {
|
const onSubmit = async (data: FormValuesProps) => {
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
console.log('data', data);
|
|
||||||
formData.append('name', data.name);
|
formData.append('name', data.name);
|
||||||
formData.append('code', data.code);
|
formData.append('code', data.code);
|
||||||
formData.append('phone', data.phone);
|
formData.append('phone', data.phone);
|
||||||
formData.append('lat', data.lat);
|
formData.append('lat', data.lat);
|
||||||
formData.append('lng', data.lng);
|
formData.append('lng', data.lng);
|
||||||
formData.append('address', data.address);
|
formData.append('address', data.address);
|
||||||
formData.append('timezone', data.timezone);
|
|
||||||
formData.append('active', data.active ? '1' : '0');
|
formData.append('active', data.active ? '1' : '0');
|
||||||
if (data.province_id === currentOrganizations?.province_id) {
|
if (data.province_id === currentOrganizations?.province_id) {
|
||||||
formData.append('province_id', data.province_id);
|
formData.append('province_id', data.province_id);
|
||||||
@@ -235,21 +213,12 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
} else {
|
} else {
|
||||||
formData.append('village_id', data.village_id?.value ?? '');
|
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('postal_code', data.postal_code);
|
||||||
formData.append('description', data.description);
|
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) {
|
if (!isEdit) {
|
||||||
|
console.log('formData', formData);
|
||||||
const response = await axios.post('/organizations', formData);
|
const response = await axios.post('/organizations', formData);
|
||||||
} else {
|
} else {
|
||||||
formData.append('_method', 'PUT');
|
formData.append('_method', 'PUT');
|
||||||
@@ -263,9 +232,10 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
!isEdit ? 'Organizations Created Successfully!' : 'Organizations Udpated Successfully!',
|
!isEdit ? 'Organizations Created Successfully!' : 'Organizations Udpated Successfully!',
|
||||||
{ variant: 'success' }
|
{ variant: 'success' }
|
||||||
);
|
);
|
||||||
navigate('/master/organizations');
|
navigate('/master/hospitals');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error && error.response.status === 422) {
|
if (error && error.response.status === 422) {
|
||||||
|
console.log('error', error.response.data.errors);
|
||||||
for (const [key, value] of Object.entries(error.response.data.errors)) {
|
for (const [key, value] of Object.entries(error.response.data.errors)) {
|
||||||
setError(key, { message: value[0] });
|
setError(key, { message: value[0] });
|
||||||
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
|
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
|
||||||
@@ -281,34 +251,10 @@ 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 [province, setProvince] = useState<any>([]);
|
||||||
const [city, setCity] = useState<any>([]);
|
const [city, setCity] = useState<any>([]);
|
||||||
const [district, setDistrict] = useState<any>([]);
|
const [district, setDistrict] = useState<any>([]);
|
||||||
// const [village, setVillage] = useState<any>([]);
|
const [village, setVillage] = useState<any>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
axios.get('/province').then((res) => {
|
axios.get('/province').then((res) => {
|
||||||
@@ -335,17 +281,15 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// if (values.province_id) {
|
const loadVillage = async () => {
|
||||||
// if (values.city_id) {
|
if (values.district_id == currentOrganizations?.district_id) {
|
||||||
// loadDistrict();
|
const res = await axios.get('/village?district_id=' + values.district_id);
|
||||||
// } else {
|
setVillage(res.data.data.map((item: any) => ({ value: item.id, label: item.name })));
|
||||||
// loadCity();
|
} else {
|
||||||
// }
|
const res = await axios.get('/village?district_id=' + values.district_id?.value);
|
||||||
// } else {
|
setVillage(res.data.data.map((item: any) => ({ value: item.id, label: item.name })));
|
||||||
// axios.get('/province').then((res) => {
|
}
|
||||||
// setProvince(res.data.data.map((item: any) => ({ value: item.id, label: item.name })));
|
};
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (values.province_id) {
|
if (values.province_id) {
|
||||||
loadCity();
|
loadCity();
|
||||||
@@ -354,12 +298,11 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
if (values.city_id) {
|
if (values.city_id) {
|
||||||
loadDistrict();
|
loadDistrict();
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [values.province_id, values.city_id, values.district_id]);
|
|
||||||
|
|
||||||
console.log('province', values.province_id);
|
if (values.district_id) {
|
||||||
console.log('city', values.city_id);
|
loadVillage();
|
||||||
console.log('district', values.district_id);
|
}
|
||||||
|
}, [values.province_id, values.city_id, values.district_id, values.village_id]);
|
||||||
|
|
||||||
const findValueProvince = province.find(
|
const findValueProvince = province.find(
|
||||||
(item: any) => item.value === currentOrganizations?.province_id
|
(item: any) => item.value === currentOrganizations?.province_id
|
||||||
@@ -368,53 +311,8 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
const findValueDistrict = district.find(
|
const findValueDistrict = district.find(
|
||||||
(item: any) => item.value === currentOrganizations?.district_id
|
(item: any) => item.value === currentOrganizations?.district_id
|
||||||
);
|
);
|
||||||
|
const findValueVillage = village.find(
|
||||||
console.log('findValueProvince', findValueProvince);
|
(item: any) => item.value === currentOrganizations?.village_id
|
||||||
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 (
|
return (
|
||||||
@@ -431,326 +329,147 @@ export default function OrganizationsForm({ isEdit, currentOrganizations }: Prop
|
|||||||
<StatusLabel value={values.active} />
|
<StatusLabel value={values.active} />
|
||||||
</Grid>
|
</Grid>
|
||||||
</HeaderStyle>
|
</HeaderStyle>
|
||||||
<Box sx={{ width: '100%', typography: 'body1' }}>
|
<Box sx={{ width: '100%', typography: 'body1', mt: 2 }}>
|
||||||
<TabContext value={valueTab}>
|
<Grid container rowSpacing={4} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||||
<Box
|
<Grid item xs={12}>
|
||||||
sx={{
|
<LabelStyle>Nama Rumah Sakit</LabelStyle>
|
||||||
borderBottom: 1,
|
<RHFTextField name="name" placeholder="Tuliskan Nama Rumah Sakit" />
|
||||||
borderColor: 'divider',
|
</Grid>
|
||||||
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>
|
|
||||||
)}
|
|
||||||
/> */}
|
|
||||||
|
|
||||||
<Controller
|
<Grid item xs={12} md={6}>
|
||||||
name="province_id"
|
<LabelStyle>Code Rumah Sakit</LabelStyle>
|
||||||
control={control}
|
<RHFTextField name="code" placeholder="Tuliskan Code Rumah Sakit" />
|
||||||
render={({ field: { onChange, value } }) => (
|
</Grid>
|
||||||
<Autocomplete
|
<Grid item xs={12} md={6}>
|
||||||
id="combo-box-demo"
|
<LabelStyle>Nomor IGD</LabelStyle>
|
||||||
options={province}
|
<RHFTextField name="phone" placeholder="Tuliskan No IGD" />
|
||||||
getOptionLabel={(option) =>
|
</Grid>
|
||||||
option.label ?? findValueProvince?.label ?? ''
|
<Grid item xs={12}>
|
||||||
}
|
<LabelStyle>Alamat</LabelStyle>
|
||||||
value={value}
|
<RHFTextField name="address" placeholder="Tuliskan Alamat" />
|
||||||
onChange={(event: any, newValue: any) => {
|
</Grid>
|
||||||
console.log('newValue', newValue);
|
<Grid item xs={12} md={6}>
|
||||||
setValue('province_id', newValue?.value);
|
<LabelStyle>Provinsi</LabelStyle>
|
||||||
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>
|
|
||||||
|
|
||||||
<Grid item xs={12} md={6}>
|
<Controller
|
||||||
<LabelStyle>Kecamatan</LabelStyle>
|
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
|
<Controller
|
||||||
name="district_id"
|
name="city_id"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field: { onChange, value } }) => (
|
render={({ field: { onChange, value } }) => (
|
||||||
<Select
|
<Autocomplete
|
||||||
className="input-container"
|
id="combo-box-demo"
|
||||||
size="medium"
|
options={city}
|
||||||
disabled={!district?.length}
|
getOptionLabel={(option) => option.label ?? findValueCity?.label ?? ''}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e: any) => {
|
onChange={(event: any, newValue: any) => {
|
||||||
onChange(e);
|
console.log('newValue', newValue);
|
||||||
}}
|
setValue('city_id', newValue?.value);
|
||||||
fullWidth
|
onChange(newValue);
|
||||||
MenuProps={{
|
}}
|
||||||
PaperProps: {
|
renderInput={(params) => (
|
||||||
sx: {
|
<TextField
|
||||||
maxHeight: 224,
|
{...params}
|
||||||
width: 250,
|
label="Kabupaten / Kota"
|
||||||
p: 1,
|
variant="outlined"
|
||||||
},
|
fullWidth
|
||||||
},
|
/>
|
||||||
}}
|
)}
|
||||||
>
|
/>
|
||||||
{district?.map((item: any) => (
|
)}
|
||||||
<MenuItem key={item.value} value={item.value}>
|
/>
|
||||||
{item.label}
|
</Grid>
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
)}
|
|
||||||
/> */}
|
|
||||||
|
|
||||||
<Controller
|
<Grid item xs={12} md={6}>
|
||||||
name="district_id"
|
<LabelStyle>Kecamatan</LabelStyle>
|
||||||
control={control}
|
|
||||||
render={({ field: { onChange, value } }) => (
|
<Controller
|
||||||
<Autocomplete
|
name="district_id"
|
||||||
id="combo-box-demo"
|
control={control}
|
||||||
options={district}
|
render={({ field: { onChange, value } }) => (
|
||||||
getOptionLabel={(option) =>
|
<Autocomplete
|
||||||
option.label ?? findValueDistrict?.label ?? ''
|
id="combo-box-demo"
|
||||||
}
|
options={district}
|
||||||
value={value}
|
getOptionLabel={(option) => option.label ?? findValueDistrict?.label ?? ''}
|
||||||
onChange={(event: any, newValue: any) => {
|
value={value}
|
||||||
console.log('newValue', newValue);
|
onChange={(event: any, newValue: any) => {
|
||||||
setValue('district_id', newValue?.value);
|
console.log('newValue', newValue);
|
||||||
onChange(newValue);
|
setValue('district_id', newValue?.value);
|
||||||
}}
|
onChange(newValue);
|
||||||
renderInput={(params) => (
|
}}
|
||||||
<TextField
|
renderInput={(params) => (
|
||||||
{...params}
|
<TextField {...params} label="Kecamatan" variant="outlined" fullWidth />
|
||||||
label="Kecamatan"
|
)}
|
||||||
variant="outlined"
|
/>
|
||||||
fullWidth
|
)}
|
||||||
/>
|
/>
|
||||||
)}
|
</Grid>
|
||||||
/>
|
<Grid item xs={12} md={6}>
|
||||||
)}
|
<LabelStyle>Desa</LabelStyle>
|
||||||
/>
|
|
||||||
</Grid>
|
<Controller
|
||||||
<Grid item xs={12} md={6}>
|
name="village_id"
|
||||||
<LabelStyle>Kode Pos</LabelStyle>
|
control={control}
|
||||||
<RHFTextField name="postal_code" placeholder="Tuliskan Kode Pos" />
|
render={({ field: { onChange, value } }) => (
|
||||||
</Grid>
|
<Autocomplete
|
||||||
<Grid item xs={12} md={4}>
|
id="combo-box-demo"
|
||||||
<LabelStyle>Latitude</LabelStyle>
|
options={village}
|
||||||
<RHFTextField name="lat" placeholder="Tuliskan Lattitude" />
|
getOptionLabel={(option) => option.label ?? findValueVillage?.label ?? ''}
|
||||||
</Grid>
|
value={value}
|
||||||
<Grid item xs={12} md={4}>
|
onChange={(event: any, newValue: any) => {
|
||||||
<LabelStyle>Longitude</LabelStyle>
|
console.log('newValue', newValue);
|
||||||
<RHFTextField name="lng" placeholder="Tuliskan Longitude" />
|
setValue('village_id', newValue?.value);
|
||||||
</Grid>
|
onChange(newValue);
|
||||||
<Grid item xs={12} md={4}>
|
}}
|
||||||
<LabelStyle>Timezone</LabelStyle>
|
renderInput={(params) => (
|
||||||
{/* <RHFTextField name="timezone" /> */}
|
<TextField {...params} label="Desa" variant="outlined" fullWidth />
|
||||||
<RHFSelect name="timezone" label="Pilih Timezone">
|
)}
|
||||||
<option value="" />
|
/>
|
||||||
{timezone.map((option, index) => (
|
)}
|
||||||
<option key={index} value={option.value}>
|
/>
|
||||||
{option.label}
|
</Grid>
|
||||||
</option>
|
<Grid item xs={12} md={4}>
|
||||||
))}
|
<LabelStyle>Kode Pos</LabelStyle>
|
||||||
</RHFSelect>
|
<RHFTextField name="postal_code" placeholder="Tuliskan Kode Pos" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
<Grid item xs={12} md={4}>
|
||||||
</Box>
|
<LabelStyle>Latitude</LabelStyle>
|
||||||
</TabPanel>
|
<RHFTextField name="lat" placeholder="Tuliskan Lattitude" />
|
||||||
<TabPanel value="2">
|
</Grid>
|
||||||
<Box sx={{ width: '100%', p: 5 }}>
|
<Grid item xs={12} md={4}>
|
||||||
<Grid container rowSpacing={4} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
<LabelStyle>Longitude</LabelStyle>
|
||||||
<Grid item xs={12}>
|
<RHFTextField name="lng" placeholder="Tuliskan Longitude" />
|
||||||
<LabelStyle>Deskripsi</LabelStyle>
|
</Grid>
|
||||||
<RHFEditor name="description" placeholder="Tuliskan Deskripsi" />
|
<Grid item xs={12}>
|
||||||
</Grid>
|
<LabelStyle>Deskripsi</LabelStyle>
|
||||||
<Grid item xs={12}>
|
<RHFEditor name="description" placeholder="Tuliskan Deskripsi" />
|
||||||
<LabelStyle>Teknologi</LabelStyle>
|
</Grid>
|
||||||
<RHFEditor name="technology" placeholder="Tuliskan Teknologi" />
|
</Grid>
|
||||||
</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>
|
||||||
<Box sx={{ width: '100%', p: 5 }}>
|
|
||||||
|
<Box sx={{ width: '100%', mt: 5 }}>
|
||||||
<Stack
|
<Stack
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
justifyContent="end"
|
justifyContent="end"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default function Organizations() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Rumah Sakit',
|
name: 'Rumah Sakit',
|
||||||
href: '/master/organizations',
|
href: '/master/hospitals',
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -147,9 +147,11 @@ export default function List() {
|
|||||||
>
|
>
|
||||||
<SearchInput onSearch={applyFilter} />
|
<SearchInput onSearch={applyFilter} />
|
||||||
|
|
||||||
{/* <Link to="/master/organizations/create/" style={{ textDecoration: 'none' }}>
|
<Link to="/master/hospitals/create" style={{ textDecoration: 'none' }}>
|
||||||
<ButtonCreate />
|
<Button variant="outlined" startIcon={<AddIcon />} sx={{ p: 1.8 }}>
|
||||||
</Link> */}
|
Create
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -259,26 +261,26 @@ export default function List() {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="left">{row.name}</TableCell>
|
<TableCell align="left">{row.name}</TableCell>
|
||||||
<TableCell align="left">{row.phone}</TableCell>
|
<TableCell align="left">{row.phone}</TableCell>
|
||||||
<TableCell align="left">{row.address?.text}</TableCell>
|
<TableCell align="left">{row.address}</TableCell>
|
||||||
|
|
||||||
{/* <TableCell align="left">
|
<TableCell align="right">
|
||||||
<Stack direction="row">
|
{/* <Stack direction="row"> */}
|
||||||
<ButtonGroup variant="text" aria-label="text button group">
|
<ButtonGroup variant="text" aria-label="text button group">
|
||||||
<Link to={'/master/organizations/' + row.id + '/edit'}>
|
<Link to={'/master/hospitals/' + row.id + '/edit'}>
|
||||||
<Button>
|
<Button>
|
||||||
<Icon icon="ph:pencil-simple-fill" style={{ width: '24px', height: '24px' }} />
|
<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>
|
</Button>
|
||||||
</ButtonGroup>
|
</Link>
|
||||||
</Stack>
|
<Button
|
||||||
</TableCell> */}
|
onClick={() => {
|
||||||
|
setOpenDialog(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon icon="eva:trash-2-outline" style={{ width: '24px', height: '24px' }} />
|
||||||
|
</Button>
|
||||||
|
</ButtonGroup>
|
||||||
|
{/* </Stack> */}
|
||||||
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
{/* COLLAPSIBLE ROW */}
|
{/* COLLAPSIBLE ROW */}
|
||||||
|
|||||||
@@ -194,10 +194,26 @@ export default function Router() {
|
|||||||
path: 'master/doctors',
|
path: 'master/doctors',
|
||||||
element: <MasterDoctors />,
|
element: <MasterDoctors />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'master/doctors/create',
|
||||||
|
element: <MasterDoctorsCreate />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'master/doctors/:id/edit',
|
||||||
|
element: <MasterDoctorsCreate />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'master/hospitals',
|
path: 'master/hospitals',
|
||||||
element: <MasterHospitals />,
|
element: <MasterHospitals />,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'master/hospitals/create',
|
||||||
|
element: <MasterHospitalsCreate />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'master/hospitals/:id/edit',
|
||||||
|
element: <MasterHospitalsCreate />,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'master/diagnosis',
|
path: 'master/diagnosis',
|
||||||
element: <MasterDiagnosis />,
|
element: <MasterDiagnosis />,
|
||||||
@@ -320,7 +336,9 @@ const CorporateFormularium = Loadable(lazy(() => import('../pages/Corporates/For
|
|||||||
|
|
||||||
const MasterDiagnosis = Loadable(lazy(() => import('../pages/Master/Diagnosis/Index')));
|
const MasterDiagnosis = Loadable(lazy(() => import('../pages/Master/Diagnosis/Index')));
|
||||||
const MasterDoctors = Loadable(lazy(() => import('../pages/Master/Doctors/Index')));
|
const MasterDoctors = Loadable(lazy(() => import('../pages/Master/Doctors/Index')));
|
||||||
|
const MasterDoctorsCreate = Loadable(lazy(() => import('../pages/Master/Doctors/Create')));
|
||||||
const MasterHospitals = Loadable(lazy(() => import('../pages/Master/Hospitals/Index')));
|
const MasterHospitals = Loadable(lazy(() => import('../pages/Master/Hospitals/Index')));
|
||||||
|
const MasterHospitalsCreate = Loadable(lazy(() => import('../pages/Master/Hospitals/Create')));
|
||||||
|
|
||||||
const MasterDrug = Loadable(lazy(() => import('../pages/Master/Drug/Index')));
|
const MasterDrug = Loadable(lazy(() => import('../pages/Master/Drug/Index')));
|
||||||
|
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export const colorPresets = [
|
|||||||
name: 'blue',
|
name: 'blue',
|
||||||
lighter: '#D1E9FC',
|
lighter: '#D1E9FC',
|
||||||
light: '#76B0F1',
|
light: '#76B0F1',
|
||||||
main: '#2065D1',
|
main: '#006a35',
|
||||||
dark: '#103996',
|
dark: '#004422',
|
||||||
darker: '#061B64',
|
darker: '#061B64',
|
||||||
contrastText: '#fff',
|
contrastText: '#fff',
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@ export const colorPresets = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const defaultPreset = colorPresets[0];
|
export const defaultPreset = colorPresets[3];
|
||||||
export const purplePreset = colorPresets[1];
|
export const purplePreset = colorPresets[1];
|
||||||
export const cyanPreset = colorPresets[2];
|
export const cyanPreset = colorPresets[2];
|
||||||
export const bluePreset = colorPresets[3];
|
export const bluePreset = colorPresets[3];
|
||||||
|
|||||||
Reference in New Issue
Block a user