CHANGE_CLAIM_API : RV

This commit is contained in:
VENKATESHWARAN 2025-02-21 09:38:33 +05:30
parent 367d035629
commit e19cc5d695
6 changed files with 243 additions and 35 deletions

View File

@ -31,6 +31,7 @@ $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderM
$routes->get("sendextraparam", "ClientController::sendextraparam");
$routes->get("updateRenewalData", "ClientController::updateRenewalData");
$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient");
$routes->get("updateRenewalInsurerData", "ClientController::updateRenewalInsurerData");
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
@ -441,13 +442,19 @@ $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::
// Test initiate Claim
$routes->post('initiateClaim',"EmployeeRestController::initiateClaim");
$routes->get('departments',"EmployeeRestController::get_ticket_type");
$routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
//api
$routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->post("logined", "RestAuthenticationController::logined");
$routes->post("getId", "RestAuthenticationController::getUserIdFromToken");
$routes->post('initiateClaim',"EmployeeRestController::initiateClaim");
$routes->get('get_ticket_type',"EmployeeRestController::get_ticket_type");
$routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
});
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {

View File

@ -4589,6 +4589,50 @@ class ClientController extends AdminController
kint::dump($successData);
}
public function updateRenewalInsurerData()
{
$db = db_connect();
$renewalData = $db->table('old_renewal_data_copy')
->where('insurer_id IS NULL')
->get()
->getResultArray();
// dd($renewalData);
$successData = [];
foreach ($renewalData as $key => $value) {
$insurer_data = $this->insurerModel->where('name', $value['insurer_name'])->where('is_active', 1)->first();
if(!empty($insurer_data)){
$insurer_branch_data = $this->insurerBranchModel->where('branch_name', $value['insurer_branch'])->first();
if(!empty($insurer_branch_data)){
$branch = $this->insurerBranchModel->where('insurer_id', $insurer_data['id'] ?? 0)->first();
$value['insurer_id'] = $insurer_data['id'] ?? null;
$value['insurer_branch_id'] = $branch['id'] ?? null;
}else{
$value['insurer_id'] = $insurer_data['id'] ?? null;
$value['insurer_branch_id'] = $this->prepareInsurerBranch($value);
}
}else{
$value['insurer_id'] = $this->prepareinsurer($value);
$value['insurer_branch_id'] = $this->prepareInsurerBranch($value);
}
// Update is_inserted field in DB
$db->table('old_renewal_data_copy')
->where('id', $value['id'])
->set([
'insurer_id' => $value['insurer_id'],
'insurer_branch_id' => $value['insurer_branch_id'],
])
->update();
$successData[] = ['id' => $value['id'], 'insurer' => $value['insurer_name'], 'insurer_id' => $value['insurer_id'], 'insurer_branch_id' => $value['insurer_branch_id'], ];
}
kint::dump($successData);
}
public function updateRenewalDataNotExistingClient()
{
@ -4920,6 +4964,51 @@ class ClientController extends AdminController
$id = $ClientModel->insert($clientData);
return $id;
}
private function prepareInsurerBranch($renewalData)
{
$insurerBranchData = [
'insurer_id' => $renewalData['insurer_id'],
'branch_name' => $renewalData['insurer_branch'],
'branch_code' => $renewalData['insurer_branch'],
'address1' => null,
'address2' => null,
'city' => null,
'district' => null,
'state' => null,
'pincode' => null,
];
$InsurerBranchModel = new InsurerBranchModel();
$id = $InsurerBranchModel->insert($insurerBranchData);
return $id;
}
private function prepareinsurer($renewalData)
{
$short_name1 = explode(" ", $renewalData['insurer_name'])[0];
$short_name2 = explode(" ", $renewalData['insurer_name'])[1];
$short_name = $short_name1 . ' ' . $short_name2;
$insurerData = [
'type' => "pvt",
'category' => "general",
'addition_add_day' => 0,
'deletion_add_day' => 0,
'name' => $renewalData['insurer_name'],
'short_name' => $short_name,
'insurer_logo' => null,
'is_multi_event' => 0, // Default is 0
];
$InsurerModel = new InsurerModel();
$id = $InsurerModel->insert($insurerData);
return $id;
}
}

View File

@ -3108,48 +3108,78 @@ class EmployeeRestController extends AdminController
{
$received_data = $this->request->getPost();
// print_r($received_data); die;
$employee_id = $received_data['emp_id'];
$client_policy_id = $received_data['client_policy_id'];
$insured_emp_id = $received_data['insured_emp_id'];
$sql = "select cp.policy_type_id as ticket_type_id,
cl_rm.user_id as acm_id,
cp.insurer_id as insurer_id,
cp.tpa_id as tpa_id,
emp.client_id ,
emp.id as emp_id,
emp_pol.uhid as policy_no,
emp.emp_code,
emp_pol.tpa_id as tpa_no,
emp.name as emp_name,
emp.email_corporate as emp_mail,
emp.mobile as emp_mobile,
empl.id as insured_emp_id,
empl.name as insured_name,
empl.relationship
$sql = "
select
cp.policy_type_id,
cl_rm.user_id as acm_id,
cp.insurer_id as insurer_id,
cp.tpa_id as tpa_id,
emp.client_id ,
emp.id as emp_id,
emp_pol.uhid as policy_no,
emp.emp_code,
emp_pol.tpa_id as tpa_no,
emp.name as emp_name,
emp.email_corporate as emp_mail,
emp.mobile as emp_mobile,
empl.id as insured_emp_id,
empl.name as insured_name,
empl.relationship,
CASE
WHEN cp.policy_type_id IN (2, 3, 4, 5) THEN 1
WHEN cp.policy_type_id = 1 THEN 2
WHEN cp.policy_type_id = 6 THEN 3
WHEN cp.policy_type_id = 7 THEN 4
ELSE NULL
END AS ticket_type_id
from employees emp
from employees emp
left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active'
left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1
left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1
left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3
left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active'
left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1
left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1
left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3
where emp.id = $employee_id and emp.is_active = 1 and emp.emp_status = 'active'
limit 1 ";
$fetchData = $this->employeeModel->query($sql)->getResultArray()[0];
$fetchData['claim_status_id'] = $this->claimStatusModel->select('id')->where('ticket_type', $fetchData['ticket_type_id'])->first()['id'];
$fetchData['claim_status_id'] = $this->claimStatusModel
->select('id')
->where('ticket_type', $fetchData['ticket_type_id'])
->orderBy('id', 'asc')
->first()['id'];
$fetchData['priority'] = 1;
$fetchData['mode_of_intimation'] = 1;
$fetchData['hospital_name'] = $received_data['hospital_name'];
$fetchData = array_merge($fetchData, $received_data);
// print_r($fetchData); die;
$insert_status = $this->ticketMaster->insert($fetchData);
$ticket_id = $this->ticketMaster->insertID();
if ($insert_status && !empty($ticket_id)) {
$messagesData = [
'ticket_id' => $ticket_id ?? null,
'sender' => 'user',
'claim_status' => $fetchData['claim_status_id'] ?? null,
'emp_mail' => $fetchData['emp_mail'] ?? null,
'mail_subject' => $fetchData['subject'] ?? null,
'mail_content' => $fetchData['message'] ?? null,
];
if (!empty($messagesData['ticket_id'])) {
$TicketMessageModel = new TicketMessageModel();
$TicketMessageModel->insert($messagesData);
}
$mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
if (gettype($mail_sent_status) == 'array') {
$message = 'Claim Iniated Successfully';
@ -3187,6 +3217,66 @@ class EmployeeRestController extends AdminController
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
}
}
//department
public function get_ticket_type()
{
$ticket_type = $this->ticketController->ticketType;
$ticket_type = array_map(fn($value, $key) => (object) ['id' => $key, 'name' => $value], array_values($ticket_type), array_keys($ticket_type));
// print_r($ticket_type); die;
return $ticket_type;
}
//ticket data
public function get_ticket_data()
{
$priorityType = $this->ticketController->priorityType;
$modeOFIntimate = $this->ticketController->modeOFIntimate;
$claimType = $this->ticketController->claimType;
$relationshipType = $this->ticketController->relationshipType;
$emp_id = $this->request->getGet('emp_id');
// dd($emp_id);
if (empty($emp_id)) {
return $this->response->setJSON(['error' => 'emp_id is required'])->setStatusCode(404);
}
$TicketMasterModel = new TicketMasterModel();
$ticket_data = $TicketMasterModel->get_ticket_data($emp_id);
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],
];
foreach ($ticket_data as $key => $value) {
foreach ($client_claim_status as $claim_key => $claim_value) {
if (in_array($value['claim_status_id'], $claim_value)) { // Corrected argument order
$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;
$claimPrimaryTypey = "1";
if (in_array($value['claim_type'], [2, 3, 4])) {
$claimPrimaryTypey = "2";
}
$ticket_data[$key]['claim_type_value'] = $claimType[$claimPrimaryTypey][$value['claim_type']] ?? null;
}
}
// print_rr($ticket_data); die;
return $ticket_data;
}
}

View File

@ -26,14 +26,14 @@ class TicketController extends BaseController
use ResponseTrait;
protected $myLogger;
protected $ticketType;
protected $priorityType;
protected $relationshipType;
protected $modeOFIntimate;
protected $claimType;
protected $claimStatus;
protected $placeHolders;
protected $extraFields;
public $ticketType;
public $priorityType;
public $relationshipType;
public $modeOFIntimate;
public $claimType;
public $claimStatus;
public $placeHolders;
public $extraFields;
protected $clientModel;
protected $ticketMasterModel;

View File

@ -259,6 +259,7 @@ class ClientPolicyModel extends Model
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
->where('client_id', $clientId)
->where('insurer_id', $insurerId)
->where('cash_deposit.is_active', 1)
->get()
->getRow();
}

View File

@ -676,5 +676,26 @@ class TicketMasterModel extends Model
return $result;
}
}
//api
public function get_ticket_data($emp_id, $ticket_type = null, $ticket_id = null)
{
$query = $this->select('*')
->where('is_active', 1)
->where('emp_id', $emp_id);
if (!empty($ticket_id)) {
$query->where('id', $ticket_id);
}
if (!empty($ticket_type)) {
$query->where('ticket_type_id', $ticket_type);
}
$data = $query->findAll();
// dd($data, db_connect()->getLastQuery());
return $data;
}
}