Update Formularium
This commit is contained in:
@@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Helpers\Helper;
|
||||||
|
use App\Models\CorporateFormularium;
|
||||||
|
use App\Models\Formularium;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Modules\Internal\Transformers\CorporateFormulariumResource;
|
||||||
|
|
||||||
|
class CorporateFormulariumController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request, $corporate_id)
|
||||||
|
{
|
||||||
|
$formulariums = Formularium::query()
|
||||||
|
->with(['corporateFormulariums' => function ($query) use ($corporate_id) {
|
||||||
|
$query->where('corporate_id', $corporate_id);
|
||||||
|
}])
|
||||||
|
->withCount('items')
|
||||||
|
->paginate();
|
||||||
|
|
||||||
|
return Helper::paginateResources(CorporateFormulariumResource::collection($formulariums));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateStatus($corporate_id, $formularium_id , $status)
|
||||||
|
{
|
||||||
|
if ($status == 'activate') {
|
||||||
|
$corporateFormularium = CorporateFormularium::firstOrCreate([
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'formularium_id' => $formularium_id
|
||||||
|
], [
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'formularium_id' => $formularium_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'active',
|
||||||
|
'message' => 'Formularium activated'
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$deleteCorporateFormularium = CorporateFormularium::where([
|
||||||
|
'corporate_id' => $corporate_id,
|
||||||
|
'formularium_id' => $formularium_id
|
||||||
|
])->delete();
|
||||||
|
|
||||||
|
return ($deleteCorporateFormularium) ? response()->json([
|
||||||
|
'status' => 'inactive',
|
||||||
|
'message' => 'Formularium deactivated'
|
||||||
|
]) : response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Error deactivating formularium'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
Modules/Internal/Http/Controllers/Api/DrugController.php
Normal file
82
Modules/Internal/Http/Controllers/Api/DrugController.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Drug;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class DrugController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$drugs = Drug::withTrashed()->filter($request->toArray())->paginate();
|
||||||
|
|
||||||
|
return $drugs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
214
Modules/Internal/Http/Controllers/Api/FormulariumController.php
Normal file
214
Modules/Internal/Http/Controllers/Api/FormulariumController.php
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Formularium;
|
||||||
|
use Illuminate\Contracts\Support\Renderable;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class FormulariumController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
* @return Renderable
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$formulariums = Formularium::withTrashed()->withCount('items')->filter($request->toArray())->paginate();
|
||||||
|
|
||||||
|
return $formulariums;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'file' => 'optional|file|mimes:xlsx,xls',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$formularium = Formularium::create($request->all());
|
||||||
|
|
||||||
|
return $formularium;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function import(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'file' => 'required|file|mimes:xls,xlsx,csv,txt',
|
||||||
|
]);
|
||||||
|
// dd($request->toArray());
|
||||||
|
$file_name = now()->getPreciseTimestamp(3).'-'.$request->file('file')->getClientOriginalName();
|
||||||
|
$file = $request->file('file')->storeAs('temp', $file_name);
|
||||||
|
$corporate = Corporate::findOrFail($corporate_id);
|
||||||
|
|
||||||
|
// $importLog = $corporate->importLogs()->create([
|
||||||
|
// 'type' => 'diagnosis-exclusions',
|
||||||
|
// 'file_path' => $file,
|
||||||
|
// 'status' => 'pending',
|
||||||
|
// 'progress' => 0,
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
$import = new ImportService();
|
||||||
|
$import->read(Storage::path('temp/'.$file_name));
|
||||||
|
$import->write(Storage::disk('public')->path('temp/result-'.$file_name), 'xsls');
|
||||||
|
|
||||||
|
foreach ($import->sheetsIterator() as $sheetIndex => $sheet) {
|
||||||
|
$doc_headers_indexes = [];
|
||||||
|
foreach ($sheet->getRowIterator() as $index => $row) {
|
||||||
|
if ($index == 1) { // First Row Must be Header
|
||||||
|
foreach ($row->getCells() as $index => $cell) {
|
||||||
|
$title = $cell->getValue();
|
||||||
|
$title = preg_replace( "/\r|\n/", " ", $title );
|
||||||
|
$title = preg_replace('/\xc2\xa0/', " ", $title );
|
||||||
|
$title = rtrim($title);
|
||||||
|
$title = ltrim($title);
|
||||||
|
$doc_headers_indexes[$index] = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write Header to File
|
||||||
|
$result_headers = array_merge($doc_headers_indexes, ['Ingest Code', 'Ingest Note']);
|
||||||
|
$import->addArrayToRow($result_headers);
|
||||||
|
|
||||||
|
// TODO Validate if First Row not Header
|
||||||
|
} else { // Next Row Should be Data
|
||||||
|
$row_data = [];
|
||||||
|
$row_map = [
|
||||||
|
0 => 'code',
|
||||||
|
1 => 'description',
|
||||||
|
2 => 'ip_exclusion',
|
||||||
|
3 => 'op_exclusion',
|
||||||
|
4 => 'de_exclusion',
|
||||||
|
5 => 'ma_exclusion',
|
||||||
|
6 => 'sp_exclusion',
|
||||||
|
7 => 'pre_exist_exclusion',
|
||||||
|
8 => 'op_de_exclusion',
|
||||||
|
9 => 'keterangan',
|
||||||
|
10 => 'maternity_waiting'
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($row->getCells() as $header_index => $cell) {
|
||||||
|
if (isset($row_map[$header_index])) {
|
||||||
|
$value = $cell->getValue();
|
||||||
|
$value = preg_replace( "/\r|\n/", " ", $value );
|
||||||
|
$value = preg_replace('/\xc2\xa0/', " ", $value );
|
||||||
|
$value = rtrim($value);
|
||||||
|
$value = ltrim($value);
|
||||||
|
$row_data[$row_map[$header_index]] = $cell->getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try { // Process the Row Data
|
||||||
|
if (
|
||||||
|
// empty($row_data['code']) &&
|
||||||
|
// empty($row_data['description']) &&
|
||||||
|
empty($row_data['ip_exclusion']) &&
|
||||||
|
empty($row_data['op_exclusion']) &&
|
||||||
|
empty($row_data['de_exclusion']) &&
|
||||||
|
empty($row_data['ma_exclusion']) &&
|
||||||
|
empty($row_data['sp_exclusion']) &&
|
||||||
|
empty($row_data['pre_exis_exclusion']) &&
|
||||||
|
empty($row_data['op_de_exclusion']) &&
|
||||||
|
empty($row_data['maternity_waiting'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the Row
|
||||||
|
$exclusionService = new ExclusionService();
|
||||||
|
$exclusionService->handleDiagnosisExclusionRow($corporate, $row_data);
|
||||||
|
|
||||||
|
// Write Success Result to File
|
||||||
|
$import->addArrayToRow(array_merge($row_data, [
|
||||||
|
'Ingest Code' => 200,
|
||||||
|
'Ingest Note' => 'Success',
|
||||||
|
]), $sheet->getName());
|
||||||
|
|
||||||
|
} catch (ImportRowException $e) {
|
||||||
|
// Write Data Validation Error to File
|
||||||
|
$import->addArrayToRow(array_merge($row_data, [
|
||||||
|
'Ingest Code' => $e->getCode(),
|
||||||
|
'Ingest Note' => $e->getMessage(),
|
||||||
|
]), $sheet->getName());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new \Exception($e);
|
||||||
|
// Write Server Error to File
|
||||||
|
$import->addArrayToRow(array_merge($row_data, [
|
||||||
|
'Ingest Code' => 500,
|
||||||
|
'Ingest Note' => env('APP_DEBUG') ? $e->getMessage() : 'Server Error',
|
||||||
|
]), $sheet->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break; // Only Read First Row
|
||||||
|
}
|
||||||
|
$import->reader->close();
|
||||||
|
Storage::delete('temp/'.$file_name);
|
||||||
|
$import->writer->close();
|
||||||
|
|
||||||
|
return [
|
||||||
|
// 'total_successed_row' => $imported_plan_data,
|
||||||
|
// 'total_failed_row' => count($failed_plan_data),
|
||||||
|
// 'failed_row' => $failed_plan_data,
|
||||||
|
'result_file' => [
|
||||||
|
'url' => Storage::disk('public')->url('temp/result-'.$file_name),
|
||||||
|
'name' => 'result-'.$file_name,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,11 +5,14 @@ use Illuminate\Http\Request;
|
|||||||
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
||||||
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;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\CorporateFormulariumController;
|
||||||
use Modules\Internal\Http\Controllers\Api\CorporatePlanController;
|
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\DivisionController;
|
use Modules\Internal\Http\Controllers\Api\DivisionController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\DrugController;
|
||||||
|
use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
||||||
use Modules\Internal\Http\Controllers\Api\MemberController;
|
use Modules\Internal\Http\Controllers\Api\MemberController;
|
||||||
use Modules\Internal\Http\Controllers\Api\PlanController;
|
use Modules\Internal\Http\Controllers\Api\PlanController;
|
||||||
|
|
||||||
@@ -72,10 +75,17 @@ Route::prefix('internal')->group(function () {
|
|||||||
Route::get('corporates/{corporate_id}/services', [CorporateServiceController::class, 'index']);
|
Route::get('corporates/{corporate_id}/services', [CorporateServiceController::class, 'index']);
|
||||||
Route::post('corporates/{corporate_id}/services', [CorporateServiceController::class, 'update']);
|
Route::post('corporates/{corporate_id}/services', [CorporateServiceController::class, 'update']);
|
||||||
|
|
||||||
|
Route::get('corporates/{corporate_id}/formulariums', [CorporateFormulariumController::class, 'index']);
|
||||||
|
Route::put('corporates/{corporate_id}/formulariums/{formularium_id}/{action}', [CorporateFormulariumController::class, 'updateStatus']);
|
||||||
|
|
||||||
// Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']);
|
// Route::get('corporates/{corporate_id}/diagnosis-exclusions', [DiagnosisExclusionController::class, 'index']);
|
||||||
// Route::get('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);
|
// Route::get('corporates/{corporate_id}/diagnosis-exclusions/import', [DiagnosisExclusionController::class, 'import']);
|
||||||
|
|
||||||
Route::get('master/diagnosis', [DiagnosisController::class, 'index']);
|
Route::get('master/diagnosis', [DiagnosisController::class, 'index']);
|
||||||
|
Route::get('master/drugs', [DrugController::class, 'index']);
|
||||||
|
Route::get('master/formulariums', [FormulariumController::class, 'index']);
|
||||||
|
Route::post('master/formulariums', [FormulariumController::class, 'store']);
|
||||||
|
Route::post('master/formulariums/import', [FormulariumController::class, 'import']);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
48
Modules/Internal/Services/FormulariumService.php
Normal file
48
Modules/Internal/Services/FormulariumService.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Services;
|
||||||
|
|
||||||
|
use App\Exceptions\ImportRowException;
|
||||||
|
use App\Models\Benefit;
|
||||||
|
use App\Models\Corporate;
|
||||||
|
use App\Models\Drug;
|
||||||
|
use App\Models\Formularium;
|
||||||
|
use App\Models\Plan;
|
||||||
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
|
|
||||||
|
class CorporateService
|
||||||
|
{
|
||||||
|
protected function validateFormulariumRow($row)
|
||||||
|
{
|
||||||
|
if (empty($row['code'])) {
|
||||||
|
throw new ImportRowException(__('formularium.CODE_REQUIRED'), 0, null, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($row['item_code'])) {
|
||||||
|
throw new ImportRowException(__('formularium.TYPE_REQUIRED'), 0, null, $row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleFormulariumRow(Formularium $formularium, $row)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$formularium_item_data = $row;
|
||||||
|
$formularium_item_data["corporate_id"] = $formularium->id;
|
||||||
|
|
||||||
|
$this->validatePlanRow($formularium_item_data);
|
||||||
|
$drug = Drug::where('code', $formularium_item_data['item_code'])->first();
|
||||||
|
|
||||||
|
if (empty($drug)) {
|
||||||
|
throw new ImportRowException(__('formularium.DRUG_CODE_NOT_FOUND'), 0, null, $row);
|
||||||
|
}
|
||||||
|
|
||||||
|
$formulariumItem = $formularium->items()->create([
|
||||||
|
'item_id' => $drug->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $formulariumItem;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Internal\Transformers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class CorporateFormulariumResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($request)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'code' => $this->code,
|
||||||
|
'name' => $this->name,
|
||||||
|
'items_count' => $this->items_count,
|
||||||
|
'status' => $this->corporateFormulariums->count() ? 'active' : 'inactive',
|
||||||
|
'corporate_formulariums' => $this->coporateFormulariums,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Models/Brand.php
Normal file
11
app/Models/Brand.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Brand extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
18
app/Models/Category.php
Normal file
18
app/Models/Category.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Category extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'parent_id',
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
'type',
|
||||||
|
];
|
||||||
|
}
|
||||||
30
app/Models/CorporateFormularium.php
Normal file
30
app/Models/CorporateFormularium.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Traits\Blameable;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class CorporateFormularium extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
|
protected $table = 'corporate_formulariums';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'corporate_id',
|
||||||
|
'formularium_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function corporate()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Corporate::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formularium()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Formularium::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
66
app/Models/Drug.php
Normal file
66
app/Models/Drug.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Traits\Blameable;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Drug extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'generic_name',
|
||||||
|
'code',
|
||||||
|
'description',
|
||||||
|
'brand_id',
|
||||||
|
'mims_class',
|
||||||
|
'indication',
|
||||||
|
'atc_code',
|
||||||
|
'segmentation',
|
||||||
|
'type',
|
||||||
|
'dosage',
|
||||||
|
'remark',
|
||||||
|
'selling_unit_id',
|
||||||
|
'status'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function categories()
|
||||||
|
{
|
||||||
|
return $this->hasMany(DrugCategories::class, 'drug_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function externalIdentifiers()
|
||||||
|
// {
|
||||||
|
// return $this->hasMany(DrugExternalIdentifier::class, 'drug_id');
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function brand()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Brand::class, 'brand_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function identifiers()
|
||||||
|
{
|
||||||
|
return $this->morphMany(Identifier::class, 'identifiable');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function manufacturers()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Organization::class, 'drug_manufacturers', 'drug_id', 'organization_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeFilter($query, Array $filters)
|
||||||
|
{
|
||||||
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
|
return $query
|
||||||
|
->where('code', 'like', "%" . $search . "%")
|
||||||
|
->orWhere('name', 'like', "%" . $search . "%")
|
||||||
|
->orWhere('type', 'like', "%" . $search . "%")
|
||||||
|
;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Models/DrugAtc.php
Normal file
11
app/Models/DrugAtc.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugAtc extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
26
app/Models/DrugCategory.php
Normal file
26
app/Models/DrugCategory.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugCategory extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'drug_id',
|
||||||
|
'category_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function drug()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Drug::class, 'drug_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Category::class, 'category_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Models/DrugComposition.php
Normal file
11
app/Models/DrugComposition.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugComposition extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
17
app/Models/DrugExternalIdentifier.php
Normal file
17
app/Models/DrugExternalIdentifier.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugExternalIdentifier extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'drug_id',
|
||||||
|
'identifier',
|
||||||
|
'identifier_type'
|
||||||
|
];
|
||||||
|
}
|
||||||
11
app/Models/DrugIdentifier.php
Normal file
11
app/Models/DrugIdentifier.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugIdentifier extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/DrugSellingUnit.php
Normal file
11
app/Models/DrugSellingUnit.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugSellingUnit extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
11
app/Models/DrugUnit.php
Normal file
11
app/Models/DrugUnit.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DrugUnit extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
46
app/Models/Formularium.php
Normal file
46
app/Models/Formularium.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Traits\Blameable;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Formularium extends Model
|
||||||
|
{
|
||||||
|
use HasFactory, SoftDeletes, Blameable;
|
||||||
|
|
||||||
|
protected $table = 'formulariums';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function setCodeAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function corporateFormulariums()
|
||||||
|
{
|
||||||
|
return $this->hasMany(CorporateFormularium::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function items()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Drug::class, 'formularium_items', 'formularium_id', 'item_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeFilter($query, Array $filters)
|
||||||
|
{
|
||||||
|
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||||
|
return $query
|
||||||
|
->where('code', 'like', "%" . $search . "%")
|
||||||
|
->orWhere('name', 'like', "%" . $search . "%")
|
||||||
|
;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Models/FormulariumItem.php
Normal file
11
app/Models/FormulariumItem.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FormulariumItem extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
26
app/Models/Identifier.php
Normal file
26
app/Models/Identifier.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Identifier extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'use',
|
||||||
|
'type',
|
||||||
|
'system',
|
||||||
|
'value',
|
||||||
|
'period_start',
|
||||||
|
'period_end',
|
||||||
|
'assigner',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function identifiable()
|
||||||
|
{
|
||||||
|
return $this->morphTo();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Models/Ingredient.php
Normal file
11
app/Models/Ingredient.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Ingredient extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
15
app/Models/Organization.php
Normal file
15
app/Models/Organization.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Organization extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
];
|
||||||
|
}
|
||||||
11
app/Models/Unit.php
Normal file
11
app/Models/Unit.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Unit extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
@@ -59,9 +59,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
|
||||||
$table->index(['policy_id', 'member_id']);
|
$table->index(['policy_id', 'member_id']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
|
||||||
$table->index(['member_id', 'plan_id']);
|
$table->index(['member_id', 'plan_id']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
|
||||||
$table->index(['corporate_id', 'service_code']);
|
$table->index(['corporate_id', 'service_code']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ return new class extends Migration
|
|||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
$table->softDeletes();
|
$table->softDeletes();
|
||||||
|
|
||||||
$table->unsignedBigInteger('created_by')->nullable();
|
$table->foreignId('created_by')->nullable();
|
||||||
$table->unsignedBigInteger('updated_by')->nullable();
|
$table->foreignId('updated_by')->nullable();
|
||||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
$table->foreignId('deleted_by')->nullable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
52
database/migrations/2022_08_09_043235_create_drugs_table.php
Normal file
52
database/migrations/2022_08_09_043235_create_drugs_table.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('drugs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('code')->index();
|
||||||
|
$table->string('name')->index();
|
||||||
|
$table->string('generic_name')->nullable()->index();
|
||||||
|
$table->foreignId('unit_id')->nullable();
|
||||||
|
$table->foreignId('selling_unit_id')->index()->nullable();
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->foreignId('brand_id')->nullable();
|
||||||
|
$table->string('mims_class')->nullable();
|
||||||
|
$table->text('indications')->nullable();
|
||||||
|
$table->string('atc_code')->nullable()->index();
|
||||||
|
$table->string('segmentation')->nullable();
|
||||||
|
$table->string('type')->nullable();
|
||||||
|
$table->string('dosage')->nullable();
|
||||||
|
$table->text('remark')->nullable();
|
||||||
|
$table->string('status')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('drugs');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('brands', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('brands');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('parent_id')->index()->nullable();
|
||||||
|
$table->string('code')->index()->nullable();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('type')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('categories');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('drug_categories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('drug_id');
|
||||||
|
$table->foreignId('category_id');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('drug_categories');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('organizations', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('type')->nullable();
|
||||||
|
$table->string('status')->nullable()->default('active');
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->foreignId('part_of')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('organizations');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('drug_compositions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('drug_id');
|
||||||
|
$table->foreignId('ingredient_id');
|
||||||
|
$table->boolean('active')->default(true);
|
||||||
|
$table->string('strength')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('drug_compositions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('drug_atcs', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('code')->index();
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('drug_atcs');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('identifiers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->morphs('identifiable');
|
||||||
|
$table->string('use')->nullable();
|
||||||
|
$table->string('type')->nullable();
|
||||||
|
$table->string('system')->nullable();
|
||||||
|
$table->string('value')->nullable();
|
||||||
|
$table->date('period_start')->nullable();
|
||||||
|
$table->date('period_end')->nullable();
|
||||||
|
$table->string('assigner')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('identifiers');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('ingredients', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
// $table->foreignId('drug_id');
|
||||||
|
$table->text('substance');
|
||||||
|
$table->string('snomed_code')->index()->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ingredients');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('drug_manufacturers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('drug_id');
|
||||||
|
$table->foreignId('organization_id');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('drug_manufacturers');
|
||||||
|
}
|
||||||
|
};
|
||||||
39
database/migrations/2022_08_12_025718_create_units_table.php
Normal file
39
database/migrations/2022_08_12_025718_create_units_table.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('units', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name')->index();
|
||||||
|
$table->string('metrics')->index()->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('units');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('formulariums', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('code')->index();
|
||||||
|
$table->string('name')->index();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('formulariums');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('formularium_items', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('formularium_id');
|
||||||
|
$table->foreignId('item_id');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('formularium_items');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('corporate_formulariums', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('corporate_id');
|
||||||
|
$table->foreignId('formularium_id');
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->foreignId('created_by')->nullable();
|
||||||
|
$table->foreignId('updated_by')->nullable();
|
||||||
|
$table->foreignId('deleted_by')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('corporate_formulariums');
|
||||||
|
}
|
||||||
|
};
|
||||||
181
database/seeders/DrugSeeder.php
Normal file
181
database/seeders/DrugSeeder.php
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\Brand;
|
||||||
|
use App\Models\Category;
|
||||||
|
use App\Models\Drug;
|
||||||
|
use App\Models\DrugCategories;
|
||||||
|
use App\Models\DrugCategory;
|
||||||
|
use App\Models\DrugComposition;
|
||||||
|
use App\Models\DrugUnit;
|
||||||
|
use App\Models\Ingredient;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\Unit;
|
||||||
|
use Box\Spout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DrugSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
$file_path = resource_path('files/daftar_masteritem_ccp_14-06-2022.xlsx');
|
||||||
|
$reader = ReaderEntityFactory::createReaderFromFile($file_path);
|
||||||
|
$reader->open($file_path);
|
||||||
|
|
||||||
|
$chunks = [];
|
||||||
|
$time = now();
|
||||||
|
$isData = false;
|
||||||
|
$cell_map = [ // Urutan kolom di excel
|
||||||
|
'no',
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
'group',
|
||||||
|
'kategori',
|
||||||
|
'satuan',
|
||||||
|
'nama_cetak',
|
||||||
|
'golongan',
|
||||||
|
'sub_golongan',
|
||||||
|
'komposisi',
|
||||||
|
'sediaan',
|
||||||
|
'brand',
|
||||||
|
'strength',
|
||||||
|
'satuan_strength',
|
||||||
|
'pabrikan',
|
||||||
|
'jenis',
|
||||||
|
'otc',
|
||||||
|
'resep',
|
||||||
|
'obat_terlarang',
|
||||||
|
'pemakaian',
|
||||||
|
'essential',
|
||||||
|
'live_saving'
|
||||||
|
];
|
||||||
|
foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
|
foreach ($sheet->getRowIterator() as $index => $row) {
|
||||||
|
if ($index >= 6) {
|
||||||
|
$row_data = [];
|
||||||
|
foreach ($row->getCells() as $cell_index => $cell) {
|
||||||
|
$row_data[$cell_map[$cell_index]] = $cell->getValue();
|
||||||
|
}
|
||||||
|
$brand = !empty($row_data['golongan']) ? Brand::firstOrCreate([
|
||||||
|
'name' => $row_data['brand']
|
||||||
|
], [
|
||||||
|
'name' => $row_data['brand']
|
||||||
|
]) : null;
|
||||||
|
|
||||||
|
$manufacturer = Organization::firstOrCreate([
|
||||||
|
'name' => $row_data['pabrikan']
|
||||||
|
], [
|
||||||
|
'name' => $row_data['pabrikan'],
|
||||||
|
'type' => 'manufacturer'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (in_array($row_data['golongan'], ['VITAMINS & MINERALS', 'NUTRITIONS'])) {
|
||||||
|
$type = 'vitamin';
|
||||||
|
} else {
|
||||||
|
$type = 'drug';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($row_data['komposisi'])) {
|
||||||
|
$ingredient = Ingredient::firstOrCreate([
|
||||||
|
'substance' => $row_data['komposisi']
|
||||||
|
], [
|
||||||
|
'substance' => $row_data['komposisi']
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$ingredient = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($row_data['sediaan'])) {
|
||||||
|
$sediaan = Unit::firstOrCreate([
|
||||||
|
'name' => $row_data['sediaan']
|
||||||
|
], [
|
||||||
|
'name' => $row_data['sediaan']
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$sediaan = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$golongan = !empty($row_data['golongan']) ? Category::firstOrCreate([
|
||||||
|
'name' => $row_data['golongan']
|
||||||
|
], [
|
||||||
|
'name' => $row_data['golongan']
|
||||||
|
]) : null;
|
||||||
|
|
||||||
|
$sub_golongan = !empty($row_data['sub_golongan']) ? Category::firstOrCreate([
|
||||||
|
'name' => $row_data['sub_golongan']
|
||||||
|
], [
|
||||||
|
'name' => $row_data['sub_golongan']
|
||||||
|
]) : null;
|
||||||
|
|
||||||
|
$new_drug_data = [
|
||||||
|
'name' => $row_data['name'],
|
||||||
|
'generic_name' => $row_data['nama_cetak'],
|
||||||
|
'code' => $row_data['code'],
|
||||||
|
'description' => null,
|
||||||
|
'brand_id' => $brand->id ?? null,
|
||||||
|
// 'manufacturer_id' => $manufacturer->id ?? null,
|
||||||
|
'mims_class' => null,
|
||||||
|
'indications' => null,
|
||||||
|
'atc_code' => null,
|
||||||
|
'segmentation' => null,
|
||||||
|
'type' => $type,
|
||||||
|
'dosage' => '',
|
||||||
|
'remark' => '',
|
||||||
|
'selling_unit_id' => $sediaan->id ?? null,
|
||||||
|
'status' => 'active',
|
||||||
|
'unit_id' => $sediaan->id ?? null,
|
||||||
|
];
|
||||||
|
$drug = Drug::create($new_drug_data);
|
||||||
|
$drug->identifiers()->create([
|
||||||
|
'use' => 'usual',
|
||||||
|
'type' => 'CCP',
|
||||||
|
'value' => $row_data['code'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($ingredient) {
|
||||||
|
DrugComposition::create([
|
||||||
|
'drug_id' => $drug->id,
|
||||||
|
'ingredient_id' => $ingredient->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($golongan) {
|
||||||
|
DrugCategory::create([
|
||||||
|
'drug_id' => $drug->id,
|
||||||
|
'category_id' => $golongan->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sub_golongan) {
|
||||||
|
DrugCategory::create([
|
||||||
|
'drug_id' => $drug->id,
|
||||||
|
'category_id' => $sub_golongan->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manufacturer) {
|
||||||
|
$drug->manufacturers()->attach($manufacturer->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $chunks[] = $row_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ($chunks && count($chunks) == 1000) {
|
||||||
|
// Icd::insert($chunks);
|
||||||
|
// $chunks = [];
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if ($chunks && count($chunks) > 0) {
|
||||||
|
// Icd::insert($chunks);
|
||||||
|
// $chunks = [];
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint --ext .ts,.tsx ./src",
|
"lint": "eslint --ext .ts,.tsx ./src",
|
||||||
"lint:fix": "eslint --fix --ext .ts,.tsx ./src",
|
"lint:fix": "eslint --fix --ext .ts,.tsx ./src",
|
||||||
"start": "vite",
|
"start": "vite --port=3000",
|
||||||
"build": "vite build --mode production && cp .htaccess build/.htaccess && rm -f -r ../../public/dashboard && cp -r build ../../public/dashboard",
|
"build": "vite build --mode production && cp .htaccess build/.htaccess && rm -f -r ../../public/dashboard && cp -r build ../../public/dashboard",
|
||||||
"serve": "vite preview",
|
"serve": "vite preview",
|
||||||
"clear-all": "rm -rf build node_modules",
|
"clear-all": "rm -rf build node_modules",
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
"simplebar-react": "^2.4.1",
|
"simplebar-react": "^2.4.1",
|
||||||
"stylis": "^4.1.1",
|
"stylis": "^4.1.1",
|
||||||
"stylis-plugin-rtl": "^2.1.1",
|
"stylis-plugin-rtl": "^2.1.1",
|
||||||
"vite": "^2.9.14",
|
"vite": "^3.0.4",
|
||||||
"vite-plugin-svgr": "^2.2.1",
|
"vite-plugin-svgr": "^2.2.1",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
},
|
},
|
||||||
|
|||||||
25
frontend/dashboard/pnpm-lock.yaml
generated
25
frontend/dashboard/pnpm-lock.yaml
generated
@@ -66,7 +66,7 @@ specifiers:
|
|||||||
stylis: ^4.1.1
|
stylis: ^4.1.1
|
||||||
stylis-plugin-rtl: ^2.1.1
|
stylis-plugin-rtl: ^2.1.1
|
||||||
typescript: ^4.7.4
|
typescript: ^4.7.4
|
||||||
vite: ^2.9.14
|
vite: ^3.0.4
|
||||||
vite-plugin-pwa: ^0.12.3
|
vite-plugin-pwa: ^0.12.3
|
||||||
vite-plugin-svgr: ^2.2.1
|
vite-plugin-svgr: ^2.2.1
|
||||||
yup: ^0.32.11
|
yup: ^0.32.11
|
||||||
@@ -111,8 +111,8 @@ dependencies:
|
|||||||
simplebar-react: 2.4.1_sfoxds7t5ydpegc3knd667wn6m
|
simplebar-react: 2.4.1_sfoxds7t5ydpegc3knd667wn6m
|
||||||
stylis: 4.1.1
|
stylis: 4.1.1
|
||||||
stylis-plugin-rtl: 2.1.1_stylis@4.1.1
|
stylis-plugin-rtl: 2.1.1_stylis@4.1.1
|
||||||
vite: 2.9.14
|
vite: 3.0.4
|
||||||
vite-plugin-svgr: 2.2.1_vite@2.9.14
|
vite-plugin-svgr: 2.2.1_vite@3.0.4
|
||||||
yup: 0.32.11
|
yup: 0.32.11
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
@@ -142,7 +142,7 @@ devDependencies:
|
|||||||
eslint-plugin-react-hooks: 4.3.0_eslint@8.20.0
|
eslint-plugin-react-hooks: 4.3.0_eslint@8.20.0
|
||||||
prettier: 2.7.1
|
prettier: 2.7.1
|
||||||
typescript: 4.7.4
|
typescript: 4.7.4
|
||||||
vite-plugin-pwa: 0.12.3_vite@2.9.14
|
vite-plugin-pwa: 0.12.3_vite@3.0.4
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -5626,7 +5626,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==}
|
resolution: {integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vite-plugin-pwa/0.12.3_vite@2.9.14:
|
/vite-plugin-pwa/0.12.3_vite@3.0.4:
|
||||||
resolution: {integrity: sha512-gmYdIVXpmBuNjzbJFPZFzxWYrX4lHqwMAlOtjmXBbxApiHjx9QPXKQPJjSpeTeosLKvVbNcKSAAhfxMda0QVNQ==}
|
resolution: {integrity: sha512-gmYdIVXpmBuNjzbJFPZFzxWYrX4lHqwMAlOtjmXBbxApiHjx9QPXKQPJjSpeTeosLKvVbNcKSAAhfxMda0QVNQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vite: ^2.0.0 || ^3.0.0-0
|
vite: ^2.0.0 || ^3.0.0-0
|
||||||
@@ -5635,7 +5635,7 @@ packages:
|
|||||||
fast-glob: 3.2.11
|
fast-glob: 3.2.11
|
||||||
pretty-bytes: 6.0.0
|
pretty-bytes: 6.0.0
|
||||||
rollup: 2.77.0
|
rollup: 2.77.0
|
||||||
vite: 2.9.14
|
vite: 3.0.4
|
||||||
workbox-build: 6.5.3
|
workbox-build: 6.5.3
|
||||||
workbox-window: 6.5.3
|
workbox-window: 6.5.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -5643,26 +5643,27 @@ packages:
|
|||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vite-plugin-svgr/2.2.1_vite@2.9.14:
|
/vite-plugin-svgr/2.2.1_vite@3.0.4:
|
||||||
resolution: {integrity: sha512-+EqwahbwjETJH/ssA/66dNYyKN1cO0AStq96MuXmq5maU7AePBMf2lDKfQna49tJZAjtRz+R899BWCsUUP45Fg==}
|
resolution: {integrity: sha512-+EqwahbwjETJH/ssA/66dNYyKN1cO0AStq96MuXmq5maU7AePBMf2lDKfQna49tJZAjtRz+R899BWCsUUP45Fg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vite: ^2.6.0 || 3
|
vite: ^2.6.0 || 3
|
||||||
dependencies:
|
dependencies:
|
||||||
'@rollup/pluginutils': 4.2.1
|
'@rollup/pluginutils': 4.2.1
|
||||||
'@svgr/core': 6.3.1
|
'@svgr/core': 6.3.1
|
||||||
vite: 2.9.14
|
vite: 3.0.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vite/2.9.14:
|
/vite/3.0.4:
|
||||||
resolution: {integrity: sha512-P/UCjSpSMcE54r4mPak55hWAZPlyfS369svib/gpmz8/01L822lMPOJ/RYW6tLCe1RPvMvOsJ17erf55bKp4Hw==}
|
resolution: {integrity: sha512-NU304nqnBeOx2MkQnskBQxVsa0pRAH5FphokTGmyy8M3oxbvw7qAXts2GORxs+h/2vKsD+osMhZ7An6yK6F1dA==}
|
||||||
engines: {node: '>=12.2.0'}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
less: '*'
|
less: '*'
|
||||||
sass: '*'
|
sass: '*'
|
||||||
stylus: '*'
|
stylus: '*'
|
||||||
|
terser: ^5.4.0
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
less:
|
less:
|
||||||
optional: true
|
optional: true
|
||||||
@@ -5670,6 +5671,8 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
stylus:
|
stylus:
|
||||||
optional: true
|
optional: true
|
||||||
|
terser:
|
||||||
|
optional: true
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild: 0.14.49
|
esbuild: 0.14.49
|
||||||
postcss: 8.4.14
|
postcss: 8.4.14
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ const navConfig = [
|
|||||||
children: [
|
children: [
|
||||||
{ title: 'Corporate', path: '/corporates' },
|
{ title: 'Corporate', path: '/corporates' },
|
||||||
{ title: 'Corporate Create', path: '/corporates/create' },
|
{ title: 'Corporate Create', path: '/corporates/create' },
|
||||||
{ title: 'Formularium', path: '/formularium' },
|
{ title: 'Formularium', path: '/master/formularium' },
|
||||||
{ title: 'Diagnosis Library (ICD-X)', path: '/masterdiagnosis' },
|
{ title: 'Obat', path: '/master/drugs' },
|
||||||
|
{ title: 'Diagnosis Library (ICD-X)', path: '/master/diagnosis' },
|
||||||
{ title: 'Hospitals', path: '/hospitals' },
|
{ title: 'Hospitals', path: '/hospitals' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
|
|||||||
|
|
||||||
<Grid item xs={12} md={4}>
|
<Grid item xs={12} md={4}>
|
||||||
<LoadingButton type="submit" variant="contained" size="large" fullWidth={true} loading={isSubmitting}>
|
<LoadingButton type="submit" variant="contained" size="large" fullWidth={true} loading={isSubmitting}>
|
||||||
{!isEdit ? 'Create Product' : 'Save Changes'}
|
{!isEdit ? 'Save New Corporate' : 'Save Corporate'}
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { Card, Grid } from "@mui/material";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
|
||||||
|
import Page from "../../../components/Page";
|
||||||
|
import useSettings from "../../../hooks/useSettings";
|
||||||
|
import CorporateTabNavigations from "../CorporateTabNavigations";
|
||||||
|
import List from "./List";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function CorporateFormularium() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Page title="Division">
|
||||||
|
|
||||||
|
<HeaderBreadcrumbs
|
||||||
|
heading={'Division'}
|
||||||
|
links={[
|
||||||
|
{
|
||||||
|
name: 'Corporates',
|
||||||
|
href: '/corporates',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Corporate Name',
|
||||||
|
href: '/corporates/'+corporate_id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Division',
|
||||||
|
href: '/corporates/'+corporate_id+'/divisions',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CorporateTabNavigations position={'services'} />
|
||||||
|
<List />
|
||||||
|
</Card>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
237
frontend/dashboard/src/pages/Corporates/Formularium/List.tsx
Normal file
237
frontend/dashboard/src/pages/Corporates/Formularium/List.tsx
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
// @mui
|
||||||
|
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup } from '@mui/material';
|
||||||
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||||
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||||
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
import UploadIcon from '@mui/icons-material/Upload';
|
||||||
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
|
// hooks
|
||||||
|
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||||
|
import useSettings from '../../../hooks/useSettings';
|
||||||
|
import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
||||||
|
// components
|
||||||
|
import axios from '../../../utils/axios';
|
||||||
|
import { CorporatePlan } from '../../../@types/corporates';
|
||||||
|
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||||
|
import BasePagination from '../../../components/BasePagination';
|
||||||
|
import { enqueueSnackbar } from 'notistack';
|
||||||
|
|
||||||
|
|
||||||
|
export default function PlanList() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
// Dummy Default Data
|
||||||
|
const [dataTableIsLoading, setDataTableLoading] = useState(true);
|
||||||
|
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>({
|
||||||
|
current_page: 1,
|
||||||
|
data: [],
|
||||||
|
path: "",
|
||||||
|
first_page_url: "",
|
||||||
|
last_page: 1,
|
||||||
|
last_page_url: "",
|
||||||
|
next_page_url: "",
|
||||||
|
prev_page_url: "",
|
||||||
|
per_page: 10,
|
||||||
|
from: 0,
|
||||||
|
to: 0,
|
||||||
|
total: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function SearchInput(props: any) {
|
||||||
|
// SEARCH
|
||||||
|
const searchInput = useRef<HTMLInputElement>(null);
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
|
const handleSearchChange = (event: any) => {
|
||||||
|
const newSearchText = event.target.value ?? ''
|
||||||
|
setSearchText(newSearchText);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = (event: any) => {
|
||||||
|
event.preventDefault();
|
||||||
|
props.onSearch(searchText); // Trigger to Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// console.log('Search Input: useEffect')
|
||||||
|
setSearchText(searchParams.get('search') ?? '');
|
||||||
|
}, [searchParams])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form onSubmit={handleSubmit} style={{ width: '100%' }}>
|
||||||
|
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called on every row to map the data to the columns
|
||||||
|
function createData( plan: CorporatePlan ): CorporatePlan {
|
||||||
|
return {
|
||||||
|
...plan,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleInactiveAction = (formularium : any) => {
|
||||||
|
axios
|
||||||
|
.put('/corporates/'+corporate_id+'/formulariums/'+formularium.id+'/activate')
|
||||||
|
.then(() => {
|
||||||
|
setDataTableData(
|
||||||
|
{
|
||||||
|
...dataTableData,
|
||||||
|
data: dataTableData.data.map((item: any) => {
|
||||||
|
if (item.id === formularium.id) {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
status: 'active'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleActiveAction = (formularium : any) => {
|
||||||
|
axios
|
||||||
|
.put('/corporates/'+corporate_id+'/formulariums/'+formularium.id+'/deactivate')
|
||||||
|
.then(() => {
|
||||||
|
setDataTableData(
|
||||||
|
{
|
||||||
|
...dataTableData,
|
||||||
|
data: dataTableData.data.map((item: any) => {
|
||||||
|
if (item.id === formularium.id) {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
status: 'inactive'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the every row of the table
|
||||||
|
function Row(props: { row: ReturnType<typeof createData> }) {
|
||||||
|
const { row } = props;
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
|
||||||
|
<TableCell align="left">{row.id}</TableCell>
|
||||||
|
<TableCell align="left">{row.code}</TableCell>
|
||||||
|
<TableCell align="left">{row.name}</TableCell>
|
||||||
|
<TableCell align="left">{row.items_count}</TableCell>
|
||||||
|
<TableCell align="right">{( row.status == 'active' ?
|
||||||
|
<Button variant="outlined" onClick={() => { handleActiveAction(row) }} color="success" size="small">Active</Button> :
|
||||||
|
<Button variant="outlined" onClick={() => { handleInactiveAction(row) }} color="error" size="small">Tidak Digunakan</Button>
|
||||||
|
)}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
{/* COLLAPSIBLE ROW */}
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={10}>
|
||||||
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
||||||
|
<Box sx={{ borderBottom: 1 }}>
|
||||||
|
<Typography variant="body2" gutterBottom component="div">
|
||||||
|
No Extra Data
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Collapse>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadDataTableData = async (appliedFilter : any | null = null) => {
|
||||||
|
setDataTableLoading(true);
|
||||||
|
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||||
|
const response = await axios.get('/corporates/'+corporate_id+'/formulariums', { params: filter });
|
||||||
|
// console.log(response.data);
|
||||||
|
setDataTableLoading(false);
|
||||||
|
|
||||||
|
setDataTableData(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headStyle = {
|
||||||
|
fontWeight: 'bold',
|
||||||
|
};
|
||||||
|
|
||||||
|
const applyFilter = async (searchFilter: any) => {
|
||||||
|
await loadDataTableData({ "search" : searchFilter });
|
||||||
|
setSearchParams({ "search" : searchFilter });
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||||
|
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||||
|
loadDataTableData(filter);
|
||||||
|
setSearchParams(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadDataTableData();
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||||
|
<SearchInput onSearch={applyFilter}/>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
{/* The Main Table */}
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table aria-label="collapsible table">
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={headStyle} align="left" width={50}>#</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Code</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Name</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Total Item</TableCell>
|
||||||
|
<TableCell style={headStyle} align="right">Status</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
{dataTableIsLoading ?
|
||||||
|
(
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">Loading</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
dataTableData.data.length == 0 ?
|
||||||
|
(
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">No Data</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
<TableBody>
|
||||||
|
{dataTableData.data.map(row => (
|
||||||
|
<Row key={row.code} row={row} />
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||||
|
</Card>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
241
frontend/dashboard/src/pages/Master/Drug/Create.tsx
Normal file
241
frontend/dashboard/src/pages/Master/Drug/Create.tsx
Normal file
@@ -0,0 +1,241 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
|
import { Card, Collapse, Divider, Grid, Stack, Typography } from "@mui/material";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
|
||||||
|
import { FormProvider, RHFCheckbox, RHFSelect, RHFTextField } from "../../../components/hook-form";
|
||||||
|
import Page from "../../../components/Page";
|
||||||
|
import useSettings from "../../../hooks/useSettings";
|
||||||
|
import CorporateTabNavigations from "../CorporateTabNavigations";
|
||||||
|
import DivisionsList from "./List";
|
||||||
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function Divisions() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
|
||||||
|
const NewDivisionSchema = Yup.object().shape({
|
||||||
|
name: Yup.string().required('Name is required'),
|
||||||
|
code: Yup.string().required('Corporate Code is required'),
|
||||||
|
active: Yup.boolean().required('Corporate Status is required'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const defaultValues = useMemo(
|
||||||
|
() => ({
|
||||||
|
code: '',
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const methods = useForm({
|
||||||
|
resolver: yupResolver(NewDivisionSchema),
|
||||||
|
defaultValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
reset,
|
||||||
|
watch,
|
||||||
|
control,
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
setError,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { isSubmitting },
|
||||||
|
} = methods;
|
||||||
|
|
||||||
|
const onSubmit = async (data: any) => {
|
||||||
|
console.log(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const benefits = [
|
||||||
|
{
|
||||||
|
'category' : 'General Practitioner',
|
||||||
|
'childs' : [
|
||||||
|
{
|
||||||
|
'name' : 'External Doctor Online',
|
||||||
|
'code' : 'gp-external-doctor-online'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'External Doctor Offline',
|
||||||
|
'code' : 'gp-external-doctor-offline'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Internal Doctor Online',
|
||||||
|
'code' : 'gp-internal-doctor-online'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Internal Doctor Offline',
|
||||||
|
'code' : 'gp-internal-doctor-offline'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'category' : 'Specialist',
|
||||||
|
'childs' : [
|
||||||
|
{
|
||||||
|
'name' : 'External Doctor Online',
|
||||||
|
'code' : 'sp-external-doctor-online'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'External Doctor Offline',
|
||||||
|
'code' : 'sp-external-doctor-offline'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Internal Doctor Online',
|
||||||
|
'code' : 'sp-internal-doctor-online'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Internal Doctor Offline',
|
||||||
|
'code' : 'sp-internal-doctor-offline'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'category' : 'Medicines',
|
||||||
|
'childs' : [
|
||||||
|
{
|
||||||
|
'name' : 'Vitamins',
|
||||||
|
'code' : 'medicines-vitamins'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Delivery Fee',
|
||||||
|
'code' : 'medicines-delivery-fee'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const products = [
|
||||||
|
{
|
||||||
|
'name' : 'Inpatient',
|
||||||
|
'code' : 'IP',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Outpatient',
|
||||||
|
'code' : 'OP',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Dental',
|
||||||
|
'code' : 'DT',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Dental',
|
||||||
|
'code' : 'DTL',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Matternity',
|
||||||
|
'code' : 'MT',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name' : 'Special Benefit',
|
||||||
|
'code' : 'SB',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Page title="Create Benefit">
|
||||||
|
|
||||||
|
<HeaderBreadcrumbs
|
||||||
|
heading={'Create Benefit'}
|
||||||
|
links={[
|
||||||
|
{ name: 'Dashboard', href: '/dashboard' },
|
||||||
|
{
|
||||||
|
name: 'Corporates',
|
||||||
|
href: '/corporates',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Corporate Name',
|
||||||
|
href: '/corporates/'+id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Benefits',
|
||||||
|
href: '/corporates/'+id+'/benefits',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Create',
|
||||||
|
href: '/corporates/'+id+'/benefits/create',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<Grid container spacing={2}>
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Card sx={{ p: 2 }}>
|
||||||
|
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<Stack spacing={3}>
|
||||||
|
|
||||||
|
<Typography variant="h6">Benefit Detail</Typography>
|
||||||
|
|
||||||
|
<RHFTextField name="name" label="Benefit Name" />
|
||||||
|
|
||||||
|
<RHFTextField name="code" label="Benefit Code" />
|
||||||
|
|
||||||
|
<Typography variant="h6">Benefit Configuration</Typography>
|
||||||
|
|
||||||
|
<Divider orientation="horizontal" flexItem />
|
||||||
|
<Stack spacing={3} divider={<Divider orientation="horizontal" flexItem />}>
|
||||||
|
<Stack spacing={2}>
|
||||||
|
<RHFCheckbox name="a" label='Outpatient'/>
|
||||||
|
{benefits.map(row => (
|
||||||
|
<Collapse in={true} timeout="auto" unmountOnExit >
|
||||||
|
<Typography>{row.category}</Typography>
|
||||||
|
<Grid container>
|
||||||
|
{row.childs.map(benefit => (
|
||||||
|
<Grid item xs={6}>
|
||||||
|
<RHFCheckbox name={benefit.code} label={benefit.name}/>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</Collapse>
|
||||||
|
))}
|
||||||
|
<Typography>Admin Fee</Typography>
|
||||||
|
<Grid container>
|
||||||
|
{benefits.map(row => (
|
||||||
|
<Grid item xs={4}>
|
||||||
|
<RHFCheckbox name="cat" label={row.category}/>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
|
||||||
|
<Stack spacing={2}>
|
||||||
|
<RHFCheckbox name="a" label='Inpatient'/>
|
||||||
|
{benefits.map(row => (
|
||||||
|
<Collapse in={true} timeout="auto" unmountOnExit >
|
||||||
|
<Typography>{row.category}</Typography>
|
||||||
|
<Grid container>
|
||||||
|
{row.childs.map(benefit => (
|
||||||
|
<Grid item xs={6}>
|
||||||
|
<RHFCheckbox name={benefit.code} label={benefit.name}/>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</Collapse>
|
||||||
|
))}
|
||||||
|
<Typography>Admin Fee</Typography>
|
||||||
|
<Grid container>
|
||||||
|
{benefits.map(row => (
|
||||||
|
<Grid item xs={4}>
|
||||||
|
<RHFCheckbox name="cat" label={row.category}/>
|
||||||
|
</Grid>
|
||||||
|
))}
|
||||||
|
</Grid>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
</Stack>
|
||||||
|
</FormProvider>
|
||||||
|
</Card>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
38
frontend/dashboard/src/pages/Master/Drug/Index.tsx
Normal file
38
frontend/dashboard/src/pages/Master/Drug/Index.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Card, Grid } from "@mui/material";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
|
||||||
|
import Page from "../../../components/Page";
|
||||||
|
import useSettings from "../../../hooks/useSettings";
|
||||||
|
import List from "./List";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function Drugs() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
|
||||||
|
const pageTitle = 'Drug';
|
||||||
|
return (
|
||||||
|
<Page title={ pageTitle }>
|
||||||
|
|
||||||
|
<HeaderBreadcrumbs
|
||||||
|
heading={ pageTitle }
|
||||||
|
links={[
|
||||||
|
{
|
||||||
|
name: 'Master',
|
||||||
|
href: '/master',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Drug',
|
||||||
|
href: '/master/drugs',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<List />
|
||||||
|
</Card>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
310
frontend/dashboard/src/pages/Master/Drug/List.tsx
Normal file
310
frontend/dashboard/src/pages/Master/Drug/List.tsx
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
// @mui
|
||||||
|
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup, Pagination } from '@mui/material';
|
||||||
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||||
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||||
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
import UploadIcon from '@mui/icons-material/Upload';
|
||||||
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
|
// hooks
|
||||||
|
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||||
|
import useSettings from '../../../hooks/useSettings';
|
||||||
|
import { useParams, useSearchParams } from 'react-router-dom';
|
||||||
|
// components
|
||||||
|
import axios from '../../../utils/axios';
|
||||||
|
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||||
|
import { Icd } from '../../../@types/diagnosis';
|
||||||
|
import BasePagination from '../../../components/BasePagination';
|
||||||
|
|
||||||
|
export default function List() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const [importResult, setImportResult] = useState(null);
|
||||||
|
|
||||||
|
function SearchInput(props: any) {
|
||||||
|
// SEARCH
|
||||||
|
const searchInput = useRef<HTMLInputElement>(null);
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
|
const handleSearchChange = (event: any) => {
|
||||||
|
const newSearchText = event.target.value ?? ''
|
||||||
|
setSearchText(newSearchText);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSearchSubmit = (event: any) => {
|
||||||
|
event.preventDefault();
|
||||||
|
props.onSearch(searchText); // Trigger to Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => { // Trigger First Search
|
||||||
|
setSearchText(searchParams.get('search') ?? '');
|
||||||
|
}, [searchParams])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}>
|
||||||
|
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ImportForm(props: any) {
|
||||||
|
// IMPORT
|
||||||
|
// Create Button Menu
|
||||||
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||||
|
const createMenu = Boolean(anchorEl);
|
||||||
|
const importForm = useRef<HTMLInputElement>(null)
|
||||||
|
const [currentImportFileName, setCurrentImportFileName] = useState(null)
|
||||||
|
|
||||||
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
|
setAnchorEl(event.currentTarget);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleImportButton = () => {
|
||||||
|
if (importForm?.current) {
|
||||||
|
handleClose();
|
||||||
|
importForm.current ? importForm.current.click() : console.log('No File selected');
|
||||||
|
} else {
|
||||||
|
alert('No file selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCancelImportButton = () => {
|
||||||
|
importForm.current.value = "";
|
||||||
|
importForm.current.dispatchEvent(new Event("change", { bubbles: true }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleImportChange = (event: any) => {
|
||||||
|
if (event.target.files[0]) {
|
||||||
|
setCurrentImportFileName(event.target.files[0].name)
|
||||||
|
} else {
|
||||||
|
setCurrentImportFileName(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUpload = () => {
|
||||||
|
if (importForm.current?.files.length) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("file", importForm.current?.files[0])
|
||||||
|
axios.post(`corporates/${corporate_id}/import-plan-benefit`, formData )
|
||||||
|
.then(response => {
|
||||||
|
handleCancelImportButton();
|
||||||
|
loadDataTableData();
|
||||||
|
setImportResult(response.data)
|
||||||
|
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
||||||
|
})
|
||||||
|
.catch(response => {
|
||||||
|
alert('Looks like something went wrong. Please check your data and try again. ' + response.message)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
alert('No File Selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<input type='file' id='file' ref={importForm} style={{ display: 'none' }} onChange={handleImportChange} accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain" />
|
||||||
|
{( !currentImportFileName && <Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||||
|
<SearchInput onSearch={applyFilter}/>
|
||||||
|
{/* <h1>kjasndkjandskjasndkjansdkjansd</h1> */}
|
||||||
|
<Button
|
||||||
|
id="import-button"
|
||||||
|
variant='outlined'
|
||||||
|
startIcon={<AddIcon />} sx={{ p: 1.8 }}
|
||||||
|
aria-controls={createMenu ? 'basic-menu' : undefined}
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded={createMenu ? 'true' : undefined}
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
|
Import
|
||||||
|
</Button>
|
||||||
|
<Menu
|
||||||
|
id="import-button"
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={createMenu}
|
||||||
|
onClose={handleClose}
|
||||||
|
MenuListProps={{
|
||||||
|
'aria-labelledby': 'basic-button',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem onClick={handleImportButton}>Import</MenuItem>
|
||||||
|
<MenuItem onClick={handleClose}>Download Template</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{( currentImportFileName && <Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||||
|
<ButtonGroup variant="outlined" aria-label="outlined button group" fullWidth>
|
||||||
|
<Button onClick={handleImportButton} fullWidth>{currentImportFileName ?? "No File Selected"}</Button>
|
||||||
|
<Button onClick={handleCancelImportButton} size="small" fullWidth={false} sx={{ p: 1.8 }}><CancelIcon color="error"/></Button>
|
||||||
|
</ButtonGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
id="upload-button"
|
||||||
|
variant='outlined'
|
||||||
|
startIcon={<UploadIcon />} sx={{ p: 1.8 }}
|
||||||
|
onClick={handleUpload}
|
||||||
|
>
|
||||||
|
Upload
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
{( importResult &&
|
||||||
|
<Stack direction={'row'} sx={{ px: 2, pb: 2 }}>
|
||||||
|
<Box sx={{ color: "text.secondary" }}>Last Import Result Report : <a href={importResult.result_file?.url ?? "#"}>{importResult.result_file?.name ?? "-"}</a></Box>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called on every row to map the data to the columns
|
||||||
|
function createData( icd: Icd ): Icd {
|
||||||
|
return {
|
||||||
|
...icd,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the every row of the table
|
||||||
|
function Row(props: { row: ReturnType<typeof createData> }) {
|
||||||
|
const { row } = props;
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
|
||||||
|
<TableCell>
|
||||||
|
<IconButton
|
||||||
|
aria-label="expand row"
|
||||||
|
size="small"
|
||||||
|
onClick={() => setOpen(!open)}
|
||||||
|
>
|
||||||
|
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
||||||
|
</IconButton>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="left">{row.type}</TableCell>
|
||||||
|
<TableCell align="left">{row.code}</TableCell>
|
||||||
|
<TableCell align="left">{row.name}</TableCell>
|
||||||
|
<TableCell align="left">{row.version}</TableCell>
|
||||||
|
|
||||||
|
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
|
||||||
|
<TableCell align="right"><Button variant="outlined" color="error" size="small">Disable</Button></TableCell>
|
||||||
|
</TableRow>
|
||||||
|
{/* COLLAPSIBLE ROW */}
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
|
||||||
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
||||||
|
<Box sx={{ borderBottom: 1 }}>
|
||||||
|
<Typography variant="body2" gutterBottom component="div">
|
||||||
|
Description : {row.description}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Collapse>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dummy Default Data
|
||||||
|
const [dataTableIsLoading, setDataTableLoading] = useState(true);
|
||||||
|
const [dataTableLastRequest, setDataTableLastRequest] = useState(0);
|
||||||
|
const [dataTableResponseState, setDataTableResponseState] = useState('idle');
|
||||||
|
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>({
|
||||||
|
current_page: 1,
|
||||||
|
data: [],
|
||||||
|
path: "",
|
||||||
|
first_page_url: "",
|
||||||
|
last_page: 1,
|
||||||
|
last_page_url: "",
|
||||||
|
next_page_url: "",
|
||||||
|
prev_page_url: "",
|
||||||
|
per_page: 10,
|
||||||
|
from: 0,
|
||||||
|
to: 0,
|
||||||
|
total: 0
|
||||||
|
});
|
||||||
|
const [dataTablePage, setDataTablePage] = useState(5);
|
||||||
|
|
||||||
|
const loadDataTableData = async (appliedFilter : any | null = null) => {
|
||||||
|
setDataTableLoading(true);
|
||||||
|
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||||
|
const response = await axios.get('/master/drugs', { params: filter });
|
||||||
|
// console.log(response.data);
|
||||||
|
setDataTableLoading(false);
|
||||||
|
|
||||||
|
setDataTableData(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headStyle = {
|
||||||
|
fontWeight: 'bold',
|
||||||
|
};
|
||||||
|
|
||||||
|
const applyFilter = async (searchFilter: string) => {
|
||||||
|
await loadDataTableData({ "search" : searchFilter });
|
||||||
|
setSearchParams({ "search" : searchFilter });
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||||
|
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||||
|
loadDataTableData(filter);
|
||||||
|
setSearchParams(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadDataTableData();
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<ImportForm />
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
{/* The Main Table */}
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table aria-label="collapsible table">
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={headStyle} align="left" />
|
||||||
|
<TableCell style={headStyle} align="left">Type</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Code</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Name</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Version</TableCell>
|
||||||
|
<TableCell style={headStyle} align="right">Status</TableCell>
|
||||||
|
<TableCell style={headStyle} align="right">Action</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
{dataTableIsLoading ?
|
||||||
|
(
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">Loading</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
dataTableData.data.length == 0 ?
|
||||||
|
(
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">No Data</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
<TableBody>
|
||||||
|
{dataTableData.data.map(row => (
|
||||||
|
<Row key={row.id} row={row} />
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
|
||||||
|
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||||
|
</Card>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
86
frontend/dashboard/src/pages/Master/Formularium/Create.tsx
Normal file
86
frontend/dashboard/src/pages/Master/Formularium/Create.tsx
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
|
import { Card, Collapse, Divider, Grid, Stack, Typography } from "@mui/material";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
|
||||||
|
import { FormProvider, RHFCheckbox, RHFSelect, RHFTextField } from "../../../components/hook-form";
|
||||||
|
import Page from "../../../components/Page";
|
||||||
|
import useSettings from "../../../hooks/useSettings";
|
||||||
|
import { useMemo, useState } from 'react';
|
||||||
|
import Form from "./Form";
|
||||||
|
|
||||||
|
|
||||||
|
export default function Divisions() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
|
||||||
|
const [isEdit, setIsEdit] = useState(false);
|
||||||
|
|
||||||
|
const [currentFormularium, setCurrentFormularium] = useState({});
|
||||||
|
|
||||||
|
const NewDivisionSchema = Yup.object().shape({
|
||||||
|
name: Yup.string().required('Name is required'),
|
||||||
|
code: Yup.string().required('Corporate Code is required'),
|
||||||
|
active: Yup.boolean().required('Corporate Status is required'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const defaultValues = useMemo(
|
||||||
|
() => ({
|
||||||
|
code: '',
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const methods = useForm({
|
||||||
|
resolver: yupResolver(NewDivisionSchema),
|
||||||
|
defaultValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
reset,
|
||||||
|
watch,
|
||||||
|
control,
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
setError,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { isSubmitting },
|
||||||
|
} = methods;
|
||||||
|
|
||||||
|
const onSubmit = async (data: any) => {
|
||||||
|
console.log(data)
|
||||||
|
};
|
||||||
|
|
||||||
|
const pageTitle = 'Create Formularium';
|
||||||
|
return (
|
||||||
|
<Page title={pageTitle}>
|
||||||
|
|
||||||
|
<HeaderBreadcrumbs
|
||||||
|
heading={pageTitle}
|
||||||
|
links={[
|
||||||
|
{
|
||||||
|
name: 'Master',
|
||||||
|
href: '/master',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Formularium',
|
||||||
|
href: '/master/formularium/',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Create',
|
||||||
|
href: '/master/formularium/create/',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<Grid container spacing={2}>
|
||||||
|
<Grid item xs={12}>
|
||||||
|
<Card sx={{ p: 2 }}>
|
||||||
|
<Form isSubmitting={isSubmitting} isEdit={isEdit} currentFormularium={currentFormularium} />
|
||||||
|
</Card>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
239
frontend/dashboard/src/pages/Master/Formularium/Form.tsx
Normal file
239
frontend/dashboard/src/pages/Master/Formularium/Form.tsx
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
import * as Yup from 'yup';
|
||||||
|
import { useSnackbar } from 'notistack';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
// form
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
|
// @mui
|
||||||
|
import { styled } from '@mui/material/styles';
|
||||||
|
import { LoadingButton } from '@mui/lab';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
|
Card,
|
||||||
|
FormHelperText,
|
||||||
|
Grid,
|
||||||
|
Stack,
|
||||||
|
Typography,
|
||||||
|
} from '@mui/material';
|
||||||
|
|
||||||
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import {
|
||||||
|
FormProvider,
|
||||||
|
RHFTextField,
|
||||||
|
RHFRadioGroup,
|
||||||
|
RHFUploadAvatar,
|
||||||
|
RHFSwitch,
|
||||||
|
RHFEditor,
|
||||||
|
RHFDatepicker,
|
||||||
|
RHFMultiCheckbox,
|
||||||
|
RHFCheckbox,
|
||||||
|
RHFCustomMultiCheckbox,
|
||||||
|
} from '../../../components/hook-form';
|
||||||
|
import { Corporate } from '../../../@types/corporates';
|
||||||
|
import axios from '../../../utils/axios';
|
||||||
|
import { fCurrency } from '../../../utils/formatNumber';
|
||||||
|
|
||||||
|
const LabelStyle = styled(Typography)(({ theme }) => ({
|
||||||
|
...theme.typography.subtitle2,
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
marginBottom: theme.spacing(1),
|
||||||
|
}));
|
||||||
|
|
||||||
|
interface FormValuesProps extends Partial<Corporate> {
|
||||||
|
taxes: boolean;
|
||||||
|
inStock: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
isEdit: boolean;
|
||||||
|
currentFormularium?: Corporate;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function FormulariumForm({ isEdit, currentFormularium }: Props) {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
// const [ errors, setErrors ] = useState<{ [key: string]: string }>({});
|
||||||
|
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
|
const NewCorporateSchema = Yup.object().shape({
|
||||||
|
name: Yup.string().required('Name is required'),
|
||||||
|
// code: Yup.string().required('Corporate Code is required'),
|
||||||
|
// file: Yup.boolean().required('Corporate Status is required'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const defaultValues = useMemo(
|
||||||
|
() => ({
|
||||||
|
code: currentFormularium?.code || '',
|
||||||
|
name: currentFormularium?.name || '',
|
||||||
|
}),
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[currentFormularium]
|
||||||
|
);
|
||||||
|
|
||||||
|
const methods = useForm<FormValuesProps>({
|
||||||
|
resolver: yupResolver(NewCorporateSchema),
|
||||||
|
defaultValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
reset,
|
||||||
|
watch,
|
||||||
|
control,
|
||||||
|
setValue,
|
||||||
|
getValues,
|
||||||
|
setError,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { isSubmitting },
|
||||||
|
} = methods;
|
||||||
|
|
||||||
|
const values = watch();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEdit && currentFormularium) {
|
||||||
|
reset(defaultValues);
|
||||||
|
}
|
||||||
|
if (!isEdit) {
|
||||||
|
reset(defaultValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [isEdit, currentFormularium]);
|
||||||
|
|
||||||
|
const onSubmit = async (data: FormValuesProps) => {
|
||||||
|
try {
|
||||||
|
if (!isEdit) {
|
||||||
|
const response = await axios.post('/master/formulariums', data);
|
||||||
|
} else {
|
||||||
|
const response = await axios.put('/master/formulariums/' + currentFormularium?.id ?? '', data);
|
||||||
|
}
|
||||||
|
reset();
|
||||||
|
enqueueSnackbar(!isEdit ? 'Formularium Created Successfully!' : 'Formularium Udpated Successfully!', { variant: 'success' });
|
||||||
|
navigate('/master/formularium');
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error && error.response.status === 422) {
|
||||||
|
for (const [key, value] of Object.entries(error.response.data.errors)) {
|
||||||
|
setError(key, { message: value[0] });
|
||||||
|
enqueueSnackbar(value[0] ?? 'Failed Processing Request', { variant: 'error' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ascent = document?.querySelector("ascent");
|
||||||
|
if (ascent != null) {
|
||||||
|
ascent.innerHTML = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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 linking_rules_checkbox_name = "linking_rules"
|
||||||
|
const linking_tools = [
|
||||||
|
{
|
||||||
|
"value" : "nrik",
|
||||||
|
"label" : "No. KTP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value" : "nik",
|
||||||
|
"label" : "Nomor Induk Karyawan (NIK)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value" : "member_id",
|
||||||
|
"label" : "Member ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value" : "phone",
|
||||||
|
"label" : "Nomor Telepon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value" : "email",
|
||||||
|
"label" : "E-Mail"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
const importForm = useRef<HTMLInputElement>(null)
|
||||||
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
||||||
|
const [currentImportFileName, setCurrentImportFileName] = useState<string|null>(null);
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleImportButton = () => {
|
||||||
|
if (importForm?.current) {
|
||||||
|
handleClose();
|
||||||
|
importForm.current ? importForm.current.click() : console.log('No File selected');
|
||||||
|
} else {
|
||||||
|
alert('No file selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCancelImportButton = () => {
|
||||||
|
importForm.current.value = "";
|
||||||
|
importForm.current.dispatchEvent(new Event("change", { bubbles: true }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleImportChange = (event: any) => {
|
||||||
|
if (event.target.files[0]) {
|
||||||
|
setCurrentImportFileName(event.target.files[0].name)
|
||||||
|
} else {
|
||||||
|
setCurrentImportFileName(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<Stack spacing={3}>
|
||||||
|
|
||||||
|
<Typography variant="h6">Formularium Detail</Typography>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<RHFTextField name="code" label="Code" />
|
||||||
|
{(!(currentFormularium?.id) && <Typography variant="caption">Will be generated if empty</Typography>)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<RHFTextField name="name" label="Name" />
|
||||||
|
|
||||||
|
<Typography variant="h6">Formularium Drug List Import</Typography>
|
||||||
|
|
||||||
|
<input type='file' id='file' ref={importForm} style={{ display: 'none' }} onChange={handleImportChange} accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain" />
|
||||||
|
<ButtonGroup variant="outlined" aria-label="outlined button group" fullWidth>
|
||||||
|
<Button onClick={handleImportButton} fullWidth>{currentImportFileName ?? "No File Selected"}</Button>
|
||||||
|
{(currentImportFileName && <Button onClick={handleCancelImportButton} size="small" fullWidth={false} sx={{ p: 1.8 }}><CancelIcon color="error"/></Button>)}
|
||||||
|
</ButtonGroup>
|
||||||
|
|
||||||
|
<LoadingButton type="submit" variant="contained" size="large" fullWidth={true} loading={isSubmitting}>
|
||||||
|
{!isEdit ? 'Save New Corporate' : 'Save Update'}
|
||||||
|
</LoadingButton>
|
||||||
|
|
||||||
|
</Stack>
|
||||||
|
</FormProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
38
frontend/dashboard/src/pages/Master/Formularium/Index.tsx
Normal file
38
frontend/dashboard/src/pages/Master/Formularium/Index.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Card, Grid } from "@mui/material";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
import HeaderBreadcrumbs from "../../../components/HeaderBreadcrumbs";
|
||||||
|
import Page from "../../../components/Page";
|
||||||
|
import useSettings from "../../../hooks/useSettings";
|
||||||
|
import List from "./List";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export default function Drugs() {
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
|
||||||
|
const pageTitle = 'Formularium';
|
||||||
|
return (
|
||||||
|
<Page title={ pageTitle }>
|
||||||
|
|
||||||
|
<HeaderBreadcrumbs
|
||||||
|
heading={ pageTitle }
|
||||||
|
links={[
|
||||||
|
{
|
||||||
|
name: 'Master',
|
||||||
|
href: '/master',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Formularium',
|
||||||
|
href: '/master/formulariums',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<List />
|
||||||
|
</Card>
|
||||||
|
</Page>
|
||||||
|
);
|
||||||
|
}
|
||||||
310
frontend/dashboard/src/pages/Master/Formularium/List.tsx
Normal file
310
frontend/dashboard/src/pages/Master/Formularium/List.tsx
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
// @mui
|
||||||
|
import { Box, Button, Card, Collapse, IconButton, InputLabel, MenuItem, OutlinedInput, Paper, Select, SelectChangeEvent, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TextField, Typography, Badge, Tab, Tabs, CardHeader, Stack, Menu, ButtonGroup, Pagination } from '@mui/material';
|
||||||
|
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||||
|
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||||
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
|
import UploadIcon from '@mui/icons-material/Upload';
|
||||||
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
|
// hooks
|
||||||
|
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||||
|
import useSettings from '../../../hooks/useSettings';
|
||||||
|
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
||||||
|
// components
|
||||||
|
import axios from '../../../utils/axios';
|
||||||
|
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||||
|
import { Icd } from '../../../@types/diagnosis';
|
||||||
|
import BasePagination from '../../../components/BasePagination';
|
||||||
|
|
||||||
|
export default function List() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { themeStretch } = useSettings();
|
||||||
|
const { corporate_id } = useParams();
|
||||||
|
const [searchParams, setSearchParams] = useSearchParams();
|
||||||
|
const [importResult, setImportResult] = useState(null);
|
||||||
|
|
||||||
|
function SearchInput(props: any) {
|
||||||
|
// SEARCH
|
||||||
|
const searchInput = useRef<HTMLInputElement>(null);
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
|
||||||
|
const handleSearchChange = (event: any) => {
|
||||||
|
const newSearchText = event.target.value ?? ''
|
||||||
|
setSearchText(newSearchText);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSearchSubmit = (event: any) => {
|
||||||
|
event.preventDefault();
|
||||||
|
props.onSearch(searchText); // Trigger to Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => { // Trigger First Search
|
||||||
|
setSearchText(searchParams.get('search') ?? '');
|
||||||
|
}, [searchParams])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form onSubmit={handleSearchSubmit} style={{ width: '100%' }}>
|
||||||
|
<TextField id="search-input" ref={searchInput} label="Search" variant="outlined" fullWidth onChange={handleSearchChange} value={searchText}/>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ImportForm(props: any) {
|
||||||
|
// IMPORT
|
||||||
|
// Create Button Menu
|
||||||
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
||||||
|
const createMenu = Boolean(anchorEl);
|
||||||
|
const importForm = useRef<HTMLInputElement>(null)
|
||||||
|
const [currentImportFileName, setCurrentImportFileName] = useState(null)
|
||||||
|
|
||||||
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
|
setAnchorEl(event.currentTarget);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleImportButton = () => {
|
||||||
|
if (importForm?.current) {
|
||||||
|
handleClose();
|
||||||
|
importForm.current ? importForm.current.click() : console.log('No File selected');
|
||||||
|
} else {
|
||||||
|
alert('No file selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCancelImportButton = () => {
|
||||||
|
importForm.current.value = "";
|
||||||
|
importForm.current.dispatchEvent(new Event("change", { bubbles: true }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleImportChange = (event: any) => {
|
||||||
|
if (event.target.files[0]) {
|
||||||
|
setCurrentImportFileName(event.target.files[0].name)
|
||||||
|
} else {
|
||||||
|
setCurrentImportFileName(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUpload = () => {
|
||||||
|
if (importForm.current?.files.length) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("file", importForm.current?.files[0])
|
||||||
|
axios.post(`master/formularium/import`, formData )
|
||||||
|
.then(response => {
|
||||||
|
handleCancelImportButton();
|
||||||
|
loadDataTableData();
|
||||||
|
setImportResult(response.data)
|
||||||
|
// alert('Succesfully read '+ response.data.total_successed_row + ' with ' + response.data.total_failed_row + ' failed rows');
|
||||||
|
})
|
||||||
|
.catch(response => {
|
||||||
|
alert('Looks like something went wrong. Please check your data and try again. ' + response.message)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
alert('No File Selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<input type='file' id='file' ref={importForm} style={{ display: 'none' }} onChange={handleImportChange} accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain" />
|
||||||
|
{( !currentImportFileName && <Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||||
|
<SearchInput onSearch={applyFilter}/>
|
||||||
|
{/* <h1>kjasndkjandskjasndkjansdkjansd</h1> */}
|
||||||
|
<Button
|
||||||
|
id="import-button"
|
||||||
|
variant='outlined'
|
||||||
|
startIcon={<AddIcon />} sx={{ p: 1.8 }}
|
||||||
|
aria-controls={createMenu ? 'basic-menu' : undefined}
|
||||||
|
aria-haspopup="true"
|
||||||
|
aria-expanded={createMenu ? 'true' : undefined}
|
||||||
|
onClick={handleClick}
|
||||||
|
>
|
||||||
|
Create
|
||||||
|
</Button>
|
||||||
|
<Menu
|
||||||
|
id="import-button"
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
open={createMenu}
|
||||||
|
onClose={handleClose}
|
||||||
|
MenuListProps={{
|
||||||
|
'aria-labelledby': 'basic-button',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem onClick={() => {navigate('/master/formularium/create')} }>Create</MenuItem>
|
||||||
|
<MenuItem onClick={handleImportButton}>Import</MenuItem>
|
||||||
|
<MenuItem onClick={handleClose}>Download Template</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{( currentImportFileName && <Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
|
||||||
|
<ButtonGroup variant="outlined" aria-label="outlined button group" fullWidth>
|
||||||
|
<Button onClick={handleImportButton} fullWidth>{currentImportFileName ?? "No File Selected"}</Button>
|
||||||
|
<Button onClick={handleCancelImportButton} size="small" fullWidth={false} sx={{ p: 1.8 }}><CancelIcon color="error"/></Button>
|
||||||
|
</ButtonGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
id="upload-button"
|
||||||
|
variant='outlined'
|
||||||
|
startIcon={<UploadIcon />} sx={{ p: 1.8 }}
|
||||||
|
onClick={handleUpload}
|
||||||
|
>
|
||||||
|
Upload
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
{( importResult &&
|
||||||
|
<Stack direction={'row'} sx={{ px: 2, pb: 2 }}>
|
||||||
|
<Box sx={{ color: "text.secondary" }}>Last Import Result Report : <a href={importResult.result_file?.url ?? "#"}>{importResult.result_file?.name ?? "-"}</a></Box>
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called on every row to map the data to the columns
|
||||||
|
function createData( icd: Icd ): Icd {
|
||||||
|
return {
|
||||||
|
...icd,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the every row of the table
|
||||||
|
function Row(props: { row: ReturnType<typeof createData> }) {
|
||||||
|
const { row } = props;
|
||||||
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
|
||||||
|
<TableCell>
|
||||||
|
<IconButton
|
||||||
|
aria-label="expand row"
|
||||||
|
size="small"
|
||||||
|
onClick={() => setOpen(!open)}
|
||||||
|
>
|
||||||
|
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
||||||
|
</IconButton>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="left">{row.code}</TableCell>
|
||||||
|
<TableCell align="left">{row.name}</TableCell>
|
||||||
|
<TableCell align="left">{row.items_count}</TableCell>
|
||||||
|
|
||||||
|
<TableCell align="right"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
|
||||||
|
<TableCell align="right"><Button variant="outlined" color="error" size="small">Disable</Button></TableCell>
|
||||||
|
</TableRow>
|
||||||
|
{/* COLLAPSIBLE ROW */}
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={99}>
|
||||||
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
||||||
|
<Box sx={{ borderBottom: 1 }}>
|
||||||
|
<Typography variant="body2" gutterBottom component="div">
|
||||||
|
Description : {row.description}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Collapse>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dummy Default Data
|
||||||
|
const [dataTableIsLoading, setDataTableLoading] = useState(true);
|
||||||
|
const [dataTableLastRequest, setDataTableLastRequest] = useState(0);
|
||||||
|
const [dataTableResponseState, setDataTableResponseState] = useState('idle');
|
||||||
|
const [dataTableData, setDataTableData] = useState<LaravelPaginatedData>({
|
||||||
|
current_page: 1,
|
||||||
|
data: [],
|
||||||
|
path: "",
|
||||||
|
first_page_url: "",
|
||||||
|
last_page: 1,
|
||||||
|
last_page_url: "",
|
||||||
|
next_page_url: "",
|
||||||
|
prev_page_url: "",
|
||||||
|
per_page: 10,
|
||||||
|
from: 0,
|
||||||
|
to: 0,
|
||||||
|
total: 0
|
||||||
|
});
|
||||||
|
const [dataTablePage, setDataTablePage] = useState(5);
|
||||||
|
|
||||||
|
const loadDataTableData = async (appliedFilter : any | null = null) => {
|
||||||
|
setDataTableLoading(true);
|
||||||
|
const filter = appliedFilter ? appliedFilter : Object.fromEntries([...searchParams.entries()]);
|
||||||
|
const response = await axios.get('/master/formulariums', { params: filter });
|
||||||
|
// console.log(response.data);
|
||||||
|
setDataTableLoading(false);
|
||||||
|
|
||||||
|
setDataTableData(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headStyle = {
|
||||||
|
fontWeight: 'bold',
|
||||||
|
};
|
||||||
|
|
||||||
|
const applyFilter = async (searchFilter: string) => {
|
||||||
|
await loadDataTableData({ "search" : searchFilter });
|
||||||
|
setSearchParams({ "search" : searchFilter });
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlePageChange = (event : ChangeEvent, value: number) => {
|
||||||
|
const filter = Object.fromEntries([...searchParams.entries(), ["page", value]]);
|
||||||
|
loadDataTableData(filter);
|
||||||
|
setSearchParams(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadDataTableData();
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<ImportForm />
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
{/* The Main Table */}
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table aria-label="collapsible table">
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={headStyle} align="left" />
|
||||||
|
<TableCell style={headStyle} align="left">Code</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Name</TableCell>
|
||||||
|
<TableCell style={headStyle} align="left">Total Item</TableCell>
|
||||||
|
<TableCell style={headStyle} align="right">Status</TableCell>
|
||||||
|
<TableCell style={headStyle} align="right">Action</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
{dataTableIsLoading ?
|
||||||
|
(
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">Loading</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
dataTableData.data.length == 0 ?
|
||||||
|
(
|
||||||
|
<TableBody>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={8} align="center">No Data</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
) : (
|
||||||
|
<TableBody>
|
||||||
|
{dataTableData.data.map(row => (
|
||||||
|
<Row key={row.id} row={row} />
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
|
||||||
|
<BasePagination paginationData={dataTableData} onPageChange={handlePageChange}/>
|
||||||
|
</Card>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -163,6 +163,11 @@ export default function Router() {
|
|||||||
element: <CorporateBenefitsCreate />,
|
element: <CorporateBenefitsCreate />,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
path: 'corporates/:corporate_id/formularium',
|
||||||
|
element: <CorporateFormularium />,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: 'corporates/:corporate_id/diagnosis-exclusions',
|
path: 'corporates/:corporate_id/diagnosis-exclusions',
|
||||||
element: <DiagnosisExclusions />,
|
element: <DiagnosisExclusions />,
|
||||||
@@ -172,6 +177,20 @@ export default function Router() {
|
|||||||
path: 'master/diagnosis',
|
path: 'master/diagnosis',
|
||||||
element: <MasterDiagnosis />,
|
element: <MasterDiagnosis />,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
path: 'master/drugs',
|
||||||
|
element: <MasterDrug />,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
path: 'master/formularium',
|
||||||
|
element: <MasterFormularium />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'master/formularium/create',
|
||||||
|
element: <MasterFormulariumCreate />,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
@@ -240,6 +259,13 @@ const Plans = Loadable(lazy(() => import('../pages/Corporates/Plan/Index')));
|
|||||||
|
|
||||||
const DiagnosisExclusions = Loadable(lazy(() => import('../pages/Corporates/DiagnosisExclusion/Index')));
|
const DiagnosisExclusions = Loadable(lazy(() => import('../pages/Corporates/DiagnosisExclusion/Index')));
|
||||||
|
|
||||||
|
const CorporateFormularium = Loadable(lazy(() => import('../pages/Corporates/Formularium/Index')));
|
||||||
|
|
||||||
const MasterDiagnosis = Loadable(lazy(() => import('../pages/Master/Diagnosis/Index')));
|
const MasterDiagnosis = Loadable(lazy(() => import('../pages/Master/Diagnosis/Index')));
|
||||||
|
|
||||||
|
const MasterDrug = Loadable(lazy(() => import('../pages/Master/Drug/Index')));
|
||||||
|
|
||||||
|
const MasterFormularium = Loadable(lazy(() => import('../pages/Master/Formularium/Index')));
|
||||||
|
const MasterFormulariumCreate = Loadable(lazy(() => import('../pages/Master/Formularium/Create')));
|
||||||
|
|
||||||
const CorporateServices = Loadable(lazy(() => import('../pages/Corporates/Services/Index')));
|
const CorporateServices = Loadable(lazy(() => import('../pages/Corporates/Services/Index')));
|
||||||
|
|||||||
BIN
resources/files/daftar_masteritem_ccp_14-06-2022.xlsx
Normal file
BIN
resources/files/daftar_masteritem_ccp_14-06-2022.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user