FIX_ISSUE

This commit is contained in:
VENKATESHWARAN 2026-02-06 11:41:25 +05:30
parent 018209de30
commit 1987a94e8a
9 changed files with 199 additions and 247 deletions

View File

@ -6380,6 +6380,8 @@ class ClientController extends AdminController
// $response = $ticketServiceController->tpaClaimDumpImporter(["file_id" => 54]); //mediassist
// $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 48]); //vidal
// $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 54]); //mediassist
// $response = $ticketServiceController->tpaClaimDumpToTicketMasterImporters(["file_id" => 4]); //abhi
// dd($response);
// ---------- TICKET CONTROLLER --------------------------------------------------------------------------------
@ -7760,180 +7762,6 @@ class ClientController extends AdminController
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id ,$pre_client_data['id']);
return $combinedHrAccessData;
}
// do not remove this commented items
// public function constructHrAccessData($data, $client_id , $pre_client_id)
// {
// // print_rr($data);die;
// $preHrs = $data['pre_hr_data'];
// $postHrs = $data['post_hr_data'];
// $hrAccessTableData = $data['hr_access_table_data'];
// $merged = [];
// // Merge based on mobile and email
// foreach ($postHrs as $post) {
// $found = false;
// foreach ($preHrs as $index => $pre) {
// if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) {
// $merged[] = [
// 'pre_hr_id' => $pre['pre_hr_id'],
// 'post_hr_id' => $post['post_hr_id'],
// 'hr_name' => $post['hr_name'],
// 'hr_mobile' => $post['hr_mobile'],
// 'hr_mail' => $post['hr_mail'],
// 'pre_branch_id' => $pre['pre_branch_id'] ?? null,
// 'post_branch_id' => $post['post_branch_id'] ?? null,
// 'post_branch_name' => $post['post_branch_name'] ?? null
// ];
// unset($preHrs[$index]); // remove matched pre_hr
// $found = true;
// break;
// }
// }
// if (!$found) {
// $merged[] = [
// 'pre_hr_id' => null,
// 'post_hr_id' => $post['post_hr_id'],
// 'hr_name' => $post['hr_name'],
// 'hr_mobile' => $post['hr_mobile'],
// 'hr_mail' => $post['hr_mail'],
// 'pre_branch_id' => $pre['pre_branch_id'] ?? null,
// 'post_branch_id' => $post['post_branch_id'] ?? null ,
// 'post_branch_name' => $post['post_branch_name'] ?? null
// ];
// }
// }
// // Remaining preHrs (not matched)
// foreach ($preHrs as $pre) {
// foreach ($merged as $value) {
// if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) {
// continue 2; // Skip adding this pre_hr as it's already matched
// }
// }
// $merged[] = [
// 'pre_hr_id' => $pre['pre_hr_id'],
// 'post_hr_id' => null,
// 'hr_name' => $pre['hr_name'],
// 'hr_mobile' => $pre['hr_mobile'],
// 'hr_mail' => $pre['hr_mail'],
// 'pre_branch_id' => $pre['pre_branch_id'] ?? null,
// 'post_branch_id' => $post['post_branch_id'] ?? null ,
// 'post_branch_name' => $post['post_branch_name'] ?? null
// ];
// }
// // dd($merged);
// $result = [];
// if (empty($hrAccessTableData)) {
// // No access data — fill result with hr data and other fields as null
// foreach ($merged as $hr) {
// $result[] = [
// 'hr_access_table_pk' => null,
// 'post_client_id' => $client_id ?? null,
// 'pre_hr_id' => $hr['pre_hr_id'] ?? null,
// 'post_hr_id' => $hr['post_hr_id'] ?? null,
// 'allowed_pre_modules' => [],
// 'allowed_post_modules' => [],
// 'allowed_pre_policies' => [],
// 'allowed_active_policies' => [],
// 'allowed_cd' => [],
// 'hr_name' => $hr['hr_name'] ?? null,
// 'hr_mobile' => $hr['hr_mobile'] ?? null,
// 'hr_mail' => $hr['hr_mail'] ?? null,
// 'pre_branch_id' => $hr['pre_branch_id'] ?? null,
// 'post_branch_id' => $hr['post_branch_id'] ?? null ,
// 'post_branch_name' => $hr['post_branch_name'] ?? null ,
// 'pre_client_id' => $pre_client_id ?? null
// ];
// }
// } else {
// // First create a map of HR data by post_hr_id for quick lookup
// $hrMap = [];
// foreach ($merged as $hr) {
// $hrMap[$hr['post_hr_id']] = $hr;
// }
// // Process access data first
// foreach ($hrAccessTableData as $access) {
// $post_hr_id = $access['post_hr_id'];
// // Check if this HR exists in our merged data
// if (isset($hrMap[$post_hr_id])) {
// $hr = $hrMap[$post_hr_id];
// $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
// // Parse allowed modules
// $allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
// $allowed_pre_modules = $allowed_modules['pre'] ?? [];
// $allowed_post_modules = $allowed_modules['post'] ?? [];
// $result[$temp_arr_key] = [
// 'hr_access_table_pk' => $access['id'] ?? null,
// 'post_client_id' => $access['post_client_id'] ?? null,
// 'pre_hr_id' => $hr['pre_hr_id'] ?? null,
// 'post_hr_id' => $hr['post_hr_id'] ?? null,
// 'allowed_pre_modules' => $allowed_pre_modules,
// 'allowed_post_modules' => $allowed_post_modules,
// 'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
// 'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [],
// 'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
// 'hr_name' => $hr['hr_name'],
// 'hr_mobile' => $hr['hr_mobile'],
// 'hr_mail' => $hr['hr_mail'],
// 'pre_branch_id' => $hr['pre_branch_id'] ?? null,
// 'post_branch_id' => $hr['post_branch_id'] ?? null ,
// 'post_branch_name' => $hr['post_branch_name'] ?? null ,
// 'pre_client_id' => $pre_client_id ?? null
// ];
// // Remove from map so we know it's been processed
// unset($hrMap[$post_hr_id]);
// }
// }
// // Now process any remaining HRs that didn't have access records
// foreach ($hrMap as $hr) {
// $temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
// $result[$temp_arr_key] = [
// 'hr_access_table_pk' => null,
// 'post_client_id' => $client_id ?? null,
// 'pre_hr_id' => $hr['pre_hr_id'] ?? null,
// 'post_hr_id' => $hr['post_hr_id'] ?? null,
// 'allowed_pre_modules' => [],
// 'allowed_post_modules' => [],
// 'allowed_pre_policies' => [],
// 'allowed_active_policies' => [],
// 'allowed_cd' => [],
// 'hr_name' => $hr['hr_name'] ?? null,
// 'hr_mobile' => $hr['hr_mobile'] ?? null,
// 'hr_mail' => $hr['hr_mail'] ?? null,
// 'pre_branch_id' => $hr['pre_branch_id'] ?? null,
// 'post_branch_id' => $hr['post_branch_id'] ?? null ,
// 'post_branch_name' => $hr['post_branch_name'] ?? null ,
// 'pre_client_id' => $pre_client_id ?? null
// ];
// }
// }
// $resultData['hr_access_data'] = array_values($result);
// $resultData['pre_policy_data'] = $data['pre_policy_data'];
// $resultData['post_policy_data'] = $data['post_policy_data'];
// $resultData['post_cd_data'] = $data['post_cd_data'];
// return $resultData;
// }
public function constructHrAccessData($data, $client_id , $pre_client_id)
{
@ -8189,7 +8017,180 @@ class ClientController extends AdminController
];
return ['status' => 'failed', 'code' => 500, 'message' => $th->getMessage(), 'error_data' => $errorData];
}
}
}
public function constructHrAccessData_OLD($data, $client_id , $pre_client_id)
{
// print_rr($data);die;
$preHrs = $data['pre_hr_data'];
$postHrs = $data['post_hr_data'];
$hrAccessTableData = $data['hr_access_table_data'];
$merged = [];
// Merge based on mobile and email
foreach ($postHrs as $post) {
$found = false;
foreach ($preHrs as $index => $pre) {
if ( trim($post['hr_mobile']) == trim($pre['hr_mobile']) && trim($post['hr_mail']) == trim($pre['hr_mail']) ) {
$merged[] = [
'pre_hr_id' => $pre['pre_hr_id'],
'post_hr_id' => $post['post_hr_id'],
'hr_name' => $post['hr_name'],
'hr_mobile' => $post['hr_mobile'],
'hr_mail' => $post['hr_mail'],
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
'post_branch_id' => $post['post_branch_id'] ?? null,
'post_branch_name' => $post['post_branch_name'] ?? null
];
unset($preHrs[$index]); // remove matched pre_hr
$found = true;
break;
}
}
if (!$found) {
$merged[] = [
'pre_hr_id' => null,
'post_hr_id' => $post['post_hr_id'],
'hr_name' => $post['hr_name'],
'hr_mobile' => $post['hr_mobile'],
'hr_mail' => $post['hr_mail'],
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
'post_branch_id' => $post['post_branch_id'] ?? null ,
'post_branch_name' => $post['post_branch_name'] ?? null
];
}
}
// Remaining preHrs (not matched)
foreach ($preHrs as $pre) {
foreach ($merged as $value) {
if ( trim($pre['hr_mobile']) == trim($value['hr_mobile']) && trim($pre['hr_mail']) == trim($value['hr_mail']) ) {
continue 2; // Skip adding this pre_hr as it's already matched
}
}
$merged[] = [
'pre_hr_id' => $pre['pre_hr_id'],
'post_hr_id' => null,
'hr_name' => $pre['hr_name'],
'hr_mobile' => $pre['hr_mobile'],
'hr_mail' => $pre['hr_mail'],
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
'post_branch_id' => $post['post_branch_id'] ?? null ,
'post_branch_name' => $post['post_branch_name'] ?? null
];
}
// dd($merged);
$result = [];
if (empty($hrAccessTableData)) {
// No access data — fill result with hr data and other fields as null
foreach ($merged as $hr) {
$result[] = [
'hr_access_table_pk' => null,
'post_client_id' => $client_id ?? null,
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
'post_hr_id' => $hr['post_hr_id'] ?? null,
'allowed_pre_modules' => [],
'allowed_post_modules' => [],
'allowed_pre_policies' => [],
'allowed_active_policies' => [],
'allowed_cd' => [],
'hr_name' => $hr['hr_name'] ?? null,
'hr_mobile' => $hr['hr_mobile'] ?? null,
'hr_mail' => $hr['hr_mail'] ?? null,
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
'post_branch_id' => $hr['post_branch_id'] ?? null ,
'post_branch_name' => $hr['post_branch_name'] ?? null ,
'pre_client_id' => $pre_client_id ?? null
];
}
} else {
// First create a map of HR data by post_hr_id for quick lookup
$hrMap = [];
foreach ($merged as $hr) {
$hrMap[$hr['post_hr_id']] = $hr;
}
// Process access data first
foreach ($hrAccessTableData as $access) {
$post_hr_id = $access['post_hr_id'];
// Check if this HR exists in our merged data
if (isset($hrMap[$post_hr_id])) {
$hr = $hrMap[$post_hr_id];
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
// Parse allowed modules
$allowed_modules = json_decode($access['allowed_modules'], true) ?? null;
$allowed_pre_modules = $allowed_modules['pre'] ?? [];
$allowed_post_modules = $allowed_modules['post'] ?? [];
$result[$temp_arr_key] = [
'hr_access_table_pk' => $access['id'] ?? null,
'post_client_id' => $access['post_client_id'] ?? null,
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
'post_hr_id' => $hr['post_hr_id'] ?? null,
'allowed_pre_modules' => $allowed_pre_modules,
'allowed_post_modules' => $allowed_post_modules,
'allowed_pre_policies' => json_decode($access['allowed_pre_policies'], true) ?? [],
'allowed_active_policies' => json_decode($access['allowed_active_policies'], true) ?? [],
'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
'hr_name' => $hr['hr_name'],
'hr_mobile' => $hr['hr_mobile'],
'hr_mail' => $hr['hr_mail'],
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
'post_branch_id' => $hr['post_branch_id'] ?? null ,
'post_branch_name' => $hr['post_branch_name'] ?? null ,
'pre_client_id' => $pre_client_id ?? null
];
// Remove from map so we know it's been processed
unset($hrMap[$post_hr_id]);
}
}
// Now process any remaining HRs that didn't have access records
foreach ($hrMap as $hr) {
$temp_arr_key = $hr['hr_mobile'] . $hr['hr_mail'];
$result[$temp_arr_key] = [
'hr_access_table_pk' => null,
'post_client_id' => $client_id ?? null,
'pre_hr_id' => $hr['pre_hr_id'] ?? null,
'post_hr_id' => $hr['post_hr_id'] ?? null,
'allowed_pre_modules' => [],
'allowed_post_modules' => [],
'allowed_pre_policies' => [],
'allowed_active_policies' => [],
'allowed_cd' => [],
'hr_name' => $hr['hr_name'] ?? null,
'hr_mobile' => $hr['hr_mobile'] ?? null,
'hr_mail' => $hr['hr_mail'] ?? null,
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
'post_branch_id' => $hr['post_branch_id'] ?? null ,
'post_branch_name' => $hr['post_branch_name'] ?? null ,
'pre_client_id' => $pre_client_id ?? null
];
}
}
$resultData['hr_access_data'] = array_values($result);
$resultData['pre_policy_data'] = $data['pre_policy_data'];
$resultData['post_policy_data'] = $data['post_policy_data'];
$resultData['post_cd_data'] = $data['post_cd_data'];
return $resultData;
}
public function saveHrAccessData()
{
@ -8854,17 +8855,6 @@ class ClientController extends AdminController
return $default_templates_inserted ? true : false;
}
// public function downloadClientKycDocs_2()
// {
// $file = WRITEPATH . 'uploads/client_kyc_documents/' . $file_name; // Example file path
// if (file_exists($file)) {
// return $this->response->download($file, null)->setFileName($file_name);
// } else {
// return "File not found.";
// }
// }
public function downloadClientKycDocs_2($file_name = null)
{
if (!$file_name) {

View File

@ -86,10 +86,6 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
// Employee / Member details
'member_code' => 'emp_code',
'relation' => 'relationship',
// Policy / Claim identifiers
'policy_number' => 'policy_no',
'abhi_claim_no' => 'claim_number',
// Dates
@ -428,41 +424,31 @@ class AbhiClaimImportService extends BaseTpaClaimImportService
return null;
}
$relation = strtolower($relation);
// trim removes whitespace, strtolower handles case sensitivity
$relation = strtolower(trim($relation));
if (str_contains($relation, 'self')) {
return 'self';
// Mapping specific keywords to standardized outputs
// ORDER MATTERS: Specific phrases (in-law) must come before general ones (father)
$map = [
'father-in-law' => ['father in law', 'father-in-law', 'fil'],
'mother-in-law' => ['mother in law', 'mother-in-law', 'mil'],
'father' => ['father', 'papa', 'dad'],
'mother' => ['mother', 'mom', 'mummy'],
'spouse' => ['spouse', 'wife', 'husband', 'hubby'],
'daughter' => ['daughter', 'daug'],
'son' => ['son'],
'self' => ['self', 'employee', 'main'],
];
foreach ($map as $standard => $keywords) {
foreach ($keywords as $keyword) {
if (str_contains($relation, $keyword)) {
return $standard;
}
}
}
if (str_contains($relation, 'spouse') || str_contains($relation, 'wife') || str_contains($relation, 'husband')) {
return 'spouse';
}
if (str_contains($relation, 'daughter')) {
return 'daughter';
}
if (str_contains($relation, 'son')) {
return 'son';
}
if (str_contains($relation, 'father in law') || str_contains($relation, 'father-in-law')) {
return 'father-in-law';
}
if (str_contains($relation, 'mother in law') || str_contains($relation, 'mother-in-law')) {
return 'mother-in-law';
}
if (str_contains($relation, 'father')) {
return 'father';
}
if (str_contains($relation, 'mother')) {
return 'mother';
}
return null; // unmatched case
return null;
}
}

View File

@ -274,20 +274,6 @@ abstract class BaseTpaClaimImportService
*/
protected function getTpaClaimDumpData(string $table, array $params): array
{
$tpaClaimDumpDataCount = $this->db
->table($table)
->where('is_active', 1)
->where('file_id', $params['file_id'])
->where('ticket_id IS NULL')
->where('master_reject_reason IS NULL')
->countAllResults();
$batch_size = 100;
$total_batch = (int) ceil($tpaClaimDumpDataCount / $batch_size);
$batch_no = isset($params['batch_no']) ? (int) $params['batch_no'] : null;
$last_emp_id = (int) ($params['last_emp_id'] ?? 0);
return $this->db
->table($table)
->where('is_active', 1)
@ -296,7 +282,6 @@ abstract class BaseTpaClaimImportService
->where('master_reject_reason IS NULL')
->get()
->getResultArray();
}
/**

View File

@ -141,12 +141,8 @@ class FhplClaimImportService extends BaseTpaClaimImportService
// Claim / Reference
'claim_id' => 'claim_number',
// Policy
'policy_no' => 'policy_no',
// Employee / Member
'employee_id' => 'emp_code',
'relationship' => 'relationship',
// Claim Dates
'admission_date' => 'doa',

View File

@ -81,7 +81,6 @@ class IciciClaimImportService extends BaseTpaClaimImportService
// Employee / Member
'employee_member_id' => 'emp_code',
'relation_group' => 'relationship',
// Claim
'claim_number' => 'claim_number',

View File

@ -116,10 +116,8 @@ class MediAssistClaimImportService extends BaseTpaClaimImportService
// Employee / Beneficiary details
'pribenef_employee_code' => 'emp_code',
'benef_relation' => 'relationship',
// Policy / Claim identifiers
'policy_no' => 'policy_no',
'claim_id' => 'claim_number',
'event_id' => 'tpa_no',
'claim_pre_auths' => 'tpa_claim_push_reference_no',

View File

@ -60,10 +60,8 @@ class RcareClaimImportService extends BaseTpaClaimImportService
// Employee / Member
'employee_member_id' => 'emp_code',
'relation' => 'relationship',
// Policy
'policy_number' => 'policy_no',
'policy_start_date' => 'date_of_incep',
// Claim Dates

View File

@ -314,7 +314,6 @@ class VidalClaimImportService extends BaseTpaClaimImportService
protected $ticketMasterMapping = [
// Policy / Claim identifiers
'insurer_policy_number' => 'policy_no',
'insurer_claim_number' => 'claim_number',
'tpa_claim_number' => 'tpa_claim_id',

View File

@ -93,6 +93,7 @@ class TicketMasterModel extends Model
'required_docs',
'policy_transaction_id',
'tpa_claim_type',
'claim_dump_ref_id',
];