FIX_ISSUE

This commit is contained in:
VENKATESHWARAN 2026-01-28 09:50:53 +05:30
parent 350cf2d520
commit 07295b3ad6
10 changed files with 262 additions and 331 deletions

View File

@ -107,4 +107,8 @@ ABHI_PRIMARY_KEY_CONSTANT =
R_CARE_PRIMARY_KEY_CONSTANT = R_CARE_PRIMARY_KEY_CONSTANT =
FHPL_PRIMARY_KEY_CONSTANT = FHPL_PRIMARY_KEY_CONSTANT =
VIDAL_PRIMARY_KEY_CONSTANT =
MEDI_ASSIST_PRIMARY_KEY_CONSTANT =

View File

@ -6588,6 +6588,7 @@ class ClientController extends AdminController
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 51]); //abhi // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 51]); //abhi
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 48]); //vidal // $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 48]); //vidal
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 53]); //icici // $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]);
// $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]); // $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]);
// dd($response); // dd($response);

View File

@ -23,11 +23,11 @@ class AuthMVC implements FilterInterface
// } // }
// Fingerprint validation // Fingerprint validation
$fp = generateFingerprint(); // $fp = generateFingerprint();
// log_message('error',$fp); // // log_message('error',$fp);
if (session()->get('fingerprint') !== $fp) { // if (session()->get('fingerprint') !== $fp) {
return AuthLogout::logout(); // return AuthLogout::logout();
} // }
} }

View File

@ -640,6 +640,8 @@ if (!function_exists('change_date_format')) {
'd/m/Y', // 01/01/2025 'd/m/Y', // 01/01/2025
'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
]; ];

View File

@ -82,7 +82,6 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
["excel_column" => ["col_name" => "CORPORATE_EMPLOYEE_CODE", "col_index" => 63], "db_column" => "corporate_employee_code"], ["excel_column" => ["col_name" => "CORPORATE_EMPLOYEE_CODE", "col_index" => 63], "db_column" => "corporate_employee_code"],
]; ];
protected $ticketMasterMapping = [ protected $ticketMasterMapping = [
// Employee / Member details // Employee / Member details
@ -115,19 +114,31 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
// Misc // Misc
'diagnosis' => 'claim_description', 'diagnosis' => 'claim_description',
'healthcard_id' => 'tpa_no', 'healthcard_id' => 'tpa_no',
'priority' => 1,
'mode_of_intimation' => 5,
'ticket_type_id' => 1,
]; ];
protected $statusMapping = [ protected $statusMapping = [
'Settled' => 11, 'Settled' => 11,
'Rejected' => 8, 'Rejected' => 8,
'Cancelled' => 13, '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 * ABSTRACT FUNCTIONs
@ -215,14 +226,13 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
$dbColumn = $map['db_column']; $dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null; $value = $row[$excelColumn] ?? null;
if ($this->isDateValue($value)) {
$value = $this->normalizeDate($value);
}
$item[$dbColumn] = trim($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 = [ $params = [
'doa' => $item['doa'] ?? null, 'doa' => $item['doa'] ?? null,
'member_code' => $item['member_code'] ?? null, 'member_code' => $item['member_code'] ?? null,
@ -346,6 +356,10 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
$item['claim_dump_ref_id'] = $row['id']; $item['claim_dump_ref_id'] = $row['id'];
$item['created_by'] = $file_data['created_by'] ?? null; $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'] = 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; $mapped[] = $item;
} }

View File

@ -4,8 +4,6 @@ namespace App\Libraries\TPAClaimsImportServices;
use App\Models\TicketMasterModel; use App\Models\TicketMasterModel;
use App\Models\ClientPolicyModel; use App\Models\ClientPolicyModel;
use App\Models\ClientRMModel;
use App\Models\EmployeeModel;
use App\Models\ClaimDumpFileModel; use App\Models\ClaimDumpFileModel;
use App\Models\ClaimsDumpFhplModel; use App\Models\ClaimsDumpFhplModel;
@ -140,39 +138,45 @@ class FhplClaimImportService extends BaseTpaClaimImportService
protected $ticketMasterMapping = [ protected $ticketMasterMapping = [
// Employee / Member details // Claim / Reference
'member_code' => 'emp_code', 'claim_id' => 'claim_number',
'relation' => 'relationship',
// Policy / Claim identifiers // Policy
'policy_number' => 'policy_no', 'policy_no' => 'policy_no',
'certificate_no' => 'claim_number',
'abhi_claim_no' => 'tpa_claim_id',
// Dates // Employee / Member
'doa' => 'doa', 'employee_id' => 'emp_code',
'dod' => 'dod', 'relationship' => 'relationship',
'intimation_date' => 'date_of_intimat',
// Claim info // Claim Dates
'claim_type' => 'claim_type', 'admission_date' => 'doa',
'claim_status' => 'tpa_claim_status', 'discharge_date' => 'dod',
'claimed_amount' => 'claim_amount', 'claim_received_date' => 'date_of_intimat',
'abhi_amount_less_coins_current_month' => 'approved_amount', 'claim_passed_date' => 'approved_date',
'settled_date' => 'settled_date',
// Hospital details 'current_claim_status' => 'tpa_claim_status',
'hospital_name' => 'hospital_name',
'hospital_city' => 'hospital_city',
'hospital_state' => 'hospital_state',
// Settlement / decision // Amounts
'repudiation_date' => 'denial_date', 'claim_amount' => 'claim_amount',
'settled_date' => 'settled_date', 'settled_amount' => 'settled_amount',
'rejection_category' => 'denial_reason', 'disallowed_amount' => 'denial_reason',
'coverage_amount' => 'si_amt',
// Misc // Hospital
'diagnosis' => 'claim_description', 'provider_name' => 'hospital_name',
'healthcard_id' => 'tpa_no', '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, 'priority' => 1,
'mode_of_intimation' => 5, 'mode_of_intimation' => 5,
@ -184,6 +188,33 @@ class FhplClaimImportService extends BaseTpaClaimImportService
'Rejected' => 8, '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 * ABSTRACT FUNCTIONs
*/ */
@ -260,27 +291,26 @@ class FhplClaimImportService extends BaseTpaClaimImportService
$dbColumn = $map['db_column']; $dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null; $value = $row[$excelColumn] ?? null;
if ($this->isDateValue($value)) {
$value = $this->normalizeDate($value);
}
$item[$dbColumn] = trim($value); $item[$dbColumn] = trim($value);
} }
// $params = [ foreach ($this->dateColumns as $key => $value) {
// 'admission_date' => change_date_format($item['admission_date'] ?? '') ?? null, $item[$value] = change_date_format($item[$value] ?? null, 'd-M-y', 'Y-m-d');
// 'employee_number' => $item['employee_number'] ?? null, }
// 'claim_amount' => $item['claim_amount'] ?? null,
// 'primary_policy_holder_card_id' => $item['primary_policy_holder_card_id'] ?? null
// ];
// $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) { $is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_fhpl', $params);
// $item = [];
// continue; if ($is_duplicate) {
// } $item = [];
continue;
}
$item['file_id'] = $file_id ?? null; $item['file_id'] = $file_id ?? null;
$item['client_id'] = $file_data['client_id'] ?? null; $item['client_id'] = $file_data['client_id'] ?? null;
@ -332,10 +362,10 @@ class FhplClaimImportService extends BaseTpaClaimImportService
foreach ($tpaClaimDumpData as $row) { foreach ($tpaClaimDumpData as $row) {
$params = [ $params = [
'doa' => change_date_format($row['date_of_admission'] ?? '') ?? null, 'doa' => change_date_format($row['admission_date'] ?? '') ?? null,
'emp_code' => $row['employee_number'] ?? null, 'emp_code' => $row['employee_id'] ?? null,
'claim_amount' => $row['claim_amount'] ?? 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); $isduplicate = $this->checkDublicateTicketMasterClaim($params);
@ -354,9 +384,9 @@ class FhplClaimImportService extends BaseTpaClaimImportService
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null; $item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? 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)) { if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null; $item['emp_id'] = $employee_data['id'] ?? null;
@ -390,7 +420,10 @@ class FhplClaimImportService extends BaseTpaClaimImportService
$item['file_id'] = $file_id; $item['file_id'] = $file_id;
$item['claim_dump_ref_id'] = $row['id']; $item['claim_dump_ref_id'] = $row['id'];
$item['created_by'] = $file_data['created_by'] ?? null; $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; $mapped[] = $item;
} }
@ -419,83 +452,47 @@ class FhplClaimImportService extends BaseTpaClaimImportService
* HELPER FUNCTIONs * HELPER FUNCTIONs
*/ */
public function isDateValue($value): bool public function convertRelation(?string $relation): ?string
{
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
{ {
if (empty($relation)) { if (empty($relation)) {
return null; return null;
} }
$relation = strtolower($relation); $relation = strtolower($relation);
$gender = strtolower($gender);
if ($relation == 'self') { if (str_contains($relation, 'self')) {
return $relation; return 'self';
} }
if ($relation == 'spouse') { if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return $relation; return 'spouse';
} }
if ($relation == 'child' && $gender == 'male') { if (str_contains($relation, 'daughter')) {
return 'son';
}
if ($relation == 'child' && $gender == 'female') {
return 'daughter'; return 'daughter';
} }
if ($relation == 'parents' && $gender == 'male') { if (str_contains($relation, 'son')) {
return 'father'; return 'son';
} }
if ($relation == 'parents' && $gender == 'female') { if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'mother';
}
if ($relation == 'parents-in-law' && $gender == 'male') {
return '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 'mother-in-law';
} }
return null; if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
} }

View File

@ -99,7 +99,7 @@ class IciciClaimImportService extends BaseTpaClaimImportService
'hospital_state' => 'hospital_state', 'hospital_state' => 'hospital_state',
'cheque_number' => 'utr_details', 'cheque_number' => 'utr_details',
'tpa_no' => 'uhid', 'uhid' => 'tpa_no',
'rejected_query_desc' => 'claim_description', 'rejected_query_desc' => 'claim_description',
]; ];
@ -108,6 +108,23 @@ class IciciClaimImportService extends BaseTpaClaimImportService
'REJECTED' => 8, '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 * ABSTRACT FUNCTIONs
@ -203,14 +220,13 @@ class IciciClaimImportService extends BaseTpaClaimImportService
$dbColumn = $map['db_column']; $dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null; $value = $row[$excelColumn] ?? null;
if ($this->isDateValue($value)) {
$value = $this->normalizeDate($value);
}
$item[$dbColumn] = $value; $item[$dbColumn] = $value;
} }
foreach ($this->dateColumns as $key => $value) {
$item[$value] = change_date_format($item[$value] ?? null);
}
$params = [ $params = [
'doa' => change_date_format($item['doa'] ?? '') ?? null, 'doa' => change_date_format($item['doa'] ?? '') ?? null,
'employee_member_id' => $item['employee_member_id'] ?? 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['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? 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)) { if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null; $item['emp_id'] = $employee_data['id'] ?? null;
@ -330,9 +346,13 @@ class IciciClaimImportService extends BaseTpaClaimImportService
// Meta fields // Meta fields
$item['claim_status_id'] = $statusMapping[$row['updated_status']] ?? 61; $item['claim_status_id'] = $statusMapping[$row['updated_status']] ?? 61;
$item['claim_dump_ref_id'] = $row['id'];
$item['file_id'] = $file_id; $item['file_id'] = $file_id;
$item['created_by'] = $file_data['created_by'] ?? null; $item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_type'] = 1; $item['claim_type'] = 1;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item; $mapped[] = $item;
} }
@ -361,83 +381,48 @@ class IciciClaimImportService extends BaseTpaClaimImportService
* HELPER FUNCTIONs * HELPER FUNCTIONs
*/ */
public function isDateValue($value): bool
{
if (empty($value)) {
return false;
}
// Excel numeric date (e.g. 44927) public function convertRelation(?string $relation): ?string
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
{ {
if (empty($relation)) { if (empty($relation)) {
return null; return null;
} }
$relation = strtolower($relation); $relation = strtolower($relation);
$gender = strtolower($gender);
if ($relation == 'self') { if (str_contains($relation, 'self')) {
return $relation; return 'self';
} }
if ($relation == 'spouse') { if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return $relation; return 'spouse';
} }
if ($relation == 'child' && $gender == 'male') { if (str_contains($relation, 'daughter')) {
return 'son';
}
if ($relation == 'child' && $gender == 'female') {
return 'daughter'; return 'daughter';
} }
if ($relation == 'parents' && $gender == 'male') { if (str_contains($relation, 'son')) {
return 'father'; return 'son';
} }
if ($relation == 'parents' && $gender == 'female') { if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'mother';
}
if ($relation == 'parents-in-law' && $gender == 'male') {
return '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 'mother-in-law';
} }
return null; if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
} }

View File

@ -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"], ["excel_column" => ["col_name" => "balance_sum_insured_exhausted", "col_index" => 93], "db_column" => "balance_sum_insured_exhausted"],
]; ];
protected $ticketMasterMapping = [ protected $ticketMasterMapping = [
// Employee / Beneficiary details // Employee / Beneficiary details
@ -121,12 +120,11 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
// Policy / Claim identifiers // Policy / Claim identifiers
'policy_no' => 'policy_no', 'policy_no' => 'policy_no',
'claim_id' => 'tpa_claim_id', 'claim_id' => 'claim_number',
'insurer_claim_ref_no' => 'tpa_no', 'event_id' => 'tpa_no',
'claim_pre_auths' => 'tpa_claim_push_reference_no', 'claim_pre_auths' => 'tpa_claim_push_reference_no',
// Claim type & status // Claim type & status
'claim_type' => 'claim_type',
'claim_status' => 'tpa_claim_status', 'claim_status' => 'tpa_claim_status',
// Dates // Dates
@ -155,12 +153,8 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
// Payment // Payment
'utr_no' => 'utr_details', 'utr_no' => 'utr_details',
'priority' => 1,
'mode_of_intimation' => 5,
'ticket_type_id' => 1,
]; ];
protected $statusMapping = [ protected $statusMapping = [
'Settled' => 11, 'Settled' => 11,
'Rejected' => 8, 'Rejected' => 8,
@ -248,19 +242,14 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
$dbColumn = $map['db_column']; $dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null; $value = $row[$excelColumn] ?? null;
if ($this->isDateValue($value)) {
$value = $this->normalizeDate($value);
}
$item[$dbColumn] = $value; $item[$dbColumn] = $value;
} }
$params = [ $params = [
'date_of_admission' => change_date_format($item['date_of_admission'] ?? '') ?? null, '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, '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); $is_duplicate = $this->checkDuplicateTpaClaim('claims_dump_medi_assist', $params);
@ -321,9 +310,9 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
$params = [ $params = [
'doa' => change_date_format($row['date_of_admission'] ?? '') ?? null, '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, '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); $isduplicate = $this->checkDublicateTicketMasterClaim($params);
@ -342,9 +331,9 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
$item['tpa_id'] = $client_policy_data['tpa_id'] ?? null; $item['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? 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)) { if (!empty($employee_data)) {
$item['emp_id'] = $employee_data['id'] ?? null; $item['emp_id'] = $employee_data['id'] ?? null;
@ -378,7 +367,10 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
$item['file_id'] = $file_id; $item['file_id'] = $file_id;
$item['claim_status_id'] = $statusMapping[$row['claim_status']] ?? 61; $item['claim_status_id'] = $statusMapping[$row['claim_status']] ?? 61;
$item['created_by'] = $file_data['created_by'] ?? null; $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; $mapped[] = $item;
} }
@ -407,85 +399,48 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
* HELPER FUNCTIONs * HELPER FUNCTIONs
*/ */
public function isDateValue($value): bool public function convertRelation(?string $relation): ?string
{
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
{ {
if (empty($relation)) { if (empty($relation)) {
return null; return null;
} }
$relation = strtolower($relation); $relation = strtolower($relation);
$gender = strtolower($gender);
if ($relation == 'self') { if (str_contains($relation, 'self')) {
return $relation; return 'self';
} }
if ($relation == 'spouse') { if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return $relation; return 'spouse';
} }
if ($relation == 'child' && $gender == 'male') { if (str_contains($relation, 'daughter')) {
return 'son';
}
if ($relation == 'child' && $gender == 'female') {
return 'daughter'; return 'daughter';
} }
if ($relation == 'parents' && $gender == 'male') { if (str_contains($relation, 'son')) {
return 'father'; return 'son';
} }
if ($relation == 'parents' && $gender == 'female') { if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'mother';
}
if ($relation == 'parents-in-law' && $gender == 'male') {
return '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 'mother-in-law';
} }
return null; if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
} }
} }

View File

@ -60,8 +60,6 @@ class RcareClaimImportService extends BaseTpaClaimImportService
// Employee / Member // Employee / Member
'employee_member_id' => 'emp_code', 'employee_member_id' => 'emp_code',
'insured_name' => 'insured_name',
'patient_name' => 'emp_name',
'relation' => 'relationship', 'relation' => 'relationship',
// Policy // Policy
@ -95,10 +93,6 @@ class RcareClaimImportService extends BaseTpaClaimImportService
// References // References
'cl_inward_no' => 'claim_number', 'cl_inward_no' => 'claim_number',
'priority' => 1,
'mode_of_intimation' => 5,
'ticket_type_id' => 1,
]; ];
protected $statusMapping = [ protected $statusMapping = [
@ -112,6 +106,17 @@ class RcareClaimImportService extends BaseTpaClaimImportService
'Cashless Document Awaited' => 3, '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 * ABSTRACT FUNCTIONs
*/ */
@ -205,14 +210,13 @@ class RcareClaimImportService extends BaseTpaClaimImportService
$dbColumn = $map['db_column']; $dbColumn = $map['db_column'];
$value = $row[$excelColumn] ?? null; $value = $row[$excelColumn] ?? null;
if ($this->isDateValue($value)) {
$value = $this->normalizeDate($value);
}
$item[$dbColumn] = $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 = [ $params = [
'doa_opd_treatment_from' => $item['doa_opd_treatment_from'] ?? null, 'doa_opd_treatment_from' => $item['doa_opd_treatment_from'] ?? null,
'employee_member_id' => $item['employee_member_id'] ?? 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['tpa_id'] = $client_policy_data['tpa_id'] ?? null;
$item['acm_id'] = $client_policy_data['acm_id'] ?? null; $item['acm_id'] = $client_policy_data['acm_id'] ?? null;
$item['policy_no'] = $client_policy_data['policy_no'] ?? 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']); $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['claim_status_id'] = $statusMapping[$row['final_status']] ?? 61;
$item['file_id'] = $file_id; $item['file_id'] = $file_id;
$item['created_by'] = $file_data['created_by'] ?? null; $item['created_by'] = $file_data['created_by'] ?? null;
$item['claim_dump_ref_id'] = $row['id'];
$item['claim_type'] = 1; $item['claim_type'] = 1;
$item['priority'] = 1;
$item['mode_of_intimation'] = 5;
$item['ticket_type_id'] = 1;
$mapped[] = $item; $mapped[] = $item;
} }
@ -363,83 +372,47 @@ class RcareClaimImportService extends BaseTpaClaimImportService
* HELPER FUNCTIONs * HELPER FUNCTIONs
*/ */
public function isDateValue($value): bool public function convertRelation(?string $relation): ?string
{
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
{ {
if (empty($relation)) { if (empty($relation)) {
return null; return null;
} }
$relation = strtolower($relation); $relation = strtolower($relation);
$gender = strtolower($gender);
if ($relation == 'self') { if (str_contains($relation, 'self')) {
return $relation; return 'self';
} }
if ($relation == 'spouse') { if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return $relation; return 'spouse';
} }
if ($relation == 'child' && $gender == 'male') { if (str_contains($relation, 'daughter')) {
return 'son';
}
if ($relation == 'child' && $gender == 'female') {
return 'daughter'; return 'daughter';
} }
if ($relation == 'parents' && $gender == 'male') { if (str_contains($relation, 'son')) {
return 'father'; return 'son';
} }
if ($relation == 'parents' && $gender == 'female') { if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'mother';
}
if ($relation == 'parents-in-law' && $gender == 'male') {
return '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 'mother-in-law';
} }
return null; if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
} }

View File

@ -346,9 +346,6 @@ class VidalClaimImportService extends BaseTpaClaimImportService
// Meta // Meta
'file_id' => 'file_id', '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['claim_dump_ref_id'] = $row['id'];
$item['created_by'] = $file_data['created_by'] ?? null; $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'] = 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; $mapped[] = $item;
} }