diff --git a/Modules/Internal/Http/Controllers/Api/CorporateController.php b/Modules/Internal/Http/Controllers/Api/CorporateController.php index 304e1ebe..a8fc5dbd 100644 --- a/Modules/Internal/Http/Controllers/Api/CorporateController.php +++ b/Modules/Internal/Http/Controllers/Api/CorporateController.php @@ -563,6 +563,12 @@ class CorporateController extends Controller "file_url" => url('files/Template Format Claim.xlsx') ]); break; + case 'request-log': + return Helper::responseJson([ + 'file_name' => "Template Update Status Request LOG.xlsx", + "file_url" => url('files/Template Update Status Request LOG.xlsx') + ]); + break; default: return Helper::responseJson([], 'error', 404); break; diff --git a/Modules/Internal/Http/Controllers/Api/RequestLogController.php b/Modules/Internal/Http/Controllers/Api/RequestLogController.php index 6f9078bc..23a99492 100644 --- a/Modules/Internal/Http/Controllers/Api/RequestLogController.php +++ b/Modules/Internal/Http/Controllers/Api/RequestLogController.php @@ -16,6 +16,12 @@ use Illuminate\Support\Facades\Storage; use App\Services\RequestLogService; use App\Exceptions\ImportRowException; use App\Events\RequestLoged; + +use Maatwebsite\Excel\Facades\Excel; +use Box\Spout\Reader\Common\Creator\ReaderEntityFactory; +use Box\Spout\Writer\Common\Creator\WriterEntityFactory; + + use Exception; use PDF; @@ -207,7 +213,7 @@ class RequestLogController extends Controller } /** - * Generate Request LOG + * Generate Request LOG PDF */ public function generateRequestLog($id) { @@ -238,6 +244,55 @@ class RequestLogController extends Controller return $requestLog; } + /** + * Generate Export Excel Request LOG + */ + + public function generateDataRequestLogExcel(){ + $file_name = 'Data Request LOG'; + // Membuat penulis entitas Spout + $writer = WriterEntityFactory::createXLSXWriter(); + // Membuka penulis untuk menulis ke file + $writer->openToFile(public_path('files/Data Request LOG.xlsx')); + + // Sheet 1 + $writer->getCurrentSheet()->setName('Data'); + $headers_map_to_table_fields = RequestLog::$listing_data_doc_headers; + $headerRow = WriterEntityFactory::createRowFromArray($headers_map_to_table_fields); + $writer->addRow($headerRow); + + $dataRequestLog = RequestLog::query() + // ->whereHas('corporatePlan', function ($corporatePlan) use ($corporate_id) { + // $corporatePlan->where('corporate_id', $corporate_id); + // }) + ->with('member') + ->orderBy('id', 'desc') + ->get()->toArray(); + + // dd($dataRequestLog); + foreach ($dataRequestLog as $index => $row){ + $serviceType = $this->getServiceName($row['service_code']); + + $rowData = [ + $row['id'], // id + $row['code'], // code + $row['member']['name'], // name + $row['submission_date'], // submission date + $serviceType, // service type + $row['payment_type_name'], // service type + $row['status'], // service type + ]; + $row = WriterEntityFactory::createRowFromArray($rowData); + $writer->addRow($row); + } + $writer->close(); + + return Helper::responseJson([ + 'file_name' => "Data Request Log " . date('Y-m-d h:i:s'), + "file_url" => url('files/Data Request LOG.xlsx') + ]); + } + public function updateFinalLog(Request $request, $id) { $requestLog = RequestLog::findOrFail($id); @@ -350,7 +405,7 @@ class RequestLogController extends Controller } - public function importClaim(Request $request) + public function importRequestLog(Request $request) { $request->validate([ @@ -398,38 +453,20 @@ class RequestLogController extends Controller $row_data[$headers_map_to_table_fields[$doc_headers_indexes[$header_index]]] = $cell->getValue(); } try { // Process the Row Data - $claimRequestService = new RequestLogService(); + $requestLog = new RequestLogService(); - $claimRequestService->handleRequestLogRow($row_data); + $requestLog->handleRequestLogRow($row_data); - // Write Success Result to File - // $import->read($fileRead); - // $import->write($fileWrite, 'xsls'); $result_headers = array_merge($row_data, ['Ingest Code' =>200, 'Ingest Note' => 'Success']); $import->addArrayToRow($result_headers, $sheet->getName()); } catch (ImportRowException $e) { - // Write Data Validation Error to File - // $import->read($fileRead); - // $import->write($fileWrite, 'xsls'); - $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->read($fileRead); - // // $import->write($fileWrite, 'xsls'); - // dd( $e->getMessage()); - // $import->addArrayToRow(array_merge($row_data, [ - // 'Ingest Code' => 500, - // 'Ingest Note' => env('APP_DEBUG') ? $e->getMessage() : 'Server Error', - // ]), $sheet->getName()); - // } } } } @@ -623,6 +660,15 @@ class RequestLogController extends Controller return $service; } + public function getServiceName($code){ + $service = DB::table('services') + ->select('name') + ->where('code', $code) + ->get() + ->first(); + return $service->name; + } + public static function getNextCode(Request $request) { // $last_number = RequestLog::max('code'); diff --git a/Modules/Internal/Routes/api.php b/Modules/Internal/Routes/api.php index a2f2821a..1977019a 100644 --- a/Modules/Internal/Routes/api.php +++ b/Modules/Internal/Routes/api.php @@ -252,6 +252,10 @@ Route::prefix('internal')->group(function () { Route::post('customer-service/request', [RequestLogController::class, 'createNew']); Route::put('customer-service/request/{id}', [RequestLogController::class, 'update']); Route::get('customer-service/request/{id}/download', [RequestLogController::class, 'generateRequestLog']); + Route::post('customer-service/request/import', [RequestLogController::class, 'importRequestLog']); + Route::get('customer-service/request/data', [RequestLogController::class, 'generateDataRequestLogExcel']); + + Route::get('search-organizations', [OrganizationController::class, 'searchOrganization']); Route::get('search-specialities', [SpecialityController::class, 'searchSpeciality']); diff --git a/app/Models/RequestLog.php b/app/Models/RequestLog.php index 7e89fa94..827cd846 100644 --- a/app/Models/RequestLog.php +++ b/app/Models/RequestLog.php @@ -41,69 +41,23 @@ class RequestLog extends Model ]; public static $doc_headers_to_field_map = [ - "PAYOR ID" => "payor_id", - "CORPORATE ID" => "corporate_id", - "POLICY NUMBER" => "policy_number", - "MEMBER ID" => "member_id", - "MEMBER NAME" => "member_name", - "RECORD TYPE (P/D)" => "record_type", - "BENEFIT CODE" => "benefit_code", - "BENEFIT DESC" => "benefit_desc", - "CLAIM TYPE" => "claim_type", - "CLAIM PROCESS STATUS" => "status", - "CLIENT CLAIM ID" => "client_claim_id", - "REFERENCE NO" => "reference_no", - "ADMEDIKA CLAIM ID" => "admika_claim_id", - "PROVIDER CODE" => "provider_code", - "ADMISSION DATE" => "admission_date", - "DISCUTRGE DATE" => "discutrge_date", - "DURATION DAYS" => "duration_days", - "COVERAGE TYPE" => "coverage_type", - "PLAN ID" => "plan_id", - "DIAGNOSIS CODE" => "diagnosis_code", - "DIAGNOSIS DESC" => "diagnosis_desc", - "TOT AMT INCURRED" => "tot_amt_insurred", - "TOT AMT APPROVED" => "tot_amt_approved", - "TOT AMT NOT APPROVED" => "tot_amt_not_approved", - "TOT EXCESS PAID" => "tot_excess_paid", - "REMARKS" => "remarks", - "SECONDARY DIAGNOSIS CODE" => "secondary_diagnosis", - "APPROVED DATE" => "approved_date", - "APPROVED BY" => "approved_by", - "DATE RECEIVED" => "data_received", - "HOSPITAL INVOICE DATE" => "hospital_invoice_date", + "ID REQUEST LOG" => "id", + "STATUS (approved, declined, requested)" => "status", ]; public static $listing_doc_headers = [ - "PAYOR ID", - "CORPORATE ID", - "POLICY NUMBER", - "MEMBER ID", - "MEMBER NAME", - "RECORD TYPE (P/D)", - "CLAIM TYPE", - "CLAIM PROCESS STATUS", - "CLIENT CLAIM ID", - "REFERENCE NO", - "ADMEDIKA CLAIM ID", - "PROVIDER CODE", - "ADMISSION DATE", - "DISCUTRGE DATE", - "DURATION DAYS", - "COVERAGE TYPE", - "PLAN ID", - "DIAGNOSIS CODE", - "DIAGNOSIS DESC", - "TOT AMT INCURRED", - "TOT AMT APPROVED", - "TOT AMT NOT APPROVED", - "TOT EXCESS PAID", - "REMARKS", - "SECONDARY DIAGNOSIS CODE", - "APPROVED DATE", - "APPROVED BY", - "DATE RECEIVED", - "HOSPITAL INVOICE DATE", + "ID REQUEST LOG", + "STATUS (approved, declined, requested)", + ]; + + public static $listing_data_doc_headers = [ + "ID REQUEST LOG", + "CODE", + "NAME", + "DATE OF SUBMISSION", + "SERVICE TYPE", + "CLAIM METHOD", + "STATUS", ]; diff --git a/frontend/dashboard/src/pages/CustomerService/FinalLog/List.tsx b/frontend/dashboard/src/pages/CustomerService/FinalLog/List.tsx index 24645d01..ece99d47 100644 --- a/frontend/dashboard/src/pages/CustomerService/FinalLog/List.tsx +++ b/frontend/dashboard/src/pages/CustomerService/FinalLog/List.tsx @@ -348,9 +348,10 @@ export default function List() { // handleShowClaim(row); // }} > - {row.code} + {row.id} + {row.member?.code} {row.member?.full_name} {row.service_name} @@ -470,6 +471,9 @@ export default function List() { {/* */} + + ID Request LOG + Code diff --git a/frontend/dashboard/src/pages/CustomerService/Request/List.tsx b/frontend/dashboard/src/pages/CustomerService/Request/List.tsx index 887d67a2..4e9927a1 100644 --- a/frontend/dashboard/src/pages/CustomerService/Request/List.tsx +++ b/frontend/dashboard/src/pages/CustomerService/Request/List.tsx @@ -143,7 +143,7 @@ export default function List() { setImportLoading(true); axios - .post(`claim-requests/import`, formData) + .post(`customer-service/request/import`, formData) .then((response) => { handleCancelImportButton(); loadDataTableData(); @@ -177,7 +177,7 @@ export default function List() { } const handleGetData = (type :string) => { - axios.get(`corporates/${corporate_id}/data-plan-benefit`) + axios.get(`customer-service/request/data`) .then((response) => { const link = document.createElement('a'); link.href = response.data.data.file_url; @@ -219,10 +219,10 @@ export default function List() { }} > Import - {handleGetTemplate('claim-request')}}>Download Template - {handleGetData('data-plan-benefit')}}>Download Claim Request + {handleGetTemplate('request-log')}}>Download Template + {handleGetData('data-request-log')}}>Download Request LOG - + */} )} @@ -351,9 +351,10 @@ export default function List() { // handleShowClaim(row); // }} > - {row.code} + {row.id} + {row.code} {row.member?.full_name} {row.service_name} @@ -361,8 +362,11 @@ export default function List() { { row.status == "requested" ? () : + row.status == "declined" ? + () + : () - } + } {/* */} + + ID Request LOG + Code diff --git a/public/files/Data Request LOG.xlsx b/public/files/Data Request LOG.xlsx new file mode 100644 index 00000000..c099f7e8 Binary files /dev/null and b/public/files/Data Request LOG.xlsx differ diff --git a/public/files/Template Update Status Request LOG.xlsx b/public/files/Template Update Status Request LOG.xlsx new file mode 100644 index 00000000..7a1957bd Binary files /dev/null and b/public/files/Template Update Status Request LOG.xlsx differ