234 lines
6.6 KiB
PHP
234 lines
6.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
|
|
use App\Models\EmployeePolicyModel;
|
|
|
|
|
|
use App\Controllers\BaseController;
|
|
use App\Controllers\VidalApiController;
|
|
use App\Controllers\ICICILombardController;
|
|
use App\Controllers\MediAssistApiController;
|
|
use App\Models\FileModel;
|
|
|
|
class ApiServiceController extends BaseController
|
|
{
|
|
use ResponseTrait;
|
|
// protected $format = 'json';
|
|
protected $db;
|
|
protected $employeePolicyModel;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->db = \Config\Database::connect();
|
|
$this->employeePolicyModel = new EmployeePolicyModel();
|
|
}
|
|
|
|
// Push Claims
|
|
public function pushClaims($claimId)
|
|
{
|
|
|
|
$data = $this->db->table('ticket_master tm')
|
|
->select('tm.id,tm.tpa_id ')->where('tm.id', $claimId)->get()->getRowArray(); // single record
|
|
|
|
if($data){
|
|
|
|
$tpaID = $data['tpa_id'];
|
|
|
|
if ($tpaID == 2) { // MediAssist
|
|
$mediAssistController = new MediAssistApiController();
|
|
return $mediAssistController->SubmitClaim($claimId);
|
|
}else{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// E-Card Request
|
|
public function ecardRequest()
|
|
{
|
|
try{
|
|
|
|
$payload = $this->request->getJSON(true);
|
|
$id = $payload['id'] ?? null;
|
|
$emp_code = $payload['emp_code'] ?? null;
|
|
$client_policy_id = $payload['client_policy_id'] ?? null;
|
|
$policy_no = $payload['policy_no'] ?? null;
|
|
|
|
|
|
$employee_policy = $this->employeePolicyModel
|
|
->select('employees.*, employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid , client_policy.tpa_id as tpa_primary_id ')
|
|
->join('employees', 'employee_polices.employee_id = employees.id', 'left')
|
|
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id', 'left')
|
|
->where('employee_polices.employee_id',$id)
|
|
->where('employee_polices.client_policy_id',$client_policy_id)
|
|
->where('employee_polices.is_active', 1 )->findAll();
|
|
|
|
|
|
|
|
if(count($employee_policy) > 0)
|
|
{
|
|
if($employee_policy[0]['tpa_id'] != null)
|
|
{
|
|
if($employee_policy[0]['tpa_primary_id'] == 2)//Medi assist
|
|
{
|
|
$mediAssistController = new MediAssistApiController();
|
|
$data['eCardDownload'] = $mediAssistController->EcardRequest( $emp_code, $policy_no );
|
|
}else{
|
|
$data['eCardDownload'] = base_url('download-e-card/') . $employee_policy[0]['rand_string'].'/1';
|
|
}
|
|
$data['message'] = "E-card generated";
|
|
|
|
} else {
|
|
$data['eCardDownload'] = null;
|
|
$data['message'] = "E-card not generated";
|
|
}
|
|
}else{
|
|
$data['eCardDownload'] = null;
|
|
$data['message'] = "E-card not generated";
|
|
}
|
|
|
|
|
|
return $this->respond(['status' => true, 'code' => 200, 'message' => '', 'data' => $data]);
|
|
|
|
} catch(\Exception $e){
|
|
|
|
}
|
|
}
|
|
|
|
// Get TPAID
|
|
public function getTPAID()
|
|
{
|
|
|
|
log_message('error', "getTPAID payloads :" . json_encode($this->request->getPost() ?? []));
|
|
$tpa_id = $this->request->getPost('tpa_id') ?? null;
|
|
$policy_no = $this->request->getPost('policy_no') ?? null;
|
|
$client_id = $this->request->getPost('client_id') ?? null;
|
|
$branch_id = $this->request->getPost('client_branch_id') ?? null;
|
|
$policy_id = $this->request->getPost('client_policy_id') ?? null;
|
|
|
|
$fileModel = new FileModel();
|
|
$filesData = $fileModel->where('is_active', 1)->where('action', 'api')->where('status', 'inprogress')->countAllResults();
|
|
|
|
if($filesData > 0){
|
|
log_message('error', "Already the TPA GetBenefDetails job inprocess");
|
|
return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA initiation is in progress.','data' => [] ]);
|
|
}
|
|
|
|
$data = [
|
|
'file_name' => "API",
|
|
'action' => "api",
|
|
'status' => "inprogress",
|
|
'client_id' => $client_id,
|
|
'policy_id' => $policy_id,
|
|
'client_branch_id'=> $branch_id,
|
|
];
|
|
|
|
if ($tpa_id == 2) // MediAssist
|
|
{
|
|
$file_id = $fileModel->insert($data);
|
|
log_message('error', "Files table inserted successfully, File id : {$file_id}");
|
|
// $mediAssistController = new MediAssistApiController();
|
|
// $mediAssistController->GetBenefDetails( [ 'polict_no' => $policy_no, 'file_id' =>$file_id ] );
|
|
$r = Jobs::addJob(['job_name' => 'GetBenefDetails', 'payload' => ['polict_no' => $policy_no, 'file_id' => $file_id]]);
|
|
log_message('error', "GetBenefDetails job pushed successfully.");
|
|
|
|
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Action Triggered','data' => [] ]);
|
|
|
|
}else{
|
|
return $this->respond(['status' => false, 'code' => 200,'message' => 'TPA not found ','data' => [] ]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get Claims
|
|
public function getClaims($id)
|
|
{
|
|
if ($id == 1) {
|
|
$controller = new VidalApiController();
|
|
} elseif ($id == 2) {
|
|
$controller = new ICICILombardController();
|
|
} elseif ($id == 3) {
|
|
$controller = new MediAssistApiController();
|
|
}
|
|
}
|
|
|
|
// Get UHID
|
|
public function getUhid($id)
|
|
{
|
|
if ($id == 1) {
|
|
$controller = new VidalApiController();
|
|
} elseif ($id == 2) {
|
|
$controller = new ICICILombardController();
|
|
} elseif ($id == 3) {
|
|
$controller = new MediAssistApiController();
|
|
}
|
|
}
|
|
|
|
// Push Enrollment
|
|
public function pushEnrollment($id)
|
|
{
|
|
if ($id == 1) {
|
|
$controller = new VidalApiController();
|
|
} elseif ($id == 2) {
|
|
$controller = new ICICILombardController();
|
|
} elseif ($id == 3) {
|
|
$controller = new MediAssistApiController();
|
|
}
|
|
}
|
|
|
|
// Get Hospital Network
|
|
public function getHospitalNetwork($id)
|
|
{
|
|
if ($id == 1) {
|
|
$controller = new VidalApiController();
|
|
} elseif ($id == 2) {
|
|
$controller = new ICICILombardController();
|
|
} elseif ($id == 3) {
|
|
$controller = new MediAssistApiController();
|
|
}
|
|
}
|
|
}
|