Update import request log

This commit is contained in:
2024-01-16 10:33:07 +07:00
parent c4d2a32cf8
commit 439daf4e2e

View File

@@ -187,11 +187,8 @@ class RequestLogService
$final_log = 1; $final_log = 1;
} }
$requestLog = RequestLog::updateOrCreate( if ($row['catatan']){
[ $data = [
'code' => $code
],
[
'code' => $code, 'code' => $code,
'member_id' => $member->id, 'member_id' => $member->id,
'submission_date' => $row['submission_date'], 'submission_date' => $row['submission_date'],
@@ -201,25 +198,55 @@ class RequestLogService
'status_final_log' => $statusFinalLog, 'status_final_log' => $statusFinalLog,
'final_log' =>$final_log, 'final_log' =>$final_log,
'import_system' =>TRUE, 'import_system' =>TRUE,
'catatan' => $row['catatan'], // 'catatan' => $row['catatan'],
'keterangan' => $row['keterangan'],
'policy_id' => $member->currentPolicy->id ?? null,
'organization_id' => $organization_id,
'diagnosis' => $row['catatan'],
'service_code' => $serviceCode,
'approved_final_log_at' => $row['approved_final_log_at'],
];
} else {
$data = [
'code' => $code,
'member_id' => $member->id,
'submission_date' => $row['submission_date'],
'discharge_date' => $row['submission_date'],
'payment_type' => 'cashless',
'status' => $status,
'status_final_log' => $statusFinalLog,
'final_log' =>$final_log,
'import_system' =>TRUE,
// 'catatan' => $row['catatan'],
'keterangan' => $row['keterangan'],
'policy_id' => $member->currentPolicy->id ?? null, 'policy_id' => $member->currentPolicy->id ?? null,
'organization_id' => $organization_id, 'organization_id' => $organization_id,
'service_code' => $serviceCode, 'service_code' => $serviceCode,
'approved_final_log_at' => $row['approved_final_log_at'], 'approved_final_log_at' => $row['approved_final_log_at'],
]); ];
}
$requestLog = RequestLog::updateOrCreate(
[
'code' => $code,
],
$data);
if ($benefit) { // jika tidak ada benefit nya maka belum ngisi benefit nya if ($benefit) { // jika tidak ada benefit nya maka belum ngisi benefit nya
RequestLogBenefit::updateOrCreate( // Delete item
[ if ($row['total_billing']){
'request_log_id' => $requestLog->id, RequestLogBenefit::where('request_log_id', '=', $requestLog->id)->delete();
], }
// Insert Item
RequestLogBenefit::create(
[ [
'request_log_id' => $requestLog->id, 'request_log_id' => $requestLog->id,
'benefit_id' => $benefit->id, 'benefit_id' => $benefit->id,
'amount_incurred' => $row['total_billing'], 'amount_incurred' => ($row['amount_not_approval'] ? $row['amount_not_approval'] : 0) + $row['amount_approval'] ,
'amount_approved' => $row['amount_approval'], 'amount_approved' => $row['amount_approval'],
'amount_not_approved' => $row['amount_not_approval'], 'amount_not_approved' => $row['amount_not_approval'] ?? 0,
'excess_paid' => $row['amount_not_approval'], 'excess_paid' => $row['amount_not_approval'],
'created_by' => auth()->user()->id, 'created_by' => auth()->user()->id,