Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
vadivelJ96 2025-11-06 14:10:17 +05:30
commit 5e3219913e
10 changed files with 543 additions and 318 deletions

View File

@ -42,7 +42,7 @@ class ApiServiceController extends BaseController
$mediAssistController = new MediAssistApiController(); $mediAssistController = new MediAssistApiController();
return $mediAssistController->SubmitClaim($claimId); return $mediAssistController->SubmitClaim($claimId);
}else{ }else{
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
} }
} }
@ -117,8 +117,13 @@ class ApiServiceController extends BaseController
$filesData = $fileModel->where('is_active', 1)->where('action', 'api')->where('status', 'inprogress')->countAllResults(); $filesData = $fileModel->where('is_active', 1)->where('action', 'api')->where('status', 'inprogress')->countAllResults();
if($filesData > 0){ if($filesData > 0){
log_message('error', "Already the TPA GetBenefDetails job inprocess"); log_message('error', "TPA GetBenefDetails job is already in process.");
return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA initiation is in progress.','data' => [] ]); return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA initiation is in progress.','data' => [] ]);
}
if (empty($policy_no)) {
log_message('error', 'GetBenefDetails: policy_no missing in request');
return $this->respond(['status' => false, 'message' => 'policy_no required']);
} }
$data = [ $data = [
@ -128,15 +133,16 @@ class ApiServiceController extends BaseController
'client_id' => $client_id, 'client_id' => $client_id,
'policy_id' => $policy_id, 'policy_id' => $policy_id,
'client_branch_id'=> $branch_id, 'client_branch_id'=> $branch_id,
'created_by'=> get_session_userid(),
]; ];
if ($tpa_id == 2) // MediAssist if ($tpa_id == 1) // MediAssist
{ {
$file_id = $fileModel->insert($data); $file_id = $fileModel->insert($data);
log_message('error', "Files table inserted successfully, File id : {$file_id}"); log_message('error', "Files table inserted successfully, File id : {$file_id}");
// $mediAssistController = new MediAssistApiController(); // $mediAssistController = new MediAssistApiController();
// $mediAssistController->GetBenefDetails( [ 'polict_no' => $policy_no, 'file_id' =>$file_id ] ); // $mediAssistController->GetBenefDetails( [ 'polict_no' => $policy_no, 'file_id' =>$file_id ] );
$r = Jobs::addJob(['job_name' => 'GetBenefDetails', 'payload' => ['polict_no' => $policy_no, 'file_id' => $file_id]]); $r = Jobs::addJob(['job_name' => 'GetBenefDetails', 'payload' => ['policy_no' => $policy_no, 'file_id' => $file_id, 'return_type' => 'job']]);
log_message('error', "GetBenefDetails job pushed successfully."); log_message('error', "GetBenefDetails job pushed successfully.");
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]); return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]);

View File

@ -5651,6 +5651,10 @@ class ClientController extends AdminController
// dd($return); // dd($return);
// die; // die;
// $ticket_id = 515;
// $apiServiceController = new ApiServiceController();
// $apiServiceController->pushClaims($ticket_id); die;
// $employeeController = new EmployeeController(); // $employeeController = new EmployeeController();
// $employeeController->truncateFileData('633'); // $employeeController->truncateFileData('633');

View File

@ -2289,8 +2289,10 @@ class EmployeeController extends AdminController
$si_enhancement_true_or_false = $policyTermsData->suminsuredenhancement; $si_enhancement_true_or_false = $policyTermsData->suminsuredenhancement;
} }
} }
$employeeRest = new EmployeeRestController();
$tpa_api_service_status = $employeeRest->checkTpaApiEnable($client_policy_id, 'getTPAID', 'internel');
$slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$policy_details['client_id']); $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$policy_details['client_id']);
$message = null; $message = null;
@ -2305,7 +2307,7 @@ class EmployeeController extends AdminController
} }
$message = isset($message) ? ($message . ' not defined for choosed policy') : null; $message = isset($message) ? ($message . ' not defined for choosed policy') : null;
return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event']], 200); return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message, 'si_enhancement' => $si_enhancement_true_or_false, 'insurer_multi_event' => $insurer_details['is_multi_event'], 'tpa_api_service_status' => $tpa_api_service_status], 200);
} }

View File

@ -3636,11 +3636,6 @@ class EmployeeRestController extends AdminController
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
} }
// this call for TPA integration
$apiServiceController = new ApiServiceController();
$apiServiceController->pushClaims($insert_status);
log_message('error', "pushClaims function called with Ticket ID: {$insert_status}, In Employee Rest Controller");
} else { } else {
$message = 'Something Went Wrong'; $message = 'Something Went Wrong';
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200); return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
@ -3651,11 +3646,12 @@ class EmployeeRestController extends AdminController
} }
} }
public function handleCliamFiles($data, $ticket_id, $ticket_message_id) public function handleCliamFiles($data, $ticket_id, $ticket_message_id = null)
{ {
if(!empty($data) && !empty($ticket_id)) if(!empty($data) && !empty($ticket_id))
{ {
$insert_ids = []; $insert_ids = [];
$pdf_exist_in_the_file = false;
$claim_file = new ClaimFilesModel(); $claim_file = new ClaimFilesModel();
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
@ -3666,11 +3662,26 @@ class EmployeeRestController extends AdminController
'url' => $value['file_path'], 'url' => $value['file_path'],
'file_type' => 2, 'file_type' => 2,
'ticket_message_id' => $ticket_message_id, 'ticket_message_id' => $ticket_message_id,
'mime_type' => getMimeTypeByFileName($value['file_name']),
]; ];
$insert_ids[] = $claim_file->insert($data); $insert_ids[] = $claim_file->insert($data);
if(getMimeTypeByFileName($value['file_name']) == "application/pdf"){
$pdf_exist_in_the_file = true;
}
} }
if($pdf_exist_in_the_file){
// this call for TPA integration
$apiServiceController = new ApiServiceController();
$apiServiceController->pushClaims($ticket_id);
log_message('error', "pushClaims function called with Ticket ID: {$ticket_id}, In Employee Rest Controller");
}else{
log_message('error', "Failed to call the pushClaims function in EmployeeRestController for Ticket ID: {$ticket_id}, because the .pdf file does not exist.");
}
return $insert_ids; return $insert_ids;
} }
@ -3867,6 +3878,7 @@ class EmployeeRestController extends AdminController
{ {
$emp_id = $this->request->getGet('emp_id'); $emp_id = $this->request->getGet('emp_id');
$db = \Config\Database::connect(); $db = \Config\Database::connect();
$data = $db->table('employees e') $data = $db->table('employees e')
->select('pt.policy_type, ->select('pt.policy_type,
@ -3883,11 +3895,12 @@ class EmployeeRestController extends AdminController
->get() ->get()
->getResultArray(); ->getResultArray();
// print_r($db->getLastQuery());die();
// print_r($data);die();
// Loop through $data and check for policy_type = GMC // Loop through $data and check for policy_type = GMC
$userParams = []; $userParams = [];
foreach ($data as $row) { foreach ($data as $row) {
if ($row['policy_type'] === 'GMC') { // if ($row['policy_type'] === 'GMC') {
$userParams['name'] = $row['name']; $userParams['name'] = $row['name'];
$userParams['email'] = $row['email']; $userParams['email'] = $row['email'];
$userParams['phone'] = $row['phone']; $userParams['phone'] = $row['phone'];
@ -3906,14 +3919,14 @@ class EmployeeRestController extends AdminController
$userParams['moduleName'] = 'home'; $userParams['moduleName'] = 'home';
break; // stop after first GMC match break; // stop after first GMC match
} // }
} }
if (empty($userParams)) { if (empty($userParams)) {
return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200); return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200);
} }
// echo 'coming';die();
// Derive 32-byte key from SHA256 // Derive 32-byte key from SHA256
$derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true); $derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true);

View File

@ -5,9 +5,14 @@ namespace App\Controllers;
use App\Controllers\BaseController; use App\Controllers\BaseController;
use App\Models\FileModel; use App\Models\FileModel;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\API\ResponseTrait;
class MediAssistApiController extends BaseController class MediAssistApiController extends BaseController
{ {
use ResponseTrait;
public function index() public function index()
{ {
// //
@ -54,7 +59,7 @@ class MediAssistApiController extends BaseController
->join('employees e', 'e.id = tm.emp_id', 'left') ->join('employees e', 'e.id = tm.emp_id', 'left')
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left')
->join('claim_files cf', 'cf.ticket_id = tm.id AND cf.file_type = 2', 'left') ->join('claim_files cf', "cf.ticket_id = tm.id AND cf.file_type = 2 and cf.mime_type = 'application/pdf'", 'left')
->where('tm.id', $claimId) ->where('tm.id', $claimId)
->get() ->get()
->getRowArray(); // single record ->getRowArray(); // single record
@ -195,126 +200,186 @@ class MediAssistApiController extends BaseController
public function GetBenefDetails($requestData) public function GetBenefDetails($requestData)
{ {
helper('api'); helper('api');
$url = getenv('MEDI_ASSIST_API_BASE_URL_LIVE') . '/GetBenefDetails'; $function_calling_type = $requestData['return_type'] ?? 'job';
$method = 'POST';
$headers = [ try {
'Content-Type: application/json',
'Username:' . getenv('MEDI_ASSIST_API_USERNAME_LIVE'),
'Password:' . getenv('MEDI_ASSIST_API_PASSWORD_LIVE'),
];
$policyNo = $requestData['policy_no'] ?? null; $url = getenv('MEDI_ASSIST_API_BASE_URL_LIVE') . '/GetBenefDetails';
$method = 'POST';
if (empty($policyNo)) { $headers = [
log_message('error', 'GetBenefDetails: policy_no missing in request'); 'Content-Type: application/json',
return $this->response->setJSON(['status' => false,'message' => 'policy_no required']); 'Username:' . getenv('MEDI_ASSIST_API_USERNAME_LIVE'),
} 'Password:' . getenv('MEDI_ASSIST_API_PASSWORD_LIVE'),
log_message('error', "GetBenefDetails called for policy_no: {$policyNo}");
$allBenef = [];
$startIndex = 0;
$range = 100;
$totalCount = 0;
do {
$body = [
"policyNo" => $policyNo,
"startDate" => "",
"endDate" => "",
"isDeActivedata" => false,
"startIndex" => $startIndex,
"range" => $range,
"employeeId" => ""
]; ];
log_message('error', "GetBenefDetails API Request (startIndex={$startIndex}): " . json_encode($body)); $policyNo = $requestData['policy_no'] ?? null;
$response = call_third_party_api($url, $method, $headers, $body); if (empty($policyNo)) {
log_message('error', 'GetBenefDetails: policy_no missing in request');
if ($response['status'] != true) { if($function_calling_type == "job"){
log_message('error', 'GetBenefDetails API failed: ' . json_encode($response)); return ['status' => false, 'message' => 'policy_no required'];
return $this->response->setJSON([ 'status' => false,'message' => 'API call failed','data' => $response]); }else{
return $this->respond(['status' => false, 'message' => 'policy_no required']);
}
} }
$data = $response['data'] ?? []; log_message('error', "GetBenefDetails called for policy_no: {$policyNo}");
if (!isset($data['benefDetails'])) { $allBenef = [];
log_message('error', "GetBenefDetails: 'benefDetails' missing in API response: " . json_encode($data)); $startIndex = 0;
break; $range = 100;
$totalCount = 0;
do {
$body = [
"policyNo" => $policyNo,
"startDate" => "",
"endDate" => "",
"isDeActivedata" => false,
"startIndex" => $startIndex,
"range" => $range,
"employeeId" => ""
];
log_message('error', "GetBenefDetails API Request (startIndex={$startIndex}): " . json_encode($body));
$response = call_third_party_api($url, $method, $headers, $body);
if ($response['status'] != true) {
// update file table status after the tpa id failed to update
if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
$file_model = new FileModel();
$file_model->where('id', $requestData['file_id'])->set('status', 'failed')->update();
log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
} else {
log_message('error', "Failed to update file table status.");
}
log_message('error', 'GetBenefDetails API failed: ' . json_encode($response));
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'API call failed', 'data' => $response];
}else{
return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => $response]);
}
}
$data = $response['data'] ?? [];
if (!isset($data['benefDetails'])) {
log_message('error', "GetBenefDetails: 'benefDetails' missing in API response: " . json_encode($data));
break;
}
$count = $data['count'] ?? 0;
$totalCount = $count;
$fetchedCount = count($data['benefDetails']);
log_message('error', "Fetched {$fetchedCount} records (startIndex={$startIndex}) of total {$count}");
$allBenef = array_merge($allBenef, $data['benefDetails']);
$startIndex += $range;
} while ($startIndex < $totalCount);
// now update DB
$db = \Config\Database::connect();
$updated = 0;
foreach ($allBenef as $row) {
// $update = $db->table('employee_polices')
// ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id AND client_policy.policy_no = ' . $db->escape($row['polNo']), 'left')
// ->join(
// 'employees',
// 'employee_polices.employee_id = employees.id
// AND employees.emp_code = ' . $db->escape($row['priBenefEmpCode']) . '
// AND employees.relationship = ' . $db->escape($row['relName']),
// 'left'
// )
// ->where('employee_polices.tpa_id IS NULL')
// ->update(['employee_polices.tpa_id' => $row['benefMediAssistID']]);
$update = $db->table('employee_polices')
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id', 'left')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('client_policy.policy_no', $row['polNo'])
->where('employees.emp_code', $row['priBenefEmpCode'])
->where('employees.relationship', $row['relName'])
->where('employee_polices.tpa_id IS NULL', null, false)
->update(['employee_polices.tpa_id' => $row['benefMediAssistID']]);
if ($db->affectedRows() > 0) {
$updated++;
log_message('error', "Updated tpa_id for emp_code={$row['priBenefEmpCode']}, policy={$row['polNo']}");
}
} }
$count = $data['count'] ?? 0; // update file table status after the tpa id successfully updated
$totalCount = $count; if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
$fetchedCount = count($data['benefDetails']); $file_model = new FileModel();
$file_model->where('id', $requestData['file_id'])->set('status', 'success')->update();
log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
} else {
log_message('error', "Failed to update file table status.");
}
log_message('error', "Fetched {$fetchedCount} records (startIndex={$startIndex}) of total {$count}");
$allBenef = array_merge($allBenef, $data['benefDetails']); log_message('error', "GetBenefDetails completed. Total fetched={$totalCount}, updated={$updated}");
$startIndex += $range; if($function_calling_type == "job"){
return [
'status' => true,
'message' => 'Updated successfully',
'total_fetched' => $totalCount,
'total_updated' => $updated
];
}else{
return $this->respond([
'status' => true,
'message' => 'Updated successfully',
'total_fetched' => $totalCount,
'total_updated' => $updated
]);
}
} while ($startIndex < $totalCount); } catch (\Throwable $th) {
// now update DB // update file table status after the tpa id failed to update
$db = \Config\Database::connect(); if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
$updated = 0; $file_model = new FileModel();
$file_model->where('id', $requestData['file_id'])->set('status', 'failed')->update();
log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
} else {
log_message('error', "Failed to update file table status.");
}
$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,
];
foreach ($allBenef as $row) { log_message('error', 'Exception thrown while calling GetBenefDetails API: ' . json_encode($errorData));
if($function_calling_type == "job"){
// $update = $db->table('employee_polices') return ['status' => false, 'message' => 'API call failed', 'data' => $errorData];
// ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id AND client_policy.policy_no = ' . $db->escape($row['polNo']), 'left') }else{
// ->join( return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => $errorData]);
// 'employees',
// 'employee_polices.employee_id = employees.id
// AND employees.emp_code = ' . $db->escape($row['priBenefEmpCode']) . '
// AND employees.relationship = ' . $db->escape($row['relName']),
// 'left'
// )
// ->where('employee_polices.tpa_id IS NULL')
// ->update(['employee_polices.tpa_id' => $row['benefMediAssistID']]);
$update = $db->table('employee_polices')
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id', 'left')
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
->where('client_policy.policy_no', $row['polNo'])
->where('employees.emp_code', $row['priBenefEmpCode'])
->where('employees.relationship', $row['relName'])
->where('employee_polices.tpa_id IS NULL', null, false)
->update(['employee_polices.tpa_id' => $row['benefMediAssistID']]);
if ($db->affectedRows() > 0) {
$updated++;
log_message('error', "Updated tpa_id for emp_code={$row['priBenefEmpCode']}, policy={$row['polNo']}");
} }
} }
// update file table status after the tpa id successfully updated
if(isset($requestData['file_id']) && !empty($requestData['file_id'])){
$file_model = new FileModel();
$file_model->where('id', $requestData['file_id'])->set('status', 'success')->update();
log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
}else{
log_message('error', "Failed to update file table status.");
}
log_message('error', "GetBenefDetails completed. Total fetched={$totalCount}, updated={$updated}");
return $this->response->setJSON([
'status' => true,
'message' => 'Updated successfully',
'total_fetched' => $totalCount,
'total_updated' => $updated
]);
} }

View File

@ -1057,11 +1057,6 @@ class TicketController extends BaseController
$mail_responce = $this->sendAutoMailTrigger($return_value); $mail_responce = $this->sendAutoMailTrigger($return_value);
$this->autoMessageInsertBasedOnMailResponse($mail_responce, $return_value); $this->autoMessageInsertBasedOnMailResponse($mail_responce, $return_value);
// this call for TPA integration
$apiServiceController = new ApiServiceController();
$apiServiceController->pushClaims($return_value);
log_message('error', "pushClaims function called with Ticket ID: {$return_value}, In Ticket Controller");
return $this->respond(['status' => true, 'ticket_id' => $return_value, 'code' => 200, 'data' => $ticket_data, "message" => "Claim created successfully", 'mail_responce' => $mail_responce], 200); return $this->respond(['status' => true, 'ticket_id' => $return_value, 'code' => 200, 'data' => $ticket_data, "message" => "Claim created successfully", 'mail_responce' => $mail_responce], 200);
} else { } else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to create claim'], 200); return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to create claim'], 200);
@ -2232,7 +2227,8 @@ class TicketController extends BaseController
} }
public function feedbackList(){ public function feedbackList()
{
$data['feedback_data'] = $this->ticketMasterModel->select("ticket_master.*,clients.client_name")->join("clients","clients.id = ticket_master.client_id")->where("ticket_master.is_active",1)->where("ticket_master.feedback_json IS NOT NULL", null, false)->where("ticket_master.feedback_json !=", "")->findAll(); $data['feedback_data'] = $this->ticketMasterModel->select("ticket_master.*,clients.client_name")->join("clients","clients.id = ticket_master.client_id")->where("ticket_master.is_active",1)->where("ticket_master.feedback_json IS NOT NULL", null, false)->where("ticket_master.feedback_json !=", "")->findAll();
$data['page_name'] = "Claims"; $data['page_name'] = "Claims";
@ -2240,7 +2236,8 @@ class TicketController extends BaseController
$this->loadLayout("ticket_feedback_list",$data); $this->loadLayout("ticket_feedback_list",$data);
} }
public function getMoreInfo($requestFrom = null , $ticket_id = null) { public function getMoreInfo($requestFrom = null , $ticket_id = null)
{
if($requestFrom == null){ if($requestFrom == null){
$ticket_id = $this->request->getPost('ticket_id'); $ticket_id = $this->request->getPost('ticket_id');
@ -2265,7 +2262,7 @@ class TicketController extends BaseController
->groupBy("th.old_value, tcs.claim_status") ->groupBy("th.old_value, tcs.claim_status")
->get() ->get()
->getResultArray(); ->getResultArray();
// dd($ticket_previous_status); // dd($ticket_previous_status);
// Loop through previous status and gather the required data // Loop through previous status and gather the required data
foreach ($ticket_previous_status as $status) { foreach ($ticket_previous_status as $status) {
// $this->myLogger->logme("error", "Status : " . json_encode($status)); // $this->myLogger->logme("error", "Status : " . json_encode($status));
@ -2326,13 +2323,15 @@ class TicketController extends BaseController
} }
} }
private function isDate($value, $format = 'Y-m-d') { private function isDate($value, $format = 'Y-m-d')
{
// Check if the value is a valid date string (basic validation) // Check if the value is a valid date string (basic validation)
$date = \DateTime::createFromFormat($format, $value); $date = \DateTime::createFromFormat($format, $value);
return $date && $date->format($format) === $value; return $date && $date->format($format) === $value;
} }
public function upload_url(){ public function upload_url()
{
$data = $this->request->getPost(); $data = $this->request->getPost();
@ -2340,34 +2339,43 @@ class TicketController extends BaseController
foreach ($data['docs_name'] as $key => $eachData) { foreach ($data['docs_name'] as $key => $eachData) {
if (!empty($eachData) ) { if (!empty($eachData)) {
$insertData = [ $insertData = [
'doc_name' => $data['docs_name'][$key]??'', 'doc_name' => $data['docs_name'][$key] ?? '',
'url' => $data['url'][$key]??'', 'url' => $data['url'][$key] ?? '',
'ticket_id'=> $data['ticket_id_url']??'', 'ticket_id' => $data['ticket_id_url'] ?? '',
'created_by' => get_session_userid(), 'created_by' => get_session_userid(),
'is_active' => 1, 'is_active' => 1,
'file_type' => 1 'file_type' => 1
]; ];
$insertArr[] = $insertData; $insertArr[] = $insertData;
}
}
} }
if(!empty($insertArr)){ if (!empty($insertArr)) {
// Insert into database // Insert into database
$insert = $this->claimFilesModel->insertBatch($insertArr); $insert = $this->claimFilesModel->insertBatch($insertArr);
} }
if (isset($insert) && !empty($insert)) { if (isset($insert) && !empty($insert)) {
if (isset($data['ticket_id_url']) && !empty($data['ticket_id_url'])) {
// this call for TPA integration
$ticket_id = $data['ticket_id_url'];
$apiServiceController = new ApiServiceController();
$apiServiceController->pushClaims($ticket_id);
log_message('error', "pushClaims function called with Ticket ID: {$ticket_id}, In Ticket Controller while claim file upload");
} else {
log_message('error', "Failed to call the pushClaims function in TicketController during claim file upload because the ticket id was not found.");
}
return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']); return $this->respond(['status' => true, 'message' => 'File uploaded successfully ']);
} else { } else {
return $this->respond(['status' => false, 'message' => 'Failed to upload file ']); return $this->respond(['status' => false, 'message' => 'Failed to upload file ']);
} }
} }
public function getUrlDataByTicketId() public function getUrlDataByTicketId()

View File

@ -901,3 +901,28 @@ if (!function_exists('formatKey')) {
} }
} }
if (!function_exists('getMimeTypeByFileName')) {
function getMimeTypeByFileName($file_name)
{
$ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
$mime_types = [
'pdf' => 'application/pdf',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xls' => 'application/vnd.ms-excel',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'csv' => 'text/csv',
'txt' => 'text/plain',
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'json' => 'application/json',
];
return $mime_types[$ext] ?? 'application/octet-stream'; // default fallback
}
}

View File

@ -21,6 +21,7 @@ class ClaimFilesModel extends Model
'updated_at', 'updated_at',
'is_active', 'is_active',
'file_name', 'file_name',
'mime_type',
]; ];
// Callbacks // Callbacks

View File

@ -175,6 +175,7 @@ option:disabled {
var client_id_param = 0; var client_id_param = 0;
var client_branch_id_param = 0; var client_branch_id_param = 0;
var client_policy_param = 0; var client_policy_param = 0;
var tpa_api_sevice = 0;
$('#file_upload').hide(); $('#file_upload').hide();
@ -984,7 +985,6 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
$.ajax({ $.ajax({
url: apiURL, url: apiURL,
@ -1011,6 +1011,19 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
var event = response.insurer_multi_event ; var event = response.insurer_multi_event ;
$('#event_type_data').val(response.insurer_multi_event); $('#event_type_data').val(response.insurer_multi_event);
console.log('response.tpa_api_service_status', response.tpa_api_service_status);
console.log('tpa_api_sevice 1', tpa_api_sevice);
if(response.tpa_api_service_status){
tpa_api_sevice = 1;
}else{
tpa_api_sevice = 0;
}
$('.fetch_tpa').hide();
$('#action_type').val('').change();
$('#event_type').val('').change();
console.log('tpa_api_sevice 2', tpa_api_sevice);
if(event == 1){ if(event == 1){
$("#event_type").attr("multiple", "multiple"); $("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]"); $("#event_type").attr("name", "event_type[]");

View File

@ -111,15 +111,22 @@
<br> <br>
<div class="form-row" id="import_excel_btn"> <div class="form-row" id="import_excel_btn">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label>Upload file</label>&nbsp;[ <a id="import_excel_download" data-toggle="tooltip" data-placement="top" title="Download Import Sample Excel" style="display: none;">Sample Excel</a> ] <label>Upload file</label>&nbsp;[ <a id="import_excel_download" data-toggle="tooltip" data-placement="top" title="Download Import Sample Excel" style="display: none;">Sample Excel</a> ]
<input type="file" name="import_file_data" id="import_file" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required> <input type="file" name="import_file_data" id="import_file" accept=" application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/vnd.oasis.opendocument.spreadsheet" required>
</div> </div>
<div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;"> <div class="d-flex align-items-center justify-content-start" style="margin-top: 18px;">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<button id="emp_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button> <button id="emp_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
</div> </div>
</div> </div>
<div class="form-group col-md-4 fetch_tpa" style="margin-top: 30px;">
<a id="fetch_tpa_btn" class="btn btn-primary waves-effect waves-light justify-content-end" onclick="fetchTpaIdFromTpa(this)">Fetch TPA ID</a>
</div>
</div> </div>
<div class="form-row" id="export_excel_btn"> <div class="form-row" id="export_excel_btn">
@ -129,6 +136,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>
@ -429,7 +437,9 @@
$.each(data, function(index, item) { $.each(data, function(index, item) {
var option = $('<option>', { var option = $('<option>', {
value: item.id, value: item.id,
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}` text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}` ,
'data-pno': item.policy_no ?? '',
'data-tid': item.tpa_id ?? ''
}); });
if (client_policy_param2 == item.id) { if (client_policy_param2 == item.id) {
option.attr('selected', true); option.attr('selected', true);
@ -438,6 +448,7 @@
}); });
} }
// On change document ready functions
$(document).ready(function() { $(document).ready(function() {
$('#client').on('change', function() { $('#client').on('change', function() {
@ -464,6 +475,183 @@
} }
}); });
$('#policy').on('change', function() {
var policy_value = $(this).val()
var insurer_or_tpa = $('insurer_or_tpa').val()
var action_type = $('action_type').val()
if(policy_value == 0 || insurer_or_tpa == 'tpa' || action_type == 'import'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}
})
$('#event_type').on('change', function() {
var selectedVal = $(this).val();
// console.log(selectedVal);
if (selectedVal === 'correction') {
$('#policy').prop('required', false);
$('#policy_danger').hide();
} else {
$('#policy').prop('required', true);
$('#policy_danger').show();
}
console.log('tpa_api_sevice', tpa_api_sevice);
console.log('tpa_api_sevice type', typeof tpa_api_sevice);
if (tpa_api_sevice == 0 || (selectedVal == 'correction' || selectedVal == 'deletion' || selectedVal == 'si_enhancement')) {
$('.fetch_tpa').hide();
} else {
$('.fetch_tpa').show();
}
});
$('#action_type').on('change', function() {
var selectedValue = $(this).val();
var insurer_or_tpa = $('#insurer_or_tpa').val()
// console.log(selectedValue);
if (selectedValue == '') {
$('#import_excel_btn').hide();
$('#export_excel_btn').hide();
} else if (selectedValue == 'import') {
$('#import_file').prop('required', true);
$('#import_file').attr('name', 'import_file_data');
$('#import_excel_btn').show();
$('#export_excel_btn').hide();
} else if (selectedValue == 'export') {
$('#import_file').removeAttr('name');
$('#import_file').prop('required', false);
$('#import_excel_btn').hide();
$('#export_excel_btn').show();
}
if (tpa_api_sevice == 0 || selectedValue == 'export' || insurer_or_tpa == "insurer") {
$('.fetch_tpa').hide();
} else {
$('.fetch_tpa').show();
}
});
$('#insurer_or_tpa').on('change', function() {
var insurer_or_tpa = $(this).val()
var policy_value = $('#policy').val()
var event_type_data = $('#event_type_data').val();
var action_type = $('#action_type').val()
var event_type_data = $('#event_type_data').val();
console.log('policy_value', policy_value)
// if(insurer_or_tpa == 'tpa' || event_type_data == 0){
if(insurer_or_tpa == 'tpa'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else if(insurer_or_tpa == 'insurer' && action_type == 'import'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 1){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 0){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else{
if(policy_value != 0){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}
}
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer") {
$('.fetch_tpa').hide();
} else {
$('.fetch_tpa').show();
}
});
$('#action_type').on('change', function() {
var action_type = $(this).val()
var policy_value = $('#policy').val()
var insurer_or_tpa = $('#insurer_or_tpa').val()
var event_type_data = $('#event_type_data').val();
console.log('policy_value', policy_value)
// if(insurer_or_tpa == 'import' || event_type_data == 0){
if(action_type == 'import'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
} else if(action_type == 'export' && insurer_or_tpa == 'tpa'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 1){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 0){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else{
if(policy_value != 0){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}
}
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer") {
$('.fetch_tpa').hide();
} else {
$('.fetch_tpa').show();
}
});
/**This function updates the download link based on the selected option in the dropdown menu. **/
$('#event_type').on('change', function() {
var selectedValue = $(this).val();
if (selectedValue !== '') {
$('#import_excel_download').show();
var fullURL = '<?= base_url("util/download_import_excel/"); ?>' + selectedValue;
$('#import_excel_download').attr('href', fullURL);
} else {
$('#import_excel_download').hide();
$('#import_excel_download').removeAttr('href');
}
});
}); });
// Function to convert object to query parameters // Function to convert object to query parameters
@ -497,156 +685,12 @@
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
$('#action_type').change(function() {
var selectedValue = $(this).val();
// console.log(selectedValue);
if (selectedValue == '') {
$('#import_excel_btn').hide();
$('#export_excel_btn').hide();
} else if (selectedValue == 'import') {
$('#import_file').prop('required', true);
$('#import_file').attr('name', 'import_file_data');
$('#import_excel_btn').show();
$('#export_excel_btn').hide();
} else if (selectedValue == 'export') {
$('#import_file').removeAttr('name');
$('#import_file').prop('required', false);
$('#import_excel_btn').hide();
$('#export_excel_btn').show();
}
});
document.getElementById('toggleIcon').addEventListener('click', function() { document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon'); var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down'); icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up'); icon.classList.toggle('mdi-chevron-up');
}); });
$(document).ready(function() {
$('#event_type').change(function() {
var selectedVal = $(this).val();
// console.log(selectedVal);
if (selectedVal === 'correction') {
$('#policy').prop('required', false);
$('#policy_danger').hide();
} else {
$('#policy').prop('required', true);
$('#policy_danger').show();
}
});
});
//--------------------------------------------------------------------------------------
$('#insurer_or_tpa').change(function(){
var insurer_or_tpa = $(this).val()
var policy_value = $('#policy').val()
var event_type_data = $('#event_type_data').val();
var action_type = $('#action_type').val()
var event_type_data = $('#event_type_data').val();
console.log('policy_value', policy_value)
// if(insurer_or_tpa == 'tpa' || event_type_data == 0){
if(insurer_or_tpa == 'tpa'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else if(insurer_or_tpa == 'insurer' && action_type == 'import'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 1){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}else if(insurer_or_tpa == 'insurer' && action_type == 'export' && event_type_data == 0){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else{
if(policy_value != 0){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}
}
});
$('#action_type').change(function(){
var action_type = $(this).val()
var policy_value = $('#policy').val()
var insurer_or_tpa = $('#insurer_or_tpa').val()
var event_type_data = $('#event_type_data').val();
console.log('policy_value', policy_value)
// if(insurer_or_tpa == 'import' || event_type_data == 0){
if(action_type == 'import'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
} else if(action_type == 'export' && insurer_or_tpa == 'tpa'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 1){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}else if(action_type == 'export' && insurer_or_tpa == 'insurer' && event_type_data == 0){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}else{
if(policy_value != 0){
$("#event_type").attr("multiple", "multiple");
$("#event_type").attr("name", "event_type[]");
$("#event_type").select2();
}
}
});
$(document).ready(function(){
$('#policy').change(function(){
var policy_value = $(this).val()
var insurer_or_tpa = $('insurer_or_tpa').val()
var action_type = $('action_type').val()
if(policy_value == 0 || insurer_or_tpa == 'tpa' || action_type == 'import'){
$("#event_type").removeAttr("multiple");
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
}
})
});
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
$('#import_excel_download').click(function() { $('#import_excel_download').click(function() {
@ -660,20 +704,6 @@
} }
}); });
/**This function updates the download link based on the selected option in the dropdown menu. **/
$('#event_type').change(function() {
var selectedValue = $(this).val();
if (selectedValue !== '') {
$('#import_excel_download').show();
var fullURL = '<?= base_url("util/download_import_excel/"); ?>' + selectedValue;
$('#import_excel_download').attr('href', fullURL);
} else {
$('#import_excel_download').hide();
$('#import_excel_download').removeAttr('href');
}
});
//------------- CHECK CD BALANCE in SESSION ----------------------------------------------------------------------------------------- //------------- CHECK CD BALANCE in SESSION -----------------------------------------------------------------------------------------
// Global variables // Global variables
@ -759,17 +789,75 @@
</script> </script>
<script> <script>
function togglePolicyIssueDate() {
let insurer = $('#insurer_or_tpa').val(); function togglePolicyIssueDate() {
let action = $('#action_type').val(); let insurer = $('#insurer_or_tpa').val();
// if (insurer === 'insurer' && action === 'import') { let action = $('#action_type').val();
// $('.policy_issue_date_row').show(); // if (insurer === 'insurer' && action === 'import') {
// $('#policy_issue_date').attr('required', true); // $('.policy_issue_date_row').show();
// $('#policy_issue_date_label').html('Policy Issue Date <span class="text-danger">*</span>'); // $('#policy_issue_date').attr('required', true);
// } else { // $('#policy_issue_date_label').html('Policy Issue Date <span class="text-danger">*</span>');
// $('.policy_issue_date_row').hide(); // } else {
// $('#policy_issue_date').removeAttr('required').val(''); // $('.policy_issue_date_row').hide();
// $('#policy_issue_date_label').text('Policy Issue Date'); // $('#policy_issue_date').removeAttr('required').val('');
// } // $('#policy_issue_date_label').text('Policy Issue Date');
} // }
}
function fetchTpaIdFromTpa(){
let event = $('#event_type').val();
let client_id = $('#client').val();
let branch_id = $('#client_branch_id').val();
let policy_id = $('#policy').val();
let tpa_id = $('#policy option:selected').data('tid');
let policy_no = $('#policy option:selected').data('pno');
let checks = [
{val: client_id, msg: 'Please select the client'},
{val: branch_id, msg: 'Please select the client branch'},
{val: policy_id, msg: 'Please select the policy'},
{val: event, msg: 'Please select the event'},
{val: tpa_id, msg: 'TPA id empty'},
{val: policy_no, msg: 'Policy No empty'},
];
for (let c of checks) {
if (!c.val || c.val == 0) {
toastr.warning(c.msg, 'WARNING');
return;
}
}
let url = '<?= base_url('getTPAID') ?>';
// Data to send in the AJAX request
let requestData = {
policy_no: policy_no,
tpa_id: tpa_id,
client_id: client_id,
client_branch_id: branch_id,
client_policy_id: policy_id,
};
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status == true) {
toastr.success(response.message || 'Initiating successafully', 'SUCCESS');
} else {
toastr.error(response.message || 'Unable to fetch data', 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
});
}
</script> </script>