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,10 +117,15 @@ 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 = [
'file_name' => "API", 'file_name' => "API",
'action' => "api", 'action' => "api",
@ -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

@ -2290,6 +2290,8 @@ class EmployeeController extends AdminController
} }
} }
$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']);
@ -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,10 +3662,25 @@ 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,9 +200,12 @@ class MediAssistApiController extends BaseController
public function GetBenefDetails($requestData) public function GetBenefDetails($requestData)
{ {
helper('api'); helper('api');
$function_calling_type = $requestData['return_type'] ?? 'job';
try {
$url = getenv('MEDI_ASSIST_API_BASE_URL_LIVE') . '/GetBenefDetails'; $url = getenv('MEDI_ASSIST_API_BASE_URL_LIVE') . '/GetBenefDetails';
$method = 'POST'; $method = 'POST';
@ -211,7 +219,11 @@ class MediAssistApiController extends BaseController
if (empty($policyNo)) { if (empty($policyNo)) {
log_message('error', 'GetBenefDetails: policy_no missing in request'); log_message('error', 'GetBenefDetails: policy_no missing in request');
return $this->response->setJSON(['status' => false,'message' => 'policy_no required']); if($function_calling_type == "job"){
return ['status' => false, 'message' => 'policy_no required'];
}else{
return $this->respond(['status' => false, 'message' => 'policy_no required']);
}
} }
log_message('error', "GetBenefDetails called for policy_no: {$policyNo}"); log_message('error', "GetBenefDetails called for policy_no: {$policyNo}");
@ -221,6 +233,7 @@ class MediAssistApiController extends BaseController
$range = 100; $range = 100;
$totalCount = 0; $totalCount = 0;
do { do {
$body = [ $body = [
"policyNo" => $policyNo, "policyNo" => $policyNo,
@ -237,8 +250,23 @@ class MediAssistApiController extends BaseController
$response = call_third_party_api($url, $method, $headers, $body); $response = call_third_party_api($url, $method, $headers, $body);
if ($response['status'] != true) { 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)); log_message('error', 'GetBenefDetails API failed: ' . json_encode($response));
return $this->response->setJSON([ 'status' => false,'message' => 'API call failed','data' => $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'] ?? []; $data = $response['data'] ?? [];
@ -257,7 +285,6 @@ class MediAssistApiController extends BaseController
$allBenef = array_merge($allBenef, $data['benefDetails']); $allBenef = array_merge($allBenef, $data['benefDetails']);
$startIndex += $range; $startIndex += $range;
} while ($startIndex < $totalCount); } while ($startIndex < $totalCount);
// now update DB // now update DB
@ -265,7 +292,6 @@ class MediAssistApiController extends BaseController
$updated = 0; $updated = 0;
foreach ($allBenef as $row) { foreach ($allBenef as $row) {
// $update = $db->table('employee_polices') // $update = $db->table('employee_polices')
@ -298,18 +324,26 @@ class MediAssistApiController extends BaseController
} }
// update file table status after the tpa id successfully updated // update file table status after the tpa id successfully updated
if(isset($requestData['file_id']) && !empty($requestData['file_id'])){ if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
$file_model = new FileModel(); $file_model = new FileModel();
$file_model->where('id', $requestData['file_id'])->set('status', 'success')->update(); $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']}"); log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
}else{ } else {
log_message('error', "Failed to update file table status."); log_message('error', "Failed to update file table status.");
} }
log_message('error', "GetBenefDetails completed. Total fetched={$totalCount}, updated={$updated}"); log_message('error', "GetBenefDetails completed. Total fetched={$totalCount}, updated={$updated}");
return $this->response->setJSON([ if($function_calling_type == "job"){
return [
'status' => true,
'message' => 'Updated successfully',
'total_fetched' => $totalCount,
'total_updated' => $updated
];
}else{
return $this->respond([
'status' => true, 'status' => true,
'message' => 'Updated successfully', 'message' => 'Updated successfully',
'total_fetched' => $totalCount, 'total_fetched' => $totalCount,
@ -317,6 +351,37 @@ class MediAssistApiController extends BaseController
]); ]);
} }
} catch (\Throwable $th) {
// 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.");
}
$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,
];
log_message('error', 'Exception thrown while calling GetBenefDetails API: ' . json_encode($errorData));
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'API call failed', 'data' => $errorData];
}else{
return $this->respond(['status' => false, 'message' => 'API call failed', 'data' => $errorData]);
}
}
}
// public function GetBenefDetails (){ // public function GetBenefDetails (){

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');
@ -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();
@ -985,7 +986,6 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
$.ajax({ $.ajax({
url: apiURL, url: apiURL,
method: 'GET', method: 'GET',
@ -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,42 +475,45 @@
} }
}); });
$('#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();
}
}); });
// Function to convert object to query parameters $('#action_type').on('change', function() {
function objectToQueryString2(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList2(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#client').val();
var policy_id = $('#policy').val();
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
var queryParams = {
client_id: client_id,
policy_id: policy_id
};
const queryString = objectToQueryString2(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
// console.log(apiURL);
window.location.href = apiURL;
}
//--------------------------------------------------------------------------------------
$('#action_type').change(function() {
var selectedValue = $(this).val(); var selectedValue = $(this).val();
var insurer_or_tpa = $('#insurer_or_tpa').val()
// console.log(selectedValue); // console.log(selectedValue);
if (selectedValue == '') { if (selectedValue == '') {
@ -516,33 +530,15 @@
$('#import_excel_btn').hide(); $('#import_excel_btn').hide();
$('#export_excel_btn').show(); $('#export_excel_btn').show();
} }
});
document.getElementById('toggleIcon').addEventListener('click', function() { if (tpa_api_sevice == 0 || selectedValue == 'export' || insurer_or_tpa == "insurer") {
var icon = document.getElementById('icon'); $('.fetch_tpa').hide();
icon.classList.toggle('mdi-chevron-down');
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 { } else {
$('#policy').prop('required', true); $('.fetch_tpa').show();
$('#policy_danger').show();
} }
}); });
});
//-------------------------------------------------------------------------------------- $('#insurer_or_tpa').on('change', function() {
$('#insurer_or_tpa').change(function(){
var insurer_or_tpa = $(this).val() var insurer_or_tpa = $(this).val()
var policy_value = $('#policy').val() var policy_value = $('#policy').val()
@ -584,9 +580,15 @@
$("#event_type").select2(); $("#event_type").select2();
} }
} }
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer") {
$('.fetch_tpa').hide();
} else {
$('.fetch_tpa').show();
}
}); });
$('#action_type').change(function(){ $('#action_type').on('change', function() {
var action_type = $(this).val() var action_type = $(this).val()
var policy_value = $('#policy').val() var policy_value = $('#policy').val()
@ -628,25 +630,67 @@
$("#event_type").select2(); $("#event_type").select2();
} }
} }
if (tpa_api_sevice == 0 || action_type == 'export' || insurer_or_tpa == "insurer") {
$('.fetch_tpa').hide();
} else {
$('.fetch_tpa').show();
}
}); });
$(document).ready(function(){ /**This function updates the download link based on the selected option in the dropdown menu. **/
$('#event_type').on('change', function() {
$('#policy').change(function(){ var selectedValue = $(this).val();
if (selectedValue !== '') {
var policy_value = $(this).val() $('#import_excel_download').show();
var insurer_or_tpa = $('insurer_or_tpa').val() var fullURL = '<?= base_url("util/download_import_excel/"); ?>' + selectedValue;
var action_type = $('action_type').val() $('#import_excel_download').attr('href', fullURL);
} else {
if(policy_value == 0 || insurer_or_tpa == 'tpa' || action_type == 'import'){ $('#import_excel_download').hide();
$("#event_type").removeAttr("multiple"); $('#import_excel_download').removeAttr('href');
$("#event_type").attr("name", "event_type");
$("#event_type").select2('destroy');
} }
}) });
}); });
// Function to convert object to query parameters
function objectToQueryString2(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList2(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#client').val();
var policy_id = $('#policy').val();
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
var queryParams = {
client_id: client_id,
policy_id: policy_id
};
const queryString = objectToQueryString2(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
// console.log(apiURL);
window.location.href = apiURL;
}
//--------------------------------------------------------------------------------------
document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
//------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------
$('#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,7 +789,8 @@
</script> </script>
<script> <script>
function togglePolicyIssueDate() {
function togglePolicyIssueDate() {
let insurer = $('#insurer_or_tpa').val(); let insurer = $('#insurer_or_tpa').val();
let action = $('#action_type').val(); let action = $('#action_type').val();
// if (insurer === 'insurer' && action === 'import') { // if (insurer === 'insurer' && action === 'import') {
@ -771,5 +802,62 @@ function togglePolicyIssueDate() {
// $('#policy_issue_date').removeAttr('required').val(''); // $('#policy_issue_date').removeAttr('required').val('');
// $('#policy_issue_date_label').text('Policy Issue Date'); // $('#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>