MERGE_TEST_STORE_CLAIM_TPA_RESPONSE_IN_DB
This commit is contained in:
commit
09bd3a37ea
@ -824,6 +824,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('feedback-list','TicketController::feedbackList');
|
||||
$routes->match(['get', 'post'], 'claim-upload','TicketController::claimDumpUpload');
|
||||
$routes->get('remove','TicketController::removeTicket');
|
||||
$routes->get('tpa-claim-push-logs','TicketController::getTpaClaimPushLogs');
|
||||
$routes->get('new/(:any)','TicketController::ticket_form/$1');
|
||||
$routes->post('create','TicketController::createTicket');
|
||||
$routes->post('update','TicketController::updateTicket');
|
||||
|
||||
@ -50,7 +50,9 @@ class ApiServiceController extends BaseController
|
||||
// Push Claims
|
||||
public function pushClaims($claimId)
|
||||
{
|
||||
|
||||
helper('tpa_claim_push_log');
|
||||
init_tpa_claim_push_logs($claimId);
|
||||
|
||||
$data = $this->db->table('ticket_master tm')
|
||||
->select('tm.id,tm.tpa_id ')->where('tm.id', $claimId)->get()->getRowArray(); // single record
|
||||
|
||||
@ -79,7 +81,7 @@ class ApiServiceController extends BaseController
|
||||
$voloApiController = new VoloApiController();
|
||||
return $voloApiController->SubmitClaim($claimId);
|
||||
}else{
|
||||
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
|
||||
tpa_claim_push_log($claimId, "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
public function SubmitClaim($claimId = null) // 515
|
||||
{
|
||||
helper('api');
|
||||
helper(['api', 'tpa_claim_push_log']);
|
||||
|
||||
$data = $this->db->table('ticket_master tm')
|
||||
->select('
|
||||
@ -99,7 +99,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
|
||||
if (count($data) && $data['filePath'] == null) {
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - Claim or File Missing");
|
||||
tpa_claim_push_log($claimId, "FHPL - Claim Push FAILED | claimId: {$claimId} - Claim or File Missing");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim or File Missing'];
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ class FhplApiController extends BaseController
|
||||
$pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
|
||||
|
||||
if (!file_exists($pdfPath)) {
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - PDF not found on server");
|
||||
tpa_claim_push_log($claimId, "FHPL - Claim Push FAILED | claimId: {$claimId} - PDF not found on server");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | PDF not found on server'];
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ class FhplApiController extends BaseController
|
||||
// Generate FHPL Token
|
||||
$tokenResponse = $this->generateAuthToken();
|
||||
if (empty($tokenResponse['data']['access_token'])) {
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - FHPL Token generation failed");
|
||||
tpa_claim_push_log($claimId, "FHPL - Claim Push FAILED | claimId: {$claimId} - FHPL Token generation failed");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | FHPL Token generation failed'];
|
||||
}
|
||||
$token = $tokenResponse['data']['access_token'];
|
||||
@ -154,14 +154,14 @@ class FhplApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'FHPL - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
tpa_claim_push_log($claimId, 'FHPL - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
log_message('error', 'FHPL - Claim Push RESPONSE | ' . json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'FHPL - Claim Push RESPONSE | ' . json_encode($response));
|
||||
|
||||
if($response['status'] != true){
|
||||
log_message('error', 'FHPL - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'FHPL - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
@ -193,15 +193,15 @@ class FhplApiController extends BaseController
|
||||
->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);
|
||||
tpa_claim_push_log($claimId, 'FHPL - 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.');
|
||||
tpa_claim_push_log($claimId, 'FHPL - Claim Push | No file_id found to update claim_files table.');
|
||||
}
|
||||
|
||||
log_message('error', 'FHPL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
|
||||
tpa_claim_push_log($claimId, 'FHPL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
}else {
|
||||
log_message('error', 'FHPL - Claim Push API SUCCESS BUT claimsInfo EMPTY | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'FHPL - Claim Push API SUCCESS BUT claimsInfo EMPTY | response: '.json_encode($response));
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT claimsInfo EMPTY'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,9 +84,9 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
public function SubmitClaim($claimId = null)
|
||||
{
|
||||
helper('api');
|
||||
helper(['api', 'tpa_claim_push_log']);
|
||||
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push | Started for claimId: ' . $claimId);
|
||||
tpa_claim_push_log($claimId, 'HEALTH_INDIA - Claim Push | Started for claimId: ' . $claimId);
|
||||
|
||||
$data = $this->db->table('ticket_master tm')
|
||||
->select('
|
||||
@ -121,12 +121,12 @@ class HealthIndiaApiController extends BaseController
|
||||
// dd($data);
|
||||
|
||||
if (!$data) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Claim not found");
|
||||
tpa_claim_push_log($claimId, "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Claim not found");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim not found'];
|
||||
}
|
||||
|
||||
if ($data['filePath'] == null) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - File Missing");
|
||||
tpa_claim_push_log($claimId, "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - File Missing");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | File Missing'];
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ class HealthIndiaApiController extends BaseController
|
||||
$pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
|
||||
|
||||
if (!file_exists($pdfPath)) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - PDF not found on server at path: {$pdfPath}");
|
||||
tpa_claim_push_log($claimId, "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - PDF not found on server at path: {$pdfPath}");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | PDF not found on server'];
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class HealthIndiaApiController extends BaseController
|
||||
// Generate Health India Token
|
||||
$tokenResponse = $this->generateAuthToken();
|
||||
if (empty($tokenResponse['data']['result'][0]['access_token'])) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Token generation failed");
|
||||
tpa_claim_push_log($claimId, "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Token generation failed");
|
||||
return;
|
||||
}
|
||||
$token = $tokenResponse['data']['result'][0]['access_token'];
|
||||
@ -206,14 +206,14 @@ class HealthIndiaApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push | claimId: ' . $claimId . ' | URL: ' . $url );
|
||||
tpa_claim_push_log($claimId, 'HEALTH_INDIA - Claim Push | claimId: ' . $claimId . ' | URL: ' . $url);
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
// dd($response);
|
||||
|
||||
if ($response['status'] != true) {
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push FAILED | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'HEALTH_INDIA - Claim Push FAILED | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update(['tpa_push_response' => json_encode($response)]);
|
||||
@ -240,15 +240,15 @@ class HealthIndiaApiController extends BaseController
|
||||
->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);
|
||||
tpa_claim_push_log($claimId, '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.');
|
||||
tpa_claim_push_log($claimId, '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);
|
||||
tpa_claim_push_log($claimId, 'HEALTH_INDIA - Claim Push SUCCESS | claimId: ' . $claimId . ' | CCN: ' . $ccn . ' | CCN_EXT: ' . $ccnExt);
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
} else {
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push API SUCCESS BUT CCN EMPTY | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'HEALTH_INDIA - Claim Push API SUCCESS BUT CCN EMPTY | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT CCN EMPTY'];
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ class MediAssistApiController extends BaseController
|
||||
public function SubmitClaim ($claimId = null)
|
||||
{
|
||||
|
||||
helper('api');
|
||||
helper(['api', 'tpa_claim_push_log']);
|
||||
|
||||
// $url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/SubmitClaim';
|
||||
$url = getenv('MEDI_ASSIST_API_BASE_URL_CLAIMSUBMIT');
|
||||
@ -133,14 +133,14 @@ class MediAssistApiController extends BaseController
|
||||
// ]
|
||||
// ];
|
||||
|
||||
log_message('error','MEDI_ASSIST - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
tpa_claim_push_log($claimId, 'MEDI_ASSIST - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
|
||||
if($response['status'] != true){
|
||||
|
||||
log_message('error','MEDI_ASSIST - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'MEDI_ASSIST - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
@ -153,7 +153,7 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
if(!empty($claimRef)){
|
||||
|
||||
log_message('error','MEDI_ASSIST - Claim Push SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef);
|
||||
tpa_claim_push_log($claimId, 'MEDI_ASSIST - Claim Push SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef);
|
||||
|
||||
// Update claim reference number in ticket_master
|
||||
$this->db->table('ticket_master')
|
||||
@ -167,15 +167,15 @@ class MediAssistApiController extends BaseController
|
||||
->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);
|
||||
tpa_claim_push_log($claimId, '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.');
|
||||
tpa_claim_push_log($claimId, 'MEDI_ASSIST - Claim Push | No file_id found to update claim_files table.');
|
||||
}
|
||||
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
|
||||
} else {
|
||||
log_message('error','MEDI_ASSIST - Claim Push API Failed | claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'MEDI_ASSIST - Claim Push API Failed | claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return ['status' => false, 'message' => 'Claim Push API Failed', 'response' => $response];
|
||||
}
|
||||
|
||||
|
||||
@ -509,6 +509,7 @@ class TicketController extends BaseController
|
||||
'tm.is_head_approved',
|
||||
'tcs.claim_status AS status',
|
||||
'tm.claim_number AS claim_no',
|
||||
'tm.tpa_claim_push_reference_no',
|
||||
'tm.tpa_id',
|
||||
'tm.tpa_no',
|
||||
'tm.emp_name',
|
||||
@ -650,6 +651,7 @@ class TicketController extends BaseController
|
||||
'tm.ticket_type_id',
|
||||
'tcs.claim_status AS status',
|
||||
'tm.claim_number AS claim_no',
|
||||
'tm.tpa_claim_push_reference_no',
|
||||
'tm.claim_status_id',
|
||||
'tm.claim_created_by',
|
||||
'tm.is_head_approved',
|
||||
@ -2535,6 +2537,43 @@ class TicketController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function getTpaClaimPushLogs()
|
||||
{
|
||||
$ticketId = $this->request->getGet('ticket_id');
|
||||
|
||||
if (empty($ticketId)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'message' => 'ticket_id is required',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$ticket = $this->ticketMasterModel
|
||||
->select('id, tpa_claim_push_logs')
|
||||
->where('id', $ticketId)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (!$ticket) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'message' => 'Claim not found',
|
||||
], 404);
|
||||
}
|
||||
|
||||
$logs = trim((string) ($ticket['tpa_claim_push_logs'] ?? ''));
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'message' => 'TPA claim push logs fetched successfully',
|
||||
'data' => [
|
||||
'ticket_id' => (int) $ticketId,
|
||||
'logs' => $logs,
|
||||
'has_logs' => $logs !== '',
|
||||
],
|
||||
], 200);
|
||||
}
|
||||
|
||||
//---- Email Trigger Part----------------------------------------------------------------------------------------------
|
||||
|
||||
public function constructMailContent($ticket_id, $status_id = null)
|
||||
|
||||
@ -41,13 +41,14 @@ class VidalApiController extends BaseController
|
||||
|
||||
|
||||
|
||||
function uploadFileToVidal($filePath,$filename)
|
||||
function uploadFileToVidal($filePath, $filename, $claimId = null)
|
||||
{
|
||||
helper('tpa_claim_push_log');
|
||||
// $apiUrl = "https://devapigw.vidalhealthtpa.com/partner-integration/api/files/upload-url";
|
||||
$apiUrl = getenv('VIDAL_API_BASE_URL').'/files/upload-url';
|
||||
$subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY');
|
||||
|
||||
log_message('error', "VIDAL - Claim Push | Starting file upload process for filename: $filename | Path: $filePath");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Starting file upload process for filename: $filename | Path: $filePath");
|
||||
|
||||
// Step 1: Get signed URL from Vidal API
|
||||
// $filePath = '/opt/lampp/htdocs/nhance/writable/uploads/claim_files/1760013019_73d94af7b96ddc2e3d51.png';
|
||||
@ -57,7 +58,7 @@ class VidalApiController extends BaseController
|
||||
"Ocp-Apim-Subscription-Key: $subscriptionKey"
|
||||
];
|
||||
|
||||
log_message('error', "VIDAL - Claim Push | Requesting signed URL from Vidal API: $apiUrl | Payload: $payload");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Requesting signed URL from Vidal API: $apiUrl | Payload: $payload");
|
||||
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@ -67,7 +68,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
log_message('error', "VIDAL - Claim Push Curl error while requesting signed URL: " . curl_error($ch));
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push Curl error while requesting signed URL: " . curl_error($ch));
|
||||
return ["status" => false, "message" => curl_error($ch)];
|
||||
}
|
||||
curl_close($ch);
|
||||
@ -75,14 +76,14 @@ class VidalApiController extends BaseController
|
||||
$responseData = json_decode($response, true);
|
||||
|
||||
if (!isset($responseData['data']['signedUrl']) || !isset($responseData['data']['fileId'])) {
|
||||
log_message('error', "VIDAL - Claim Push | Invalid signed URL response received: " . json_encode($responseData));
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Invalid signed URL response received: " . json_encode($responseData));
|
||||
return ["status" => false, "message" => "Invalid signed URL response", "response" => $responseData];
|
||||
}
|
||||
|
||||
$signedUrl = $responseData['data']['signedUrl'];
|
||||
$fileId = $responseData['data']['fileId'];
|
||||
|
||||
log_message('error', "VIDAL - Claim Push | Received signed URL & fileId. fileId: $fileId");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Received signed URL & fileId. fileId: $fileId");
|
||||
|
||||
// Step 2: Upload file to signed URL using PUT (Azure Blob)
|
||||
$fileSize = filesize($filePath);
|
||||
@ -107,12 +108,12 @@ class VidalApiController extends BaseController
|
||||
curl_close($ch2);
|
||||
|
||||
if ($curlErr) {
|
||||
log_message('error', "VIDAL - Claim Push | Curl error during file upload: $curlErr");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Curl error during file upload: $curlErr");
|
||||
return ["status" => false, "message" => "File upload failed", "data" => $curlErr];
|
||||
}
|
||||
|
||||
if ($httpCode !== 200 && $httpCode !== 201) {
|
||||
log_message('error', "VIDAL - Claim Push | File upload failed with HTTP Code: $httpCode | Response: $uploadResponse");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | File upload failed with HTTP Code: $httpCode | Response: $uploadResponse");
|
||||
return [
|
||||
"status" => false,
|
||||
"message" => "File upload failed",
|
||||
@ -133,7 +134,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
public function SubmitClaim ($claimId = null) //515
|
||||
{
|
||||
helper('api');
|
||||
helper(['api', 'tpa_claim_push_log']);
|
||||
|
||||
// Fetch the data from DB
|
||||
$data = $this->db->table('ticket_master tm')
|
||||
@ -174,7 +175,7 @@ class VidalApiController extends BaseController
|
||||
->getRowArray(); // single record
|
||||
|
||||
if (count($data) && $data['filePath'] == null) {
|
||||
log_message('error', "VIDAL - Claim Push | Submit claim failed - Claim or File Missing");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Submit claim failed - Claim or File Missing");
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim or File Missing'];
|
||||
}
|
||||
|
||||
@ -185,9 +186,9 @@ class VidalApiController extends BaseController
|
||||
// dd($data);
|
||||
// Upload file first
|
||||
|
||||
$upload = $this->uploadFileToVidal($filePath,$filename);
|
||||
$upload = $this->uploadFileToVidal($filePath, $filename, $claimId);
|
||||
if ($upload['status'] !== true) {
|
||||
log_message('error', "VIDAL - Claim Push | Submit claim failed - File upload failed");
|
||||
tpa_claim_push_log($claimId, "VIDAL - Claim Push | Submit claim failed - File upload failed");
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'File upload failed',
|
||||
@ -247,7 +248,7 @@ class VidalApiController extends BaseController
|
||||
];
|
||||
// dd($body);
|
||||
|
||||
log_message('error', 'VIDAL - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
tpa_claim_push_log($claimId, 'VIDAL - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
|
||||
// $body = [
|
||||
// 'policyNo' => "351500/D0534/PP/20-20/PC",
|
||||
@ -279,7 +280,7 @@ class VidalApiController extends BaseController
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
if($response['status'] != true){
|
||||
log_message('error', 'VIDAL - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'VIDAL - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
@ -295,7 +296,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
if(!empty($claimNO) && !empty($claimInwardNO)){
|
||||
|
||||
log_message('error', 'VIDAL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$claimNO.' | claimInwardNO: '.$claimInwardNO);
|
||||
tpa_claim_push_log($claimId, 'VIDAL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$claimNO.' | claimInwardNO: '.$claimInwardNO);
|
||||
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
@ -308,19 +309,19 @@ class VidalApiController extends BaseController
|
||||
->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);
|
||||
tpa_claim_push_log($claimId, 'VIDAL - 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.');
|
||||
tpa_claim_push_log($claimId, 'VIDAL - Claim Push | No file_id found to update claim_files table.');
|
||||
}
|
||||
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS'];
|
||||
|
||||
} else {
|
||||
log_message('error', 'VIDAL - Claim Push API SUCCESS BUT claimNO,claimInwardNO EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'VIDAL - Claim Push API SUCCESS BUT claimNO,claimInwardNO EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT claimNO,claimInwardNO EMPTY'];
|
||||
}
|
||||
}else{
|
||||
log_message('error', 'VIDAL - Claim Push API FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'VIDAL - Claim Push API FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return ['status' => false, 'message' => 'Claim Push API FAILED'];
|
||||
}
|
||||
|
||||
|
||||
@ -682,7 +682,7 @@ class VoloApiController extends BaseController
|
||||
*/
|
||||
public function SubmitClaim($claimId = null)
|
||||
{
|
||||
helper('api');
|
||||
helper(['api', 'tpa_claim_push_log']);
|
||||
|
||||
$data = $this->db->table('ticket_master tm')
|
||||
->select('
|
||||
@ -702,12 +702,12 @@ class VoloApiController extends BaseController
|
||||
->getRowArray();
|
||||
|
||||
if (!$data) {
|
||||
log_message('error', 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | claim not found');
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | claim not found');
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim not found'];
|
||||
}
|
||||
|
||||
if (empty($data['filePath'])) {
|
||||
log_message('error', 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | file missing');
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | file missing');
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | File Missing'];
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ class VoloApiController extends BaseController
|
||||
$filename = basename($data['filePath']);
|
||||
$pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
|
||||
if (!is_readable($pdfPath)) {
|
||||
log_message('error', 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | PDF not readable');
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | PDF not readable');
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | PDF not found on server'];
|
||||
}
|
||||
|
||||
@ -723,13 +723,13 @@ class VoloApiController extends BaseController
|
||||
|
||||
$entityId = $this->resolveEntityId($data['policyNo'] ?? '');
|
||||
if ($entityId === null) {
|
||||
log_message('error', 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | entity id not resolved');
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | entity id not resolved');
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | entity id not resolved'];
|
||||
}
|
||||
|
||||
$hospitalId = getenv('VOLO_DEFAULT_HOSPITAL_ID');
|
||||
if ($hospitalId === false || $hospitalId === '') {
|
||||
log_message('error', 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | VOLO_DEFAULT_HOSPITAL_ID not set');
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | VOLO_DEFAULT_HOSPITAL_ID not set');
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | hospital id not configured'];
|
||||
}
|
||||
|
||||
@ -754,12 +754,12 @@ class VoloApiController extends BaseController
|
||||
'insurerPolicyNumber' => (string) ($data['policyNo'] ?? ''),
|
||||
];
|
||||
|
||||
log_message('error', 'VOLO - Claim Push | claimId: ' . $claimId . ' | payload: ' . json_encode($payload));
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push | claimId: ' . $claimId . ' | payload: ' . json_encode($payload));
|
||||
|
||||
$response = $this->intimateClaim($payload);
|
||||
|
||||
if (empty($response['status'])) {
|
||||
log_message('error', 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | ' . json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push FAILED | claimId: ' . $claimId . ' | ' . json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update(['tpa_push_response' => json_encode($response)]);
|
||||
@ -781,7 +781,7 @@ class VoloApiController extends BaseController
|
||||
'tpa_claim_id' => $ref,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
log_message('error', 'VOLO - Claim Push SUCCESS | claimId: ' . $claimId . ' | ref: ' . $ref);
|
||||
tpa_claim_push_log($claimId, '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)){
|
||||
@ -790,15 +790,15 @@ class VoloApiController extends BaseController
|
||||
->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);
|
||||
tpa_claim_push_log($claimId, '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.');
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push | No file_id found to update claim_files table.');
|
||||
}
|
||||
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
}
|
||||
|
||||
log_message('error', 'VOLO - Claim Push empty reference | claimId: ' . $claimId . ' | ' . json_encode($response));
|
||||
tpa_claim_push_log($claimId, 'VOLO - Claim Push empty reference | claimId: ' . $claimId . ' | ' . json_encode($response));
|
||||
|
||||
return ['status' => false, 'message' => 'Claim Push API response missing reference', 'response' => $response];
|
||||
}
|
||||
|
||||
48
app/Helpers/tpa_claim_push_log_helper.php
Normal file
48
app/Helpers/tpa_claim_push_log_helper.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('init_tpa_claim_push_logs')) {
|
||||
/**
|
||||
* Reset claim push logs for a ticket before a new push attempt.
|
||||
*/
|
||||
function init_tpa_claim_push_logs($claimId): void
|
||||
{
|
||||
if ($claimId === null || $claimId === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$started = date('Y-m-d H:i:s');
|
||||
\Config\Database::connect()
|
||||
->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update(['tpa_claim_push_logs' => "[{$started}] Claim push started\n"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('tpa_claim_push_log')) {
|
||||
/**
|
||||
* Write to application log and append the same line to ticket_master.tpa_claim_push_logs.
|
||||
*/
|
||||
function tpa_claim_push_log($claimId, string $message, string $level = 'error'): void
|
||||
{
|
||||
log_message($level, $message);
|
||||
|
||||
if ($claimId === null || $claimId === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$line = "[{$timestamp}] {$message}\n";
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$row = $db->table('ticket_master')
|
||||
->select('tpa_claim_push_logs')
|
||||
->where('id', $claimId)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
$existing = $row['tpa_claim_push_logs'] ?? '';
|
||||
$db->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update(['tpa_claim_push_logs' => $existing . $line]);
|
||||
}
|
||||
}
|
||||
@ -86,6 +86,13 @@ table.dataTable tbody td {
|
||||
color: #9d174d;
|
||||
}
|
||||
|
||||
.tpa-push-status-item {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
cursor: default;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
</style>
|
||||
<style>
|
||||
.table th:nth-child(1),
|
||||
@ -328,6 +335,13 @@ table.dataTable tbody td {
|
||||
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removeClaim(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<a class="dropdown-item" href="javascript:void(0);" onclick="showTpaClaimPushLogs(event, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-text-box-search-outline mr-2 text-muted font-18 vertical-middle"></i>TPA Push Logs
|
||||
</a>
|
||||
<?php $tpaPushSuccess = !empty($row['tpa_claim_push_reference_no']); ?>
|
||||
<span class="dropdown-item-text tpa-push-status-item px-3 py-2 <?= $tpaPushSuccess ? 'text-success' : 'text-danger' ?>">
|
||||
TPA PUSH : <?= $tpaPushSuccess ? 'Success.' : 'Failed.' ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -346,8 +360,6 @@ table.dataTable tbody td {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-------------------------------------------------------------------------------------------------->
|
||||
|
||||
<script>
|
||||
@ -434,6 +446,14 @@ function getStatusTooltip(row) {
|
||||
return status;
|
||||
}
|
||||
|
||||
function getTpaPushStatusMenuItem(row) {
|
||||
var ref = row.tpa_claim_push_reference_no;
|
||||
var isSuccess = ref !== null && ref !== undefined && String(ref).trim() !== '';
|
||||
var statusClass = isSuccess ? 'text-success' : 'text-danger';
|
||||
var statusLabel = isSuccess ? 'TPA PUSH : Success.' : 'TPA PUSH : Failed.';
|
||||
return '<span class="dropdown-item-text tpa-push-status-item px-3 py-2 ' + statusClass + '">' + escapeHtml(statusLabel) + '</span>';
|
||||
}
|
||||
|
||||
function getActionCell(row) {
|
||||
if (!window.ticketTableIsDeleteEnabled) return '';
|
||||
var id = escapeHtml(row.id || '');
|
||||
@ -445,6 +465,10 @@ function getActionCell(row) {
|
||||
' <a class="dropdown-item delete" data-id="' + id + '" onclick="removeClaim(this, \'' + id + '\')">' +
|
||||
' <i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete' +
|
||||
' </a>' +
|
||||
' <a class="dropdown-item" href="javascript:void(0);" onclick="showTpaClaimPushLogs(event, \'' + id + '\')">' +
|
||||
' <i class="mdi mdi-text-box-search-outline mr-2 text-muted font-18 vertical-middle"></i>TPA Push Logs' +
|
||||
' </a>' +
|
||||
getTpaPushStatusMenuItem(row) +
|
||||
' </div>' +
|
||||
' </div>' +
|
||||
'</td>';
|
||||
@ -649,6 +673,133 @@ function viewTicket(ticket_id){
|
||||
|
||||
}
|
||||
|
||||
function forceShowTpaClaimPushLogsModal() {
|
||||
var modalEl = document.getElementById('tpaClaimPushLogsModal');
|
||||
if (!modalEl) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (modalEl.parentNode !== document.body) {
|
||||
document.body.appendChild(modalEl);
|
||||
}
|
||||
|
||||
modalEl.style.display = 'block';
|
||||
modalEl.classList.add('show', 'in');
|
||||
modalEl.removeAttribute('aria-hidden');
|
||||
modalEl.setAttribute('aria-modal', 'true');
|
||||
document.body.classList.add('modal-open');
|
||||
|
||||
if (!document.querySelector('.modal-backdrop.tpa-claim-push-logs-backdrop')) {
|
||||
var backdrop = document.createElement('div');
|
||||
backdrop.className = 'modal-backdrop fade show in tpa-claim-push-logs-backdrop';
|
||||
document.body.appendChild(backdrop);
|
||||
}
|
||||
}
|
||||
|
||||
function hideTpaClaimPushLogsModal() {
|
||||
var modalEl = document.getElementById('tpaClaimPushLogsModal');
|
||||
if (!modalEl) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof jQuery !== 'undefined' && jQuery.fn && typeof jQuery.fn.modal === 'function') {
|
||||
$('#tpaClaimPushLogsModal').modal('hide');
|
||||
}
|
||||
|
||||
modalEl.classList.remove('show', 'in');
|
||||
modalEl.style.display = 'none';
|
||||
modalEl.setAttribute('aria-hidden', 'true');
|
||||
modalEl.removeAttribute('aria-modal');
|
||||
document.body.classList.remove('modal-open');
|
||||
document.body.style.removeProperty('padding-right');
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
|
||||
function openTpaClaimPushLogsModal() {
|
||||
var $modal = $('#tpaClaimPushLogsModal');
|
||||
if (!$modal.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($modal.parent()[0] !== document.body) {
|
||||
$modal.appendTo('body');
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof jQuery !== 'undefined' && jQuery.fn && typeof jQuery.fn.modal === 'function') {
|
||||
$modal.off('shown.bs.modal.tpaLogs').on('shown.bs.modal.tpaLogs', function() {
|
||||
$('.modal-backdrop').last().addClass('tpa-claim-push-logs-backdrop');
|
||||
});
|
||||
$modal.modal('show');
|
||||
setTimeout(function() {
|
||||
if ((!$modal.hasClass('show') && !$modal.hasClass('in')) || !$modal.is(':visible')) {
|
||||
forceShowTpaClaimPushLogsModal();
|
||||
}
|
||||
}, 120);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.bootstrap && bootstrap.Modal) {
|
||||
var modalEl = document.getElementById('tpaClaimPushLogsModal');
|
||||
if (modalEl && typeof bootstrap.Modal.getOrCreateInstance === 'function') {
|
||||
bootstrap.Modal.getOrCreateInstance(modalEl).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('TPA claim push logs modal open failed:', e);
|
||||
}
|
||||
|
||||
forceShowTpaClaimPushLogsModal();
|
||||
}
|
||||
|
||||
function showTpaClaimPushLogs(event, ticketId) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
var $content = $('#tpaClaimPushLogsContent');
|
||||
var $titleMeta = $('#tpaClaimPushLogsTicketId');
|
||||
|
||||
$titleMeta.text('Claim ID: ' + ticketId);
|
||||
$content.text('Loading...');
|
||||
openTpaClaimPushLogsModal();
|
||||
|
||||
var url = '<?= base_url('ticket/tpa-claim-push-logs') ?>';
|
||||
sendAjaxRequestForGlobal(url, 'GET', { ticket_id: ticketId }, function(response) {
|
||||
if (response.status === true && response.data) {
|
||||
if (response.data.has_logs) {
|
||||
$content.text(response.data.logs);
|
||||
} else {
|
||||
$content.text('No TPA claim push logs found for this claim.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
$content.text(response.message || 'Failed to load TPA claim push logs.');
|
||||
toastr.warning(response.message || 'Failed to load TPA claim push logs.', 'Warning');
|
||||
}, function(xhr) {
|
||||
var message = 'Failed to load TPA claim push logs.';
|
||||
if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
message = xhr.responseJSON.message;
|
||||
}
|
||||
$content.text(message);
|
||||
toastr.error(message, 'Error');
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var $modal = $('#tpaClaimPushLogsModal');
|
||||
if ($modal.length && $modal.parent()[0] !== document.body) {
|
||||
$modal.appendTo('body');
|
||||
}
|
||||
|
||||
$(document).on('click', '#tpaClaimPushLogsModal [data-dismiss="modal"]', function(e) {
|
||||
e.preventDefault();
|
||||
hideTpaClaimPushLogsModal();
|
||||
});
|
||||
});
|
||||
|
||||
function removeClaim(input, ticket_id) {
|
||||
|
||||
confirmActionSweertAlert("Do you want to delete this Claim?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
|
||||
|
||||
@ -201,6 +201,59 @@
|
||||
<?php include('ticket_list.php'); ?>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#tpaClaimPushLogsModal.show,
|
||||
#tpaClaimPushLogsModal.in {
|
||||
display: block !important;
|
||||
z-index: 1055;
|
||||
}
|
||||
#tpaClaimPushLogsModal .modal-dialog {
|
||||
z-index: 1056;
|
||||
}
|
||||
#tpaClaimPushLogsModal .modal-content {
|
||||
background: #ffffff;
|
||||
border: 1px solid #c5cdd8;
|
||||
border-radius: 8px;
|
||||
box-shadow:
|
||||
0 12px 28px rgba(15, 23, 42, 0.18),
|
||||
0 4px 12px rgba(15, 23, 42, 0.12);
|
||||
}
|
||||
#tpaClaimPushLogsModal .modal-header {
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
#tpaClaimPushLogsModal .modal-footer {
|
||||
border-top: 1px solid #e2e8f0;
|
||||
background: #f8fafc;
|
||||
border-radius: 0 0 8px 8px;
|
||||
}
|
||||
.modal-backdrop.tpa-claim-push-logs-backdrop {
|
||||
background-color: rgba(15, 23, 42, 0.5);
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="modal fade" id="tpaClaimPushLogsModal" tabindex="-1" role="dialog" aria-labelledby="tpaClaimPushLogsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg modal-dialog-scrollable" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="tpaClaimPushLogsModalLabel">TPA Claim Push Logs</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="text-muted mb-2" id="tpaClaimPushLogsTicketId"></p>
|
||||
<pre id="tpaClaimPushLogsContent" class="mb-0 p-3 bg-light border rounded" style="white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow-y: auto; font-size: 12px;">Loading...</pre>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- end page title -->
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user