From 4f6919980e09ef48949abc8c0645b8d91628268a Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 20 Dec 2025 11:03:55 +0530 Subject: [PATCH 1/7] FIX_BDS_REPORT_AND_CHANGE_STATEMENT_UPLOAD_ERROR_HANDLING --- app/Controllers/ClientController.php | 2 +- .../PolicyTransactionController.php | 183 +++++++++++------- app/Models/PolicyTransactionModel.php | 13 +- app/Views/insurer_statement_list.php | 80 +++++++- app/Views/layout/header.php | 2 +- app/Views/report_bds.php | 16 +- 6 files changed, 209 insertions(+), 87 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index dea5763b..d90b46cd 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5998,7 +5998,7 @@ class ClientController extends AdminController // ---------- POLICY TRANSACTION CONTROLLER -------------------------------------------------------------------------------- $policyTransactionController = new PolicyTransactionController(); - // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '62']); + // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '271']); // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '62']); // dd('-----', $res); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index 4f2fcb49..fdfb3d42 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -3628,7 +3628,7 @@ } } - public function validateInsurerStatement($params) + public function validateInsurerStatementOld($params) { helper('excel_util_helper'); //get file info @@ -3742,101 +3742,142 @@ return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']); } - public function validateInsurerStatementNew($params) + public function validateInsurerStatement($params) { helper('excel_util_helper'); - //get file info $file_id = $params['file_id']; - $file = $this->insurerStatements->find($file_id); - // dd($file); - $date = new \DateTime($file['month']); + try { - $month = $date->format('m'); - $year = $date->format('Y'); + //get file info + $file = $this->insurerStatements->find($file_id); + // dd($file); - $error_data = ['error_code' => '', 'error_data' => []]; - $status = 'success'; - $ret_status = true; - - $return = []; - if (!isset($file)) { - //file not found in DB - return array('status' => false, 'msg' => 'statement file not found in DB'); - } - $file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name']; + $date = new \DateTime($file['month']); - //check physical file - if (!file_exists($file_name_with_path)) { - //file not found update status and reason - $message = "Physcial file not found"; - // echo $message; - $this->myLogger->logme('error', ($message . ' for statement file id ' . $file_id)); - $this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => $message])])->update(); - return array('status' => false, 'error_code' => 0); //0 - Physcial file not found - } + $month = $date->format('m'); + $year = $date->format('Y'); - //get excel data to php array - $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); - $sheet = $spreadsheet->getActiveSheet(); + $error_data = ['error_code' => '', 'error_data' => []]; + $status = 'success'; + $ret_status = true; - $highestRow = $sheet->getHighestRow(); - $highestColumn = $sheet->getHighestColumn(); + $return = []; + if (!isset($file)) { + //file not found in DB + $this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => 'statement file not found in DB'])])->update(); + return array('status' => false, 'msg' => 'statement file not found in DB'); + } + $file_name_with_path = WRITEPATH . "/uploads/statements/" . $file['file_name']; - $excel_data = $sheet->rangeToArray('A1:' . $highestColumn . $highestRow, null, true, true, true); - unset($excel_data[0]); - $excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data); + //check physical file + if (!file_exists($file_name_with_path)) { + //file not found update status and reason + $message = "Physcial file not found"; + // echo $message; + $this->myLogger->logme('error', ($message . ' for statement file id ' . $file_id)); + $this->insurerStatements->where('id', $file_id)->set(['file_status' => 'failed', 'reason' => json_encode(['error_code' => 0, 'error_data' => $message])])->update(); + return array('status' => false, 'error_code' => 0, 'error_data' => $message); //0 - Physcial file not found + } - //get no of line items and update in DB - $line_items = 0; + //get excel data to php array + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name_with_path); + $sheet = $spreadsheet->getActiveSheet(); - // get uploaded month transactions data - $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']); + $highestRow = $sheet->getHighestRow(); + $highestColumn = $sheet->getHighestColumn(); - // check policy no,insurer and etc in DB for this month - // if all good return true, otherwise return false with messssage - foreach ($excel_data as $excel_key => $excel_row) { + $excel_data = $sheet->rangeToArray('A1:' . $highestColumn . $highestRow); + unset($excel_data[0]); + $excel_data = ExcelSanitizeHelper::sanitizeArrayData($excel_data); + // dd($excel_data); - $is_row_empty = check_row_is_empty_or_null($excel_row); + //get no of line items and update in DB + $line_items = 0; - if (!$is_row_empty) { + // get uploaded month transactions data + $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']); - $is_source_found = 0; + // check policy no,insurer and etc in DB for this month + // if all good return true, otherwise return false with messssage + $matched_entry = []; + $error_messages = []; // row-wise error storage - $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_number from excel - $policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_number from excel - - $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]??''); //endorsement number from excel - $endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]??''); //endorsement number from excel + foreach ($excel_data as $excel_key => $excel_row) { - foreach ($source_data as $source_key => $source_row) { + $row_number = $excel_key; + $is_row_empty = check_row_is_empty_or_null($excel_row); - $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; - - if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { - $is_source_found = 1; - $line_items = $line_items + 1; - unset($source_data[$source_key]); - continue 2; + if (!$is_row_empty) { + + $policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_number from excel + $policy_no = preg_replace('/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_number from excel + + $endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2] ?? ''); //endorsement number from excel + $endorsement_no = preg_replace('/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2] ?? ''); //endorsement number from excel + + foreach ($source_data as $source_key => $source_row) { + + $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; + + + // Policy number mismatch + if ($policy_no != $source_row['policy_no']) { + $error_messages[$row_number]['policy_no_mismatch'] = + "Policy number ({$policy_no}) not in NHance."; + } + + // Endorsement number mismatch + if (!empty($endorsement_no) && $endorsement_no != $source_endorsement_no) { + $error_messages[$row_number]['endorsement_no_mismatch'] = + "Endorsement number ({$endorsement_no}) not not in NHance."; + } + + // Duplicate check + if (isset($matched_entry[$policy_no . '|' . $endorsement_no])) { + $error_messages[$row_number]['duplicate'] = + "Duplicate entry found. This policy and endorsement ({$policy_no} '|' {$endorsement_no}) combination has already been matched."; + continue 2; + } + + if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { + $line_items = $line_items + 1; + $matched_entry[] = $policy_no . '|' . $endorsement_no; + continue 2; + } } } - - if ($is_source_found == 0) { - $error_data['error_code'] = 1; //match not found - $error_data['error_data'] = array_merge($error_data['error_data'], [$excel_row[0]]); //match not found - } } - } + // print_rr($error_messages);die; - if ($error_data['error_code']) { - $status = 'failed'; - $ret_status = false; - } + if (!empty($error_messages)) { + $error_data['error_code'] = 2; + $error_data['error_data'] = $error_messages; + $status = 'failed'; + $ret_status = false; + } - //update in DB - $this->insurerStatements->where('id', $file_id)->set(['line_items' => $line_items, 'file_status' => $status, 'reason' => json_encode($error_data)])->update(); - return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']); + //update in DB + $this->insurerStatements->where('id', $file_id)->set(['line_items' => $line_items, 'file_status' => $status, 'reason' => json_encode($error_data)])->update(); + return array('status' => $ret_status, 'error_code' => $error_data['error_code'], 'error_data' => $error_data['error_data']); + } catch (\Throwable $th) { + + $errorData = [ + 'message' => $th->getMessage(), + 'file' => $th->getFile(), + 'line' => $th->getLine(), + 'code' => $th->getCode(), + 'trace' => $th->getTraceAsString(), + 'trace_array' => $th->getTrace(), // full array version (optional) + 'function' => $th->getTrace()[0]['function'] ?? null, + 'class' => $th->getTrace()[0]['class'] ?? null, + ]; + + $this->myLogger->logme("error", "POLICY-TRANSACTION-CONTROLLER - validateInsurerStatement: Exception: " . json_encode($errorData ?? [])); + $this->insurerStatements->where('id', $file_id)->set(['line_items' => 0, 'file_status' => 'failed', 'reason' => json_encode($errorData)])->update(); + return array('status' => false, 'error_code' => [], 'error_data' => $errorData); + } } diff --git a/app/Models/PolicyTransactionModel.php b/app/Models/PolicyTransactionModel.php index 2dc9af06..05a734c1 100644 --- a/app/Models/PolicyTransactionModel.php +++ b/app/Models/PolicyTransactionModel.php @@ -3649,8 +3649,8 @@ if ($reward > 0 && ($row['billed_amt'] ?? 0) == 0.00) { $row['total_irda_amt'] = '0.00'; - $row['billed_amt'] = - $reward; $rewardFlag = 'R'; // Reward row + $row['billed_amt'] = $reward; + $rewardFlag = 'R'; // Reward row } else { $rewardFlag = 'N'; // Normal row } @@ -3689,15 +3689,20 @@ $key = $row['pt_id'].'-'.$row['insurer_id']; // Sum billed amount - $totalBilled[$key] = ($totalBilled[$key] ?? 0) - + (float) ($row['billed_amt'] ?? 0); + $totalBilled[$key] = ($totalBilled[$key] ?? 0) + (float) ($row['billed_amt'] ?? 0); // Store total_irda_amt once if (!isset($totalIrdaMap[$key]) && ($row['total_irda_amt'] ?? 0) > 0) { $totalIrdaMap[$key] = (float) $row['total_irda_amt']; } + + if(($row['reward'] ?? 0) > 0){ + $totalIrdaMap[$key] = ($totalIrdaMap[$key] ?? 0) + (float) $row['reward']; + } } + // dd($totalIrdaMap); + $ptSeen = []; $final = []; diff --git a/app/Views/insurer_statement_list.php b/app/Views/insurer_statement_list.php index 3728bfff..4e4a9192 100644 --- a/app/Views/insurer_statement_list.php +++ b/app/Views/insurer_statement_list.php @@ -174,6 +174,20 @@ } + + + +
@@ -1325,7 +1339,7 @@ }); - function fetchFileError(file_id) { + function fetchFileErrorOld(file_id) { $('#loader').show(); var apiURL = 'getFileErr/' + file_id; // console.log('fetchFileError'); @@ -1370,6 +1384,69 @@ $('#loader').hide(); } + function fetchFileError(file_id) { + $('#loader').show(); + var apiURL = 'getFileErr/' + file_id; + // console.log('fetchFileError'); + // console.log(apiURL); + $.ajax({ + url: apiURL, + method: 'GET', + headers: { + "X-Requested-With": "XMLHttpRequest" + }, + success: function(response) { + console.log(response); + $(this).find(".modal-body").html(""); + if (response.code === 200 && response.dataStatus === true && response.data !== "") { + try { + var file_error_data = JSON.parse(response.data); + var file_error_html = ""; + + // Handle only error_code = 1 (row-wise errors) + if (file_error_data.error_code == 2) { + + Object.keys(file_error_data.error_data).forEach(function (rowNo) { + + file_error_html += ` + Row ${rowNo} :

`; + + Object.values(file_error_data.error_data[rowNo]).forEach(function (message, index) { + file_error_html += `    ${index + 1}. ${message}
`; + }); + + file_error_html += `

`; + }); + + } else if (file_error_data.error_code == 1) { + + file_error_html += 'The following row no(s) from excel are not found with policy transactions / duplicates.'; + file_error_html += ' : ' + '' + file_error_data.error_data.join(',') + ''; + } + // All other error codes → plain text message + else { + file_error_html = `${file_error_data.error_data}`; + } + + $('#file-err-modal').find(".modal-body").html(file_error_html); + return file_error_html; + + } catch (error) { + console.error('Error parsing API response data:', error); + } + } else if (response.code === 404 && response.dataStatus === false) { + console.error('no data found', response); + } else { + console.error('Something went wrong!'); + } + }, + error: function(xhr, status, error) { + console.error('Error fetching data from API:', error); + } + }); + + $('#loader').hide(); + } function checkInvAmont(event = null) { var total = 0; @@ -1404,7 +1481,6 @@ return true; } - function switchRequired(elementId, isRequired, type = 'id') { // console.log('switchRequired: ' + elementId+' - '+' - '+ type); if (type == 'id') //id attribute diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index 2ed7e44e..d4f88fbd 100755 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -993,7 +993,7 @@ /* Common modal Title styles */ .modal .modal-title { font-weight: 500; - font-size: 27px; + font-size: 23px; line-height: 100%; letter-spacing: 0; text-align: center; diff --git a/app/Views/report_bds.php b/app/Views/report_bds.php index 15cd5a00..23636b9b 100644 --- a/app/Views/report_bds.php +++ b/app/Views/report_bds.php @@ -109,7 +109,7 @@ table.dataTable tbody td { Total Premium Agreed BP % Agreed TP % - Rewards + Rewards Agreed Amount Invoiced Amount Outstanding Amount @@ -197,7 +197,7 @@ table.dataTable tbody td { % % - + - + Date: Sat, 20 Dec 2025 11:20:04 +0530 Subject: [PATCH 2/7] FIX_Partner manager la "UpdateID" already replaced by id . now fixed in updated section --- app/Controllers/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 22451e89..f6b4cc60 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -634,7 +634,7 @@ class UserController extends AdminController $text = "update"; $data['updated_by'] = get_session_userid(); - $result = $this->partnerStaffModel->update($updateID, $data); + $result = $this->partnerStaffModel->update($id, $data); } else { $text = "create"; $data['role_id'] = 1; From 782ba26f1a477358c627d55a2da6327e6d044445 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Sat, 20 Dec 2025 11:36:06 +0530 Subject: [PATCH 3/7] GWM : code merge --- app/Config/Routes.php | 2 +- app/Controllers/MediAssistApiController.php | 149 ++++++++++++++++++++ app/Controllers/VidalApiController.php | 85 ++++++----- 3 files changed, 202 insertions(+), 34 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 857f4c69..7c3af13e 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -762,7 +762,7 @@ $routes->get('claimStatus','VidalApiController::claimStatus'); $routes->get('EcardRequest','MediAssistApiController::EcardRequest'); $routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork'); $routes->get('GetBenefDetails','MediAssistApiController::GetBenefDetails'); -$routes->get('ClaimDetail','MediAssistApiController::ClaimDetail'); +$routes->get('ClaimDetail','VidalApiController::ClaimDetail'); $routes->get('SubmitClaim','MediAssistApiController::SubmitClaim'); $routes->get('IntimateClaim','MediAssistApiController::IntimateClaim'); $routes->get('IRSubmission','MediAssistApiController::IRSubmission'); diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index e293c57f..c01f507d 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -722,6 +722,155 @@ class MediAssistApiController extends BaseController } + public function ClaimStatusUpdate() + { + helper('api'); + + $url = getenv('MEDI_ASSIST_API_BASE_URL_CLAIMSTATUS'); + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Username:' . getenv('MEDI_ASSIST_API_USERNAME'), + 'Password:' . getenv('MEDI_ASSIST_API_PASSWORD'), + ]; + + // Fetch ticket master details + $TicketData = $this->db->table('ticket_master tm') + ->select(" + tm.id, + tm.tpa_no as memberId, + tm.tpa_claim_push_reference_no as claimRefNo, + cp.policy_no as policyNo, + cp.policy_start_date as startDate, + cp.policy_end_date as endDate, + e.emp_code as employeeCode + ") + ->join('employees e', 'e.id = tm.emp_id', 'left') + ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') + + ->get() + ->getRowArray(); + + if (!$TicketData) { + return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]); + } + + foreach ($TicketData as $key => $ticket) + { + $claimId = $ticket['id']; + if (!$ticket) { + return $this->response->setJSON(['status' => false,'message' => 'Invalid Claim ID' ]); + } + + // REQUEST BODY + if($ticket['claimRefNo'] != null) + { + $body = [ + "policyNo" => $ticket['policyNo'] ?? "", + "startDate" => "", + "endDate" => "", + "employeeCode" => $ticket['employeeCode'] ?? "", + "memberID" => "", + "claimNo" => "", + "claimRefNo" => $ticket['claimRefNo'] ?? "", + ]; + + }else{ + + $body = [ + "policyNo" => $ticket['policyNo'] ?? "", + "startDate" => "", + "endDate" => "", + "employeeCode" => $ticket['employeeCode'] ?? "", + "memberID" => "", + "claimNo" => "", + "claimRefNo" => "", + ]; + + } + + // CALL API + $response = call_third_party_api($url, $method, $headers, $body); + + if ($response['status'] != true || empty($response['data']['claimsData'][0])) { + log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response)); + + return $this->response->setJSON(['status' => false,'message' => 'API call failed.','data' => $response]); + } + + // Extract claim status + $claimData = $response['data']['claimsData'][0]; + $currentStatus = $claimData['claim_Current_Status'] ?? ''; + $tpa_claim_no = $claimData['tpA_CLAIM_NO'] ?? ''; + + // VALID STATUS LIST + $validStatuses = [ + "Claim Received" => 1, + "In Progress" => 5, + "Processed" => 11, + "Claim Paid" => 11, + "Denied" => 13, + "Cancelled" => 13, + + "Information Awaited" => 4, + "Confirmation Awaited" => 4, + "Information Awaited Reminder" => 4, + "Information Awaited Final Reminder" => 4, + "Insurer Concurrence Awaited" => 6, + "Closed" => 12, + + "Physical Documents Awaited" => 9, + "Processed - Payment Initiated" => 10, + "Processed - Transaction Failed" => 10, + "Processed - Account Details Updated" => 10, + "Processed - Debit Note Raised With Insurer for Payment"=> 10, + "Processed - Payment Initiated by Insurer" => 10, + "Payment - Refunded to Insurer" => 14, + "Processed - Processing Payment" => 10, + "Processed - Physical Documents Awaited" => 9, + + // Extra Mappings (based on your DB list) + "NON ID" => 1, + "ID NOT GENERATED" => 2, + "CDA" => 3, + "REJECTED" => 8, + "APPROVED" => 9, + "PAYMENT INITIATED" => 10, + "SETTLED" => 11, + "RETURNED" => 14, + "UNDER PROCESS - TPA" => 61, + "DENIAL REVIEW AWAITED" => 66, + ]; + + + // Maping tpa claim status with local claim Status + if (isset($validStatuses[$currentStatus])) + { + $updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no , 'updated_at' => date('Y-m-d H:i:s')]; + }else{ + $updateArray = ['tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no , 'updated_at' => date('Y-m-d H:i:s')]; + } + + // UPDATE ticket_master + $this->db->table('ticket_master')->where('id', $claimId)->update($updateArray); + + // LOG UPDATE + log_message('info', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus"); + + } + + + + return $this->response->setJSON([ + 'status' => true, + 'message' => 'Claim status updated.', + 'updated_status' => $currentStatus, + 'api_response' => $response + ]); + } + + diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index 78fc7d57..3fb32afe 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -400,6 +400,58 @@ class VidalApiController extends BaseController return ['status' => 'success','data' => $decryptedData["redirectUrl"]]; } + public function ClaimDetail($claimId = null) + { + helper('api'); + + $url = getenv('VIDAL_API_BASE_URL').'/claims/claim-dependent-info'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', + ]; + + // Fetch ticket master details + $ticket = $this->db->table('ticket_master tm') + ->select(" + tm.id, + tm.tpa_no as memberId, + tm.tpa_claim_push_reference_no as claimRefNo, + cp.policy_no as policyNo, + cp.policy_start_date as startDate, + cp.policy_end_date as endDate, + e.emp_code as employeeCode + ") + ->join('employees e', 'e.id = tm.emp_id', 'left') + ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') + ->where('tm.id', $claimId) + ->get() + ->getRowArray(); + + $body = [ + 'empNO' => "", + 'tpaCardID' => "", + 'claimID' => "BLR-0284-CL-9349459", + 'emailID' => "", + 'mobileNO' => "", + ]; + + + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != true){ + return $this->response->setJSON([ + 'status' => false, + 'message' => 'failed.', + 'data' => $response + ]); + } + + return $this->response->setJSON($response); + } + //----------yet to start only submit claim given @@ -452,40 +504,7 @@ class VidalApiController extends BaseController } - public function claimStatus ($claimId = null) - { - helper('api'); - $url = getenv('VIDAL_API_BASE_URL').'/claims/claim-dependent-info'; - $method = 'POST'; - - $headers = [ - 'Content-Type: application/json', - 'Ocp-Apim-Subscription-Key:' .getenv('VIDAL_API_SUBSCRIPTION_KEY').'', - ]; - - $body = [ - 'empNO' => "", - 'tpaCardID' => "", - 'claimID' => "BLR-0284-CL-9349459", - 'emailID' => "", - 'mobileNO' => "", - ]; - - - - $response = call_third_party_api($url, $method, $headers, $body); - - if($response['status'] != true){ - return $this->response->setJSON([ - 'status' => false, - 'message' => 'failed.', - 'data' => $response - ]); - } - - return $this->response->setJSON($response); - } public function hospitalNetwork(){ From fdcb3fa473bbdf14506852355a4441be47b2877b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 20 Dec 2025 14:32:27 +0530 Subject: [PATCH 4/7] FEAT_CLAIM_STATUS_UPDATE_CRONE --- app/Config/Routes.php | 3 ++ app/Controllers/MediAssistApiController.php | 46 ++++++++++++--------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 23821ffa..48c7fbb8 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -523,6 +523,8 @@ $routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPoli $routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus'); $routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr'); $routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery'); +$routes->cli('cli/ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate'); + @@ -768,6 +770,7 @@ $routes->get('ClaimDetail','VidalApiController::ClaimDetail'); $routes->get('SubmitClaim','MediAssistApiController::SubmitClaim'); $routes->get('IntimateClaim','MediAssistApiController::IntimateClaim'); $routes->get('IRSubmission','MediAssistApiController::IRSubmission'); +$routes->get('ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate'); // API service diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 19c3678b..d2b40c67 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -16,10 +16,12 @@ class MediAssistApiController extends BaseController { use ResponseTrait; protected $db; + protected $mediAssistTpaId; public function __construct() { $this->db = \Config\Database::connect(); + $this->mediAssistTpaId = getenv('MEDI_ASSIST_PRIMARY_KEY_CONSTANT'); } @@ -620,7 +622,7 @@ class MediAssistApiController extends BaseController $this->db->table('ticket_master')->where('id', $claimId)->update($updateArray); // LOG UPDATE - log_message('info', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus"); + log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus"); return $this->response->setJSON([ 'status' => true, @@ -632,7 +634,7 @@ class MediAssistApiController extends BaseController public function IRSubmission($claimId = null) // 585 this id for test { - log_message('info', "IRSubmission INIT for ticket_id={$claimId}"); + log_message('error', "IRSubmission INIT for ticket_id={$claimId}"); // 1. FETCH TICKET DETAILS $ticket = $this->db->table('ticket_master tm') @@ -685,7 +687,7 @@ class MediAssistApiController extends BaseController log_message('error', "File NOT FOUND on server → {$fileDir}"); } - log_message('info', "IRSubmission Attachment Ready: {$filename} | URL={$downloadUrl}"); + log_message('error', "IRSubmission Attachment Ready: {$filename} | URL={$downloadUrl}"); $Attachments[] = [ "AttachmentName" => $filename, @@ -703,7 +705,7 @@ class MediAssistApiController extends BaseController "Attachments" => $Attachments ]; - log_message('info', "IRSubmission Request Body => " . json_encode($body)); + log_message('error', "IRSubmission Request Body => " . json_encode($body)); // 4. SEND API CALL helper('api'); @@ -719,7 +721,7 @@ class MediAssistApiController extends BaseController $response = call_third_party_api($url, $method, $headers, $body); - log_message('info', "IRSubmission API Response => " . json_encode($response)); + log_message('error', "IRSubmission API Response => " . json_encode($response)); // 5. HANDLE RESPONSE if (!$response['status']) { @@ -735,7 +737,7 @@ class MediAssistApiController extends BaseController ]; } - log_message('info', "IRSubmission SUCCESS → ClaimID={$ticket['ClaimID']}"); + log_message('error', "IRSubmission SUCCESS → ClaimID={$ticket['ClaimID']}"); return [ 'status' => true, @@ -819,20 +821,26 @@ class MediAssistApiController extends BaseController ") ->join('employees e', 'e.id = tm.emp_id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') - + ->where('tm.tpa_claim_push_reference_no IS NOT NULL') + ->where('tm.is_active', 1) + ->whereNotIn('tm.claim_status_id', [8, 11, 12, 13, 66, 22, 24, 47, 49, 32, 34, 53, 55, 42, 44, 58, 60]) + ->where('tm.tpa_id', $this->mediAssistTpaId) ->get() - ->getRowArray(); + ->getResultArray(); + + // dd($TicketData); if (!$TicketData) { - return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]); + log_message('error', "Claims not found to update status"); + return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]); } + $error_data = []; + $status_updated_count = 0; + foreach ($TicketData as $key => $ticket) { $claimId = $ticket['id']; - if (!$ticket) { - return $this->response->setJSON(['status' => false,'message' => 'Invalid Claim ID' ]); - } // REQUEST BODY if($ticket['claimRefNo'] != null) @@ -866,8 +874,7 @@ class MediAssistApiController extends BaseController if ($response['status'] != true || empty($response['data']['claimsData'][0])) { log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response)); - - return $this->response->setJSON(['status' => false,'message' => 'API call failed.','data' => $response]); + $error_data[$claimId][['status' => false,'message' => 'API call failed.','data' => $response]]; } // Extract claim status @@ -877,6 +884,7 @@ class MediAssistApiController extends BaseController // VALID STATUS LIST $validStatuses = [ + "Claim Received" => 1, "In Progress" => 5, "Processed" => 11, @@ -914,7 +922,6 @@ class MediAssistApiController extends BaseController "DENIAL REVIEW AWAITED" => 66, ]; - // Maping tpa claim status with local claim Status if (isset($validStatuses[$currentStatus])) { @@ -925,19 +932,20 @@ class MediAssistApiController extends BaseController // UPDATE ticket_master $this->db->table('ticket_master')->where('id', $claimId)->update($updateArray); + $status_updated_count ++; // LOG UPDATE - log_message('info', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus"); + log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus"); } - - return $this->response->setJSON([ 'status' => true, 'message' => 'Claim status updated.', 'updated_status' => $currentStatus, - 'api_response' => $response + 'api_response' => $response, + 'count' => $status_updated_count, + 'error_data' => $error_data, ]); } From 374aa0fa8ce5c3aa58915bf06d964eb827f44b2e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 20 Dec 2025 14:44:10 +0530 Subject: [PATCH 5/7] FIX_VARIENCE --- app/Views/variance_report_list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Views/variance_report_list.php b/app/Views/variance_report_list.php index 7ec34dbb..144df61f 100644 --- a/app/Views/variance_report_list.php +++ b/app/Views/variance_report_list.php @@ -163,8 +163,8 @@ S.No     Client     - - + Client Branch     + Insurer     Insurer Branch     Policy Type     Policy No     @@ -183,8 +183,8 @@ - + + From 4bfd58a0e5bc15be331692e673aac23d586c08c5 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 20 Dec 2025 16:59:24 +0530 Subject: [PATCH 6/7] FIX_STATEMENT_UPLOAD --- app/Controllers/ClientController.php | 2 +- .../PolicyTransactionController.php | 44 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index d90b46cd..039f6f99 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -5998,7 +5998,7 @@ class ClientController extends AdminController // ---------- POLICY TRANSACTION CONTROLLER -------------------------------------------------------------------------------- $policyTransactionController = new PolicyTransactionController(); - // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '271']); + // $res = $policyTransactionController->validateInsurerStatement(['file_id' => '281']); // $res = $policyTransactionController->updateInsurerStatement(['file_id' => '62']); // dd('-----', $res); diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index fdfb3d42..385a4bff 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -3798,6 +3798,7 @@ // get uploaded month transactions data $source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']); + // dd($source_data); // check policy no,insurer and etc in DB for this month // if all good return true, otherwise return false with messssage @@ -3808,6 +3809,9 @@ $row_number = $excel_key; $is_row_empty = check_row_is_empty_or_null($excel_row); + $policy_source_found = 0; + $endorsement_source_found = 0; + $dublicate_found = 0; if (!$is_row_empty) { @@ -3821,33 +3825,47 @@ $source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null; - - // Policy number mismatch - if ($policy_no != $source_row['policy_no']) { - $error_messages[$row_number]['policy_no_mismatch'] = - "Policy number ({$policy_no}) not in NHance."; - } - - // Endorsement number mismatch - if (!empty($endorsement_no) && $endorsement_no != $source_endorsement_no) { - $error_messages[$row_number]['endorsement_no_mismatch'] = - "Endorsement number ({$endorsement_no}) not not in NHance."; + if (($policy_no == $source_row['policy_no']) ){ + $policy_source_found = 1; + } + + if( $endorsement_no == $source_endorsement_no) { + $endorsement_source_found = 1; } // Duplicate check if (isset($matched_entry[$policy_no . '|' . $endorsement_no])) { - $error_messages[$row_number]['duplicate'] = - "Duplicate entry found. This policy and endorsement ({$policy_no} '|' {$endorsement_no}) combination has already been matched."; + $dublicate_found = 1; continue 2; } if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no) { $line_items = $line_items + 1; $matched_entry[] = $policy_no . '|' . $endorsement_no; + unset($source_data[$source_key]); continue 2; } } + + // Policy number mismatch + if ($policy_source_found == 0) { + $error_messages[$row_number]['policy_no_mismatch'] = + "Policy number ({$policy_no}) not in NHance."; + } + + // Endorsement number mismatch + if (!empty($endorsement_no) && $endorsement_source_found == 0) { + $error_messages[$row_number]['endorsement_no_mismatch'] = + "Endorsement number ({$endorsement_no}) not in NHance."; + } + + // Duplicate check + if ($dublicate_found == 1) { + $error_messages[$row_number]['duplicate'] = + "Duplicate entry found. This policy and endorsement ({$policy_no} '|' {$endorsement_no}) combination has already been matched."; + } } + } // print_rr($error_messages);die; From 385ae41f0812eb80cde0f61cbc6d8a448381674b Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Sat, 20 Dec 2025 18:46:46 +0530 Subject: [PATCH 7/7] FIX_CD_AC_NO_HIDE --- .../policy_transaction_inception_form.php | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index 10294b98..9fb5cbfe 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -2080,6 +2080,9 @@ if ($(this).is(':checked')) { // Hide all + $('[name="cd_ac_no_for_child[]"]').val(''); + $('[id^="cd_current_balance_"]').val(''); + $('[name="cd_ac_no_for_child[]"]').hide(); $('[id^="cd_current_balance_"]').hide(); @@ -2087,6 +2090,10 @@ $('#cd_ac_no_' + uniqueid).show(); $('#cd_current_balance_' + uniqueid).show(); } else { + + $('[name="cd_ac_no_for_child[]"]').val(''); + $('[id^="cd_current_balance_"]').val(''); + // Show all back $('[name="cd_ac_no_for_child[]"]').show(); $('[id^="cd_current_balance_"]').show(); @@ -3365,8 +3372,16 @@ $('input[name="co_ter_premium[]"]').addClass('readonly-select'); $('#co_ter_premium_' + value).removeClass('readonly-select'); - $('input[name="cd_ac_no_for_child[]"]').addClass('readonly-select'); - $('#cd_ac_no_' + value).removeClass('readonly-select'); + + $('[name="cd_ac_no_for_child[]"]').hide(); + $('[id^="cd_current_balance_"]').hide(); + + // Show only current one + $('#cd_ac_no_' + value).show(); + $('#cd_current_balance_' + value).show(); + + // $('input[name="cd_ac_no_for_child[]"]').addClass('readonly-select'); + // $('#cd_ac_no_' + value).removeClass('readonly-select'); } } @@ -3722,11 +3737,11 @@ const selectedValue = $(currentSelect).val(); - if (selectedValue) { - $('.follow_insurer_cd').not(currentSelect).prop('disabled', true); - } else { - $('.follow_insurer_cd').prop('disabled', false); - } + // if (selectedValue) { + // $('.follow_insurer_cd').not(currentSelect).prop('disabled', true); + // } else { + // $('.follow_insurer_cd').prop('disabled', false); + // } } function removeAllColumnsExceptFirst(tableId) {