nhance/app/Helpers/ChatbotHelper.php
2025-02-10 12:37:36 +05:30

260 lines
10 KiB
PHP

<?php
// File: App\Helpers\DepositHelper.php
namespace App\Helpers;
use App\Models\EmployeeModel;
use App\Models\CDMasterModel;
use App\Models\EmployeePolicyModel;
use App\Models\TPAModel;
use App\Helpers\MailHelper;
use App\Models\InsurerModel;
use App\Models\TicketMasterModel;
use App\Controllers\TicketController;
class ChatbotHelper
{
//get list of policies againest an employee_id
public static function getListOfPolicies($chat_session_info)
{
// $emp_id = 12288;
// $emp_code = 'HTL-007';
// $client_id = 159;
// $policy_id = 0;
// $client_branch_id = 126;
$emp_id = $chat_session_info['emp_id'];
$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';
$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];
}
public static function getHospitalLink($client_policy_id){
// $client_policy_id = 336;
// $emp_id = 12288;
$EmployeePolicyModel = new EmployeePolicyModel();
$res = $EmployeePolicyModel->getHospitalLinkByPolicyandEmp($client_policy_id);
return is_array($res) && count($res) ? $res[0]['network_hospitals'] : null;
}
public static function getPhoneNumber($chat_session_info){
$emp_id = $chat_session_info['emp_id'];
$EmployeeModel = new EmployeeModel();
return $EmployeeModel->select('mobile')->where('id',$emp_id)->first()['mobile'];
}
public static function sendReimbursementProcessOverMail($chat_session_info)
{
$emp_id = $chat_session_info['emp_id'];
$emp_code = $chat_session_info['emp_code'];
$client_id = $chat_session_info['client_id'];
$client_branch_id = $chat_session_info['client_branch_id'];
// $policy_id = 0;
// $relationship ='Father';
$EmployeeModel = new EmployeeModel();
$data = $EmployeeModel->find($emp_id);
if(isset($data) && isset($data['email_corporate']))
{
$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"]
];
$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]);
$res = json_decode($res);
if($res->status == 'success')
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
public static function ReimbursementProcessMailTemplate()
{
$template = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How to Claim Your Insurance Reimbursement</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
max-width: 600px;
margin: 20px auto;
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
color: #2c3e50;
text-align: center;
}
p {
font-size: 16px;
color: #555;
line-height: 1.5;
}
.steps {
padding: 10px;
background-color: #ecf0f1;
border-radius: 5px;
margin-bottom: 20px;
}
.steps ol {
padding-left: 20px;
}
.btn {
display: block;
width: 200px;
margin: 20px auto;
padding: 12px;
text-align: center;
background-color: #3498db;
color: #ffffff;
text-decoration: none;
border-radius: 5px;
font-size: 16px;
}
.btn:hover {
background-color: #2980b9;
}
.footer {
text-align: center;
font-size: 14px;
color: #777;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<h2>How to Claim Your Insurance Reimbursement</h2>
<p>Dear [Customer Name],</p>
<p>We are here to assist you in claiming your insurance reimbursement smoothly. Please follow the steps below:</p>
<div class="steps">
<ol>
<li><strong>Gather Documents:</strong> Collect all required documents such as bills, invoices, and medical reports.</li>
<li><strong>Complete the Claim Form:</strong> Fill out the insurance claim form accurately.</li>
<li><strong>Attach Supporting Documents:</strong> Attach all necessary documents to support your claim.</li>
<li><strong>Submit Your Claim:</strong> Send the completed form and documents via email or through our online portal.</li>
<li><strong>Track Your Claim:</strong> Use our tracking system to monitor the status of your claim.</li>
<li><strong>Receive Reimbursement:</strong> Once approved, the reimbursement will be processed to your registered account.</li>
</ol>
</div>
<a href="[CLAIM_PORTAL_URL]" class="btn">Submit Your Claim</a>
<p>If you have any questions, feel free to contact our support team.</p>
<div class="footer">
<p>Best Regards,<br><strong>Insurance Support Team</strong><br><a href="mailto:support@example.com">support@example.com</a></p>
</div>
</div>
</body>
</html>
';
return $template;
}
public static function getInsurersList(){
$insurer = new InsurerModel();
$data = $insurer->select('short_name,name')->where('category','general')->where('is_active',1)->findAll();
return $data;
}
public static function sendQuotationRequestMail($data){
$message = SELF::quotationRequestMailTemplate($data);
$common = ['mail_type'=>'request_quotation_bot'];
$email_id = 'no-reply-otp@nhanceindia.in';
$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));
if($res->status == 'success')
{
return true;
}
else
{
return false;
}
}
public static function quotationRequestMailTemplate($data){
$message = 'A customer has requested for a quotation using bot,Here are all the details for it:
'.$data;
return $message;
}
public static function getReimbursementClaimStatus($chat_session_info){
$emp_id = $chat_session_info['emp_id'];
$emp_code = $chat_session_info['emp_code'];
$client_id = $chat_session_info['client_id'];
$client_branch_id = $chat_session_info['client_branch_id'];
$ticketMaster = new TicketMasterModel();
$data = $ticketMaster->select('tcs.claim_status,ticket_master.claim_number,ticket_master.id')
// ->join('client_policy cp',"cp.client_id = {$client_id} and cp.client_branch_id = {$client_branch_id} and cp.policy_id = {$policy_id} and cp.is_active = 1")
->join('ticket_claim_status tcs',"ticket_master.claim_status_id = tcs.id and tcs.is_active = 1")
->where('ticket_master.emp_id',$emp_id)
->where('ticket_master.emp_code',$emp_code)
->where('ticket_master.is_active',1)
->orderBy('ticket_master.created_at', 'DESC')
->first();
$ticket_controller = new TicketController();
if (!empty($data)){
$ticket_id = $data['id'];
$mail_content = $ticket_controller->constructMailContent($ticket_id);
$mail_response = $ticket_controller->sendTrigger($mail_content);
return $data;
}else{
return false;
}
}
}
?>