diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3baa4314..73afbb74 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -560,6 +560,8 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) { $routes->get("getSSORedirectUrl", "ApiServiceController::getSSORedirectUrl"); $routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy"); $routes->get("downloadCdSplitUpFile", "EmployeeRestController::downloadCdSplitUpFile"); +$routes->get("downloadFileTableFile/(:any)", "EmployeeController::downloadFileList/$1"); + $routes->group("employeeRest", ['filter' => ['appSignature'] ], function ($routes) { diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 1f235e7b..bd9f4a54 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -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) { diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index bc2e1dae..ba145e85 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -606,6 +606,7 @@ class EmployeeRestController extends AdminController public function getEmployeeAndDependenceByClientId() { try { + $empData = $this->employeePolicyModel->getEmployeePolicy(client_id: $this->request->getGet('client_id'), policy_id: $this->request->getGet('client_policy_id'), status: 0, branch_id: $this->request->getGet('client_branch_id')); if ($empData) { @@ -2503,11 +2504,12 @@ class EmployeeRestController extends AdminController $client_id = isset($search_data['client_id']) ? (int) $search_data['client_id'] : 0; unset($search_data['client_id']); unset($search_data['client_branch_id']); + $policy_number = isset($search_data['policy_no']) ? $search_data['policy_no'] : null; $from_date = isset($search_data['from_date']) ? $search_data['from_date'] : null; $to_date = isset($search_data['to_date']) ? $search_data['to_date'] : null; $claim_status_id = isset($search_data['claim_status_id']) ? $search_data['claim_status_id'] : null; - unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id']); + unset($search_data['from_date'], $search_data['to_date'], $search_data['claim_status_id'], $search_data['policy_no']); $where = []; @@ -2627,6 +2629,10 @@ class EmployeeRestController extends AdminController $builder->whereIn('claim_status_id', $claim_status_ids); } + if (!empty($policy_number)) { + $builder->where('cp.policy_no', $policy_number); + } + $builder->orderBy('tm.id', 'DESC'); $data = $builder->get()->getResultArray(); @@ -4521,11 +4527,12 @@ class EmployeeRestController extends AdminController $post_data = [ 'client_id' => $this->request->getPost('client_id') ?? null, - 'client_branch_id' => $this->request->getPost('client_branch_id'), - 'policy_id' => $this->request->getPost('policy_id'), - 'file_action' => $this->request->getPost('file_action'), - 'created_by' => $this->request->getPost('created_by'), - 'file_name' => $this->request->getFile('file_name') + 'client_branch_id' => $this->request->getPost('client_branch_id') ?? null, + 'policy_id' => $this->request->getPost('policy_id') ?? null, + 'file_action' => $this->request->getPost('file_action') ?? null, + 'created_by' => $this->request->getPost('created_by') ?? null, + 'file_name' => $this->request->getFile('file_name') ?? null, + 'policy_no' => $this->request->getPost('policy_no') ?? null, ]; // print_r($post_data); die; @@ -4717,28 +4724,40 @@ class EmployeeRestController extends AdminController try { $file_id = $this->request->getGet('id') ?? $id; + $client_id = $this->request->getGet('client_id') ?? null; + + $client_data = []; + if(!empty($client_id)){ + if (is_string($client_id) && preg_match('/^[a-f0-9]{32}$/i', $client_id)) { + $client_data = $this->clientModel->where('MD5(id)', $client_id)->first(); + } else { + $client_data = $this->clientModel->where('id', $client_id)->first(); + } + } // Find record - $record = $this->hrFileUploadModel->where('id', (int)$file_id)->find(); - - // print_rr( $record);die; + if($client_data && $client_data['hr_file_processed_by'] == 1){ + $record = $this->fileModel->where('id', (int)$file_id)->find(); + $uploadPath = WRITEPATH . 'uploads/excel/'; + }else{ + $record = $this->hrFileUploadModel->where('id', (int)$file_id)->find(); + $uploadPath = WRITEPATH . 'uploads/hr_files/'; + } if (!$record) { return $this->failNotFound("File record not found"); } - $uploadPath = WRITEPATH . 'uploads/hr_files/'; - $filePath = $uploadPath . $record[0]['file_name']; + $filePath = $uploadPath . $record[0]['file_name']; if (!file_exists($filePath)) { - // return $this->failNotFound("File not found on server"); - $data['message'] = 'The Physical File Not Found'; - return view('errors/404', $data); + return $this->failNotFound("File not found on server"); } // Force file download return $this->response->download($filePath, null) ->setFileName($record[0]['file_name']); + } catch (\Exception $e) { return $this->failServerError($e->getMessage()); } @@ -4797,7 +4816,14 @@ class EmployeeRestController extends AdminController $data = $this->getDataFromHrFileUploadTable($search_data); $table = "hr_file_upload"; }else{ - $client_data = $this->clientModel->where('MD5(id)', $search_data['client_id'])->first(); + + if (is_string($search_data['client_id']) && preg_match('/^[a-f0-9]{32}$/i', $search_data['client_id'])) { + $client_data = $this->clientModel->where('MD5(id)', $search_data['client_id'])->first(); + $search_data['client_id'] = $client_data['id']; + } else { + $client_data = $this->clientModel->where('id', $search_data['client_id'])->first(); + } + if($client_data['hr_file_processed_by'] == 1){ $data = $this->getDataFromHrFilesTable($search_data); $table = "files"; @@ -4862,7 +4888,8 @@ class EmployeeRestController extends AdminController THEN hr_file_upload.status ELSE CONCAT(UCASE(LEFT(f.status, 1)), LCASE(SUBSTRING(f.status, 2))) END AS status, - '0' as file_error_status + '0' as file_error_status, + '' as file_error_status ", false) ->join('clients c', 'c.id = hr_file_upload.client_id AND c.is_active = 1', 'left') ->join('client_branch cb', 'cb.id = hr_file_upload.client_branch_id AND cb.is_active = 1', 'left') @@ -4909,7 +4936,7 @@ class EmployeeRestController extends AdminController public function getDataFromHrFilesTable($search_data) { - $file_download_base = base_url('util/download-file-list/'); + $file_download_base = base_url('downloadFileTableFile/'); $builder = $this->fileModel ->select(" files.id, @@ -5502,12 +5529,17 @@ class EmployeeRestController extends AdminController return $this->respond(['status' => false, 'code' => 404, 'message' => 'No file found', 'data' => []], 200); } - $policyTransactionModel = new PolicyTransactionModel(); - $policy_transaction_data = $policyTransactionModel - ->where('is_active', 1) - ->where('policy_no', $client_policy_data['policy_no']) - ->where('action_type', $cd_data['event_name']) - ->findAll(); + $policyTransactionModel = new PolicyTransactionModel(); + $builder = $policyTransactionModel + ->where('is_active', 1) + ->where('policy_no', $client_policy_data['policy_no']) + ->where('action_type', $cd_data['event_name']); + + if (!empty($cd_data['endorsement_no']) && $cd_data['event_name'] != 'inception') { + $builder->where('endorsement_no', $cd_data['endorsement_no']); + } + + $policy_transaction_data = $builder->findAll(); if(empty($policy_transaction_data)){ $this->myLogger->logme('error', 'getPolicyAndEndorsementFiles: No Policy Transaction data found for policy_no=' . $client_policy_data['policy_no']); diff --git a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php index 1f9837b9..3ee5c066 100644 --- a/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/AbhiClaimImportService.php @@ -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; } } diff --git a/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php b/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php index 619b6d31..f2e94cfa 100644 --- a/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/BaseTpaClaimImportService.php @@ -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(); - } /** diff --git a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php index 58dd1282..f4410b55 100644 --- a/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/FhplClaimImportService.php @@ -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', diff --git a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php index f2717fd5..fb1d731f 100644 --- a/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/IciciClaimImportService.php @@ -81,7 +81,6 @@ class IciciClaimImportService extends BaseTpaClaimImportService // Employee / Member 'employee_member_id' => 'emp_code', - 'relation_group' => 'relationship', // Claim 'claim_number' => 'claim_number', diff --git a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php index ad5a8657..0c68ece9 100644 --- a/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/MediAssistClaimImportService.php @@ -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', diff --git a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php index b77b035f..a75289a2 100644 --- a/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/RcareClaimImportService.php @@ -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 diff --git a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php index fee2cc9f..50ef9924 100644 --- a/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php +++ b/app/Libraries/TPAClaimsImportServices/VidalClaimImportService.php @@ -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', diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 98cad654..7c3af69c 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -94,6 +94,8 @@ class TicketMasterModel extends Model 'policy_transaction_id', 'tpa_claim_type', 'tpa_ailments' + 'claim_dump_ref_id', + ];