update import/export excel request log

This commit is contained in:
2023-11-29 16:22:00 +07:00
parent a208d5f11e
commit dc582244a5
8 changed files with 112 additions and 91 deletions

View File

@@ -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;

View File

@@ -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');

View File

@@ -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']);

View File

@@ -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",
];

View File

@@ -348,9 +348,10 @@ export default function List() {
// handleShowClaim(row);
// }}
>
{row.code}
{row.id}
</Typography>
</TableCell>
<TableCell align="left">{row.member?.code}</TableCell>
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left"><Label>{fDateTimesecond(row.submission_date)}</Label></TableCell>
<TableCell align="left">{row.service_name}</TableCell>
@@ -470,6 +471,9 @@ export default function List() {
<TableHead>
<TableRow>
{/* <TableCell style={headStyle} align="left" /> */}
<TableCell style={headStyle} align="left">
ID Request LOG
</TableCell>
<TableCell style={headStyle} align="left">
Code
</TableCell>

View File

@@ -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() {
}}
>
<MenuItem onClick={handleImportButton}>Import</MenuItem>
<MenuItem onClick={() => {handleGetTemplate('claim-request')}}>Download Template</MenuItem>
<MenuItem onClick={() => {handleGetData('data-plan-benefit')}}>Download Claim Request</MenuItem>
<MenuItem onClick={() => {handleGetTemplate('request-log')}}>Download Template</MenuItem>
<MenuItem onClick={() => {handleGetData('data-request-log')}}>Download Request LOG</MenuItem>
</Menu>
<Button
{/* <Button
variant="contained"
startIcon={<AddIcon />}
sx={{ p: 1.8 }}
@@ -231,7 +231,7 @@ export default function List() {
}}
>
Create
</Button>
</Button> */}
</Stack>
)}
@@ -351,9 +351,10 @@ export default function List() {
// handleShowClaim(row);
// }}
>
{row.code}
{row.id}
</Typography>
</TableCell>
<TableCell align="left">{row.code}</TableCell>
<TableCell align="left">{row.member?.full_name}</TableCell>
<TableCell align="left"><Label>{fDateTimesecond(row.submission_date)}</Label></TableCell>
<TableCell align="left">{row.service_name}</TableCell>
@@ -361,8 +362,11 @@ export default function List() {
<TableCell align="left">
{ row.status == "requested" ?
(<Label variant='ghost' color='primary'>{capitalizeFirstLetter(row.status)}</Label>) :
row.status == "declined" ?
(<Label color='error'> {capitalizeFirstLetter(row.status)}</Label>)
:
(<Label color='success'> {capitalizeFirstLetter(row.status)}</Label>)
}
}
</TableCell>
<TableCell align="right">
<TableMoreMenu actions={
@@ -478,6 +482,9 @@ export default function List() {
<TableHead>
<TableRow>
{/* <TableCell style={headStyle} align="left" /> */}
<TableCell style={headStyle} align="left">
ID Request LOG
</TableCell>
<TableCell style={headStyle} align="left">
Code
</TableCell>

Binary file not shown.

Binary file not shown.