From 1096511b1ab78e63fa11ed75999cc59734616fb7 Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Fri, 14 Nov 2025 12:13:58 +0530 Subject: [PATCH] CHANGE_EMP_CLAIM_STATUS_AND_HISTORY --- app/Controllers/EmployeeRestController.php | 62 +++++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index a77a10cb..0daa1d6b 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2626,19 +2626,34 @@ class EmployeeRestController extends AdminController $data['ticket_history'] = $ticketController->ticketHistory($ticket_id); $data['claims_data'] = $this->ticketMaster->getTicketDataByTicketID($ticket_id); $data['ticket_data'] = $ticketController->getMoreInfo($requestFrom = 'rest', $ticket_id); + $status_list = [ + "DENIAL REVIEW AWAITED" => 'Denial Review Awaited', + "UNDER PROCESS - TPA" => 'Under Process', + "SETTLED" => 'Settled', + "PAYMENT INITIATED" => 'Under Process', + "APPROVED" => 'Approved', + "REJECTED" => 'Rejected', + "UNDER PROCESS - QUERY DOCUMENT RECEIVED" => 'Under Process', + "UNDER PROCESS - CLAIM NO. UPDATION" => 'Under Process' , + "INFORMATION REQUIRED" => 'Information Required', + "CDA" => 'Claim Received', + "ID NOT GENERATED" => 'Claim Received', + "NON ID" => 'Claim Received' + ]; - // $data = $response['data']; // Assuming your full array is stored in $response // $ticketData = $data['ticket_data']; // $ticketHistory = $data['ticket_history']; + $data['ticket_data'] = array_fill_keys(array_keys($data['ticket_data']), []); // Loop through ticket_data foreach ($data['ticket_data'] as $status => &$fields) { // Search ticket_history for matching old_status_value foreach ($data['ticket_history'] as $history) { + if ($history['old_status_value'] === $status) { // Attach modified_by and created_at - $fields['modified_by'] = $history['modified_by']; + // $fields['modified_by'] = $history['modified_by']; $fields['modified_at'] = date('d-m-Y h:i A', strtotime($history['created_at'])); // Break after first match (assuming latest entry is enough) break; @@ -2646,6 +2661,25 @@ class EmployeeRestController extends AdminController } } + $new_ticket_data = []; + + foreach ($data['ticket_data'] as $oldKey => $value) { + + // Only process if key exists in status_list + if (!isset($status_list[$oldKey])) { + continue; // skip and do NOT add to new array + } + + // Get new key based on mapping + $newKey = $status_list[$oldKey]; + + // Avoid duplicates + if (!isset($new_ticket_data[$newKey])) { + $new_ticket_data[$newKey] = $value; + } + } + + $data['ticket_data'] = $new_ticket_data; $ticketMesssageModel = new TicketMessageModel(); $ticket_message = $ticketMesssageModel @@ -3818,16 +3852,27 @@ class EmployeeRestController extends AdminController if (!empty($ticket_data)) { + // $client_claim_status = [ + // 'Received' => [1, 2, 3, 4, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38], + // 'Rejected' => [8, 49, 55, 60], + // 'Cancelled' => [13, 47, 53, 58], + // 'Returned' => [14, 48, 54, 59], + // 'Closed' => [12, 22, 32, 42], + // 'Approved' => [9, 20, 30, 40], + // 'Settled' => [11, 24, 34], + // 'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56], + // ]; + $client_claim_status = [ - 'Received' => [1, 2, 3, 4, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38], - 'Rejected' => [8, 49, 55, 60], - 'Cancelled' => [13, 47, 53, 58], - 'Returned' => [14, 48, 54, 59], - 'Closed' => [12, 22, 32, 42], + 'Claim Received' => [1, 2, 3, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38], + 'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56], + 'Information Required' => [ 4 ], 'Approved' => [9, 20, 30, 40], 'Settled' => [11, 24, 34], - 'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56], + 'Denial Review Awaited' => [66], + 'Rejected' => [8, 49, 55, 60], ]; + foreach ($data['ticket_data'] as $status => &$fields) { foreach ($ticket_data as $key => $value) { @@ -3836,6 +3881,7 @@ class EmployeeRestController extends AdminController $ticket_data[$key]['claim_status'] = $claim_key ?? null; // Assign back to the main array } } + $ticket_data[$key]['priority_type'] = $priorityType[$value['priority']] ?? null; $ticket_data[$key]['mode_of_intimate_type'] = $modeOFIntimate[$value['mode_of_intimation']] ?? null; $ticket_data[$key]['relationship_type'] = ucfirst($value['relationship']) ?? null;