From ca84f743d6ed8002398b742fe632a95d0deffe36 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 10 Sep 2025 09:28:02 +0530 Subject: [PATCH] FIX_LIVE_ISSUES --- .../Chatbot/NetworkHospitalConversation.php | 14 ++++---- .../doYouWantToContinueConversation.php | 1 + .../Chatbot/vehicleFormConversation.php | 2 +- app/Controllers/Home.php | 14 ++++---- app/Helpers/ChatbotHelper.php | 36 ++++++++++--------- app/Models/EmployeePolicyModel.php | 10 ++++-- 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/app/Controllers/Chatbot/NetworkHospitalConversation.php b/app/Controllers/Chatbot/NetworkHospitalConversation.php index 4a1e991c..34e44f2b 100644 --- a/app/Controllers/Chatbot/NetworkHospitalConversation.php +++ b/app/Controllers/Chatbot/NetworkHospitalConversation.php @@ -52,25 +52,27 @@ class NetworkHospitalConversation extends Conversation // }); $this->bot->ask($question, function ($answer) { - $path = $this->bot->userStorage()->get('path'); + $path = $this->bot->userStorage()->get('path'); array_push($path, $answer->getValue() ); $this->bot->userStorage()->save([ 'path' => $path ]); - log_message('error', ('user_reponse : ' . $answer->getValue())); - + // log_message('error', ('user_reponse : ' . $answer->getValue())); + // log_message('error', ('user_reponse : ' . json_encode(explode('#',$answer->getValue())))); switch ($answer->getValue()) { case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2: - $client_poilicy_id = explode('#',$answer->getValue())[1]; - $hospital_link = ChatbotHelper::getHospitalLink($client_poilicy_id); + $emp_poilicy_id = explode('#',$answer->getValue()); + $emp_poilicy_id = array_shift($emp_poilicy_id); + log_message('error','EMP POL ID FOR HOSPITAL' . $emp_poilicy_id); + $hospital_link = ChatbotHelper::getHospitalLink($emp_poilicy_id); if($hospital_link) { - $this->say('Click here for hospital details'); + $this->say('Click here for hospital details'); } else { diff --git a/app/Controllers/Chatbot/doYouWantToContinueConversation.php b/app/Controllers/Chatbot/doYouWantToContinueConversation.php index 31bcf174..d7160bb7 100644 --- a/app/Controllers/Chatbot/doYouWantToContinueConversation.php +++ b/app/Controllers/Chatbot/doYouWantToContinueConversation.php @@ -77,6 +77,7 @@ class doYouWantToContinueConversation extends Conversation $this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!"); + $this->say("Say Hi or Help or Hello to start conversation again!"); break; default: $this->say("Invalid selection. Please choose an option."); diff --git a/app/Controllers/Chatbot/vehicleFormConversation.php b/app/Controllers/Chatbot/vehicleFormConversation.php index 3bcf39fd..70cb5d7a 100644 --- a/app/Controllers/Chatbot/vehicleFormConversation.php +++ b/app/Controllers/Chatbot/vehicleFormConversation.php @@ -196,7 +196,7 @@ class vehicleFormConversation extends Conversation // $cityName = $response->getText(); $sent_staus = ChatbotHelper::sendQuotationRequestMail($vehicle_info); if ($sent_staus){ - $this->say('Our Executive will contact you with the quotation soon.'); + $this->say('Thanks.Our Executive will contact you with the quotation soon.'); $this->bot->startConversation(new doYouWantToContinueConversation()); }else{ $this->say("There was a problem while requesting for a quotation please try again later."); diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index cc084f72..03878326 100755 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -57,8 +57,8 @@ class Home extends PublicController $data['gemini_response'] = 'An error occurred: ' . $e->getMessage(); } - print_rr($data); - } + //print_rr($data); + } public function check_gemini_2() { @@ -78,8 +78,9 @@ class Home extends PublicController $filePath = 'C:/Users/Venba/Desktop/ins stmts/NIC MDU June-2025 (1).pdf'; $filePath = 'C:/Users/Venba/Desktop/ins stmts/UIIC GR June-2025.pdf'; $filePath = 'C:/Users/Venba/Desktop/ins stmts/UIIC VLR June-2025 (2).xlsx'; - $filePath = 'C:/Users/Venba/Desktop/ins stmts/pdf/2.pdf'; - $filePath = 'C:\Users\Venba\Downloads\Raheja June-2025.csv'; + $filePath = 'C:/Users/Venba/Desktop/ins stmts/pdf/1.pdf'; + $filePath = 'C:/Users/Venba/Desktop/ins stmts/output.csv'; + // $filePath = 'C:\Users\Venba\Downloads\Raheja June-2025.csv'; // $filePath = 'C:/Users/Venba/Downloads/Raheja June-2025.pdf'; // $filePath = 'C:/Users/Venba/Desktop/ins stmts/ICICI Pru June-2025 (1).xlsx'; // $filePath = 'C:/Users/Venba/Desktop/ins stmts/Digit Life June-2025.xlsx'; @@ -102,7 +103,7 @@ class Home extends PublicController $base64Content = base64_encode($fileContent); // The prompt you want to send to the model $prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations"; - $prompt = "Read the following insurer monthly statement file and convert into JSON format as sample specified.attach statement items in 'items' key and if any other data available put it in 'meta'. Give me only JSON,not any explanations. If you find the same details like insured name, policy number,endorsement no,policy start date,policy end date group it as single policy and identify base premium, third party premium and terrorism premium."; + $prompt = "Read the following insurer monthly statement file and convert into JSON format as sample specified.attach statement items in 'items' key and if any other data available put it in 'meta'. Give me only JSON,not any explanations. If you find the same details like insured name, policy number,endorsement no,policy start date,policy end date group it as single policy and identify base premium, third party premium and terrorism premium.All brokerage amount may in the same name as brokerage or commission, so pick accordingly"; $prompt .= "{\'items\': [{\'sno\': 1, \'policy_no\': \'\', \'insured_name\': \'\', \'endorsement_no\': \'\', \'policy_start_date\': \'\', \'policy_end_date\': \'\', \'actual_base_premium_amount\': \'\', \'actual_third_party_premium_amount\': \'\', \'actual_terrorism_premium_amount\': \'\', \'actual_base_premium_percentage\': \'\', \'actual_third_party_premium_percentage\': \'\', \'actual_terrorism_premium_percentage\': \'\', \'actual_bp_brokerage_amount\': \'\', \'actual_tp_brokerage_amount\': \'\', \'actual_tep_brokerage_amount\': \'\', \'reward_amount\': \'\'}]}"; $payloadPart = null; @@ -270,6 +271,7 @@ public function convertToPdf($inputFile = null) { // 1. Load your Excel file $inputFile = 'C:/Users/Venba/Desktop/ins stmts/Raheja June-2025.xlsx'; + $inputFile = 'C:/Users/Venba/Desktop/ins stmts/ICICI Lom June-2025.xlsx'; // $inputFile = 'C:/Users/Venba/Desktop/ins stmts/pdf/sample.pdf'; $spreadsheet = IOFactory::load($inputFile); @@ -293,7 +295,7 @@ public function convertToPdf($inputFile = null) $mpdf->AddPage(); $mpdf->WriteHTML($html); } - $pdfPath = 'C:/Users/Venba/Desktop/ins stmts/pdf/2.pdf'; + $pdfPath = 'C:/Users/Venba/Desktop/ins stmts/pdf/1.pdf'; // $pdfPath = WRITEPATH.'tmp'; $mpdf->Output($pdfPath, \Mpdf\Output\Destination::FILE); // Save file on server // 4. Output diff --git a/app/Helpers/ChatbotHelper.php b/app/Helpers/ChatbotHelper.php index e1f213d3..3ec5eb31 100644 --- a/app/Helpers/ChatbotHelper.php +++ b/app/Helpers/ChatbotHelper.php @@ -30,16 +30,16 @@ class ChatbotHelper $emp_code = $chat_session_info['emp_code']; $client_id = $chat_session_info['client_id']; $client_branch_id = $chat_session_info['client_branch_id']; - // $relationship ='Father'; + $relationship ='Self'; $EmployeeModel = new EmployeeModel(); - return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ]);//,relationship:[$relationship]; + return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['active'],policy_status:['active'],client_branch_id:[ $client_branch_id ],relationship:[$relationship]);//,relationship:[$relationship]; } - public static function getHospitalLink($client_policy_id){ + public static function getHospitalLink($emp_policy_id){ // $client_policy_id = 336; // $emp_id = 12288; $EmployeePolicyModel = new EmployeePolicyModel(); - $res = $EmployeePolicyModel->getHospitalLinkByPolicyandEmp($client_policy_id); + $res = $EmployeePolicyModel->getHospitalLinkByPolicyandEmp($emp_policy_id); return is_array($res) && count($res) ? $res[0]['network_hospitals'] : null; } @@ -64,16 +64,18 @@ class ChatbotHelper { $message = SELF::ReimbursementProcessMailTemplate(); - $attachments = [ - ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"], - ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], - ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] - ]; + // $attachments = [ + // ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"], + // ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], + // ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] + // ]; $common = ['mail_type'=>'reimbursement_mail_process_bot']; $email_id = $data['email_corporate']; - $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]); + // $email_id = 'vitvelz@gmail.com'; + // $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Claim Reimbursement Process', 'message' => $message,'attachments' => $attachments,'common'=>$common]); + $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Claim Reimbursement Process', 'message' => $message,'common'=>$common]); $res = json_decode($res); if($res->status == 'success') @@ -166,7 +168,7 @@ class ChatbotHelper
  1. Gather Documents: Collect all required documents such as bills, invoices, and medical reports.
  2. -
  3. Complete the Claim Form: Fill out the insurance claim form accurately.
  4. +
  5. Complete the Claim Form: Fill out the insurance claim form in the portal.
  6. Attach Supporting Documents: Attach all necessary documents to support your claim.
  7. Submit Your Claim: Send the completed form and documents via email or through our online portal.
  8. Track Your Claim: Use our tracking system to monitor the status of your claim.
  9. @@ -174,12 +176,10 @@ class ChatbotHelper
- Submit Your Claim -

If you have any questions, feel free to contact our support team.

@@ -202,7 +202,8 @@ class ChatbotHelper $common = ['mail_type'=>'request_quotation_bot']; $email_id = getenv('email.enquiryMail'); - $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Quotation Request Received from bot.', 'message' => $message,'common'=>$common]); + // $res = MailHelper::send_email(['mail' => $email_id, 'bcc' => 'vitvelz@gmail.com','subject' => '(TESTING)Quotation Request Received from bot.', 'message' => $message,'common'=>$common]); + $res = MailHelper::send_email(['mail' => $email_id,'subject' => 'Quotation Request Received from bot.', 'message' => $message,'common'=>$common]); $res = json_decode($res); log_message('error','res: '.json_encode($res)); @@ -218,7 +219,7 @@ class ChatbotHelper } public static function quotationRequestMailTemplate($data){ - $message = 'A customer has requested for a quotation using bot,Here are all the details for it: + $message = 'A customer has requested for a quotation using bot,Here are all the details for it:
'.$data; return $message; } @@ -266,7 +267,8 @@ class ChatbotHelper $mail_content = Self::ReimbursementStatusMailTemplate($data['emp_name'],$data['claim_number'],$matched_key); $common = ['mail_type'=>'Claim Status']; $email_id = $data['emp_mail']; - $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Here is your claim status you requested in bot.', 'message' => $mail_content,'common'=>$common]); + // $email_id = 'vitvelz@gmail.com'; + $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Claim status as you requested in bot.', 'message' => $mail_content,'common'=>$common]); $res = json_decode($res); log_message('error','res: '.json_encode($res)); diff --git a/app/Models/EmployeePolicyModel.php b/app/Models/EmployeePolicyModel.php index 82a8cb3b..bf34881a 100755 --- a/app/Models/EmployeePolicyModel.php +++ b/app/Models/EmployeePolicyModel.php @@ -2089,11 +2089,15 @@ class EmployeePolicyModel extends Model return $result[0]; } - public function getHospitalLinkByPolicyandEmp($client_policy_id){ - $data = $this->db->table('client_policy') + public function getHospitalLinkByPolicyandEmp($emp_policy_id){ + $data = $this->db->table('employee_polices') ->select('tpa.network_hospitals') - ->where('client_policy.id', $client_policy_id) + ->where('employee_polices.id', $emp_policy_id) + ->where('employee_polices.is_active', 1) + ->where('employee_polices.status', 'active') + // ->where('client_policy.id', $client_policy_id) // ->where('employee_polices.is_active', 1) + ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id AND client_policy.is_active = 1') ->join('tpa', 'tpa.id = client_policy.tpa_id AND tpa.is_active = 1') // ->join('employees', 'employees.id = employee_polices.employee_id AND employees.id = ' . (int) $emp_id) ->get()->getResultArray();