FEAT_CLAIM_STATUS_UPDATE_CRONE
This commit is contained in:
parent
01cf2c6e8c
commit
fdcb3fa473
@ -523,6 +523,8 @@ $routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPoli
|
||||
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
|
||||
$routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr');
|
||||
$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery');
|
||||
$routes->cli('cli/ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -768,6 +770,7 @@ $routes->get('ClaimDetail','VidalApiController::ClaimDetail');
|
||||
$routes->get('SubmitClaim','MediAssistApiController::SubmitClaim');
|
||||
$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim');
|
||||
$routes->get('IRSubmission','MediAssistApiController::IRSubmission');
|
||||
$routes->get('ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
|
||||
|
||||
|
||||
// API service
|
||||
|
||||
@ -16,10 +16,12 @@ class MediAssistApiController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
protected $db;
|
||||
protected $mediAssistTpaId;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->mediAssistTpaId = getenv('MEDI_ASSIST_PRIMARY_KEY_CONSTANT');
|
||||
}
|
||||
|
||||
|
||||
@ -620,7 +622,7 @@ class MediAssistApiController extends BaseController
|
||||
$this->db->table('ticket_master')->where('id', $claimId)->update($updateArray);
|
||||
|
||||
// LOG UPDATE
|
||||
log_message('info', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
@ -632,7 +634,7 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
public function IRSubmission($claimId = null) // 585 this id for test
|
||||
{
|
||||
log_message('info', "IRSubmission INIT for ticket_id={$claimId}");
|
||||
log_message('error', "IRSubmission INIT for ticket_id={$claimId}");
|
||||
|
||||
// 1. FETCH TICKET DETAILS
|
||||
$ticket = $this->db->table('ticket_master tm')
|
||||
@ -685,7 +687,7 @@ class MediAssistApiController extends BaseController
|
||||
log_message('error', "File NOT FOUND on server → {$fileDir}");
|
||||
}
|
||||
|
||||
log_message('info', "IRSubmission Attachment Ready: {$filename} | URL={$downloadUrl}");
|
||||
log_message('error', "IRSubmission Attachment Ready: {$filename} | URL={$downloadUrl}");
|
||||
|
||||
$Attachments[] = [
|
||||
"AttachmentName" => $filename,
|
||||
@ -703,7 +705,7 @@ class MediAssistApiController extends BaseController
|
||||
"Attachments" => $Attachments
|
||||
];
|
||||
|
||||
log_message('info', "IRSubmission Request Body => " . json_encode($body));
|
||||
log_message('error', "IRSubmission Request Body => " . json_encode($body));
|
||||
|
||||
// 4. SEND API CALL
|
||||
helper('api');
|
||||
@ -719,7 +721,7 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
log_message('info', "IRSubmission API Response => " . json_encode($response));
|
||||
log_message('error', "IRSubmission API Response => " . json_encode($response));
|
||||
|
||||
// 5. HANDLE RESPONSE
|
||||
if (!$response['status']) {
|
||||
@ -735,7 +737,7 @@ class MediAssistApiController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
log_message('info', "IRSubmission SUCCESS → ClaimID={$ticket['ClaimID']}");
|
||||
log_message('error', "IRSubmission SUCCESS → ClaimID={$ticket['ClaimID']}");
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
@ -819,20 +821,26 @@ class MediAssistApiController extends BaseController
|
||||
")
|
||||
->join('employees e', 'e.id = tm.emp_id', 'left')
|
||||
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
|
||||
|
||||
->where('tm.tpa_claim_push_reference_no IS NOT NULL')
|
||||
->where('tm.is_active', 1)
|
||||
->whereNotIn('tm.claim_status_id', [8, 11, 12, 13, 66, 22, 24, 47, 49, 32, 34, 53, 55, 42, 44, 58, 60])
|
||||
->where('tm.tpa_id', $this->mediAssistTpaId)
|
||||
->get()
|
||||
->getRowArray();
|
||||
->getResultArray();
|
||||
|
||||
// dd($TicketData);
|
||||
|
||||
if (!$TicketData) {
|
||||
return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]);
|
||||
log_message('error', "Claims not found to update status");
|
||||
return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]);
|
||||
}
|
||||
|
||||
$error_data = [];
|
||||
$status_updated_count = 0;
|
||||
|
||||
foreach ($TicketData as $key => $ticket)
|
||||
{
|
||||
$claimId = $ticket['id'];
|
||||
if (!$ticket) {
|
||||
return $this->response->setJSON(['status' => false,'message' => 'Invalid Claim ID' ]);
|
||||
}
|
||||
|
||||
// REQUEST BODY
|
||||
if($ticket['claimRefNo'] != null)
|
||||
@ -866,8 +874,7 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
|
||||
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
|
||||
return $this->response->setJSON(['status' => false,'message' => 'API call failed.','data' => $response]);
|
||||
$error_data[$claimId][['status' => false,'message' => 'API call failed.','data' => $response]];
|
||||
}
|
||||
|
||||
// Extract claim status
|
||||
@ -877,6 +884,7 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
// VALID STATUS LIST
|
||||
$validStatuses = [
|
||||
|
||||
"Claim Received" => 1,
|
||||
"In Progress" => 5,
|
||||
"Processed" => 11,
|
||||
@ -914,7 +922,6 @@ class MediAssistApiController extends BaseController
|
||||
"DENIAL REVIEW AWAITED" => 66,
|
||||
];
|
||||
|
||||
|
||||
// Maping tpa claim status with local claim Status
|
||||
if (isset($validStatuses[$currentStatus]))
|
||||
{
|
||||
@ -925,19 +932,20 @@ class MediAssistApiController extends BaseController
|
||||
|
||||
// UPDATE ticket_master
|
||||
$this->db->table('ticket_master')->where('id', $claimId)->update($updateArray);
|
||||
$status_updated_count ++;
|
||||
|
||||
// LOG UPDATE
|
||||
log_message('info', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'Claim status updated.',
|
||||
'updated_status' => $currentStatus,
|
||||
'api_response' => $response
|
||||
'api_response' => $response,
|
||||
'count' => $status_updated_count,
|
||||
'error_data' => $error_data,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user