diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php index 3e38230f..8bf81189 100644 --- a/app/Controllers/ICICILombardController.php +++ b/app/Controllers/ICICILombardController.php @@ -4,6 +4,8 @@ namespace App\Controllers; use CodeIgniter\Controller; use Kint; +use Ramsey\Uuid\Uuid; + class ICICILombardController extends AdminController { @@ -40,7 +42,12 @@ class ICICILombardController extends AdminController public function createEnrollmentBatch() { - helper('api'); + + + $client_id = $this->request->getGet('client_id'); + $client_branch_id = $this->request->getGet('client_branch_id'); + $policy_id = $this->request->getGet('policy_id'); + $event = $this->request->getGet('event'); //fetch token $tokenResponse = $this->generateAuthToken(); @@ -52,58 +59,35 @@ class ICICILombardController extends AdminController ]); } $token = $tokenResponse['data']['access_token']; - // dd($token); + $url = 'https://ilesbapigee.insurancearticlez.com/health/ilservices/health/v1/enrollment/batchcreation'; $headers = [ 'Authorization: Bearer ' . $token, 'Content-Type: application/json', - //'Scope: esbgpabatchcreation' ]; - #old policy info start - #"PolicyNumber" => "4016/A/51974976/00/000", - # "CDBGAccountNumber" => "CD-MUM-3344", - #"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f", - #old policy inf end - #"EmployeeMemberId" => "EMPID3625556", + //Prepare body data + $db = \Config\Database::connect(); + $data = $db->table('employee_polices ep') + ->select('cp.policy_no as policyNumber, + e.id,e.emp_code as MemberEmpId, e.doj as DOJ, e.name as InsuredName, e.dob as DOB, e.relationship as Relationship, + e.gender as Gender, ep.date_coverage as DOC,ep.basic_cover_si as SumInsured, e.email_corporate as EmailId + ') + ->join('employees e', 'e.id = ep.employee_id') + ->join('client_policy cp', 'ep.client_policy_id = cp.id') + ->where('ep.client_policy_id', $policy_id) + ->where('ep.status', 'active') + ->where('ep.is_active', 1) + // ->where('ep.uhid', null) + ->get() + ->getResultArray(); + + $body = $this->formatPolicyData($data); + dd($body); - $body = [ - "PolicyNumber" => "4016/A/O/53077718/00/000", - "CDBGAccountNumber" => "CD-MUM-0026", - "CorrelationId" => "550e8400-e29b-41d4-a716-446655440001", - "MemberDetails" => [ - [ - "MemberEmpId" => "EMPID3625557", - "DOJ" => "21-MAR-2019", - "InsuredName" => "Kumar", - "DOB" => "7-JUL-1983", - "Relationship" => "SELF", - "Gender" => "MALE", - "DOC" => "08-JUL-2025", - "SumInsured" => "400000", - "EmailId" => "KUMAR@GMAIL.COM", - "FlagStatus" => "A" - ], - [ - "MemberEmpId" => "EMPID3625557", - "DOJ" => "21-MAR-2019", - "InsuredName" => "Saranya", - "DOB" => "8-AUG-1970", - "Relationship" => "MOTHER", - "Gender" => "FEMALE", - "DOC" => "08-JUL-2025", - "SumInsured" => "400000", - "EmailId" => "Saranya@GMAIL.COM", - "FlagStatus" => "A" - ], - ] - ]; - // Kint::dump($body); - // print_rr(json_encode($body)); - // dd(); - $response = call_third_party_api($url, 'POST', $headers, ($body),true); // true = raw body mode + $response = call_third_party_api($url, 'POST', $headers, $body, true); // true = raw body mode // print_rr(json_encode($response));die(); return $this->response->setJSON($response); } @@ -178,5 +162,105 @@ class ICICILombardController extends AdminController } + public function formatPolicyData($data) + { + // Helper to format date + $formatDate = function ($date) { + return strtoupper(date('j-M-Y', strtotime($date))); // Example: 7-JUL-1983 + }; + + // Generate UUID v4 for CorrelationId + $generateUUID = function () { + return sprintf( + '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0x0fff) | 0x4000, + mt_rand(0, 0x3fff) | 0x8000, + mt_rand(0, 0xffff), + mt_rand(0, 0xffff), + mt_rand(0, 0xffff) + ); + }; + + // Map MemberDetails + $memberDetails = array_map(function ($row) use ($formatDate) { + return [ + "MemberEmpId" => $row['MemberEmpId'], + "DOJ" => $formatDate($row['DOJ']), + "InsuredName" => $row['InsuredName'], + "DOB" => $formatDate($row['DOB']), + "Relationship" => strtoupper($row['Relationship']), + "Gender" => strtoupper($row['Gender']), + "DOC" => $formatDate($row['DOC']), + "SumInsured" => $row['SumInsured'], + "EmailId" => $row['EmailId'], + "FlagStatus" => "A" // fixed value + ]; + }, $data); + + // Final body + return [ + "PolicyNumber" => $data[0]['policyNumber'] ?? null, + "CDBGAccountNumber" => "CD-MUM-0026", + "CorrelationId" => $generateUUID(), + "MemberDetails" => $memberDetails + ]; + } + + + + + + + + + + + + + + + + + + + + + + + // $body = [ + // "PolicyNumber" => "4016/A/O/53077718/00/000", + // "CDBGAccountNumber" => "CD-MUM-0026", + // "CorrelationId" => "550e8400-e29b-41d4-a716-446655440001", + // "MemberDetails" => [ + // [ + // "MemberEmpId" => "EMPID3625557", + // "DOJ" => "21-MAR-2019", + // "InsuredName" => "Kumar", + // "DOB" => "7-JUL-1983", + // "Relationship" => "SELF", + // "Gender" => "MALE", + // "DOC" => "08-JUL-2025", + // "SumInsured" => "400000", + // "EmailId" => "KUMAR@GMAIL.COM", + // "FlagStatus" => "A" + // ], + // [ + // "MemberEmpId" => "EMPID3625557", + // "DOJ" => "21-MAR-2019", + // "InsuredName" => "Saranya", + // "DOB" => "8-AUG-1970", + // "Relationship" => "MOTHER", + // "Gender" => "FEMALE", + // "DOC" => "08-JUL-2025", + // "SumInsured" => "400000", + // "EmailId" => "Saranya@GMAIL.COM", + // "FlagStatus" => "A" + // ], + // ] + // ]; + } diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php index 36dc3f01..54ffba09 100644 --- a/app/Controllers/VidalApiController.php +++ b/app/Controllers/VidalApiController.php @@ -145,7 +145,7 @@ class VidalApiController extends BaseController 'Authorization:' .getenv('VIDAL_API_KEY').'', ]; - $body = [ + $body = [ 'username' => getenv('VIDAL_API_USERNAME'), 'password' => getenv('VIDAL_API_PASSWORD'), 'policyNo' => $postData['policyNo'] ?? '', @@ -191,9 +191,8 @@ class VidalApiController extends BaseController return $this->response->setJSON($response); } - - - public function enrollment(){ + public function enrollment() + { $postData = $this->request->getJSON(true); diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 484a5f2f..2367957c 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -882,6 +882,7 @@ if (isset($selected_lead_type)) { if (data.salse_person_id) { selecSalsePerson(data.salse_person_id); } + } catch (error) { console.error('Error in dynamicLeadsDataForEdit function:', error); $('.loader').fadeOut(); @@ -1147,6 +1148,22 @@ if (isset($selected_lead_type)) { dateFormat: "d-m-Y" }); }); + + setTimeout(function () { + let selectedOption = $('#contact_person_summary option').filter(function () { + return $(this).text().trim() === (data.contact_person_name || '').trim(); + }); + + if (selectedOption.length) { + selectedOption.prop('selected', true); + console.log("Selected option:", selectedOption.text().trim(), "Value:", selectedOption.val()); + } else { + console.log("No match found for:", data.contact_person_name); + } + + $('#contact_person_summary').trigger('change'); + }, 2000); + }); }); } diff --git a/app/Views/policy_transaction_inception_form.php b/app/Views/policy_transaction_inception_form.php index a2867ce6..76ae987c 100644 --- a/app/Views/policy_transaction_inception_form.php +++ b/app/Views/policy_transaction_inception_form.php @@ -3110,6 +3110,7 @@ let unique_id = $(input).data('count'); let client_id = $('#client_id').val(); let client_type = $('#client_type').val(); + let policy_type_id = $('#policy_type_id').val(); let insurer_id = $(input).find('option:selected').attr('data-id'); let insurer_branch_id = $(input).find('option:selected').attr('data-bid'); @@ -3120,7 +3121,7 @@ console.log('follow_insurer_id unique_id', unique_id); if(client_id && insurer_id){ - if(client_type == 1){ + if(client_type == 1 && policy_type_id > 7){ $.ajax({ url: '' + client_id + '/' + insurer_id + '/' + insurer_branch_id, type: "GET", @@ -3328,8 +3329,10 @@ $("#inception_form_id").submit(function(event) { + event.preventDefault(); + let policy_type_id = $('#policy_type_id').val(); var isValid = $('#inception_form_id').parsley().validate(); var client_type_id = $('#client_type').val(); var policy_status = $('#policy_status').val(); @@ -3350,7 +3353,7 @@ return; } - if(client_type_id == 1 && policy_status == 'completed'){ + if(client_type_id == 1 && policy_status == 'completed' && policy_type_id > 7){ let isAnyDropdownSelected = $('select[name="cd_ac_no_for_child[]"]').filter(function() { return $(this).val() !== "";