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