Import request LOG

This commit is contained in:
2024-01-24 12:59:16 +07:00
parent e83bfedee1
commit 9274f86bb8
2 changed files with 78 additions and 59 deletions

View File

@@ -21,21 +21,21 @@ class RequestLogService
private static $code_prefix = 'LOG'; private static $code_prefix = 'LOG';
public $doc_headers_to_field_map = [ public $doc_headers_to_field_map = [
"Date Of Request" => "submission_date", "Record Mode" => "record_mode",
"Date Addmission" => "submission_date", "Date Addmission" => "submission_date",
"Date Discharge" => "discharge_date", "Date Discharge" => "discharge_date",
"Member ID Peserta" => "member_id", "Member ID Peserta" => "member_id",
"Type of patient" => "service", "Type of patient" => "service",
"Provider Name" => "organization_id", "Provider Code" => "organization_id",
"End Of Claim Numbers" => "code", "End Of Claim Numbers" => "code",
"Remarks" => "keterangan", "Diagnosis" => "diagnosis",
"Diagnosis" => "catatan",
"Tgl Billing dari RS" => "approved_final_log_at", "Tgl Billing dari RS" => "approved_final_log_at",
"Benefit Item" => "benefit_id",
"Total Billing" => "total_billing", "Total Billing" => "total_billing",
"Benefit Item" => "benefit_id",
"Amount Approval" => "amount_approval", "Amount Approval" => "amount_approval",
"Amount Not Approval" => "amount_not_approval", "Amount Not Approval" => "amount_not_approval",
"Final Billing" => "final_billing", "Final Billing" => "final_billing",
"Remarks" => "keterangan",
"QC 1" => "status_final_log", "QC 1" => "status_final_log",
"Ingestion Code" => "ingestion_code", // TODO I think this should not be here because if user uploading result then ingestion code and status will be filled "Ingestion Code" => "ingestion_code", // TODO I think this should not be here because if user uploading result then ingestion code and status will be filled
"Ingestion Status" => "ingestion_status", "Ingestion Status" => "ingestion_status",
@@ -43,20 +43,20 @@ class RequestLogService
]; ];
public $field_to_doc_headers_map = [ public $field_to_doc_headers_map = [
"submission_date" => "Date Of Request", "record_mode" => "Record Mode",
"submission_date" => "Date Addmission", "submission_date" => "Date Addmission",
"discharge_date" => "Date Discharge", "discharge_date" => "Date Discharge",
"member_id" => "Member ID Peserta", "member_id" => "Member ID Peserta",
"service" => "Type of patient", "service" => "Type of patient",
"organization_id" => "Provider Name", "organization_id" => "Provider Code",
"code" => "End Of Claim Numbers", "code" => "End Of Claim Numbers",
"keterangan" => "Remarks", "diagnosis" => "Diagnosis",
"catatan" => "Diagnosis",
"approved_final_log_at" => "Tgl Billing dari RS", "approved_final_log_at" => "Tgl Billing dari RS",
"benefit_id" => "Benefit Item",
"total_billing" => "Total Billing", "total_billing" => "Total Billing",
"benefit_id" => "Benefit Item",
"amount_approval" => "Amount Approval", "amount_approval" => "Amount Approval",
"amount_not_approval" => "Amount Not Approval", "amount_not_approval" => "Amount Not Approval",
"keterangan" => "Remarks",
"final_billing" => "Final Billing", "final_billing" => "Final Billing",
"status_final_log" => "QC 1" , "status_final_log" => "QC 1" ,
"ingestion_code" => "Ingestion Code", "ingestion_code" => "Ingestion Code",
@@ -64,42 +64,42 @@ class RequestLogService
]; ];
public $result_doc_headers = [ public $result_doc_headers = [
"Date Of Request", "Record Mode",
"Date Addmission", "Date Addmission",
"Date Discharge", "Date Discharge",
"Member ID Peserta", "Member ID Peserta",
"Type of patient", "Type of patient",
"Provider Name", "Provider Code",
"End Of Claim Numbers", "End Of Claim Numbers",
"Remarks",
"Diagnosis", "Diagnosis",
"Tgl Billing dari RS", "Tgl Billing dari RS",
"Benefit Item",
"Total Billing", "Total Billing",
"Benefit Item",
"Amount Approval", "Amount Approval",
"Amount Not Approval", "Amount Not Approval",
"Final Billing", "Final Billing",
"Remarks",
"QC 1", "QC 1",
"Ingestion Code", "Ingestion Code",
"Ingestion Status", "Ingestion Status",
]; ];
public $listing_doc_headers = [ public $listing_doc_headers = [
"Date Of Request", "Record Mode",
"Date Addmission", "Date Addmission",
"Date Discharge", "Date Discharge",
"Member ID Peserta", "Member ID Peserta",
"Type of patient", "Type of patient",
"Provider Name", "Provider Code",
"End Of Claim Numbers", "End Of Claim Numbers",
"Remarks",
"Diagnosis", "Diagnosis",
"Tgl Billing dari RS", "Tgl Billing dari RS",
"Benefit Item",
"Total Billing", "Total Billing",
"Benefit Item",
"Amount Approval", "Amount Approval",
"Amount Not Approval", "Amount Not Approval",
"Final Billing", "Final Billing",
"Remarks",
"QC 1", "QC 1",
"Ingestion Code", "Ingestion Code",
"Ingestion Status", "Ingestion Status",
@@ -152,35 +152,44 @@ class RequestLogService
throw new ImportRowException(__('Format Date Invalid'), 0, null, $row); throw new ImportRowException(__('Format Date Invalid'), 0, null, $row);
} }
// Membuat singkatan dari nama rumah sakit if (!$row['organization_id']){
$singkatan = ""; throw new ImportRowException(__('Provider Required'), 0, null, $row);
$words = explode(' ', $row['organization_id']);
foreach ($words as $word) {
$singkatan .= strtoupper(substr($word, 0, 1));
} }
// Membuat singkatan dari nama rumah sakit
// $singkatan = "";
// $words = explode(' ', $row['organization_id']);
// foreach ($words as $word) {
// $singkatan .= strtoupper(substr($word, 0, 1));
// }
// Membuat kode organisasi // Membuat kode organisasi
$kodeOrganisasi = "ORG000" . $singkatan; // $kodeOrganisasi = "ORG000" . $singkatan;
// Insert data ke tabel organizations // Insert data ke tabel organizations
$organization = DB::table('organizations')->where('code', $kodeOrganisasi)->first(); $organization = DB::table('organizations')->where('code', $row['organization_id'])->first();
// dd( $organization);
if ($organization) { if (!$organization){
$organization_id = $organization->id; throw new ImportRowException(__('Provider Not Found'), 0, null, $row);
} else {
$organization_id = DB::table('organizations')
->insertGetId([
'name' => $row['organization_id'],
'code' => $kodeOrganisasi,
'type' => 'hospital',
'created_at' => now(),
'created_by' => auth()->user()->id
]);
} }
// if ($organization) {
$organization_id = $organization->id;
// } else {
// $organization_id = DB::table('organizations')
// ->insertGetId([
// 'name' => $row['organization_id'],
// 'code' => $kodeOrganisasi,
// 'type' => 'hospital',
// 'created_at' => now(),
// 'created_by' => auth()->user()->id
// ]);
// }
$data = [ $data = [
'source' => 'H', 'source' => 'H',
'provideCode' => $kodeOrganisasi , // 'provideCode' => $kodeOrganisasi ,
'provideCode' => $organization->code ,
'date' => $this->dateParserCode($row['submission_date']), 'date' => $this->dateParserCode($row['submission_date']),
'policy' => $member->currentPolicy->code, 'policy' => $member->currentPolicy->code,
'member_code' => $row['member_id'] 'member_code' => $row['member_id']
@@ -212,7 +221,7 @@ class RequestLogService
$final_log = 1; $final_log = 1;
} }
if ($row['catatan']){ if ($row['diagnosis']){
$data = [ $data = [
'code' => $code, 'code' => $code,
'member_id' => $member->id, 'member_id' => $member->id,
@@ -227,7 +236,7 @@ class RequestLogService
'keterangan' => $row['keterangan'], 'keterangan' => $row['keterangan'],
'policy_id' => $member->currentPolicy->id ?? null, 'policy_id' => $member->currentPolicy->id ?? null,
'organization_id' => $organization_id, 'organization_id' => $organization_id,
'diagnosis' => $row['catatan'], 'diagnosis' => $row['diagnosis'],
'service_code' => $serviceCode, 'service_code' => $serviceCode,
'approved_final_log_at' => $row['approved_final_log_at'], 'approved_final_log_at' => $row['approved_final_log_at'],
]; ];
@@ -242,7 +251,7 @@ 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'], 'diagnosis' => $row['diagnosis'],
'keterangan' => $row['keterangan'], 'keterangan' => $row['keterangan'],
'policy_id' => $member->currentPolicy->id ?? null, 'policy_id' => $member->currentPolicy->id ?? null,
'organization_id' => $organization_id, 'organization_id' => $organization_id,
@@ -251,25 +260,31 @@ class RequestLogService
]; ];
} }
$requestLog = RequestLog::updateOrCreate( if ($row['record_mode'] == 1){
[ $requestLog = RequestLog::updateOrCreate(["code" => $code], $data);
'code' => $code, } else if ($row['record_mode'] == 2) {
], $requestLog = RequestLog::updateOrCreate(
$data); [
'member_id' => $member->id,
'submission_date' => $row['submission_date'],
'organization_id' => $organization_id,
],
$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
// Delete item // Delete item
if ($row['final_billing']){ if ($row['total_billing']){
RequestLogBenefit::where('request_log_id', '=', $requestLog->id)->delete(); RequestLogBenefit::where('request_log_id', '=', $requestLog->id)->delete();
} }
// Insert Item // Insert Item
RequestLogBenefit::create( RequestLogBenefit::create(
[ [
'request_log_id' => $requestLog->id, 'request_log_id' => $requestLog->id,
'benefit_id' => $benefit->id, 'benefit_id' => $benefit->id,
'amount_incurred' => ($row['amount_approval'] ? $row['amount_approval'] : 0) + ($row['amount_not_approval'] ? $row['amount_not_approval'] : 0) , // 'amount_incurred' => ($row['amount_approval'] ? $row['amount_approval'] : 0) + ($row['amount_not_approval'] ? $row['amount_not_approval'] : 0) ,
'amount_incurred' => $row['total_billing'] ,
'amount_approved' => $row['amount_approval'] ?? 0, 'amount_approved' => $row['amount_approval'] ?? 0,
'amount_not_approved' => $row['amount_not_approval'] ?? 0, 'amount_not_approved' => $row['amount_not_approval'] ?? 0,
'excess_paid' => $row['amount_not_approval'] ?? 0, 'excess_paid' => $row['amount_not_approval'] ?? 0,
@@ -277,8 +292,6 @@ class RequestLogService
]); ]);
} }
// Commit transaksi // Commit transaksi
DB::commit(); DB::commit();
} catch (\Exception $e) { } catch (\Exception $e) {

View File

@@ -56,36 +56,42 @@ class RequestLog extends Model
]; ];
public static $doc_headers_to_field_map = [ public static $doc_headers_to_field_map = [
"Date Of Request" => "submission_date", "Record Mode" => "record_mode",
"Date Addmission" => "submission_date", "Date Addmission" => "submission_date",
"Date Discharge" => "discharge_date",
"Member ID Peserta" => "member_id", "Member ID Peserta" => "member_id",
"Type of patient" => "service", "Type of patient" => "service",
"Provider Name" => "organization_id", "Provider Code" => "organization_id",
"End Of Claim Numbers" => "code", "End Of Claim Numbers" => "code",
"Remarks" => "keterangan", "Remarks" => "keterangan",
"Diagnosis" => "catatan", "Diagnosis" => "catatan",
"Tgl Billing dari RS" => "approved_final_log_at", "Tgl Billing dari RS" => "approved_final_log_at",
"Benefit Item" => "benefit_id",
"Total Billing" => "total_billing", "Total Billing" => "total_billing",
"Benefit Item" => "benefit_id",
"Amount Approval" => "amount_approval", "Amount Approval" => "amount_approval",
"Amount Not Approval" => "amount_not_approval", "Amount Not Approval" => "amount_not_approval",
"Final Billing" => "final_billing",
"Remarks" => "keterangan",
"QC 1" => "status_final_log", "QC 1" => "status_final_log",
]; ];
public static $listing_doc_headers = [ public static $listing_doc_headers = [
"Date Of Request", "Record Mode",
"Date Addmission", "Date Addmission",
"Date Discharge",
"Member ID Peserta", "Member ID Peserta",
"Type of patient", "Type of patient",
"Provider Name", "Provider Code",
"End Of Claim Numbers", "End Of Claim Numbers",
"Remarks", "Remarks",
"Diagnosis", "Diagnosis",
"Tgl Billing dari RS", "Tgl Billing dari RS",
"Benefit Item",
"Total Billing", "Total Billing",
"Benefit Item",
"Amount Approval", "Amount Approval",
"Amount Not Approval", "Amount Not Approval",
"Final Billing",
"Remarks",
"QC 1", "QC 1",
]; ];