update create e-prescription
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Drug;
|
||||
use App\Models\Unit;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
@@ -25,6 +26,37 @@ class DrugController extends Controller
|
||||
return $drugs;
|
||||
}
|
||||
|
||||
public function drugList(Request $request){
|
||||
$drugs = Drug::query()
|
||||
->where([
|
||||
'atc_code' => 'lms', // ini untuk menggunakan list obat yang baru
|
||||
])
|
||||
->get();
|
||||
|
||||
$manipulatedDrugs = $drugs->map(function ($drug) {
|
||||
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
|
||||
return [
|
||||
'value' => $drug->id, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'label' => $drug->name, // Ganti dengan properti yang sesuai dari model Icd
|
||||
];
|
||||
});
|
||||
return Helper::responseJson(data: $manipulatedDrugs);
|
||||
}
|
||||
|
||||
public function unitList(Request $request){
|
||||
$units = Unit::query()
|
||||
->get();
|
||||
|
||||
$manipulatedUnits = $units->map(function ($unit) {
|
||||
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
|
||||
return [
|
||||
'value' => $unit->id, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'label' => $unit->name, // Ganti dengan properti yang sesuai dari model Icd
|
||||
];
|
||||
});
|
||||
return Helper::responseJson(data: $manipulatedUnits);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
@@ -123,20 +155,22 @@ class DrugController extends Controller
|
||||
|
||||
foreach ($processedData as $row) {
|
||||
try {
|
||||
Drug::create(
|
||||
[
|
||||
'name' => $row['name'],
|
||||
'code' => $row['code'],
|
||||
'generic_name' => $row['generic_name'],
|
||||
'description' => $row['description'],
|
||||
'mims_class' => $row['mims_class'],
|
||||
'indications' => $row['indications'],
|
||||
'atc_code' => $row['atc_code'],
|
||||
'segmentation' => $row['segmentation'],
|
||||
'type' => $row['type'],
|
||||
'dosage' => $row['dosage'],
|
||||
'remark' => $row['remark'],
|
||||
]
|
||||
Drug::updateOrCreate([
|
||||
'code' => $row['code'],
|
||||
],
|
||||
[
|
||||
'name' => $row['name'],
|
||||
'code' => $row['code'],
|
||||
'generic_name' => $row['generic_name'],
|
||||
'description' => $row['description'],
|
||||
'mims_class' => $row['mims_class'],
|
||||
'indications' => $row['indications'],
|
||||
'atc_code' => $row['atc_code'],
|
||||
'segmentation' => $row['segmentation'],
|
||||
'type' => $row['type'],
|
||||
'dosage' => $row['dosage'],
|
||||
'remark' => $row['remark'],
|
||||
]
|
||||
);
|
||||
$importedRows++;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Internal\Transformers\LivechatResource;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
class EprescriptionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$startDate = $request->startDate;
|
||||
$endDate = $request->endDate;
|
||||
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare');
|
||||
// ->where('nIDAppointment', '!=', null)
|
||||
// ->where('nIDAppointment', '!=', '');
|
||||
|
||||
|
||||
if ($startDate) {
|
||||
$livechat = $livechat->where('dCreateOn', '>=', $startDate);
|
||||
}
|
||||
|
||||
if ($endDate) {
|
||||
$endDate = date('Y-m-d', strtotime($endDate . ' +1 day'));
|
||||
$livechat = $livechat->where('dCreateOn', '<', $endDate);
|
||||
}
|
||||
$livechat = $livechat->latest()->paginate(15);
|
||||
|
||||
return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||
->where('nID', $id)
|
||||
->first();
|
||||
return response()->json(new LivechatResource($livechat));
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
||||
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
||||
|
||||
$liveChats = Livechat::with('user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser', 'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName', 'appointment:nID,sPaymentStatus,sPaymentMethod', 'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment', 'healthCare:nID,sHealthCare')
|
||||
->where(function (Builder $query) use ($startDate, $endDate) {
|
||||
// $query->where('nIDAppointment', '!=', null);
|
||||
// $query->where('nIDAppointment', '!=', '');
|
||||
if ($startDate) {
|
||||
$query->where('dCreateOn', '>=', $startDate);
|
||||
}
|
||||
if ($endDate) {
|
||||
$endDate = date('Y-m-d', strtotime($endDate . ' +1 day'));
|
||||
$query->where('dCreateOn', '<', $endDate);
|
||||
}
|
||||
})
|
||||
->orderBy('nID', 'desc')
|
||||
->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn']);
|
||||
|
||||
$headers = [
|
||||
['value' => 'No', 'cell' => 'A1', 'mergeCell' => true, 'mergeToCell' => 'A2'],
|
||||
['value' => 'Kode TC', 'cell' => 'B1', 'mergeCell' => true, 'mergeToCell' => 'B2'],
|
||||
['value' => 'Tanggal', 'cell' => 'C1', 'mergeCell' => true, 'mergeToCell' => 'C2'],
|
||||
['value' => 'Waktu', 'cell' => 'D1', 'mergeCell' => true, 'mergeToCell' => 'D2'],
|
||||
['value' => 'Faskes', 'cell' => 'E1', 'mergeCell' => true, 'mergeToCell' => 'E2'],
|
||||
['value' => 'Nama Dokter', 'cell' => 'F1', 'mergeCell' => true, 'mergeToCell' => 'F2'],
|
||||
['value' => 'Spesialis', 'cell' => 'G1', 'mergeCell' => true, 'mergeToCell' => 'G2'],
|
||||
['value' => 'Chat Via App/Website', 'cell' => 'H1', 'mergeCell' => true, 'mergeToCell' => 'I1'],
|
||||
['value' => 'Pasien', 'cell' => 'H2', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Dokter', 'cell' => 'I2', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'nIDUser', 'cell' => 'J1', 'mergeCell' => true, 'mergeToCell' => 'J2'],
|
||||
['value' => 'Nama Pasien', 'cell' => 'K1', 'mergeCell' => true, 'mergeToCell' => 'K2'],
|
||||
['value' => 'No Telepon Pasien', 'cell' => 'L1', 'mergeCell' => true, 'mergeToCell' => 'L2'],
|
||||
['value' => 'Email Pasien', 'cell' => 'M1', 'mergeCell' => true, 'mergeToCell' => 'M2'],
|
||||
['value' => 'Status', 'cell' => 'N1', 'mergeCell' => true, 'mergeToCell' => 'N2'],
|
||||
['value' => 'Record Type', 'cell' => 'O1', 'mergeCell' => true, 'mergeToCell' => 'O2'],
|
||||
['value' => 'nID Principal', 'cell' => 'P1', 'mergeCell' => true, 'mergeToCell' => 'P2'],
|
||||
['value' => 'Metode Pembayaran', 'cell' => 'Q1', 'mergeCell' => true, 'mergeToCell' => 'Q2'],
|
||||
];
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
foreach ($headers as $header) {
|
||||
$sheet->setCellValue($header['cell'], $header['value']);
|
||||
|
||||
if ($header['mergeCell'] === true) {
|
||||
$sheet->mergeCells($header['cell'] . ':' . $header['mergeToCell']);
|
||||
}
|
||||
|
||||
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
||||
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
}
|
||||
|
||||
$startFrom = 3;
|
||||
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||
$paymentMethod = $liveChat->appointment ? Helper::sPaymentMethod($liveChat->appointment->sPaymentMethod) : 'N/A';
|
||||
$fullNameDoctor = '-';
|
||||
if ($liveChat->doctor->user !== null) {
|
||||
$fullNameDoctor = '';
|
||||
|
||||
if ($liveChat->doctor->user->detail !== null) {
|
||||
if ($liveChat->doctor->user->detail->sTitlePrefix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitlePrefix . '. ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->full_name !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->full_name . ' ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->detail->sTitleSuffix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitleSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$recordType = 'P';
|
||||
if ($nIDUser){
|
||||
$recordType = 'D';
|
||||
}
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$statusLivechat = "Request TC";
|
||||
break;
|
||||
case 1:
|
||||
$statusLivechat = "Accepted by Doctor but User not Payment";
|
||||
break;
|
||||
case 2:
|
||||
$statusLivechat = "Payment Success";
|
||||
break;
|
||||
case 3:
|
||||
$statusLivechat = "Decline by Doctor";
|
||||
break;
|
||||
case 4:
|
||||
$statusLivechat = "Payment Expired";
|
||||
break;
|
||||
default:
|
||||
$statusLivechat = "Cancel by Patient";
|
||||
}
|
||||
|
||||
$sheet->setCellValue('A' . $startFrom, $indexLiveChat + 1);
|
||||
$sheet->setCellValue('B' . $startFrom, $liveChat->nID ?? '-');
|
||||
$sheet->setCellValue('C' . $startFrom, Carbon::parse($liveChat->dCreateOn)->format('d-m-Y'));
|
||||
$sheet->setCellValue('D' . $startFrom, Carbon::parse($liveChat->dCreateOn)->format('H:i:s'));
|
||||
// $sheet->setCellValue('D' . $startFrom, Carbon::parse($liveChat->dRequestTime)->format('H:i:s'));
|
||||
$sheet->setCellValue('E' . $startFrom, $liveChat->healthCare->sHealthCare ?? '-');
|
||||
$sheet->setCellValue('F' . $startFrom, $fullNameDoctor);
|
||||
$sheet->setCellValue('G' . $startFrom, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
||||
$sheet->setCellValue('H' . $startFrom, $liveChat->sMedia ?? '-');
|
||||
$sheet->setCellValue('I' . $startFrom, $liveChat->sMediaDokter ?? '-');
|
||||
$sheet->setCellValue('J' . $startFrom, $liveChat->user->nID ?? '-');
|
||||
$sheet->setCellValue('K' . $startFrom, $liveChat->user->full_name ?? '-');
|
||||
$sheet->setCellValue('L' . $startFrom, preg_replace('/(\d{3})(\d{4})(\d{3})/', '$1$2$3', $phone));
|
||||
$sheet->setCellValue('M' . $startFrom, $liveChat->user->sEmail ?? '-');
|
||||
$sheet->setCellValue('N' . $startFrom, $statusLivechat);
|
||||
$sheet->setCellValue('O' . $startFrom, $recordType);
|
||||
$sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-');
|
||||
$sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-');
|
||||
$startFrom++;
|
||||
}
|
||||
|
||||
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P'] as $header) {
|
||||
if ($header === 'A') {
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px');
|
||||
} elseif ($header === 'H' || $header === 'I') {
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px');
|
||||
} else {
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true);
|
||||
}
|
||||
}
|
||||
|
||||
$spreadsheet->getActiveSheet()->getStyle('A3:A' . $startFrom)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
|
||||
$sheet->getDefaultRowDimension()->setRowHeight(-1);
|
||||
$sheet->setTitle('Live Chat Report');
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
ob_start();
|
||||
$writer->save('php://output');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$fileName = 'result-' . now()->getPreciseTimestamp(3) . '-livechat-report.xlsx';
|
||||
Storage::disk('public')->put('temp/' . $fileName, $content);
|
||||
|
||||
$fileUrl = url('storage/temp/' . $fileName);
|
||||
|
||||
return Helper::responseJson([
|
||||
"file_url" => $fileUrl
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,30 @@
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use App\Models\OLDLMS\LivechatSummary;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use App\Models\OLDLMS\User;
|
||||
use App\Models\OLDLMS\UserDetail;
|
||||
use App\Models\OLDLMS\Prescription;
|
||||
use App\Models\OLDLMS\PrescriptionItem;
|
||||
use App\Models\Icd;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Drug;
|
||||
use App\Models\Unit;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Modules\Internal\Transformers\LivechatResource;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use DB;
|
||||
|
||||
class PrescriptionController extends Controller
|
||||
{
|
||||
@@ -15,21 +34,30 @@ class PrescriptionController extends Controller
|
||||
* @param int|null $id
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function index($id = null)
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Prescription::query();
|
||||
if ($id !== null) {
|
||||
$query->where('nID', $id);
|
||||
$startDate = $request->startDate;
|
||||
$endDate = $request->endDate;
|
||||
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare', 'summary');
|
||||
// ->where('nIDAppointment', '!=', null)
|
||||
// ->where('nIDAppointment', '!=', '');
|
||||
if ($startDate) {
|
||||
$livechat = $livechat->where('dCreateOn', '>=', $startDate);
|
||||
}
|
||||
|
||||
$prescriptions = $query->select('nID','nIDLiveChat', 'nIDLiveChatSummary', 'nIDDokter', 'sDokterName', 'dTanggalResep', 'sSource', 'nIDUser', 'sKodeResep', 'sDiagnose', 'sStatus')
|
||||
->get();
|
||||
|
||||
// $prescriptions->toArray();
|
||||
// dd($prescriptions);
|
||||
if ($endDate) {
|
||||
$endDate = date('Y-m-d', strtotime($endDate . ' +1 day'));
|
||||
$livechat = $livechat->where('dCreateOn', '<', $endDate);
|
||||
}
|
||||
|
||||
return response()->json($prescriptions);
|
||||
// return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||
$livechat = $livechat->whereHas('summary', function ($query) {
|
||||
$query->whereNotNull('nIDLiveChat');
|
||||
});
|
||||
|
||||
$livechat = $livechat->latest()->paginate(15);
|
||||
|
||||
return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +79,94 @@ class PrescriptionController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$livechat = Livechat::where('nID', $request->id)->first();
|
||||
$livechatSummary = LivechatSummary::where('nIDLivechat', $request->id)->first();
|
||||
|
||||
$userDokter = User::where('nID', $livechat->nIDDokter)->first();
|
||||
$userDetailDokter = UserDetail::where('nIDUser', $userDokter->nID)->first();
|
||||
|
||||
$dokter = $userDetailDokter->sTitlePrefix . ' ' . $userDokter->sFirstName . ' ' . $userDokter->sLastName . ' ' . $userDetailDokter->sTitleSuffix;
|
||||
|
||||
$kodeResep = 'LMS' . date('ymd') . rand(1,100);
|
||||
$diagnosis = explode(",",$request->diagnosis);
|
||||
|
||||
if(isset($request->diagnosis) && is_array($diagnosis) && count($diagnosis) > 0) {
|
||||
foreach($diagnosis as $data){
|
||||
$icd = Icd::where('code', $data)->first();
|
||||
array_push($diagnosis, $icd->name);
|
||||
};
|
||||
}
|
||||
$sDiagnosis = implode(", ",$diagnosis);
|
||||
$hospitalData = Organization::where('id', $request->hospital)->first();
|
||||
$hospital = '';
|
||||
if ($hospitalData) {
|
||||
$hospital = $hospitalData->code;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'nIDLivechat' => $request->id,
|
||||
'nIDLivechatSummary' => $livechatSummary->nID,
|
||||
'nIDDokter' => $livechat->nIDDokter,
|
||||
'sDokterName' => $dokter,
|
||||
'dTanggalResep' => date('Y-m-d H:i:s'),
|
||||
'sSource' => 'lms',
|
||||
'nIDUser' => $livechat->nIDUser,
|
||||
'sRegID' => '',
|
||||
'sKodeResep' => $kodeResep,
|
||||
'sDiagnose' => $sDiagnosis,
|
||||
'sKodeRS' => $hospital,
|
||||
];
|
||||
|
||||
$prescription = Prescription::create($data);
|
||||
|
||||
$medicine = $request->medicine;
|
||||
$customMessages = [
|
||||
'required' => 'Kolom :attribute wajib diisi.',
|
||||
'numeric' => 'Kolom :attribute harus berupa angka.',
|
||||
];
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'medicine' => 'required|array',
|
||||
'medicine.*' => 'required',
|
||||
], $customMessages);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Helper::responseJson([$request->all()],'error', 400, $validator->errors());
|
||||
} else {
|
||||
// BeginTransaction
|
||||
DB::beginTransaction();
|
||||
foreach($medicine as $key => $value){
|
||||
$drugData = Drug::where('id', $value['drug_id'])->first();
|
||||
$drug = '';
|
||||
if ($drugData){
|
||||
$drug = $drugData->name;
|
||||
}
|
||||
$unitData = Unit::where('id', $value['unit_id'])->first();
|
||||
$unit = '';
|
||||
if ($unitData) {
|
||||
$unit = $unitData->name;
|
||||
}
|
||||
$data = [
|
||||
'nIDPrescription' => $prescription->id,
|
||||
'sItemName' => $drug,
|
||||
'nQty' => $value['qty'],
|
||||
'sSatuan' => $unit,
|
||||
'sSigna' => $value['signa'],
|
||||
'sNote' => $value['note'],
|
||||
];
|
||||
// Insert Data
|
||||
try {
|
||||
PrescriptionItem::create($data);
|
||||
} catch (\Throwable $th) {
|
||||
DB::rollBack();
|
||||
return Helper::responseJson(status: 'failed', statusCode: 500, message: $th->getMessage());
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
return Helper::responseJson(status: 'success', statusCode: 201, message: 'success', data: $request->toArray());
|
||||
}
|
||||
|
||||
return Helper::responseJson(status: 'success', statusCode: 200, message: 'Resep Online berhasil ajukan!', data: $prescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,6 +211,24 @@ class RequestLogController extends Controller
|
||||
});
|
||||
return Helper::responseJson(data: $manipulatedIcds);
|
||||
}
|
||||
|
||||
public function hospitals(){
|
||||
$organizations = Organization::query()
|
||||
->where([
|
||||
'type' => 'hospital',
|
||||
'status' => 'active',
|
||||
])
|
||||
->get();
|
||||
|
||||
$manipulatedOrganizations = $organizations->map(function ($organization) {
|
||||
// Contoh manipulasi, tambahkan atau ubah properti sesuai kebutuhan
|
||||
return [
|
||||
'value' => $organization->id, // Ganti dengan properti yang sesuai dari model Icd
|
||||
'label' => $organization->name, // Ganti dengan properti yang sesuai dari model Icd
|
||||
];
|
||||
});
|
||||
return Helper::responseJson(data: $manipulatedOrganizations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
|
||||
@@ -286,6 +286,9 @@ Route::prefix('internal')->group(function () {
|
||||
|
||||
// search diagnosis
|
||||
Route::get('diagnosis', [RequestLogController::class, 'diagnosis']);
|
||||
Route::get('hospitals', [RequestLogController::class, 'hospitals']);
|
||||
Route::get('drugs', [DrugController::class, 'drugList']);
|
||||
Route::get('units', [DrugController::class, 'unitList']);
|
||||
|
||||
// insert benefit
|
||||
Route::post('customer-service/request/insert-benefit', [RequestLogBenefitController::class, 'store']);
|
||||
@@ -303,7 +306,12 @@ Route::prefix('internal')->group(function () {
|
||||
Route::resource('appointments', AppointmentController::class);
|
||||
Route::get('live-chat/export', [LivechatController::class, 'export']);
|
||||
Route::resource('live-chat', LivechatController::class);
|
||||
|
||||
Route::get('prescription', [PrescriptionController::class, 'index']);
|
||||
|
||||
Route::post('prescription', [PrescriptionController::class, 'store']);
|
||||
|
||||
|
||||
Route::get('prescription/{id}', [PrescriptionController::class, 'index']);
|
||||
Route::get('doctorrating', [DoctorRatingController::class, 'index']);
|
||||
Route::get('doctorrating/{id}', [PrescriptionController::class, 'index']);
|
||||
|
||||
40
app/Models/OLDLMS/LivechatSummary.php
Normal file
40
app/Models/OLDLMS/LivechatSummary.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LivechatSummary extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
// public $sStatusNames = [
|
||||
// 0 => 'Menunggu Konfirmasi',
|
||||
// 1 => 'Diterima',
|
||||
// 3 => 'Ditolak',
|
||||
// 2 => 'Selesai',
|
||||
// 4 => 'Expired',
|
||||
// ];
|
||||
|
||||
public $sStatusNames = [
|
||||
0 => 'Request TC',
|
||||
1 => 'Accepted by Doctor but User not Payment',
|
||||
3 => 'Decline by Doctor',
|
||||
2 => 'Payment Success',
|
||||
4 => 'Payment Expired',
|
||||
5 => 'Cancel by Patient'
|
||||
];
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_livechat_summary';
|
||||
|
||||
protected $primaryKey = 'nID';
|
||||
}
|
||||
@@ -10,6 +10,20 @@ class Prescription extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nIDLivechat',
|
||||
'nIDLivechatSummary',
|
||||
'nIDDokter',
|
||||
'sDokterName',
|
||||
'dTanggalResep',
|
||||
'sSource',
|
||||
'nIDUser',
|
||||
'sRegID',
|
||||
'sKodeResep',
|
||||
'sDiagnose',
|
||||
'sKodeRS',
|
||||
];
|
||||
|
||||
|
||||
// public $sStatusNames = [
|
||||
// 0 => 'Menunggu Konfirmasi',
|
||||
|
||||
51
app/Models/OLDLMS/PrescriptionItem.php
Normal file
51
app/Models/OLDLMS/PrescriptionItem.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PrescriptionItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nIDPrescription',
|
||||
'sItemCode',
|
||||
'sOriginCode',
|
||||
'sItemName',
|
||||
'nQty',
|
||||
'sSatuan',
|
||||
'sSigna',
|
||||
'sNote',
|
||||
'isRacikan',
|
||||
'ParentCode',
|
||||
];
|
||||
|
||||
|
||||
// public $sStatusNames = [
|
||||
// 0 => 'Menunggu Konfirmasi',
|
||||
// 1 => 'Diterima',
|
||||
// 2 => 'Ditolak',
|
||||
// 3 => 'Selesai',
|
||||
// 4 => 'Expired',
|
||||
// ];
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_prescription_items';
|
||||
|
||||
// protected $appends = [
|
||||
// 'status_name',
|
||||
// ];
|
||||
|
||||
protected $casts = [
|
||||
'dTanggalResep' => 'datetime',
|
||||
];
|
||||
|
||||
}
|
||||
@@ -30,6 +30,13 @@ export type Specialities = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type PeriodStart = {
|
||||
date: string;
|
||||
};
|
||||
export type PeriodEnd = {
|
||||
date: string;
|
||||
};
|
||||
|
||||
export type Practitioner = {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -50,6 +57,35 @@ export type Practitioner = {
|
||||
active: boolean | number;
|
||||
organizations?: Organizations[];
|
||||
specialities?: Specialities[];
|
||||
period_start?: PeriodStart[];
|
||||
period_end?: PeriodEnd[];
|
||||
};
|
||||
|
||||
export type Medicine = {
|
||||
id: number;
|
||||
drug_id: number;
|
||||
unit_id: number;
|
||||
qty: number;
|
||||
signa: string;
|
||||
note: string;
|
||||
}
|
||||
|
||||
export type Appointment = {
|
||||
id:number;
|
||||
name:string;
|
||||
address:string;
|
||||
birth_date:string;
|
||||
gender:string;
|
||||
description:string;
|
||||
birth_place:string;
|
||||
active:number;
|
||||
avatar_url:string;
|
||||
doctor_id:number;
|
||||
organizations:Organizations[];
|
||||
specialities:Specialities[];
|
||||
diagonis:string;
|
||||
hospital:string;
|
||||
medicine: Medicine[];
|
||||
}
|
||||
|
||||
export type PractitionerType = Practitioner;
|
||||
@@ -100,7 +100,7 @@ const navConfig = [
|
||||
{ title: 'Appointment', path: '/report/appointments' },
|
||||
{ title: 'Live Chat', path: '/report/live-chat' },
|
||||
{ title: 'Linksehat Payment', path: '/report/linksehat-payments' },
|
||||
{ title: 'Prescription', path: '/report/prescription' },
|
||||
// { title: 'Prescription', path: '/report/prescription' },
|
||||
{ title: 'Doctor Rating', path: '/report/doctorrating' },
|
||||
|
||||
],
|
||||
@@ -123,6 +123,10 @@ const navConfig = [
|
||||
title: 'LINKING TOOLS',
|
||||
path: '/linking',
|
||||
},
|
||||
{
|
||||
title: 'E - PRESCRIPTION',
|
||||
path: '/e-prescription/live-chat',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -31,6 +31,8 @@ export type DetailFinalLogType = {
|
||||
id : number,
|
||||
code : string,
|
||||
member_id : string,
|
||||
invoice_no : string,
|
||||
billing_no : string,
|
||||
provider : string,
|
||||
policy_number : string,
|
||||
name : string|any,
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { paramCase } from 'change-case';
|
||||
import { useParams, useLocation } from 'react-router-dom';
|
||||
// @mui
|
||||
import { Container, Stack } from '@mui/material';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import Page from '../../../components/Page';
|
||||
import Form from './Form';
|
||||
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
||||
import axios from '../../../utils/axios';
|
||||
import { Practitioner } from '../../../@types/doctor';
|
||||
import ButtonBack from '../../../components/ButtonBack';
|
||||
|
||||
export default function Create() {
|
||||
const { themeStretch } = useSettings();
|
||||
const { id } = useParams();
|
||||
|
||||
const isEdit = id ? true : false;
|
||||
|
||||
const [currentPractitioner, setCurrentPractitioner] = useState<Practitioner>();
|
||||
|
||||
useEffect(() => {
|
||||
if (isEdit) {
|
||||
axios.get('/doctors/' + id).then((res) => {
|
||||
setCurrentPractitioner(res.data);
|
||||
});
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
return (
|
||||
<Page title="Membership: Create a new Dokter">
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
<Stack direction="row" alignItems="center">
|
||||
{/* <ButtonBack /> */}
|
||||
<HeaderBreadcrumbs
|
||||
heading={!isEdit ? 'Manage a new Dokter' : 'Manage Dokter'}
|
||||
links={[
|
||||
{ name: 'Master', href: '/master' },
|
||||
{
|
||||
name: 'Doctors',
|
||||
href: '/master/doctors',
|
||||
},
|
||||
{ name: !isEdit ? 'Create' : currentPractitioner?.name ?? '' },
|
||||
]}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Form
|
||||
// isSubmitting={isSubmitting}
|
||||
isEdit={isEdit}
|
||||
currentPractitioner={currentPractitioner}
|
||||
/>
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
// const pageTitle = 'Create Data Dokter';
|
||||
// return (
|
||||
// <Page title={pageTitle}>
|
||||
// <Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
// <HeaderBreadcrumbs
|
||||
// heading={pageTitle}
|
||||
// links={[
|
||||
// {
|
||||
// name: 'Master',
|
||||
// href: '/master',
|
||||
// },
|
||||
// {
|
||||
// name: 'Dokter',
|
||||
// href: '/master/organizations/',
|
||||
// },
|
||||
// {
|
||||
// name: 'Create',
|
||||
// href: '/master/organizations/create/',
|
||||
// },
|
||||
// ]}
|
||||
// />
|
||||
|
||||
// <Grid container spacing={2}>
|
||||
// <Grid item xs={12}>
|
||||
// <Card sx={{ p: 2 }}>
|
||||
// <Form
|
||||
// isSubmitting={isSubmitting}
|
||||
// isEdit={isEdit}
|
||||
// currentOrganizations={currentOrganizations}
|
||||
// />
|
||||
// </Card>
|
||||
// </Grid>
|
||||
// </Grid>
|
||||
// </Container>
|
||||
// </Page>
|
||||
// );
|
||||
// }
|
||||
260
frontend/dashboard/src/pages/EPrescription/Livechat/Form.tsx
Normal file
260
frontend/dashboard/src/pages/EPrescription/Livechat/Form.tsx
Normal file
@@ -0,0 +1,260 @@
|
||||
import * as Yup from 'yup';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
|
||||
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
||||
import * as React 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,
|
||||
Avatar,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Card,
|
||||
FormHelperText,
|
||||
Grid,
|
||||
Stack,
|
||||
Typography,
|
||||
TextField,
|
||||
Chip,
|
||||
} 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 axios from '../../../utils/axios';
|
||||
import { fCurrency } from '../../../utils/formatNumber';
|
||||
import { Practitioner } from '../../../@types/doctor';
|
||||
|
||||
import { Label, Rowing } from '@mui/icons-material';
|
||||
|
||||
const LabelStyle = styled(Typography)(({ theme }) => ({
|
||||
...theme.typography.subtitle2,
|
||||
color: theme.palette.text.secondary,
|
||||
marginBottom: theme.spacing(1),
|
||||
}));
|
||||
|
||||
const HeaderStyle = styled('header')(({ theme }) => ({
|
||||
paddingBottom: theme.spacing(5),
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
}));
|
||||
|
||||
const Title = styled(Typography)(({ theme }) => ({
|
||||
...theme.typography.h4,
|
||||
boxShadow: 'none',
|
||||
// paddingBottom: theme.spacing(3),
|
||||
fontWeight: 700,
|
||||
color: '#005B7F',
|
||||
}));
|
||||
|
||||
interface FormValuesProps extends Partial<Practitioner> {
|
||||
taxes: boolean;
|
||||
inStock: boolean;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
isEdit: boolean;
|
||||
currentPractitioner?: Practitioner;
|
||||
};
|
||||
|
||||
const Span = styled(Typography)(({ theme }) => ({
|
||||
boxShadow: 'none',
|
||||
paddingBottom: theme.spacing(1),
|
||||
}));
|
||||
|
||||
const Text = styled(Typography)(({ theme }) => ({
|
||||
boxShadow: 'none',
|
||||
paddingBottom: theme.spacing(3),
|
||||
}));
|
||||
|
||||
export default function PractitionerForm({ isEdit, currentPractitioner }: Props) {
|
||||
const navigate = useNavigate();
|
||||
const [practitioner_group, setPractitionerGroups] = useState([]);
|
||||
|
||||
// const [ errors, setErrors ] = useState<{ [key: string]: string }>({});
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const NewCorporateSchema = Yup.object().shape({
|
||||
name: Yup.string().required('Name is required'),
|
||||
// file: Yup.boolean().required('Corporate Status is required'),
|
||||
});
|
||||
|
||||
const defaultValues = useMemo(
|
||||
() => ({
|
||||
id: currentPractitioner?.id,
|
||||
name: currentPractitioner?.name || '',
|
||||
address: currentPractitioner?.address || '',
|
||||
birth_date: currentPractitioner?.birth_date || '',
|
||||
gender: currentPractitioner?.gender || '',
|
||||
description: currentPractitioner?.description || '',
|
||||
birth_place: currentPractitioner?.birth_place || '',
|
||||
active: currentPractitioner?.active === 1 ? true : false,
|
||||
avatar_url: currentPractitioner?.avatar_url || '',
|
||||
doctor_id: currentPractitioner?.doctor_id || '',
|
||||
organizations: currentPractitioner?.organizations || [],
|
||||
specialities: currentPractitioner?.specialities || [],
|
||||
}),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[currentPractitioner]
|
||||
);
|
||||
|
||||
console.log('defaultValues', defaultValues);
|
||||
|
||||
function StatusLabel({ value }: { value: boolean }) {
|
||||
return (
|
||||
<Chip
|
||||
label={value ? 'Aktif' : 'Tidak Aktif'}
|
||||
size="medium"
|
||||
sx={{
|
||||
backgroundColor: value ? 'rgba(84, 214, 44, 0.16)' : 'rgba(255, 72, 66, 0.16)',
|
||||
color: value ? '#229A16' : '#B72136',
|
||||
padding: '1 8 1 8 px',
|
||||
borderRadius: '4px',
|
||||
fontSize: '12px',
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
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 && currentPractitioner) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
if (!isEdit) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isEdit, currentPractitioner]);
|
||||
|
||||
const handleActivate = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setValue('active', event.target.checked);
|
||||
|
||||
console.log('event.target.checked', event.target.checked);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('active', event.target.checked ? '1' : '0');
|
||||
formData.append('_method', 'PUT');
|
||||
axios.post('/doctors/' + currentPractitioner?.id ?? '', formData);
|
||||
|
||||
enqueueSnackbar('active Updated Successfully!', { variant: 'success' });
|
||||
};
|
||||
|
||||
return (
|
||||
<FormProvider methods={methods}>
|
||||
<Stack spacing={3}>
|
||||
<Box sx={{ width: '100%' }}>
|
||||
{/* <Stack spacing={3}> */}
|
||||
<Card sx={{ p: 5 }}>
|
||||
<HeaderStyle>
|
||||
<Grid item xs={6} md={6}>
|
||||
<Title>Data Dokter</Title>
|
||||
</Grid>
|
||||
<Grid item xs={6} md={6}>
|
||||
{/* <Typography>Status Rumah Sakit</Typography> */}
|
||||
<RHFSwitch name="active" label="" onClick={handleActivate} />
|
||||
<StatusLabel value={values.active} />
|
||||
</Grid>
|
||||
</HeaderStyle>
|
||||
<Title variant="h5">Informasi Umum</Title>
|
||||
<Avatar
|
||||
alt="Remy Sharp"
|
||||
src={currentPractitioner?.avatar_url}
|
||||
sx={{ width: 120, height: 120, marginBottom: 2 }}
|
||||
/>
|
||||
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid item xs={7}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Nama Dokter</Span>
|
||||
<Text>{currentPractitioner?.name ? currentPractitioner?.name : '-'}</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>No Telp</Span>
|
||||
<Text>{currentPractitioner?.phone ? currentPractitioner?.phone : '-'}</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Tempat Lahir</Span>
|
||||
<Text>
|
||||
{currentPractitioner?.birth_place ? currentPractitioner?.birth_place : '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Alamat</Span>
|
||||
<Text>{currentPractitioner?.address ? currentPractitioner?.address : '-'}</Text>
|
||||
</Grid>
|
||||
<Grid item xs={5} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Jenis Kelamin</Span>
|
||||
<Text>{currentPractitioner?.gender ? currentPractitioner?.gender : '-'}</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Email</Span>
|
||||
<Text>{currentPractitioner?.email ? currentPractitioner?.email : '-'}</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Lahir</Span>
|
||||
<Text>
|
||||
{currentPractitioner?.birth_date ? currentPractitioner?.birth_date : '-'}
|
||||
</Text>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Card>
|
||||
<Card sx={{ p: 5, marginTop: 2 }}>
|
||||
<Title variant="h5">Tempat Praktik</Title>
|
||||
{currentPractitioner?.organizations?.map((item, index) => (
|
||||
<Box key={index} sx={{ mt: 3 }}>
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid item xs={7}>
|
||||
<Text>{item.name}</Text>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
))}
|
||||
</Card>
|
||||
<Card sx={{ p: 5, marginTop: 2 }}>
|
||||
<Title variant="h5">Spesialisasi</Title>
|
||||
{currentPractitioner?.specialities?.map((item, index) => (
|
||||
<Box key={index} sx={{ mt: 3 }}>
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid item xs={7}>
|
||||
<Text>{item.name}</Text>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
))}
|
||||
</Card>
|
||||
</Box>
|
||||
</Stack>
|
||||
</FormProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Card, Grid, Container } 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 Doctor() {
|
||||
const { themeStretch } = useSettings();
|
||||
|
||||
const { id } = useParams();
|
||||
|
||||
const pageTitle = 'E-Prescription';
|
||||
return (
|
||||
<Page title={pageTitle}>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
<HeaderBreadcrumbs
|
||||
heading={pageTitle}
|
||||
links={[
|
||||
{
|
||||
name: ' E-Prescription',
|
||||
href: 'e-prescription/live-chat',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<List />
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
573
frontend/dashboard/src/pages/EPrescription/Livechat/List.tsx
Normal file
573
frontend/dashboard/src/pages/EPrescription/Livechat/List.tsx
Normal file
@@ -0,0 +1,573 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Collapse,
|
||||
Paper,
|
||||
Select,
|
||||
SelectChangeEvent,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableContainer,
|
||||
TableHead,
|
||||
TableRow,
|
||||
TextField,
|
||||
Typography,
|
||||
Stack,
|
||||
ButtonGroup,
|
||||
Grid,
|
||||
Chip,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogActions,
|
||||
FormControl,
|
||||
Autocomplete,
|
||||
InputAdornment,
|
||||
IconButton,
|
||||
} from '@mui/material';
|
||||
|
||||
import {
|
||||
Link,
|
||||
NavLink as RouterLink,
|
||||
useSearchParams,
|
||||
useNavigate,
|
||||
useParams,
|
||||
} from 'react-router-dom';
|
||||
// hooks
|
||||
import React, { ChangeEvent, Component, useEffect, useRef, useState } from 'react';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
// components
|
||||
import axios from '../../../utils/axios';
|
||||
import { LaravelPaginatedData } from '../../../@types/paginated-data';
|
||||
import { Icd } from '../../../@types/diagnosis';
|
||||
import BasePagination from '../../../components/BasePagination';
|
||||
import { Practitioner } from '../../../@types/doctor';
|
||||
import CreateIcon from '@mui/icons-material/Create';
|
||||
import { Props } from '../../../components/editor/index';
|
||||
import { red } from '@mui/material/colors';
|
||||
import { margin, padding } from '@mui/system';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import { Controller } from 'react-hook-form';
|
||||
|
||||
import SvgIconStyle from '../../../components/SvgIconStyle';
|
||||
import { GridSearchIcon } from '@mui/x-data-grid';
|
||||
import { Add, Search } from '@mui/icons-material';
|
||||
import { Icon } from '@iconify/react';
|
||||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||
import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
|
||||
import { RHFDatepicker } from '@/components/hook-form';
|
||||
import { DesktopDatePicker, LocalizationProvider } from '@mui/x-date-pickers';
|
||||
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
|
||||
import { fDateOnly } from '@/utils/formatTime';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
export default function List() {
|
||||
// Generate the every row of the table
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { organization_id } = useParams();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const [searchParamsOrganizations, setSearchParamsOrganizations] = useSearchParams();
|
||||
const [searchParamsSpecialities, setSearchParamsSpecialities] = useSearchParams();
|
||||
const [searchParamsFilter, setSearchParamsFilter] = useSearchParams();
|
||||
|
||||
function Filter(props: any) {
|
||||
// SEARCH
|
||||
const searchInput = useRef<HTMLInputElement>(null);
|
||||
const [searchText, setSearchText] = useState('');
|
||||
|
||||
//handle search
|
||||
const handleSearchChange = (event: any) => {
|
||||
const newSearchText = event.target.value ?? '';
|
||||
setSearchText(newSearchText);
|
||||
};
|
||||
|
||||
const handleSearchSubmit = (event: any) => {
|
||||
event.preventDefault();
|
||||
|
||||
props.onSearch(searchText);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Trigger First Search
|
||||
setSearchText(searchParams.get('search') ?? '');
|
||||
}, []);
|
||||
|
||||
const item = [
|
||||
{
|
||||
id: '',
|
||||
value: '',
|
||||
name: 'Semua',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<form style={{ width: '100%' }}>
|
||||
<Grid container spacing={2} sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<Grid item xs={12} md={6}>
|
||||
<TextField
|
||||
id="search-input"
|
||||
ref={searchInput}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
onChange={handleSearchChange}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Enter') {
|
||||
handleSearchSubmit(event);
|
||||
}
|
||||
}}
|
||||
value={searchText}
|
||||
InputProps={{
|
||||
startAdornment: (
|
||||
<InputAdornment position="start">
|
||||
<Search />
|
||||
</InputAdornment>
|
||||
),
|
||||
placeholder: 'Search',
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
value={searchParams.get('startDate')}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
onChange={(value) => {
|
||||
try {
|
||||
if (value && !!Date.parse(value)) {
|
||||
const date = value ? fDateOnly(value) : '';
|
||||
var entries = [...searchParams.entries(), ['startDate', date ?? '']];
|
||||
if (!searchParams.get('endDate')) {
|
||||
entries = [...entries, ['endDate', date ?? '']];
|
||||
}
|
||||
const filter = Object.fromEntries(entries);
|
||||
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
} catch (e) {}
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} fullWidth label="Start" />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={2}>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DesktopDatePicker
|
||||
value={searchParams.get('endDate')}
|
||||
inputFormat="dd/MM/yyyy"
|
||||
onChange={(value) => {
|
||||
try {
|
||||
if (value && !!Date.parse(value)) {
|
||||
const date = fDateOnly(value);
|
||||
var entries = [...searchParams.entries(), ['endDate', date ?? '']];
|
||||
if (!searchParams.get('startDate')) {
|
||||
entries = [...entries, ['startDate', date ?? '']];
|
||||
}
|
||||
const filter = Object.fromEntries(entries);
|
||||
|
||||
setSearchParams(filter);
|
||||
loadDataTableData(filter);
|
||||
}
|
||||
} catch (e) {}
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
fullWidth
|
||||
label="End"
|
||||
// error={!!error}
|
||||
// helperText={error?.message}
|
||||
// {...other}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
</Grid>
|
||||
<Grid item xs={12} md={2}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
startIcon={<Add />}
|
||||
sx={{ p: 1.8 }}
|
||||
onClick={exportExcel}
|
||||
>
|
||||
Export
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
function FilterForm(props: any) {
|
||||
// IMPORT
|
||||
return (
|
||||
<Grid
|
||||
container
|
||||
spacing={2}
|
||||
sx={{ p: 2, justifyContent: 'space-between', alignItems: 'center' }}
|
||||
>
|
||||
<Grid item xs={12} md={12} lg={12}>
|
||||
<Filter onSearch={applyItems} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
|
||||
function createData(doctor: Practitioner): Practitioner {
|
||||
return {
|
||||
...doctor,
|
||||
};
|
||||
}
|
||||
|
||||
function Row(props: { row: ReturnType<typeof createData> }) {
|
||||
const { row } = props;
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [openDialog, setOpenDialog] = React.useState(false);
|
||||
|
||||
const handleDelete = (model: any) => {
|
||||
axios
|
||||
.delete(`/doctors/${row.id}`)
|
||||
.then((res) => {
|
||||
setDataTableData({
|
||||
...dataTableData,
|
||||
data: dataTableData.data.filter((model) => model.id != row.id),
|
||||
});
|
||||
enqueueSnackbar('Data berhasil dihapus', { variant: 'success' });
|
||||
})
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(
|
||||
error.response.data.message ?? error.message ?? 'Failed Processing Request',
|
||||
{ variant: 'error' }
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<TableRow>
|
||||
<TableCell>
|
||||
<IconButton aria-label="expand row" size="small" onClick={() => setOpen(!open)}>
|
||||
{open ? <KeyboardArrowDownIcon /> : <KeyboardArrowRightIcon />}
|
||||
</IconButton>
|
||||
</TableCell>
|
||||
<TableCell align="left">{row.date_created ? row.date_created : '-'}</TableCell>
|
||||
<TableCell align="left">{row.time_request ? row.time_request : '-'}</TableCell>
|
||||
<TableCell align="left">{row.health_care ? row.health_care : '-'}</TableCell>
|
||||
<TableCell align="left">{row.doctor_name ? row.doctor_name : '-'}</TableCell>
|
||||
<TableCell align="left">{row.speciality ? row.speciality : '-'}</TableCell>
|
||||
<TableCell align="left">{row.pasien_name ? row.pasien_name : '-'}</TableCell>
|
||||
<TableCell align="left">{row.pasien_phone ? row.pasien_phone : '-'}</TableCell>
|
||||
{/* <TableCell align="left">{row.appointment_media ? row.appointment_media : '-'}</TableCell> */}
|
||||
<TableCell align="left">{row.patient_media ? row.patient_media : '-'}</TableCell>
|
||||
<TableCell align="left">{row.doctor_media ? row.doctor_media : '-'}</TableCell>
|
||||
{/* <TableCell align="left">
|
||||
{row.status_appointment ? row.status_appointment : '-'}
|
||||
</TableCell> */}
|
||||
<TableCell align="left">{row.status_chat ? row.status_chat : '-'}</TableCell>
|
||||
<TableCell align="center">
|
||||
<ButtonGroup variant="text" aria-label="text button group">
|
||||
<Link to={'/e-prescription/live-chat/' + row.id + '/show'}>
|
||||
<Button>
|
||||
<Icon icon="ph:eye-bold" style={{ width: '24px', height: '24px' }} />
|
||||
</Button>
|
||||
</Link>
|
||||
</ButtonGroup>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/* COLLAPSIBLE ROW */}
|
||||
<TableRow>
|
||||
<TableCell
|
||||
style={{ paddingBottom: 0, paddingTop: 0, backgroundColor: 'rgba(244, 246, 248, 0.5)' }}
|
||||
colSpan={6}
|
||||
>
|
||||
<Collapse in={open} timeout="auto" unmountOnExit>
|
||||
<Box sx={{ margin: 1, pb: 2, pl: 4 }}>
|
||||
<Grid container>
|
||||
<Grid item xs={12} sx={{ padding: 2 }}>
|
||||
<Grid container>
|
||||
<Grid item xs={6}>
|
||||
Metode Pembayaran
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
: {row.payment_method ? row.payment_method : '-'}
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={6}>
|
||||
Jenis Benefit
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
: -
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
Durasi
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
: {row.duration ? row.duration : '-'}
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
Kode
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
: {row.id ? row.id : '-'}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
</Collapse>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
{/* END COLLAPSIBLE ROW */}
|
||||
<Dialog
|
||||
open={openDialog}
|
||||
onClose={() => {
|
||||
setOpenDialog(false);
|
||||
}}
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogContent sx={{ p: 5 }}>
|
||||
<Icon
|
||||
icon="eva:trash-2-outline"
|
||||
style={{
|
||||
width: '100px',
|
||||
height: '100px',
|
||||
color: '#FF0000',
|
||||
margin: 'auto',
|
||||
display: 'block',
|
||||
marginBottom: '20px',
|
||||
alignContent: 'center',
|
||||
}}
|
||||
/>
|
||||
<DialogContentText sx={{ fontWeight: 'bold', pb: 1 }} id="alert-dialog-title">
|
||||
Apakah anda yakin ingin menghapus
|
||||
</DialogContentText>
|
||||
<Typography sx={{ fontWeight: 'bold' }} id="alert-dialog-title">
|
||||
{row.name}?
|
||||
</Typography>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setOpenDialog(false);
|
||||
}}
|
||||
color="primary"
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
handleDelete(row.id);
|
||||
}}
|
||||
color="primary"
|
||||
autoFocus
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
const headStyle = {
|
||||
fontWeight: 'bold',
|
||||
};
|
||||
// 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('/prescription', {
|
||||
params: filter,
|
||||
});
|
||||
setDataTableLoading(false);
|
||||
setDataTableData(response.data);
|
||||
};
|
||||
|
||||
const exportExcel = async () => {
|
||||
var filter = Object.fromEntries([...searchParams.entries()]);
|
||||
|
||||
await axios
|
||||
.get('live-chat/export', { params: filter })
|
||||
.then((res) => {
|
||||
enqueueSnackbar('Data berhasil di Export', {
|
||||
variant: 'success',
|
||||
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
||||
});
|
||||
|
||||
document.location.href = res.data.data.file_url;
|
||||
})
|
||||
.catch((err) =>
|
||||
enqueueSnackbar('Data Gagal di Export', {
|
||||
variant: 'error',
|
||||
anchorOrigin: { horizontal: 'right', vertical: 'top' },
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
// const applyFilter = async (searchFilter: string) => {
|
||||
// await loadDataTableData({ search: searchFilter });
|
||||
// setSearchParams({ search: searchFilter });
|
||||
// };
|
||||
|
||||
const applyItems = async (
|
||||
searchFilter: string,
|
||||
searchFilterOrganization: string,
|
||||
searchFilterSpecialities: string
|
||||
) => {
|
||||
await loadDataTableData({
|
||||
search: searchFilter,
|
||||
organization_id: searchFilterOrganization,
|
||||
speciality_id: searchFilterSpecialities,
|
||||
});
|
||||
setSearchParamsFilter({
|
||||
search: searchFilter,
|
||||
organization_id: searchFilterOrganization,
|
||||
speciality_id: searchFilterSpecialities,
|
||||
});
|
||||
};
|
||||
|
||||
const handlePageChange = (event: ChangeEvent, value: number) => {
|
||||
const filter = Object.fromEntries([...searchParams.entries(), ['page', value]]);
|
||||
loadDataTableData(filter);
|
||||
setSearchParams(filter);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadDataTableData();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
{/* <Ambulace /> */}
|
||||
|
||||
<Card sx={{ marginTop: '30px' }}>
|
||||
<FilterForm sx={{ marginTop: '100px' }} />
|
||||
|
||||
{/* The Main Table */}
|
||||
<TableContainer component={Paper}>
|
||||
<Table>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
{/* <TableCell colSpan={8} rowSpan={1} align="center" /> */}
|
||||
<TableCell style={headStyle} align="left" />
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Tanggal
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Waktu
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Faskes
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Nama Dokter
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Spesialisasi
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Nama Pasien
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
No Telepon Pasien
|
||||
</TableCell>
|
||||
{/* <TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Appointment Via App/Website
|
||||
</TableCell> */}
|
||||
<TableCell
|
||||
colSpan={2}
|
||||
style={headStyle}
|
||||
align="center"
|
||||
sx={{ borderBottom: '3px solid #d7d7d7' }}
|
||||
>
|
||||
Chat Via App/Website
|
||||
</TableCell>
|
||||
{/* <TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Status Appointment
|
||||
</TableCell> */}
|
||||
<TableCell style={headStyle} rowSpan={2} align="left">
|
||||
Status
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TableCell style={headStyle} align="left" />
|
||||
{/* <TableCell style={headStyle} align="left">
|
||||
Tanggal Booking
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Tanggal Appointment
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Faskes
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Nama Dokter
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Spesialisasi
|
||||
</TableCell> */}
|
||||
<TableCell style={headStyle} align="left">
|
||||
Pasien
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
Dokter
|
||||
</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>
|
||||
);
|
||||
}
|
||||
52
frontend/dashboard/src/pages/EPrescription/Livechat/Show.tsx
Normal file
52
frontend/dashboard/src/pages/EPrescription/Livechat/Show.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { paramCase } from 'change-case';
|
||||
import { useParams, useLocation } from 'react-router-dom';
|
||||
// @mui
|
||||
import { Container, Stack } from '@mui/material';
|
||||
import useSettings from '../../../hooks/useSettings';
|
||||
import Page from '../../../components/Page';
|
||||
import View from './View';
|
||||
import HeaderBreadcrumbs from '../../../components/HeaderBreadcrumbs';
|
||||
import axios from '../../../utils/axios';
|
||||
import { Appointment } from '../../../@types/doctor';
|
||||
|
||||
export default function Create() {
|
||||
const { themeStretch } = useSettings();
|
||||
const { id } = useParams();
|
||||
|
||||
const isEdit = id ? true : false;
|
||||
|
||||
const [currentAppointment, setCurrentAppointment] = useState<Appointment>();
|
||||
|
||||
useEffect(() => {
|
||||
if (isEdit) {
|
||||
axios.get('/live-chat/' + id).then((res) => {
|
||||
setCurrentAppointment(res.data);
|
||||
});
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
return (
|
||||
<Page title="E-Prescription">
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
<Stack direction="row" alignItems="center">
|
||||
<HeaderBreadcrumbs
|
||||
heading={!isEdit ? 'E-Prescription' : 'E-Prescription'}
|
||||
links={[
|
||||
{
|
||||
name: 'E-Prescription',
|
||||
href: 'e-prescription/live-chat',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<View
|
||||
// isSubmitting={isSubmitting}
|
||||
isEdit={isEdit}
|
||||
currentAppointment={currentAppointment}
|
||||
/>
|
||||
</Container>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
614
frontend/dashboard/src/pages/EPrescription/Livechat/View.tsx
Normal file
614
frontend/dashboard/src/pages/EPrescription/Livechat/View.tsx
Normal file
@@ -0,0 +1,614 @@
|
||||
import * as Yup from 'yup';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
|
||||
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
||||
import * as React from 'react';
|
||||
|
||||
// form
|
||||
import {useFieldArray, 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,
|
||||
Autocomplete,
|
||||
Avatar,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Card,
|
||||
FormHelperText,
|
||||
Grid,
|
||||
Stack,
|
||||
Typography,
|
||||
TextField,
|
||||
Chip,
|
||||
Badge,
|
||||
Divider,
|
||||
} 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 axios from '../../../utils/axios';
|
||||
import { fCurrency } from '../../../utils/formatNumber';
|
||||
import { Appointment } from '../../../@types/doctor';
|
||||
import RHFTextFieldMoney from "@/components/hook-form/v2/RHFTextFieldMoney";
|
||||
|
||||
import { Label, Rowing, Spa } from '@mui/icons-material';
|
||||
import { border, padding } from '@mui/system';
|
||||
import { IconButton } from '@mui/material';
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
import RemoveIcon from '@mui/icons-material/Remove';
|
||||
|
||||
const LabelStyle = styled(Typography)(({ theme }) => ({
|
||||
...theme.typography.subtitle2,
|
||||
color: theme.palette.text.secondary,
|
||||
marginBottom: theme.spacing(1),
|
||||
}));
|
||||
|
||||
const HeaderStyle = styled('header')(({ theme }) => ({
|
||||
paddingBottom: theme.spacing(5),
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
}));
|
||||
|
||||
const Title = styled(Typography)(({ theme }) => ({
|
||||
...theme.typography.h4,
|
||||
boxShadow: 'none',
|
||||
// paddingBottom: theme.spacing(3),
|
||||
fontWeight: 700,
|
||||
color: '#005B7F',
|
||||
}));
|
||||
|
||||
interface FormValuesProps extends Partial<Appointment> {
|
||||
taxes: boolean;
|
||||
inStock: boolean;
|
||||
}
|
||||
|
||||
type Props = {
|
||||
isEdit: boolean;
|
||||
currentAppointment?: Appointment;
|
||||
};
|
||||
|
||||
const Span = styled(Typography)(({ theme }) => ({
|
||||
boxShadow: 'none',
|
||||
paddingBottom: theme.spacing(1),
|
||||
}));
|
||||
|
||||
const Text = styled(Typography)(({ theme }) => ({
|
||||
boxShadow: 'none',
|
||||
paddingBottom: theme.spacing(3),
|
||||
}));
|
||||
|
||||
export default function AppointmentForm({ isEdit, currentAppointment }: 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'),
|
||||
// file: Yup.boolean().required('Corporate Status is required'),
|
||||
});
|
||||
|
||||
const defaultValues = useMemo(
|
||||
() => ({
|
||||
id: currentAppointment?.id,
|
||||
name: currentAppointment?.name || '',
|
||||
address: currentAppointment?.address || '',
|
||||
birth_date: currentAppointment?.birth_date || '',
|
||||
gender: currentAppointment?.gender || '',
|
||||
description: currentAppointment?.description || '',
|
||||
birth_place: currentAppointment?.birth_place || '',
|
||||
active: currentAppointment?.active === 1 ? true : false,
|
||||
avatar_url: currentAppointment?.avatar_url || '',
|
||||
doctor_id: currentAppointment?.doctor_id || '',
|
||||
organizations: currentAppointment?.organizations || [],
|
||||
specialities: currentAppointment?.specialities || [],
|
||||
diagnosis: currentAppointment?.diagnosis || '',
|
||||
hospital: currentAppointment?.hospital || '',
|
||||
medicine : [{
|
||||
id: 0,
|
||||
drug_id: 0,
|
||||
qty: 0,
|
||||
signa: '',
|
||||
unit_id: 0,
|
||||
note: '', // input to database
|
||||
}],
|
||||
}),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[currentAppointment]
|
||||
);
|
||||
|
||||
|
||||
const methods = useForm<FormValuesProps>({
|
||||
// resolver: yupResolver(NewCorporateSchema),
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
const {fields, append, remove} = useFieldArray({name: 'medicine',control: methods.control})
|
||||
|
||||
// Autocomplite ICD
|
||||
const [icdOptions, setIcdOptions] = useState([
|
||||
{ value: '-', label: '-' }
|
||||
]);
|
||||
const [selectedIcdOptions, setSelectedIcdOptions] = useState([]);
|
||||
useEffect(() => {
|
||||
const selectedCodes = icdOptions.filter((icd) => {
|
||||
// Logika pemilihan sesuai kebutuhan
|
||||
});
|
||||
setSelectedIcdOptions(selectedCodes);
|
||||
}, [icdOptions]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
// Ambil data dari API dan atur opsi ICD
|
||||
axios.get('diagnosis')
|
||||
.then((response) => {
|
||||
setIcdOptions(response.data.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error fetching ICD options:', error);
|
||||
});
|
||||
}, []); // useEffect dijalankan hanya sekali saat komponen dimount
|
||||
|
||||
|
||||
|
||||
// Autocomplite Rumah Sakit
|
||||
const [hospitalOptions, setHospitalOptions] = useState([]);
|
||||
const [selectedHospitalOption, setSelectedHospitalOption] = useState(null);
|
||||
|
||||
// Ambil data dari API dan atur opsi rumah sakit
|
||||
useEffect(() => {
|
||||
axios.get('hospitals')
|
||||
.then((response) => {
|
||||
setHospitalOptions(response.data.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error fetching hospital options:', error);
|
||||
});
|
||||
}, []); // useEffect dijalankan hanya sekali saat komponen dimount
|
||||
|
||||
// Set default value saat hospitalOptions berubah
|
||||
useEffect(() => {
|
||||
if (hospitalOptions.length > 0 && !selectedHospitalOption) {
|
||||
setSelectedHospitalOption({value: '-', label: '-'});
|
||||
}
|
||||
}, [hospitalOptions, selectedHospitalOption]);
|
||||
|
||||
// Autocomplite drugs
|
||||
const [drugOptions, setDrugsOptions] = useState([]);
|
||||
const [selectedDrugsOptions, setSelectedDrugsOptions] = useState({});
|
||||
|
||||
const handleAutocompleteChange = (newValue, index) => {
|
||||
setSelectedDrugsOptions((prevState) => ({
|
||||
...prevState,
|
||||
[index]: newValue
|
||||
}));
|
||||
setValue(`medicine.${index}.drug_id`, newValue ? newValue.value : '');
|
||||
};
|
||||
|
||||
// Ambil data dari API dan atur opsi rumah sakit
|
||||
useEffect(() => {
|
||||
axios.get('drugs')
|
||||
.then((response) => {
|
||||
setDrugsOptions(response.data.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error fetching drug options:', error);
|
||||
});
|
||||
}, []); // useEffect dijalankan hanya sekali saat komponen dimount
|
||||
|
||||
// Autocomplite unit
|
||||
const [unitOptions, setUnitsOptions] = useState([]);
|
||||
const [selectedUnitsOptions, setSelectedUnitsOptions] = useState({});
|
||||
|
||||
const handleAutocompleteChangeUnit = (newValue, index) => {
|
||||
setSelectedUnitsOptions((prevState) => ({
|
||||
...prevState,
|
||||
[index]: newValue
|
||||
}));
|
||||
setValue(`medicine.${index}.unit_id`, newValue ? newValue.value : '');
|
||||
};
|
||||
|
||||
// Ambil data dari API dan atur opsi rumah sakit
|
||||
useEffect(() => {
|
||||
axios.get('units')
|
||||
.then((response) => {
|
||||
setUnitsOptions(response.data.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error fetching unit options:', error);
|
||||
});
|
||||
}, []); // useEffect dijalankan hanya sekali saat komponen dimount
|
||||
|
||||
|
||||
const {
|
||||
reset,
|
||||
watch,
|
||||
control,
|
||||
setValue,
|
||||
getValues,
|
||||
setError,
|
||||
handleSubmit,
|
||||
formState: { isSubmitting },
|
||||
} = methods;
|
||||
|
||||
const values = watch();
|
||||
|
||||
useEffect(() => {
|
||||
if (isEdit && currentAppointment) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
if (!isEdit) {
|
||||
reset(defaultValues);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isEdit, currentAppointment]);
|
||||
|
||||
const onSubmit = async (data: FormValuesProps) => {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('id', data.id);
|
||||
formData.append('diagnosis', data.diagnosis);
|
||||
formData.append('hospital', data.hospital);
|
||||
|
||||
// Iterasi melalui setiap objek dalam array medicine dan menambahkannya ke FormData
|
||||
data.medicine.forEach((medicineObj, index) => {
|
||||
// Anda dapat menambahkan setiap properti dari objek medicine ke FormData
|
||||
formData.append(`medicine[${index}][drug_id]`, medicineObj.drug_id);
|
||||
formData.append(`medicine[${index}][qty]`, medicineObj.qty);
|
||||
formData.append(`medicine[${index}][unit_id]`, medicineObj.unit_id);
|
||||
formData.append(`medicine[${index}][signa]`, medicineObj.signa);
|
||||
formData.append(`medicine[${index}][note]`, medicineObj.note);
|
||||
});
|
||||
|
||||
|
||||
const response = await axios.post('/prescription', formData);
|
||||
reset();
|
||||
enqueueSnackbar('Berhasil menambahkan resep', {
|
||||
variant: 'success',
|
||||
});
|
||||
navigate('/e-prescription/live-chat');
|
||||
} catch (error: any) {
|
||||
console.log(error, 'submit')
|
||||
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
|
||||
}
|
||||
|
||||
const ascent = document?.querySelector('ascent');
|
||||
if (ascent != null) {
|
||||
ascent.innerHTML = '';
|
||||
}
|
||||
};
|
||||
return (
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<Stack spacing={3}>
|
||||
<Box sx={{ width: '100%' }}>
|
||||
{/* <Stack spacing={3}> */}
|
||||
<Card sx={{ p: 5 }}>
|
||||
<HeaderStyle>
|
||||
<Grid item xs={6} md={6}>
|
||||
<Stack
|
||||
direction="row"
|
||||
divider={<Divider orientation="vertical" flexItem />}
|
||||
spacing={2}
|
||||
>
|
||||
<Title>Data Live Chat</Title>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</HeaderStyle>
|
||||
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid item xs={12}>
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Stack direction="row" spacing={2} alignItems="center">
|
||||
<Span style={{ fontWeight: 'bold', paddingBottom: '0px' }}>
|
||||
Status Appointment :
|
||||
</Span>
|
||||
<Chip
|
||||
label={
|
||||
currentAppointment?.status_appointment
|
||||
? currentAppointment?.status_appointment
|
||||
: '-'
|
||||
}
|
||||
variant="outlined"
|
||||
/>
|
||||
</Stack>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Stack direction="row" spacing={2} alignItems="center">
|
||||
<Span style={{ fontWeight: 'bold', paddingBottom: '0px' }}>
|
||||
Status Chat :
|
||||
</Span>
|
||||
<Chip
|
||||
label={
|
||||
currentAppointment?.status_chat ? currentAppointment?.status_chat : '-'
|
||||
}
|
||||
variant="outlined"
|
||||
/>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</Grid>
|
||||
<Grid item xs={12} sx={{ marginTop: '20px' }}>
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Booking :</Span>
|
||||
<Text>
|
||||
{currentAppointment?.date_created ? currentAppointment?.date_created : '-'}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Stack direction="row" spacing={2}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Tanggal Appointment :</Span>
|
||||
<Text>
|
||||
{currentAppointment?.date_appointment
|
||||
? currentAppointment?.date_appointment
|
||||
: '-'}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={6}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Nama Dokter</Span>
|
||||
<Text>
|
||||
{currentAppointment?.doctor_name ? currentAppointment?.doctor_name : '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Faskes</Span>
|
||||
<Text>
|
||||
{currentAppointment?.health_care ? currentAppointment?.health_care : '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Durasi</Span>
|
||||
<Text>{currentAppointment?.duration ? currentAppointment?.duration : '-'}</Text>
|
||||
</Grid>
|
||||
<Grid item xs={6} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Spesialis</Span>
|
||||
<Text>{currentAppointment?.speciality ? currentAppointment?.speciality : '-'}</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Appointment Via Web/App</Span>
|
||||
<Text>
|
||||
{currentAppointment?.appointment_media
|
||||
? currentAppointment?.appointment_media
|
||||
: '-'}
|
||||
</Text>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Card>
|
||||
<Card sx={{ mt: 5, p: 5 }}>
|
||||
<HeaderStyle>
|
||||
<Grid item xs={6} md={6}>
|
||||
<Title>Data Pembayaran</Title>
|
||||
</Grid>
|
||||
</HeaderStyle>
|
||||
|
||||
{currentAppointment?.payment_detail !== null ? (
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid item xs={6}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Metode Pembayaran</Span>
|
||||
<Text>
|
||||
{currentAppointment?.payment_method ? currentAppointment?.payment_method : '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Harga</Span>
|
||||
<Text>
|
||||
{currentAppointment?.payment_detail?.gross_amount
|
||||
? currentAppointment?.payment_detail?.gross_amount
|
||||
: '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Mata Uang</Span>
|
||||
<Text>
|
||||
{currentAppointment?.payment_detail?.currency
|
||||
? currentAppointment?.payment_detail?.currency
|
||||
: '-'}
|
||||
</Text>
|
||||
</Grid>
|
||||
<Grid item xs={6} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Tipe Pembayaran</Span>
|
||||
<Text>
|
||||
{currentAppointment?.payment_detail?.payment_type
|
||||
? currentAppointment?.payment_detail?.payment_type
|
||||
: '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Waktu Transaksi</Span>
|
||||
<Text>
|
||||
{currentAppointment?.payment_detail?.transaction_time
|
||||
? currentAppointment?.payment_detail?.transaction_time
|
||||
: '-'}
|
||||
</Text>
|
||||
<Span style={{ fontWeight: 'bold' }}>Status</Span>
|
||||
<Text>
|
||||
{currentAppointment?.payment_detail?.status_message
|
||||
? currentAppointment?.payment_detail?.status_message
|
||||
: '-'}
|
||||
</Text>
|
||||
</Grid>
|
||||
</Grid>
|
||||
) : (
|
||||
<Span>Belum ada pembayaran</Span>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card sx={{ mt: 5, p: 5 }}>
|
||||
<HeaderStyle>
|
||||
<Grid item xs={12} md={12}>
|
||||
<Title>E-Prescription</Title>
|
||||
</Grid>
|
||||
</HeaderStyle>
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
|
||||
<Grid item xs={12} columnSpacing={{ xs: 1, sm: 2, md: 3 }} sx={{marginBottom: 4}}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Diagnosa</Span>
|
||||
<Autocomplete
|
||||
multiple
|
||||
options={icdOptions}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={selectedIcdOptions}
|
||||
onChange={(e, newValues) => {
|
||||
const selectedCodes = newValues.map((value) => value.value);
|
||||
setValue('diagnosis', selectedCodes);
|
||||
setSelectedIcdOptions(newValues);
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="Diagnosis ICD - X"
|
||||
variant="outlined"
|
||||
// required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12} columnSpacing={{ xs: 1, sm: 2, md: 3 }} sx={{marginBottom: 4}}>
|
||||
<Span style={{ fontWeight: 'bold' }}>Rumah Sakit</Span>
|
||||
<Autocomplete
|
||||
options={hospitalOptions}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={selectedHospitalOption}
|
||||
onChange={(e, newValue) => {
|
||||
setSelectedHospitalOption(newValue);
|
||||
setValue('hospital', newValue ? newValue.value : ''); // Simpan nilai rumah sakit
|
||||
}}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="Rumah Sakit"
|
||||
variant="outlined"
|
||||
// required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Stack direction="row" alignItems="center" sx={{marginBottom: 4}}>
|
||||
<Typography variant='subtitle1' gutterBottom>Obat</Typography>
|
||||
<Button color="inherit" variant="outlined" startIcon={<AddIcon/>} sx={{marginLeft: 'auto'}} onClick={() => append({medicine_name: '', medicine_price: 0, request_log_id: 1 })}>
|
||||
<Typography variant="button" display="block">Obat</Typography>
|
||||
</Button>
|
||||
</Stack>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={12}>
|
||||
{fields.map((field, index) => (
|
||||
<Grid container spacing={2} key={index} sx={{ marginBottom: '15px' }}>
|
||||
<Grid item xs={3}>
|
||||
<Autocomplete
|
||||
options={drugOptions}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={selectedDrugsOptions[index] || null}
|
||||
onChange={(e, newValue) => handleAutocompleteChange(newValue, index)}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="Drugs"
|
||||
variant="outlined"
|
||||
required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={1}>
|
||||
<RHFTextField
|
||||
id={`qty_${index}`}
|
||||
name={`medicine.${index}.qty`}
|
||||
label="Qty"
|
||||
required
|
||||
type="number"
|
||||
placeholder="Qty"
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={2}>
|
||||
<Autocomplete
|
||||
options={unitOptions}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={selectedUnitsOptions[index] || null}
|
||||
onChange={(e, newValue) => handleAutocompleteChangeUnit(newValue, index)}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="Units"
|
||||
variant="outlined"
|
||||
required
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={2}>
|
||||
<RHFTextField
|
||||
id={`signa_${index}`}
|
||||
name={`medicine.${index}.signa`}
|
||||
label="Signa"
|
||||
required
|
||||
placeholder="Signa"
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={3}>
|
||||
<RHFTextField
|
||||
id={`note_${index}`}
|
||||
name={`medicine.${index}.note`}
|
||||
label="Note"
|
||||
required
|
||||
placeholder="Note"
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
{index !== fields.length - 1 && (
|
||||
<Grid item xs={1} sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
<IconButton size='large' color='error' onClick={() => remove(index)}>
|
||||
<RemoveIcon />
|
||||
</IconButton>
|
||||
</Grid>
|
||||
)}
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
<Grid item xs={12} md={12} sx={{ display: 'flex', justifyContent: 'flex-end' }}>
|
||||
<LoadingButton
|
||||
sx={{ boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)' }}
|
||||
type="submit"
|
||||
variant="contained"
|
||||
size="large"
|
||||
loading={isSubmitting}
|
||||
>
|
||||
{!isEdit ? 'Save' : 'Save'}
|
||||
</LoadingButton>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Card>
|
||||
</Box>
|
||||
</Stack>
|
||||
</FormProvider>
|
||||
);
|
||||
}
|
||||
@@ -188,6 +188,8 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
// formData.append('active', data.active ? '1' : '0');
|
||||
forms.forEach((form, index) => {
|
||||
formData.append(`practices[${index}][organization_id]`, form.organizationId);
|
||||
formData.append(`practices[${index}][period_start]`, form.periodStart);
|
||||
formData.append(`practices[${index}][period_end]`, form.periodEnd);
|
||||
form.specialities.forEach((speciality, i) => {
|
||||
formData.append(`practices[${index}][specialities][${i}][speciality_id]`, speciality);
|
||||
});
|
||||
@@ -225,6 +227,7 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
|
||||
const [organizations, setOrganizations] = useState<any>([]);
|
||||
const [specialities, setSpecialities] = useState<any>([]);
|
||||
const [price, setPrice] = useState<any>([]);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get(`/search-organizations`).then((response) => {
|
||||
@@ -281,6 +284,8 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
return {
|
||||
organizationId: practice.organization_id,
|
||||
specialities: practice.specialities.map((s) => s.speciality_id),
|
||||
periodStart: practice.period_start,
|
||||
periodEnd: practice.period_end,
|
||||
};
|
||||
});
|
||||
setForms(newForms);
|
||||
@@ -289,6 +294,9 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
{
|
||||
organizationId: '',
|
||||
specialities: [],
|
||||
periodStart: '',
|
||||
periodEnd: '',
|
||||
|
||||
},
|
||||
]);
|
||||
}
|
||||
@@ -333,6 +341,8 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
...forms,
|
||||
{
|
||||
organizationId: '',
|
||||
periodStart: '',
|
||||
periodEnd: '',
|
||||
specialities: [],
|
||||
},
|
||||
]);
|
||||
@@ -397,6 +407,8 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
setForms(updatedForms);
|
||||
};
|
||||
|
||||
console.log(forms, 'forms')
|
||||
|
||||
return (
|
||||
<FormProvider methods={methods} onSubmit={handleSubmit(onSubmit)}>
|
||||
<Stack spacing={3}>
|
||||
@@ -492,7 +504,6 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
value={findValueOrganization(form.organizationId) ?? ''}
|
||||
getOptionLabel={(option) => option.name}
|
||||
isOptionEqualToValue={(option, value) => {
|
||||
console.log(value, option, 'test')
|
||||
return option.value === value.value
|
||||
}
|
||||
}
|
||||
@@ -541,6 +552,23 @@ export default function PractitionerForm({ isEdit, currentPractitioner }: Props)
|
||||
)}
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container rowSpacing={1} columnSpacing={{ xs: 1, sm: 2, md: 3 }}>
|
||||
<Grid item xs={6}>
|
||||
<LabelStyle>Period Start</LabelStyle>
|
||||
<RHFDatepicker
|
||||
name={`period_start`}
|
||||
placeholder="Silahkan Pilih Tanggal Mulai"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={6}>
|
||||
<LabelStyle>Period End</LabelStyle>
|
||||
<RHFDatepicker
|
||||
name={`period_end`}
|
||||
placeholder="Silahkan Pilih Tanggal Selesai" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -511,6 +511,18 @@ export default function Router() {
|
||||
path: 'custormer-service/final-log/detail/:id',
|
||||
element: <FinalLogDetail />,
|
||||
},
|
||||
{
|
||||
path: 'e-prescription/live-chat',
|
||||
element: <EPrescription />,
|
||||
},
|
||||
{
|
||||
path: 'e-prescription/live-chat/:id',
|
||||
element: <EPrescriptionCreate />,
|
||||
},
|
||||
{
|
||||
path: 'e-prescription/live-chat/:id/show',
|
||||
element: <EPrescriptionShow />,
|
||||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
@@ -672,6 +684,11 @@ const Livechat = Loadable(lazy(() => import('../pages/Report/Livechat/Index')));
|
||||
const LivechatCreate = Loadable(lazy(() => import('../pages/Report/Livechat/Create')));
|
||||
const LivechatShow = Loadable(lazy(() => import('../pages/Report/Livechat/Show')));
|
||||
|
||||
|
||||
const EPrescription = Loadable(lazy(() => import('../pages/EPrescription/Livechat/Index')));
|
||||
const EPrescriptionCreate = Loadable(lazy(() => import('../pages/EPrescription/Livechat/Create')));
|
||||
const EPrescriptionShow = Loadable(lazy(() => import('../pages/EPrescription/Livechat/Show')));
|
||||
|
||||
const LinksehatPayment = Loadable(lazy(() => import('../pages/Report/LinksehatPayments/Index')));
|
||||
|
||||
const MasterDrug = Loadable(lazy(() => import('../pages/Master/Drug/Index')));
|
||||
|
||||
Reference in New Issue
Block a user