From 07295b3ad6492dfd95ce2f9ef84277af01f31b96 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Wed, 28 Jan 2026 09:50:53 +0530 Subject: [PATCH] FIX_ISSUE --- .env.sample | 6 +- app/Controllers/ClientController.php | 1 + app/Filters/AuthMVC.php | 10 +- app/Helpers/utility_helper.php | 2 + .../AbhiClaimImportService.php | 36 ++- .../FhplClaimImportService.php | 209 +++++++++--------- .../IciciClaimImportService.php | 109 ++++----- .../MediAssistClaimImportService.php | 107 +++------ .../RcareClaimImportService.php | 107 ++++----- .../VidalClaimImportService.php | 6 +- 10 files changed, 262 insertions(+), 331 deletions(-) diff --git a/.env.sample b/.env.sample index 9c0f9e71..cd4743fb 100755 --- a/.env.sample +++ b/.env.sample @@ -107,4 +107,8 @@ ABHI_PRIMARY_KEY_CONSTANT = R_CARE_PRIMARY_KEY_CONSTANT = -FHPL_PRIMARY_KEY_CONSTANT = \ No newline at end of file +FHPL_PRIMARY_KEY_CONSTANT = + +VIDAL_PRIMARY_KEY_CONSTANT = + +MEDI_ASSIST_PRIMARY_KEY_CONSTANT = \ No newline at end of file diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index de732501..47f5b5fb 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -6588,6 +6588,7 @@ class ClientController extends AdminController // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 51]); //abhi // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 48]); //vidal // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 53]); //icici + // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 54]); //mediassist // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]); // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]); // dd($response); diff --git a/app/Filters/AuthMVC.php b/app/Filters/AuthMVC.php index ef2da046..298a72b9 100755 --- a/app/Filters/AuthMVC.php +++ b/app/Filters/AuthMVC.php @@ -23,11 +23,11 @@ class AuthMVC implements FilterInterface // } // Fingerprint validation - $fp = generateFingerprint(); - // log_message('error',$fp); - if (session()->get('fingerprint') !== $fp) { - return AuthLogout::logout(); - } + // $fp = generateFingerprint(); + // // log_message('error',$fp); + // if (session()->get('fingerprint') !== $fp) { + // return AuthLogout::logout(); + // } } diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php index dc7ba8b2..79e4ddf9 100755 --- a/app/Helpers/utility_helper.php +++ b/app/Helpers/utility_helper.php @@ -640,6 +640,8 @@ if (!function_exists('change_date_format')) { 'd/m/Y', // 01/01/2025 'd-m-Y', // 01-01-2025 + 'm/d/Y h:i:s A', // 01-01-2025 + 'm/d/Y', // 25-05-2025 ]; diff --git a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php index 1f62ea7f..21818613 100644 --- a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php @@ -82,7 +82,6 @@ class AbhiClaimImportService extends BaseTpaClaimImportService ["excel_column" => ["col_name" => "CORPORATE_EMPLOYEE_CODE", "col_index" => 63], "db_column" => "corporate_employee_code"], ]; - protected $ticketMasterMapping = [ // Employee / Member details @@ -115,19 +114,31 @@ class AbhiClaimImportService extends BaseTpaClaimImportService // Misc 'diagnosis' => 'claim_description', 'healthcard_id' => 'tpa_no', - - 'priority' => 1, - 'mode_of_intimation' => 5, - 'ticket_type_id' => 1, ]; - protected $statusMapping = [ 'Settled' => 11, 'Rejected' => 8, 'Cancelled' => 13, ]; + protected $dateColumns = [ + 'policy_from', + 'policy_upto', + + 'intimation_date', + 'date_of_doc_rec', + + 'doa', + 'dod', + + 'repudiation_date', + 'settled_date', + + 'expected_doa', + 'expected_dod', + ]; + /** * ABSTRACT FUNCTIONs @@ -215,14 +226,13 @@ class AbhiClaimImportService extends BaseTpaClaimImportService $dbColumn = $map['db_column']; $value = $row[$excelColumn] ?? null; - - if ($this->isDateValue($value)) { - $value = $this->normalizeDate($value); - } - $item[$dbColumn] = trim($value); } + foreach ($this->dateColumns as $key => $value) { + $item[$value] = change_date_format($item[$value] ?? null, 'm/d/Y h:i:s A', 'Y-m-d'); + } + $params = [ 'doa' => $item['doa'] ?? null, 'member_code' => $item['member_code'] ?? null, @@ -346,6 +356,10 @@ class AbhiClaimImportService extends BaseTpaClaimImportService $item['claim_dump_ref_id'] = $row['id']; $item['created_by'] = $file_data['created_by'] ?? null; $item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3; + $item['priority'] = 1; + $item['mode_of_intimation'] = 5; + $item['ticket_type_id'] = 1; + $mapped[] = $item; } diff --git a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php index ced6c2f3..72614418 100644 --- a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php @@ -4,8 +4,6 @@ namespace App\Libraries\TPAClaimsImportServices; use App\Models\TicketMasterModel; use App\Models\ClientPolicyModel; -use App\Models\ClientRMModel; -use App\Models\EmployeeModel; use App\Models\ClaimDumpFileModel; use App\Models\ClaimsDumpFhplModel; @@ -140,39 +138,45 @@ class FhplClaimImportService extends BaseTpaClaimImportService protected $ticketMasterMapping = [ - // Employee / Member details - 'member_code' => 'emp_code', - 'relation' => 'relationship', + // Claim / Reference + 'claim_id' => 'claim_number', - // Policy / Claim identifiers - 'policy_number' => 'policy_no', - 'certificate_no' => 'claim_number', - 'abhi_claim_no' => 'tpa_claim_id', + // Policy + 'policy_no' => 'policy_no', - // Dates - 'doa' => 'doa', - 'dod' => 'dod', - 'intimation_date' => 'date_of_intimat', + // Employee / Member + 'employee_id' => 'emp_code', + 'relationship' => 'relationship', - // Claim info - 'claim_type' => 'claim_type', - 'claim_status' => 'tpa_claim_status', - 'claimed_amount' => 'claim_amount', - 'abhi_amount_less_coins_current_month' => 'approved_amount', + // Claim Dates + 'admission_date' => 'doa', + 'discharge_date' => 'dod', + 'claim_received_date' => 'date_of_intimat', + 'claim_passed_date' => 'approved_date', + 'settled_date' => 'settled_date', - // Hospital details - 'hospital_name' => 'hospital_name', - 'hospital_city' => 'hospital_city', - 'hospital_state' => 'hospital_state', + 'current_claim_status' => 'tpa_claim_status', - // Settlement / decision - 'repudiation_date' => 'denial_date', - 'settled_date' => 'settled_date', - 'rejection_category' => 'denial_reason', + // Amounts + 'claim_amount' => 'claim_amount', + 'settled_amount' => 'settled_amount', + 'disallowed_amount' => 'denial_reason', + 'coverage_amount' => 'si_amt', - // Misc - 'diagnosis' => 'claim_description', - 'healthcard_id' => 'tpa_no', + // Hospital + 'provider_name' => 'hospital_name', + 'provider_address' => 'hospital_address', + 'provider_state' => 'hospital_state', + 'provider_place' => 'hospital_city', + 'provider_pincode' => 'hospital_pin_code', + + // Remarks / Description + 'diagnosis' => 'claim_description', + 'rejection_remarks' => 'return_remark', + + // Payment + 'cheque_no' => 'utr_details', + 'uhid_no' => 'tpa_no', 'priority' => 1, 'mode_of_intimation' => 5, @@ -184,6 +188,33 @@ class FhplClaimImportService extends BaseTpaClaimImportService 'Rejected' => 8, ]; + protected $dateColumns = [ + 'intimation_date', + 'policy_start_date', + 'policy_commencing_date', + 'policy_expiry_date', + 'claim_received_date', + 'admission_date', + 'discharge_date', + 'cheque_date', + 'claim_passed_date', + 'settled_date', + 'ir_date', + 'ir_retrieval_date', + 'first_reminder', + 'second_reminder', + 'date_of_joining', + 'nidb_removed_date', + 'investigation_date', + 'investigation_retrieval_date', + 'reopened_date', + 'refer_to_insurer_date', + 'received_date_from_insurer', + 'claim_created_datetime', + 'last_modified_date' + ]; + + /** * ABSTRACT FUNCTIONs */ @@ -260,27 +291,26 @@ class FhplClaimImportService extends BaseTpaClaimImportService $dbColumn = $map['db_column']; $value = $row[$excelColumn] ?? null; - - if ($this->isDateValue($value)) { - $value = $this->normalizeDate($value); - } - $item[$dbColumn] = trim($value); } - // $params = [ - // 'admission_date' => change_date_format($item['admission_date'] ?? '') ?? null, - // 'employee_number' => $item['employee_number'] ?? null, - // 'claim_amount' => $item['claim_amount'] ?? null, - // 'primary_policy_holder_card_id' => $item['primary_policy_holder_card_id'] ?? null - // ]; + foreach ($this->dateColumns as $key => $value) { + $item[$value] = change_date_format($item[$value] ?? null, 'd-M-y', 'Y-m-d'); + } - // $is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_fhpl', $params); + $params = [ + 'admission_date' => $item['admission_date'] ?? null, + 'employee_id' => $item['employee_id'] ?? null, + 'claim_amount' => $item['claim_amount'] ?? null, + 'uhid_no' => $item['uhid_no'] ?? null + ]; - // if ($is_duplicate) { - // $item = []; - // continue; - // } + $is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_fhpl', $params); + + if ($is_duplicate) { + $item = []; + continue; + } $item['file_id'] = $file_id ?? null; $item['client_id'] = $file_data['client_id'] ?? null; @@ -332,10 +362,10 @@ class FhplClaimImportService extends BaseTpaClaimImportService foreach ($tpaClaimDumpData as $row) { $params = [ - 'doa' => change_date_format($row['date_of_admission'] ?? '') ?? null, - 'emp_code' => $row['employee_number'] ?? null, + 'doa' => change_date_format($row['admission_date'] ?? '') ?? null, + 'emp_code' => $row['employee_id'] ?? null, 'claim_amount' => $row['claim_amount'] ?? null, - 'tpa_no' => $row['primary_policy_holder_card_id'] ?? null + 'tpa_no' => $row['uhid_no'] ?? null ]; $isduplicate = $this->checkDublicateTicketMasterClaim($params); @@ -354,9 +384,9 @@ class FhplClaimImportService extends BaseTpaClaimImportService $item['tpa_id'] = $client_policy_data['tpa_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['policy_no'] = $client_policy_data['policy_no'] ?? null; - $item['relationship'] = $this->convertRelation($row['relation'] ?? null, $row['gender'] ?? null); + $item['relationship'] = $this->convertRelation($row['relationship'] ?? null); - $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_number'], $item['relationship']); + $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_id'], $item['relationship']); if (!empty($employee_data)) { $item['emp_id'] = $employee_data['id'] ?? null; @@ -390,7 +420,10 @@ class FhplClaimImportService extends BaseTpaClaimImportService $item['file_id'] = $file_id; $item['claim_dump_ref_id'] = $row['id']; $item['created_by'] = $file_data['created_by'] ?? null; - $item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3; + $item['claim_type'] = 1; + $item['priority'] = 1; + $item['mode_of_intimation'] = 5; + $item['ticket_type_id'] = 1; $mapped[] = $item; } @@ -419,83 +452,47 @@ class FhplClaimImportService extends BaseTpaClaimImportService * HELPER FUNCTIONs */ - public function isDateValue($value): bool - { - if (empty($value)) { - return false; - } - - // Excel numeric date (e.g. 44927) - if (is_numeric($value) && $value > 30000) { - return true; - } - - // Common date formats - return preg_match( - '/^\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}$|^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/', - (string) $value - ) === 1; - } - - - public function normalizeDate($value): ?string - { - try { - // Excel numeric date - if (is_numeric($value)) { - return date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($value)); - } - - // String date - return date('Y-m-d', strtotime(str_replace('/', '-', $value))); - } catch (\Throwable $e) { - return null; - } - } - - - public function convertRelation(string $relation, string $gender): ?string + public function convertRelation(?string $relation): ?string { if (empty($relation)) { return null; } $relation = strtolower($relation); - $gender = strtolower($gender); - if ($relation == 'self') { - return $relation; + if (str_contains($relation, 'self')) { + return 'self'; } - if ($relation == 'spouse') { - return $relation; + if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) { + return 'spouse'; } - if ($relation == 'child' && $gender == 'male') { - return 'son'; - } - - if ($relation == 'child' && $gender == 'female') { + if (str_contains($relation, 'daughter')) { return 'daughter'; } - if ($relation == 'parents' && $gender == 'male') { - return 'father'; + if (str_contains($relation, 'son')) { + return 'son'; } - if ($relation == 'parents' && $gender == 'female') { - return 'mother'; - } - - if ($relation == 'parents-in-law' && $gender == 'male') { + if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) { return 'father-in-law'; } - if ($relation == 'parents-in-law' && $gender == 'female') { + if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) { return 'mother-in-law'; } - return null; + if (str_contains($relation, 'father')) { + return 'father'; + } + + if (str_contains($relation, 'mother')) { + return 'mother'; + } + + return null; // unmatched case } diff --git a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php index 9f1ddfe3..b89221ae 100644 --- a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php @@ -99,7 +99,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService 'hospital_state' => 'hospital_state', 'cheque_number' => 'utr_details', - 'tpa_no' => 'uhid', + 'uhid' => 'tpa_no', 'rejected_query_desc' => 'claim_description', ]; @@ -108,6 +108,23 @@ class IciciClaimImportService extends BaseTpaClaimImportService 'REJECTED' => 8, ]; + protected $dateColumns = [ + 'policy_start_date', + 'policy_end_date', + + 'dt_of_deficiencies_sent', + 'dt_of_deficiencies_received', + + 'payment_date', + + 'doa', + 'dod', + + 'rejected_query_closed_date', + 'rejreopen_closure_date', + ]; + + /** * ABSTRACT FUNCTIONs @@ -203,14 +220,13 @@ class IciciClaimImportService extends BaseTpaClaimImportService $dbColumn = $map['db_column']; $value = $row[$excelColumn] ?? null; - - if ($this->isDateValue($value)) { - $value = $this->normalizeDate($value); - } - $item[$dbColumn] = $value; } + foreach ($this->dateColumns as $key => $value) { + $item[$value] = change_date_format($item[$value] ?? null); + } + $params = [ 'doa' => change_date_format($item['doa'] ?? '') ?? null, 'employee_member_id' => $item['employee_member_id'] ?? null, @@ -297,9 +313,9 @@ class IciciClaimImportService extends BaseTpaClaimImportService $item['tpa_id'] = $client_policy_data['tpa_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['policy_no'] = $client_policy_data['policy_no'] ?? null; - $item['relationship'] = strtolower($row['relation_group'] ?? ''); + $item['relationship'] = $this->convertRelation($row['relation_group'] ?? ''); - $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_number'], $item['relationship']); + $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_member_id'], $item['relationship']); if (!empty($employee_data)) { $item['emp_id'] = $employee_data['id'] ?? null; @@ -330,9 +346,13 @@ class IciciClaimImportService extends BaseTpaClaimImportService // Meta fields $item['claim_status_id'] = $statusMapping[$row['updated_status']] ?? 61; + $item['claim_dump_ref_id'] = $row['id']; $item['file_id'] = $file_id; $item['created_by'] = $file_data['created_by'] ?? null; $item['claim_type'] = 1; + $item['priority'] = 1; + $item['mode_of_intimation'] = 5; + $item['ticket_type_id'] = 1; $mapped[] = $item; } @@ -361,83 +381,48 @@ class IciciClaimImportService extends BaseTpaClaimImportService * HELPER FUNCTIONs */ - public function isDateValue($value): bool - { - if (empty($value)) { - return false; - } - // Excel numeric date (e.g. 44927) - if (is_numeric($value) && $value > 30000) { - return true; - } - - // Common date formats - return preg_match( - '/^\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}$|^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/', - (string) $value - ) === 1; - } - - - public function normalizeDate($value): ?string - { - try { - // Excel numeric date - if (is_numeric($value)) { - return date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($value)); - } - - // String date - return date('Y-m-d', strtotime(str_replace('/', '-', $value))); - } catch (\Throwable $e) { - return null; - } - } - - - public function convertRelation(string $relation, string $gender): ?string + public function convertRelation(?string $relation): ?string { if (empty($relation)) { return null; } $relation = strtolower($relation); - $gender = strtolower($gender); - if ($relation == 'self') { - return $relation; + if (str_contains($relation, 'self')) { + return 'self'; } - if ($relation == 'spouse') { - return $relation; + if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) { + return 'spouse'; } - if ($relation == 'child' && $gender == 'male') { - return 'son'; - } - - if ($relation == 'child' && $gender == 'female') { + if (str_contains($relation, 'daughter')) { return 'daughter'; } - if ($relation == 'parents' && $gender == 'male') { - return 'father'; + if (str_contains($relation, 'son')) { + return 'son'; } - if ($relation == 'parents' && $gender == 'female') { - return 'mother'; - } - - if ($relation == 'parents-in-law' && $gender == 'male') { + if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) { return 'father-in-law'; } - if ($relation == 'parents-in-law' && $gender == 'female') { + if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) { return 'mother-in-law'; } - return null; + if (str_contains($relation, 'father')) { + return 'father'; + } + + if (str_contains($relation, 'mother')) { + return 'mother'; + } + + return null; // unmatched case } diff --git a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php index c8e39b21..7326567d 100644 --- a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php @@ -112,7 +112,6 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService ["excel_column" => ["col_name" => "balance_sum_insured_exhausted", "col_index" => 93], "db_column" => "balance_sum_insured_exhausted"], ]; - protected $ticketMasterMapping = [ // Employee / Beneficiary details @@ -121,12 +120,11 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService // Policy / Claim identifiers 'policy_no' => 'policy_no', - 'claim_id' => 'tpa_claim_id', - 'insurer_claim_ref_no' => 'tpa_no', + 'claim_id' => 'claim_number', + 'event_id' => 'tpa_no', 'claim_pre_auths' => 'tpa_claim_push_reference_no', // Claim type & status - 'claim_type' => 'claim_type', 'claim_status' => 'tpa_claim_status', // Dates @@ -155,12 +153,8 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService // Payment 'utr_no' => 'utr_details', - 'priority' => 1, - 'mode_of_intimation' => 5, - 'ticket_type_id' => 1, ]; - protected $statusMapping = [ 'Settled' => 11, 'Rejected' => 8, @@ -248,19 +242,14 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService $dbColumn = $map['db_column']; $value = $row[$excelColumn] ?? null; - - if ($this->isDateValue($value)) { - $value = $this->normalizeDate($value); - } - $item[$dbColumn] = $value; } $params = [ 'date_of_admission' => change_date_format($item['date_of_admission'] ?? '') ?? null, - 'employee_number' => $item['employee_number'] ?? null, + 'pribenef_employee_code' => $item['pribenef_employee_code'] ?? null, 'claim_amount' => $item['claim_amount'] ?? null, - 'primary_policy_holder_card_id' => $item['primary_policy_holder_card_id'] ?? null + 'event_id' => $item['event_id'] ?? null ]; $is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_medi_assist', $params); @@ -321,9 +310,9 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService $params = [ 'doa' => change_date_format($row['date_of_admission'] ?? '') ?? null, - 'emp_code' => $row['employee_number'] ?? null, + 'emp_code' => $row['pribenef_employee_code'] ?? null, 'claim_amount' => $row['claim_amount'] ?? null, - 'tpa_no' => $row['primary_policy_holder_card_id'] ?? null + 'tpa_no' => $row['event_id'] ?? null ]; $isduplicate = $this->checkDublicateTicketMasterClaim($params); @@ -342,9 +331,9 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService $item['tpa_id'] = $client_policy_data['tpa_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['policy_no'] = $client_policy_data['policy_no'] ?? null; - $item['relationship'] = $this->convertRelation($row['relation'] ?? null, $row['gender'] ?? null); + $item['relationship'] = $this->convertRelation($row['benef_relation'] ?? null); - $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_number'], $item['relationship']); + $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['pribenef_employee_code'], $item['relationship']); if (!empty($employee_data)) { $item['emp_id'] = $employee_data['id'] ?? null; @@ -378,7 +367,10 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService $item['file_id'] = $file_id; $item['claim_status_id'] = $statusMapping[$row['claim_status']] ?? 61; $item['created_by'] = $file_data['created_by'] ?? null; - $item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3; + $item['claim_type'] = 1; + $item['priority'] = 1; + $item['mode_of_intimation'] = 5; + $item['ticket_type_id'] = 1; $mapped[] = $item; } @@ -407,85 +399,48 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService * HELPER FUNCTIONs */ - public function isDateValue($value): bool - { - if (empty($value)) { - return false; - } - - // Excel numeric date (e.g. 44927) - if (is_numeric($value) && $value > 30000) { - return true; - } - - // Common date formats - return preg_match( - '/^\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}$|^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/', - (string) $value - ) === 1; - } - - - public function normalizeDate($value): ?string - { - try { - // Excel numeric date - if (is_numeric($value)) { - return date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($value)); - } - - // String date - return date('Y-m-d', strtotime(str_replace('/', '-', $value))); - } catch (\Throwable $e) { - return null; - } - } - - - public function convertRelation(string $relation, string $gender): ?string + public function convertRelation(?string $relation): ?string { if (empty($relation)) { return null; } $relation = strtolower($relation); - $gender = strtolower($gender); - if ($relation == 'self') { - return $relation; + if (str_contains($relation, 'self')) { + return 'self'; } - if ($relation == 'spouse') { - return $relation; + if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) { + return 'spouse'; } - if ($relation == 'child' && $gender == 'male') { - return 'son'; - } - - if ($relation == 'child' && $gender == 'female') { + if (str_contains($relation, 'daughter')) { return 'daughter'; } - if ($relation == 'parents' && $gender == 'male') { - return 'father'; + if (str_contains($relation, 'son')) { + return 'son'; } - if ($relation == 'parents' && $gender == 'female') { - return 'mother'; - } - - if ($relation == 'parents-in-law' && $gender == 'male') { + if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) { return 'father-in-law'; } - if ($relation == 'parents-in-law' && $gender == 'female') { + if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) { return 'mother-in-law'; } - return null; + if (str_contains($relation, 'father')) { + return 'father'; + } + + if (str_contains($relation, 'mother')) { + return 'mother'; + } + + return null; // unmatched case } - } diff --git a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php index 8fef8232..4808d89e 100644 --- a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php @@ -60,8 +60,6 @@ class RcareClaimImportService extends BaseTpaClaimImportService // Employee / Member 'employee_member_id' => 'emp_code', - 'insured_name' => 'insured_name', - 'patient_name' => 'emp_name', 'relation' => 'relationship', // Policy @@ -95,10 +93,6 @@ class RcareClaimImportService extends BaseTpaClaimImportService // References 'cl_inward_no' => 'claim_number', - - 'priority' => 1, - 'mode_of_intimation' => 5, - 'ticket_type_id' => 1, ]; protected $statusMapping = [ @@ -112,6 +106,17 @@ class RcareClaimImportService extends BaseTpaClaimImportService 'Cashless Document Awaited' => 3, ]; + protected $dateColumns = [ + 'inward_date', + 'policy_start_date', + 'policy_end_date', + 'doa_opd_treatment_from', + 'dod_opd_treatment_to', + 'approved_date', + 'cheque_neft_date' + ]; + + /** * ABSTRACT FUNCTIONs */ @@ -205,14 +210,13 @@ class RcareClaimImportService extends BaseTpaClaimImportService $dbColumn = $map['db_column']; $value = $row[$excelColumn] ?? null; - - if ($this->isDateValue($value)) { - $value = $this->normalizeDate($value); - } - $item[$dbColumn] = $value; } + foreach ($this->dateColumns as $key => $value) { + $item[$value] = change_date_format($item[$value] ?? null, 'd-M-y', 'Y-m-d'); + } + $params = [ 'doa_opd_treatment_from' => $item['doa_opd_treatment_from'] ?? null, 'employee_member_id' => $item['employee_member_id'] ?? null, @@ -299,7 +303,7 @@ class RcareClaimImportService extends BaseTpaClaimImportService $item['tpa_id'] = $client_policy_data['tpa_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['policy_no'] = $client_policy_data['policy_no'] ?? null; - $item['relationship'] = $this->convertRelation($row['relation'] ?? null, $row['gender'] ?? null); + $item['relationship'] = $this->convertRelation($row['relation'] ?? null); $employee_data = $this->getEmployeeDetails($file_data['client_id'], $file_data['client_policy_id'], $row['employee_member_id'], $item['relationship']); @@ -334,7 +338,12 @@ class RcareClaimImportService extends BaseTpaClaimImportService $item['claim_status_id'] = $statusMapping[$row['final_status']] ?? 61; $item['file_id'] = $file_id; $item['created_by'] = $file_data['created_by'] ?? null; + $item['claim_dump_ref_id'] = $row['id']; $item['claim_type'] = 1; + $item['priority'] = 1; + $item['mode_of_intimation'] = 5; + $item['ticket_type_id'] = 1; + $mapped[] = $item; } @@ -363,83 +372,47 @@ class RcareClaimImportService extends BaseTpaClaimImportService * HELPER FUNCTIONs */ - public function isDateValue($value): bool - { - if (empty($value)) { - return false; - } - - // Excel numeric date (e.g. 44927) - if (is_numeric($value) && $value > 30000) { - return true; - } - - // Common date formats - return preg_match( - '/^\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}$|^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/', - (string) $value - ) === 1; - } - - - public function normalizeDate($value): ?string - { - try { - // Excel numeric date - if (is_numeric($value)) { - return date('Y-m-d', \PhpOffice\PhpSpreadsheet\Shared\Date::excelToTimestamp($value)); - } - - // String date - return date('Y-m-d', strtotime(str_replace('/', '-', $value))); - } catch (\Throwable $e) { - return null; - } - } - - - public function convertRelation(string $relation, string $gender): ?string + public function convertRelation(?string $relation): ?string { if (empty($relation)) { return null; } $relation = strtolower($relation); - $gender = strtolower($gender); - if ($relation == 'self') { - return $relation; + if (str_contains($relation, 'self')) { + return 'self'; } - if ($relation == 'spouse') { - return $relation; + if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) { + return 'spouse'; } - if ($relation == 'child' && $gender == 'male') { - return 'son'; - } - - if ($relation == 'child' && $gender == 'female') { + if (str_contains($relation, 'daughter')) { return 'daughter'; } - if ($relation == 'parents' && $gender == 'male') { - return 'father'; + if (str_contains($relation, 'son')) { + return 'son'; } - if ($relation == 'parents' && $gender == 'female') { - return 'mother'; - } - - if ($relation == 'parents-in-law' && $gender == 'male') { + if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) { return 'father-in-law'; } - if ($relation == 'parents-in-law' && $gender == 'female') { + if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) { return 'mother-in-law'; } - return null; + if (str_contains($relation, 'father')) { + return 'father'; + } + + if (str_contains($relation, 'mother')) { + return 'mother'; + } + + return null; // unmatched case } diff --git a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php index 33243d22..b8bc92b8 100644 --- a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php @@ -346,9 +346,6 @@ class VidalClaimImportService extends BaseTpaClaimImportService // Meta 'file_id' => 'file_id', - 'priority' => 1, - 'mode_of_intimation' => 5, - 'ticket_type_id' => 1, ]; @@ -566,6 +563,9 @@ class VidalClaimImportService extends BaseTpaClaimImportService $item['claim_dump_ref_id'] = $row['id']; $item['created_by'] = $file_data['created_by'] ?? null; $item['claim_type'] = isset($row['mainclaim_prepost_type']) && !empty($row['mainclaim_prepost_type']) && strtolower($row['mainclaim_prepost_type']) == 'normal' ? 1 : 3; + $item['priority'] = 1; + $item['mode_of_intimation'] = 5; + $item['ticket_type_id'] = 1; $mapped[] = $item; }