From 52e89db7b617b6c7370c5365e1d1cebb4c1c72fc Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Mon, 20 Apr 2026 15:21:22 +0530 Subject: [PATCH 1/2] CHANGE_ADD_NEW_KEY_SEND_FILE_TO_TPA_FOR_THE_CLAIM_FILES --- app/Controllers/ApiServiceController.php | 3 ++ app/Controllers/FhplApiController.php | 15 ++++++++ app/Controllers/HealthIndiaApiController.php | 14 ++++++++ app/Controllers/MediAssistApiController.php | 37 ++++++++++++++++++-- app/Controllers/VidalApiController.php | 28 +++++++++++++++ app/Controllers/VoloApiController.php | 14 ++++++++ app/Models/ClaimFilesModel.php | 1 + 7 files changed, 110 insertions(+), 2 deletions(-) diff --git a/app/Controllers/ApiServiceController.php b/app/Controllers/ApiServiceController.php index ea3103e9..2c28bb6c 100644 --- a/app/Controllers/ApiServiceController.php +++ b/app/Controllers/ApiServiceController.php @@ -446,6 +446,9 @@ class ApiServiceController extends BaseController if ($tpaID == $this->medi_assist_primary_key) { // MediAssist $mediAssistController = new MediAssistApiController(); return $mediAssistController->IRSubmission($claimId); + }else if ($tpaID == $this->vidal_primary_key) { // Vidal + $vidalApiController = new VidalApiController(); + return $vidalApiController->IRSubmission($claimId); }else{ log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}"); } diff --git a/app/Controllers/FhplApiController.php b/app/Controllers/FhplApiController.php index 532776ff..1d280ea5 100644 --- a/app/Controllers/FhplApiController.php +++ b/app/Controllers/FhplApiController.php @@ -85,6 +85,8 @@ class FhplApiController extends BaseController cp.policy_no as policyNo, e.emp_code as memberId, tn.note as disease, + cf.id as fileId, + cf.url as filePath, cf.url as filePath ') ->join('employees e', 'e.id = tm.emp_id', 'left') @@ -102,6 +104,7 @@ class FhplApiController extends BaseController } // Build absolute file path + $file_id = $data['fileId'] ?? null; $filename = basename($data['filePath']); $pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename; @@ -182,6 +185,18 @@ class FhplApiController extends BaseController 'tpa_claim_push_reference_no' => $fhplClaimNo, 'updated_at' => date('Y-m-d H:i:s') ]); + + // Update claim files table that file is sent to tpa for this claim + if(!empty($file_id)){ + + $this->db->table('claim_files') + ->where('id', $file_id) + ->update([ 'is_file_sent_to_tpa' => 1 ]); + + log_message('error','HEALTH_INDIA - Claim Push | Updating claim_files table for file_id: '.$file_id); + }else{ + log_message('error','HEALTH_INDIA - Claim Push | No file_id found to update claim_files table.'); + } log_message('error', 'FHPL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo); return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response]; diff --git a/app/Controllers/HealthIndiaApiController.php b/app/Controllers/HealthIndiaApiController.php index 0552700a..f498f039 100644 --- a/app/Controllers/HealthIndiaApiController.php +++ b/app/Controllers/HealthIndiaApiController.php @@ -105,6 +105,7 @@ class HealthIndiaApiController extends BaseController cp.policy_no as policyNumber, e.emp_code as employeeCode, tn.note as disease, + cf.id as fileId, cf.url as filePath, tm.claim_type as claimType, tm.claim_type as benefitType @@ -130,6 +131,7 @@ class HealthIndiaApiController extends BaseController } // Build absolute file path + $file_id = $data['fileId'] ?? null; $filename = basename($data['filePath']); $pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename; @@ -231,6 +233,18 @@ class HealthIndiaApiController extends BaseController 'updated_at' => date('Y-m-d H:i:s') ]); + // Update claim files table that file is sent to tpa for this claim + if(!empty($file_id)){ + + $this->db->table('claim_files') + ->where('id', $file_id) + ->update([ 'is_file_sent_to_tpa' => 1 ]); + + log_message('error','HEALTH_INDIA - Claim Push | Updating claim_files table for file_id: '.$file_id); + }else{ + log_message('error','HEALTH_INDIA - Claim Push | No file_id found to update claim_files table.'); + } + log_message('error', 'HEALTH_INDIA - Claim Push SUCCESS | claimId: ' . $claimId . ' | CCN: ' . $ccn . ' | CCN_EXT: ' . $ccnExt); return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response]; } else { diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php index 327531cb..ade693bf 100644 --- a/app/Controllers/MediAssistApiController.php +++ b/app/Controllers/MediAssistApiController.php @@ -42,8 +42,9 @@ class MediAssistApiController extends BaseController 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD').'', ]; + $file_id = null; + //Prepare body data - // Fetch the data from DB $data = $this->db->table('ticket_master tm') ->select(' @@ -59,6 +60,7 @@ class MediAssistApiController extends BaseController tm.tpa_no as memberId, tn.note as disease, tn.note as reasonForHospitalization, + cf.id as fileId, cf.url as fileName, cf.url as filePath ') @@ -83,6 +85,7 @@ class MediAssistApiController extends BaseController if ($fileDir) { $downloadUrl = base_url('fileDownload?file_path=').$fileDir; + $file_id = $data['fileId'] ?? null; } else { $downloadUrl = ''; } @@ -152,10 +155,23 @@ class MediAssistApiController extends BaseController log_message('error','MEDI_ASSIST - Claim Push SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef); + // Update claim reference number in ticket_master $this->db->table('ticket_master') ->where('id',$claimId) ->update([ 'tpa_claim_push_reference_no' => $claimRef ]); + // Update claim files table that file is sent to tpa for this claim + if(!empty($file_id)){ + + $this->db->table('claim_files') + ->where('id', $file_id) + ->update([ 'is_file_sent_to_tpa' => 1 ]); + + log_message('error','MEDI_ASSIST - Claim Push | Updating claim_files table for file_id: '.$file_id); + }else{ + log_message('error','MEDI_ASSIST - Claim Push | No file_id found to update claim_files table.'); + } + return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response]; } else { @@ -695,12 +711,14 @@ class MediAssistApiController extends BaseController $fileData = $this->db->table('claim_files f') ->where('f.ticket_id', $claimId) ->where('f.docs_for_ir', 1) - ->where('f.file_type', 2) // PDF + ->where('f.file_type', 2) + ->where('f.is_file_sent_to_tpa', 0) ->get() ->getResultArray(); $Attachments = []; + $tpaSentFileIds = []; if (count($fileData)) { foreach ($fileData as $file) { @@ -722,6 +740,9 @@ class MediAssistApiController extends BaseController "AttachmentName" => $filename, "AttachmentPath" => $downloadUrl ]; + + $tpaSentFileIds[] = $file['id']; // Collect file IDs to update later + } else { log_message('error',"MEDI_ASSIST - IR Submission Missing File URL → file_id={$file['id']}"); } @@ -768,6 +789,18 @@ class MediAssistApiController extends BaseController log_message('error',"MEDI_ASSIST - IR Submission SUCCESS → ClaimID={$ticket['ClaimID']}"); + // 6. UPDATE FILES AS SENT TO TPA + if(count($tpaSentFileIds) > 0){ + + $this->db->table('claim_files') + ->whereIn('id', $tpaSentFileIds) + ->update(['is_file_sent_to_tpa' => 1]); + + log_message('error',"MEDI_ASSIST - IR Submission | Updating claim_files for file IDs: " . implode(', ', $tpaSentFileIds)); + } else { + log_message('error',"MEDI_ASSIST - IR Submission | No files to update as sent to TPA"); + } + return [ 'status' => true, 'message' => 'IR Submitted successfully', diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index 82fd5db4..5aaddeba 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -156,6 +156,7 @@ class VidalApiController extends BaseController e.emp_code as memberId, tn.note as disease, tn.note as reasonForHospitalization, + cf.id as cfFileId, cf.url as fileName, cf.url as filePath, pt.policy_type as typeOfClaim, @@ -195,6 +196,7 @@ class VidalApiController extends BaseController } $fileId = $upload['fileId']; + $tpa_sent_file_id = $data['cfFileId'] ?? null; // $url = 'https://devapigw.vidalhealthtpa.com/partner-integration/api/claims/submit'; $url = getenv('VIDAL_API_BASE_URL').'/claims/submit'; $method = 'POST'; @@ -299,6 +301,18 @@ class VidalApiController extends BaseController ->where('id',$claimId) ->update([ 'tpa_claim_push_reference_no' => $claimInwardNO , 'tpa_claim_id' => $claimNO , 'claim_number' => $claimNO ]); + // Update claim files table that file is sent to tpa for this claim + if(!empty($tpa_sent_file_id)){ + + $this->db->table('claim_files') + ->where('id', $tpa_sent_file_id) + ->update([ 'is_file_sent_to_tpa' => 1 ]); + + log_message('error','MEDI_ASSIST - Claim Push | Updating claim_files table for file_id: '.$tpa_sent_file_id); + }else{ + log_message('error','MEDI_ASSIST - Claim Push | No file_id found to update claim_files table.'); + } + return ['status' => true, 'message' => 'Claim Push SUCCESS']; } else { @@ -1679,6 +1693,7 @@ class VidalApiController extends BaseController // 3. UPLOAD FILES TO VIDAL $fileIdList = []; + $tpaSentFileIds = []; foreach ($fileData as $file) { @@ -1702,6 +1717,7 @@ class VidalApiController extends BaseController } $fileIdList[] = $upload['fileId']; // deeplink URL + $tpaSentFileIds[] = $file['id']; // local file ID for updating } if (empty($fileIdList)) { @@ -1757,6 +1773,18 @@ class VidalApiController extends BaseController log_message('error', "VIDAL - IR Submission SUCCESS → ClaimNO={$ticket['claimNO']}"); + // 6. UPDATE FILES AS SENT TO TPA + if(count($tpaSentFileIds) > 0){ + + $this->db->table('claim_files') + ->whereIn('id', $tpaSentFileIds) + ->update(['is_file_sent_to_tpa' => 1]); + + log_message('error',"VIDAL - IR Submission | Updating claim_files for file IDs: " . implode(', ', $tpaSentFileIds)); + } else { + log_message('error',"VIDAL - IR Submission | No files to update as sent to TPA"); + } + return [ 'status' => true, 'message' => 'IR Submitted successfully', diff --git a/app/Controllers/VoloApiController.php b/app/Controllers/VoloApiController.php index 79320a2b..63e63c6d 100644 --- a/app/Controllers/VoloApiController.php +++ b/app/Controllers/VoloApiController.php @@ -692,6 +692,7 @@ class VoloApiController extends BaseController tm.claim_amount as requestedAmount, tm.tpa_no as memberId, cp.policy_no as policyNo, + cf.id as fileId, cf.url as filePath ') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') @@ -710,6 +711,7 @@ class VoloApiController extends BaseController return ['status' => false, 'message' => 'Claim Push FAILED | File Missing']; } + $file_id = $data['fileId'] ?? null; $filename = basename($data['filePath']); $pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename; if (!is_readable($pdfPath)) { @@ -781,6 +783,18 @@ class VoloApiController extends BaseController ]); log_message('error', 'VOLO - Claim Push SUCCESS | claimId: ' . $claimId . ' | ref: ' . $ref); + // Update claim files table that file is sent to tpa for this claim + if(!empty($file_id)){ + + $this->db->table('claim_files') + ->where('id', $file_id) + ->update([ 'is_file_sent_to_tpa' => 1 ]); + + log_message('error','VOLO - Claim Push | Updating claim_files table for file_id: '.$file_id); + }else{ + log_message('error','VOLO - Claim Push | No file_id found to update claim_files table.'); + } + return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response]; } diff --git a/app/Models/ClaimFilesModel.php b/app/Models/ClaimFilesModel.php index 0d48ce05..055b9b3b 100644 --- a/app/Models/ClaimFilesModel.php +++ b/app/Models/ClaimFilesModel.php @@ -24,6 +24,7 @@ class ClaimFilesModel extends Model 'file_name', 'mime_type', 'docs_for_ir', + 'is_file_sent_to_tpa', ]; // Callbacks From 6f62808b9ba901d1318e5043e96cecfd8fd6dded Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Mon, 20 Apr 2026 15:28:32 +0530 Subject: [PATCH 2/2] FIX_VIDAL_IR_SUBMITION_FLAIM_FILE_ONLY_GET_THE_NO_SENT --- app/Controllers/VidalApiController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index 5aaddeba..e09fc9fb 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -1678,7 +1678,8 @@ class VidalApiController extends BaseController $fileData = $this->db->table('claim_files f') ->where('f.ticket_id', $claimId) ->where('f.docs_for_ir', 1) - ->where('f.file_type', 2) // PDF + ->where('f.file_type', 2) + ->where('f.is_file_sent_to_tpa', 0) ->get() ->getResultArray();