CHANGE_TAT_IN_CLAIM_LIST : RV

This commit is contained in:
VENKATESHWARAN 2025-02-05 09:37:56 +05:30
parent 85423bc341
commit 8491a72213
2 changed files with 127 additions and 54 deletions

View File

@ -144,20 +144,52 @@ class TicketController extends BaseController
{ {
//action 1 get last 100 rows, action 2 filter and get all rows related to that //action 1 get last 100 rows, action 2 filter and get all rows related to that
if ($action == 1) { if ($action == 1) {
$data = $this->ticketMasterModel $data = $this->ticketMasterModel
->select('ticket_master.id, ticket_claim_status.claim_status as status, ->select("
ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name,
insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name, ticket_master.id,
DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') ticket_claim_status.claim_status as status,
ticket_master.claim_number as claim_no,
ticket_master.tpa_id,
ticket_master.emp_name,
insurers.name as insurer_name,
clients.client_name,
ticket_master.insured_name,
clients.short_name,
DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date,
CASE
WHEN DATEDIFF(
ticket_master.updated_at,
COALESCE(ticket_master.updated_at, ticket_history.created_at)
) BETWEEN 0 AND 6 THEN '0-6 Days'
WHEN DATEDIFF(
ticket_master.updated_at,
COALESCE(ticket_master.updated_at, ticket_history.created_at)
) BETWEEN 7 AND 12 THEN '7-12 Days'
WHEN DATEDIFF(
ticket_master.updated_at,
COALESCE(ticket_master.updated_at, ticket_history.created_at)
) BETWEEN 13 AND 20 THEN '13-20 Days'
ELSE 'Above 20 Days'
END AS tat
")
->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left')
->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left')
->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left')
->join('ticket_history', "ticket_master.id = ticket_history.ticket_id")
->where('ticket_master.is_active', 1) ->where('ticket_master.is_active', 1)
->where('ticket_history.is_active', 1)
->groupBy('ticket_master.id')
->orderBy('ticket_master.id', 'DESC') ->orderBy('ticket_master.id', 'DESC')
->limit(100) ->limit(100)
->findAll(); ->findAll();
// dd($data);
return $data; return $data;
} else { } else {
$search_data = $this->request->getPost(); $search_data = $this->request->getPost();
// print_r($search_data); // print_r($search_data);
@ -169,15 +201,41 @@ class TicketController extends BaseController
} }
// print_rr($where); // print_rr($where);
$data = $this->ticketMasterModel $data = $this->ticketMasterModel
->select('ticket_master.id, ticket_claim_status.claim_status as status, ->select("
ticket_master.claim_number as claim_no,ticket_master.tpa_id,ticket_master.emp_name, ticket_master.id,
insurers.name as insurer_name, clients.client_name,ticket_master.insured_name,clients.short_name, ticket_claim_status.claim_status as status,
DATE_FORMAT(ticket_master.created_at, "%d-%m-%Y") as tat') ticket_master.claim_number as claim_no,
ticket_master.tpa_id,
ticket_master.emp_name,
insurers.name as insurer_name,
clients.client_name,ticket_master.insured_name,
clients.short_name,
DATE_FORMAT(ticket_master.created_at, '%d-%m-%Y') as ticket_created_date,
CASE
WHEN DATEDIFF(
ticket_master.updated_at,
COALESCE(ticket_master.updated_at, ticket_history.created_at)
) BETWEEN 0 AND 6 THEN '0-6 Days'
WHEN DATEDIFF(
ticket_master.updated_at,
COALESCE(ticket_master.updated_at, ticket_history.created_at)
) BETWEEN 7 AND 12 THEN '7-12 Days'
WHEN DATEDIFF(
ticket_master.updated_at,
COALESCE(ticket_master.updated_at, ticket_history.created_at)
) BETWEEN 13 AND 20 THEN '13-20 Days'
ELSE 'Above 20 Days'
END AS tat
")
->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left') ->join('insurers', 'insurers.id = ticket_master.insurer_id and insurers.is_active = 1', 'left')
->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left') ->join('clients', 'clients.id = ticket_master.client_id and clients.is_active = 1', 'left')
->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left') ->join('ticket_claim_status', 'ticket_claim_status.id = ticket_master.claim_status_id and ticket_claim_status.is_active = 1', 'left')
->join('ticket_history', "ticket_master.id = ticket_history.ticket_id")
->where('ticket_master.is_active', 1) ->where('ticket_master.is_active', 1)
->where('ticket_history.is_active', 1)
->where($where) ->where($where)
->groupBy('ticket_master.id')
->orderBy('ticket_master.id', 'DESC')
->findAll(); ->findAll();
// print_rr($data); // print_rr($data);
// log_message('error',' Claims Master Data '.json_encode($data));die(); // log_message('error',' Claims Master Data '.json_encode($data));die();
@ -842,23 +900,24 @@ class TicketController extends BaseController
return 'Ticket id\'s : '.json_encode($ticket_ids); return 'Ticket id\'s : '.json_encode($ticket_ids);
} }
public function ticketReports(){ public function ticketReports()
{
if ($this->request->is('get')){ if ($this->request->is('get')) {
$default_start = new \DateTime(); $default_start = new \DateTime();
$data['default_end'] = $default_start->format('d-m-Y'); $data['default_end'] = $default_start->format('d-m-Y');
$data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y'); $data['default_start'] = $default_start->modify('-60 days')->format('d-m-Y');
$data['policy_type'] = $this->ticketType; $data['policy_type'] = $this->ticketType;
$data['account_manager'] = $this->userModel->select('first_name')->where('is_active',1)->where('role',3)->findAll(); $data['account_manager'] = $this->userModel->select('first_name')->where('is_active', 1)->where('role', 3)->findAll();
$data['report_type'] = [ $data['report_type'] = [
'acc_manager_wise_status'=>'Account Manger Wise Status Report', 'acc_manager_wise_status' => 'Account Manger Wise Status Report',
'tpa_wise_status' => 'TPA Wise Status Report', 'tpa_wise_status' => 'TPA Wise Status Report',
'tat_band_wise' => 'TAT Wise Status Report' 'tat_band_wise' => 'TAT Wise Status Report'
]; ];
// //
$this->loadLayout('ticket_reports',$data); $this->loadLayout('ticket_reports', $data);
}else{ } else {
$received_data = $this->request->getPost(); $received_data = $this->request->getPost();
$from_Date = $received_data['fromDate']; $from_Date = $received_data['fromDate'];
$to_Date = $received_data['toDate']; $to_Date = $received_data['toDate'];
@ -866,38 +925,33 @@ class TicketController extends BaseController
$toDate = \DateTime::createFromFormat('d-m-Y', $to_Date)->format('Y-m-d'); $toDate = \DateTime::createFromFormat('d-m-Y', $to_Date)->format('Y-m-d');
$policy_type = $received_data['policy_type']; $policy_type = $received_data['policy_type'];
// print_rr($received_data); // print_rr($received_data);
if ($received_data['report_type'] == "acc_manager_wise_status"){ if ($received_data['report_type'] == "acc_manager_wise_status") {
$viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type,$fromDate,$toDate); $viewData['account_manager_wise_data'] = $this->accountManagerWiseReport($policy_type, $fromDate, $toDate);
// print_rr($viewData); // print_rr($viewData);
if ($policy_type == 1){ if ($policy_type == 1) {
$html = view('claims_report_acc_manager_gmc', $viewData); $html = view('claims_report_acc_manager_gmc', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
}else{ } else {
$html = view('claims_report_acc_manager_gpa', $viewData); $html = view('claims_report_acc_manager_gpa', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} }
} elseif ($received_data['report_type'] == 'tpa_wise_status') {
}elseif ($received_data['report_type'] == 'tpa_wise_status'){ $viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type, $fromDate, $toDate);
$html = view('claims_report_tpa_wise', $viewData);
$viewData['tpa_wise_data'] = $this->tpaWiseReport($policy_type,$fromDate,$toDate);
$html = view('claims_report_tpa_wise',$viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} else if ($received_data['report_type'] == 'tat_band_wise') {
}else if ($received_data['report_type'] == 'tat_band_wise'){
$viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate); $viewData['data'] = $this->ticketMasterModel->getTATReport($policy_type, $fromDate, $toDate);
$html = view('tat_report_band_wise_list',$viewData); $html = view('tat_report_band_wise_list', $viewData);
return $this->respond(['status' => true, 'html' => $html], 200); return $this->respond(['status' => true, 'html' => $html], 200);
} }
} }
} }
public function accountManagerWiseReport($policy_type = null ,$start_date = null, $end_date = null){ public function accountManagerWiseReport($policy_type = null, $start_date = null, $end_date = null)
{
if ($policy_type == 1) { if ($policy_type == 1) {
$sql = "SELECT $sql = "SELECT
@ -933,9 +987,7 @@ class TicketController extends BaseController
// dd($result); // dd($result);
return $result; return $result;
} else {
}else{
$sql = "SELECT u.first_name AS acc_manager_name, $sql = "SELECT u.first_name AS acc_manager_name,
COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation, COUNT(CASE WHEN tcs.claim_status = 'CLAIM INTIMATION' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS claim_intimation,
COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer, COUNT(CASE WHEN tcs.claim_status = 'INTIMATION TO INSURER' AND master.ticket_type_id = '$policy_type' THEN master.id END) AS int_to_insurer,
@ -979,7 +1031,8 @@ class TicketController extends BaseController
} }
} }
public function tpaWiseReport($policy_type = null ,$start_date = null,$end_date = null ){ public function tpaWiseReport($policy_type = null, $start_date = null, $end_date = null)
{
// $policy_type = 1; // $policy_type = 1;
$sql = "SELECT $sql = "SELECT
tpa.name AS tpa_name, tpa.name AS tpa_name,
@ -1022,9 +1075,9 @@ class TicketController extends BaseController
"; ";
$result = $this->ticketMasterModel->query($sql)->getResultArray(); $result = $this->ticketMasterModel->query($sql)->getResultArray();
return $result; return $result;
} }
} }

View File

@ -166,7 +166,7 @@ class TicketMasterModel extends Model
// Fetch claim statuses from the `ticket_claim_status` table // Fetch claim statuses from the `ticket_claim_status` table
$statusQuery = " SELECT $statusQuery = " SELECT
id, claim_status id, claim_status, ticket_type
FROM ticket_claim_status FROM ticket_claim_status
Where is_active = 1 Where is_active = 1
$ticket_type_data_1 $ticket_type_data_1
@ -176,20 +176,40 @@ class TicketMasterModel extends Model
// Initialize dynamic query parts // Initialize dynamic query parts
$dynamicSelect = ''; $dynamicSelect = '';
// Loop through each claim status and generate the COALESCE and CASE statements for the SELECT // Loop through each claim status and generate the COALESCE and CASE statements for the SELECT
foreach ($statusResult as $status) { foreach ($statusResult as $status) {
// Dynamically add the COALESCE and CASE for each status in the SELECT part
$columnName = $status['claim_status']; // Default column name
if (empty($ticket_type)) {
// Append the insurance type prefix based on `ticket_type`
switch ($status['ticket_type']) {
case 1:
$columnName = "GMC - {$status['claim_status']}";
break;
case 2:
$columnName = "GPA - {$status['claim_status']}";
break;
case 3:
$columnName = "EDLI - {$status['claim_status']}";
break;
case 4:
$columnName = "GTLI - {$status['claim_status']}";
break;
}
}
$dynamicSelect .= " $dynamicSelect .= "
COALESCE( COALESCE(
SUM( SUM(
CASE CASE
WHEN subquery.status_id = {$status['id']} THEN 1 WHEN subquery.status_id = {$status['id']} THEN 1
ELSE 0 ELSE 0
END END
), ),
0 0
) AS `{$status['claim_status']}`, "; ) AS `$columnName`, ";
} }
// Remove the trailing comma from the SELECT part // Remove the trailing comma from the SELECT part
@ -219,15 +239,15 @@ class TicketMasterModel extends Model
tcs.id AS status_id, tcs.id AS status_id,
CASE CASE
WHEN DATEDIFF( WHEN DATEDIFF(
th.created_at, tm.updated_at,
COALESCE(tm.updated_at, th.created_at) COALESCE(tm.updated_at, th.created_at)
) BETWEEN 0 AND 6 THEN '0-6 Days' ) BETWEEN 0 AND 6 THEN '0-6 Days'
WHEN DATEDIFF( WHEN DATEDIFF(
th.created_at, tm.updated_at,
COALESCE(tm.updated_at, th.created_at) COALESCE(tm.updated_at, th.created_at)
) BETWEEN 7 AND 12 THEN '7-12 Days' ) BETWEEN 7 AND 12 THEN '7-12 Days'
WHEN DATEDIFF( WHEN DATEDIFF(
th.created_at, tm.updated_at,
COALESCE(tm.updated_at, th.created_at) COALESCE(tm.updated_at, th.created_at)
) BETWEEN 13 AND 20 THEN '13-20 Days' ) BETWEEN 13 AND 20 THEN '13-20 Days'
ELSE 'Above 20 Days' ELSE 'Above 20 Days'