Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
3cb3cd8264
@ -314,19 +314,20 @@ class ApiServiceController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getSSORedirectUrl($email = 'user@example.com')
|
function getSSORedirectUrl($email = 'user@example.com')
|
||||||
{
|
{
|
||||||
|
log_message('info', "SSO: Starting authentication for email: $email");
|
||||||
|
|
||||||
// ---------- CONFIG ----------
|
// ---------- CONFIG ----------
|
||||||
$authUrl = env('VIDAL_WELLNESS_BASE_URL'); // Authentication API URL
|
$authUrl = env('VIDAL_WELLNESS_BASE_URL');
|
||||||
$subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
|
$subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
|
||||||
$apiVersion = "1";
|
$apiVersion = "1";
|
||||||
|
|
||||||
// Provided Base64 AES key
|
// Provided Base64 AES key
|
||||||
$base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
|
$base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
|
||||||
$key = base64_decode($base64Key);
|
$key = base64_decode($base64Key);
|
||||||
|
|
||||||
|
log_message('info', "SSO: Config loaded, Auth URL: $authUrl");
|
||||||
|
|
||||||
// ---------- STEP 1: Build plaintext payload ----------
|
// ---------- STEP 1: Build plaintext payload ----------
|
||||||
$plainPayload = json_encode([
|
$plainPayload = json_encode([
|
||||||
@ -340,6 +341,8 @@ class ApiServiceController extends BaseController
|
|||||||
$encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
|
$encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
|
||||||
|
|
||||||
$encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
|
$encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
|
||||||
|
|
||||||
|
log_message('info', "SSO: Payload encrypted successfully");
|
||||||
|
|
||||||
// ---------- STEP 3: Call Authentication API ----------
|
// ---------- STEP 3: Call Authentication API ----------
|
||||||
$requestBody = json_encode([
|
$requestBody = json_encode([
|
||||||
@ -362,38 +365,168 @@ class ApiServiceController extends BaseController
|
|||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
$apiResponse = curl_exec($ch);
|
$apiResponse = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$curlError = curl_error($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
log_message('info', "SSO: API response received, HTTP Code: $httpCode");
|
||||||
|
|
||||||
|
// Check for cURL errors
|
||||||
|
if ($curlError) {
|
||||||
|
log_message('error', "SSO: cURL error - $curlError");
|
||||||
|
return ["error" => "cURL error: $curlError"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check HTTP status
|
||||||
|
if ($httpCode !== 200) {
|
||||||
|
log_message('error', "SSO: HTTP error - Code: $httpCode, Response: $apiResponse");
|
||||||
|
return ["error" => "HTTP error: $httpCode", "response" => $apiResponse];
|
||||||
|
}
|
||||||
|
|
||||||
$jsonResponse = json_decode($apiResponse, true);
|
$jsonResponse = json_decode($apiResponse, true);
|
||||||
|
|
||||||
dd($jsonResponse);
|
// Check JSON decode error
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
if (!isset($jsonResponse["data"])) {
|
log_message('error', "SSO: JSON decode error - " . json_last_error_msg());
|
||||||
return ["error" => "Invalid API response", "response" => $apiResponse];
|
return ["error" => "JSON decode error: " . json_last_error_msg(), "response" => $apiResponse];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check API response status
|
||||||
|
if (!isset($jsonResponse["status"]) || $jsonResponse["status"] !== "success") {
|
||||||
|
log_message('error', "SSO: API error - " . json_encode($jsonResponse));
|
||||||
|
return ["error" => "API error", "response" => $jsonResponse];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($jsonResponse["data"])) {
|
||||||
|
log_message('error', "SSO: Missing data field in response");
|
||||||
|
return ["error" => "Invalid API response - missing data field", "response" => $jsonResponse];
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('info', "SSO: API response validated successfully");
|
||||||
|
|
||||||
// ---------- STEP 4: Decrypt response ----------
|
// ---------- STEP 4: Decrypt response ----------
|
||||||
list($ivBase64, $cipherBase64) = explode(":", $jsonResponse["data"]);
|
log_message('info', "SSO: Starting response decryption");
|
||||||
|
|
||||||
|
$dataParts = explode(":", $jsonResponse["data"]);
|
||||||
|
|
||||||
|
if (count($dataParts) !== 2) {
|
||||||
|
log_message('error', "SSO: Invalid encrypted data format");
|
||||||
|
return ["error" => "Invalid encrypted data format", "data" => $jsonResponse["data"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
list($ivBase64, $cipherBase64) = $dataParts;
|
||||||
|
|
||||||
$respIv = base64_decode($ivBase64);
|
$respIv = base64_decode($ivBase64);
|
||||||
$respCipher = base64_decode($cipherBase64);
|
$respCipher = base64_decode($cipherBase64);
|
||||||
|
|
||||||
|
if ($respIv === false || $respCipher === false) {
|
||||||
|
log_message('error', "SSO: Base64 decode error");
|
||||||
|
return ["error" => "Base64 decode error"];
|
||||||
|
}
|
||||||
|
|
||||||
$decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
|
$decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
|
||||||
|
|
||||||
|
if ($decryptedJson === false) {
|
||||||
|
log_message('error', "SSO: Decryption failed");
|
||||||
|
return ["error" => "Decryption failed"];
|
||||||
|
}
|
||||||
|
|
||||||
$decryptedData = json_decode($decryptedJson, true);
|
$decryptedData = json_decode($decryptedJson, true);
|
||||||
|
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
|
log_message('error', "SSO: Decrypted JSON decode error - " . json_last_error_msg());
|
||||||
|
return ["error" => "Decrypted JSON decode error: " . json_last_error_msg()];
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($decryptedData["redirectUrl"])) {
|
if (!isset($decryptedData["redirectUrl"])) {
|
||||||
|
log_message('error', "SSO: redirectUrl missing in decrypted data");
|
||||||
return ["error" => "redirectUrl missing", "decrypted" => $decryptedData];
|
return ["error" => "redirectUrl missing", "decrypted" => $decryptedData];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- FINAL ----------
|
// ---------- FINAL ----------
|
||||||
|
log_message('info', "SSO: Authentication successful, redirectUrl obtained");
|
||||||
return $decryptedData["redirectUrl"];
|
return $decryptedData["redirectUrl"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// function getSSORedirectUrl($email = 'user@example.com')
|
||||||
|
// {
|
||||||
|
// // ---------- CONFIG ----------
|
||||||
|
// $authUrl = env('VIDAL_WELLNESS_BASE_URL'); // Authentication API URL
|
||||||
|
// $subscriptionKey = env('VIDAL_WELLNESS_SUBSCRIPTION_KEY');
|
||||||
|
// $apiVersion = "1";
|
||||||
|
|
||||||
|
// // Provided Base64 AES key
|
||||||
|
// $base64Key = env('VIDAL_WELLNESS_BASE64_KEY');
|
||||||
|
// $key = base64_decode($base64Key);
|
||||||
|
|
||||||
|
// // ---------- STEP 1: Build plaintext payload ----------
|
||||||
|
// $plainPayload = json_encode([
|
||||||
|
// "email" => $email,
|
||||||
|
// "corporateId" => env('VIDAL_WELLNESS_CORPORATE_ID'),
|
||||||
|
// "urlIdentifier" => env('VIDAL_WELLNESS_URL_IDENTIFIER')
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// // ---------- STEP 2: Encrypt payload ----------
|
||||||
|
// $iv = random_bytes(16);
|
||||||
|
// $encryptedRaw = openssl_encrypt($plainPayload, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $iv);
|
||||||
|
|
||||||
|
// $encryptedPayload = base64_encode($iv) . ":" . base64_encode($encryptedRaw);
|
||||||
|
|
||||||
|
// // ---------- STEP 3: Call Authentication API ----------
|
||||||
|
// $requestBody = json_encode([
|
||||||
|
// "payload" => $encryptedPayload,
|
||||||
|
// "source" => "portal",
|
||||||
|
// "subPartnerId" => env('VIDAL_WELLNESS_SUB_PARTNER_ID')
|
||||||
|
// ]);
|
||||||
|
|
||||||
|
// $headers = [
|
||||||
|
// "Ocp-Apim-Subscription-Key: $subscriptionKey",
|
||||||
|
// "apiver: $apiVersion",
|
||||||
|
// "mode: encrypt",
|
||||||
|
// "Content-Type: application/json"
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// $ch = curl_init($authUrl);
|
||||||
|
// curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
// curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
|
||||||
|
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
|
||||||
|
// $apiResponse = curl_exec($ch);
|
||||||
|
// curl_close($ch);
|
||||||
|
|
||||||
|
// $jsonResponse = json_decode($apiResponse, true);
|
||||||
|
|
||||||
|
// dd($jsonResponse);
|
||||||
|
|
||||||
|
// if (!isset($jsonResponse["data"])) {
|
||||||
|
// return ["error" => "Invalid API response", "response" => $apiResponse];
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // ---------- STEP 4: Decrypt response ----------
|
||||||
|
// list($ivBase64, $cipherBase64) = explode(":", $jsonResponse["data"]);
|
||||||
|
|
||||||
|
// $respIv = base64_decode($ivBase64);
|
||||||
|
// $respCipher = base64_decode($cipherBase64);
|
||||||
|
|
||||||
|
// $decryptedJson = openssl_decrypt($respCipher, "AES-256-CBC", $key, OPENSSL_RAW_DATA, $respIv);
|
||||||
|
|
||||||
|
// $decryptedData = json_decode($decryptedJson, true);
|
||||||
|
|
||||||
|
// if (!isset($decryptedData["redirectUrl"])) {
|
||||||
|
// return ["error" => "redirectUrl missing", "decrypted" => $decryptedData];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // ---------- FINAL ----------
|
||||||
|
// return $decryptedData["redirectUrl"];
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,15 +12,17 @@ use CodeIgniter\API\ResponseTrait;
|
|||||||
|
|
||||||
class MediAssistApiController extends BaseController
|
class MediAssistApiController extends BaseController
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
protected $db;
|
||||||
|
|
||||||
public function index()
|
public function __construct()
|
||||||
{
|
{
|
||||||
//
|
$this->db = \Config\Database::connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function SubmitClaim ($claimId = null){
|
public function SubmitClaim ($claimId = null)
|
||||||
|
{
|
||||||
|
|
||||||
helper('api');
|
helper('api');
|
||||||
|
|
||||||
@ -35,9 +37,9 @@ class MediAssistApiController extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
//Prepare body data
|
//Prepare body data
|
||||||
$db = \Config\Database::connect();
|
|
||||||
// Fetch the data from DB
|
// Fetch the data from DB
|
||||||
$data = $db->table('ticket_master tm')
|
$data = $this->db->table('ticket_master tm')
|
||||||
->select('
|
->select('
|
||||||
tm.id,
|
tm.id,
|
||||||
tm.emp_mobile as mobileNo,
|
tm.emp_mobile as mobileNo,
|
||||||
@ -141,7 +143,7 @@ class MediAssistApiController extends BaseController
|
|||||||
|
|
||||||
log_message('error', 'TPA CLAIM PUSH SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef);
|
log_message('error', 'TPA CLAIM PUSH SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef);
|
||||||
|
|
||||||
$db->table('ticket_master')
|
$this->db->table('ticket_master')
|
||||||
->where('id',$claimId)
|
->where('id',$claimId)
|
||||||
->update([ 'tpa_claim_push_reference_no' => $claimRef ]);
|
->update([ 'tpa_claim_push_reference_no' => $claimRef ]);
|
||||||
|
|
||||||
@ -154,7 +156,8 @@ class MediAssistApiController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function EcardRequest ($employeeId = null, $policyNo = null){
|
public function EcardRequest ($employeeId = null, $policyNo = null)
|
||||||
|
{
|
||||||
|
|
||||||
helper('api');
|
helper('api');
|
||||||
|
|
||||||
@ -198,7 +201,6 @@ class MediAssistApiController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function GetBenefDetails($requestData)
|
public function GetBenefDetails($requestData)
|
||||||
{
|
{
|
||||||
helper('api');
|
helper('api');
|
||||||
@ -326,33 +328,13 @@ class MediAssistApiController extends BaseController
|
|||||||
} while ($startIndex < $totalCount);
|
} while ($startIndex < $totalCount);
|
||||||
|
|
||||||
// now update DB
|
// now update DB
|
||||||
$db = \Config\Database::connect();
|
|
||||||
$updated = 0;
|
$updated = 0;
|
||||||
|
|
||||||
$employee_policy_ids = [];
|
$employee_policy_ids = [];
|
||||||
foreach ($employeePolicyData as $policy_data) {
|
foreach ($employeePolicyData as $policy_data) {
|
||||||
foreach ($allBenef as $row) {
|
|
||||||
|
|
||||||
// log_message(
|
$hasMatchForThisPolicy = false;
|
||||||
// "error",
|
|
||||||
// "POLICY MATCH CHECK: " . json_encode([
|
foreach ($allBenef as $row) {
|
||||||
// 'policy_data' => [
|
|
||||||
// 'name' => $policy_data['name'] ?? null,
|
|
||||||
// 'emp_code' => $policy_data['emp_code'] ?? null,
|
|
||||||
// 'relationship' => $policy_data['relationship'] ?? null,
|
|
||||||
// 'gender' => $policy_data['gender'] ?? null,
|
|
||||||
// 'dob' => $policy_data['dob'] ?? null,
|
|
||||||
// ],
|
|
||||||
// 'row_data' => [
|
|
||||||
// 'benefName' => $row['benefName'] ?? null,
|
|
||||||
// 'priBenefEmpCode' => $row['priBenefEmpCode'] ?? null,
|
|
||||||
// 'relName' => $row['relName'] ?? null,
|
|
||||||
// 'benefSex' => $row['benefSex'] ?? null,
|
|
||||||
// 'benefDOB' => $row['benefDOB'] ?? null,
|
|
||||||
// 'benefDOB_fmt' => change_date_format($row['benefDOB'],'d/m/Y H:i:s') ?? null,
|
|
||||||
// ],
|
|
||||||
// ])
|
|
||||||
// );
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
strtolower(trim($policy_data['name'] ?? '')) == strtolower(trim($row['benefName'] ?? '')) &&
|
strtolower(trim($policy_data['name'] ?? '')) == strtolower(trim($row['benefName'] ?? '')) &&
|
||||||
@ -361,32 +343,53 @@ class MediAssistApiController extends BaseController
|
|||||||
($policy_data['gender'] ?? '') == ($row['benefSex'] ?? '') &&
|
($policy_data['gender'] ?? '') == ($row['benefSex'] ?? '') &&
|
||||||
($policy_data['dob'] ?? '') == (change_date_format($row['benefDOB'], 'd/m/Y H:i:s') ?? '')
|
($policy_data['dob'] ?? '') == (change_date_format($row['benefDOB'], 'd/m/Y H:i:s') ?? '')
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
$hasMatchForThisPolicy = true;
|
||||||
|
|
||||||
log_message('error', "✅ Match found: emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
// log_message('error', "✅ Match found: emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
||||||
|
|
||||||
$sql = "UPDATE employee_polices
|
$sql = "UPDATE employee_polices
|
||||||
SET tpa_id = ?
|
SET tpa_id = ?
|
||||||
WHERE id = ?";
|
WHERE id = ?";
|
||||||
$db->query($sql, [$row['benefMediAssistID'], $policy_data['emp_policy_id']]);
|
$this->db->query($sql, [$row['benefMediAssistID'], $policy_data['emp_policy_id']]);
|
||||||
|
|
||||||
// for e-card send
|
// for e-card send
|
||||||
if(strtolower(trim($policy_data['relationship'])) == 'self'){
|
if(strtolower(trim($policy_data['relationship'])) == 'self'){
|
||||||
$employee_policy_ids[] = $policy_data['emp_policy_id'];
|
$employee_policy_ids[] = $policy_data['emp_policy_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($db->affectedRows() > 0) {
|
if ($this->db->affectedRows() > 0) {
|
||||||
$updated++;
|
$updated++;
|
||||||
log_message('error', "✅ Updated tpa_id={$row['benefMediAssistID']} for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
log_message('error', "✅ Updated tpa_id={$row['benefMediAssistID']} for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
||||||
} else {
|
} else {
|
||||||
log_message('error', "⚠️ No update (already set or not matched) for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
log_message('error', "⚠️ No update (already set or not matched) for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
|
||||||
log_message('error', "❌ Not matched: emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle NO MATCH for this policy
|
||||||
|
if (!$hasMatchForThisPolicy) {
|
||||||
|
|
||||||
|
$nhanceSideData = [
|
||||||
|
'name' => $policy_data['name'] ?? null,
|
||||||
|
'emp_code' => $policy_data['emp_code'] ?? null,
|
||||||
|
'relationship' => $policy_data['relationship'] ?? null,
|
||||||
|
'gender' => $policy_data['gender'] ?? null,
|
||||||
|
'dob' => $policy_data['dob'] ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
|
log_message(
|
||||||
|
'error',
|
||||||
|
"❌ No match for Nhance = " . json_encode($nhanceSideData)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// send e-card
|
// send e-card
|
||||||
if(!empty($employee_policy_ids)){
|
if(!empty($employee_policy_ids)){
|
||||||
log_message('error', "sendMailForDownloadingECard JOB PUSHED.");
|
log_message('error', "sendMailForDownloadingECard JOB PUSHED.");
|
||||||
@ -452,14 +455,138 @@ class MediAssistApiController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ClaimDetail($claimId = 585)
|
||||||
|
{
|
||||||
|
helper('api');
|
||||||
|
|
||||||
// public function GetBenefDetails (){
|
$url = getenv('MEDI_ASSIST_API_BASE_URL_CLAIMSTATUS');
|
||||||
|
$method = 'POST';
|
||||||
|
|
||||||
|
$headers = [
|
||||||
|
'Content-Type: application/json',
|
||||||
|
'Username:' . getenv('MEDI_ASSIST_API_USERNAME'),
|
||||||
|
'Password:' . getenv('MEDI_ASSIST_API_PASSWORD'),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Fetch ticket master details
|
||||||
|
$ticket = $this->db->table('ticket_master tm')
|
||||||
|
->select("
|
||||||
|
tm.id,
|
||||||
|
tm.tpa_no as memberId,
|
||||||
|
tm.tpa_claim_push_reference_no as claimRefNo,
|
||||||
|
cp.policy_no as policyNo,
|
||||||
|
cp.policy_start_date as startDate,
|
||||||
|
cp.policy_end_date as endDate,
|
||||||
|
e.emp_code as employeeCode
|
||||||
|
")
|
||||||
|
->join('employees e', 'e.id = tm.emp_id', 'left')
|
||||||
|
->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
|
||||||
|
->where('tm.id', $claimId)
|
||||||
|
->get()
|
||||||
|
->getRowArray();
|
||||||
|
|
||||||
|
if (!$ticket) {
|
||||||
|
return $this->response->setJSON(['status' => false,'message' => 'Invalid Claim ID' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// REQUEST BODY
|
||||||
|
$body = [
|
||||||
|
"policyNo" => $ticket['policyNo'] ?? "",
|
||||||
|
"startDate" => $ticket['startDate'] ?? "",
|
||||||
|
"endDate" => $ticket['endDate'] ?? "",
|
||||||
|
"employeeCode" => $ticket['employeeCode'] ?? "",
|
||||||
|
"memberID" => $ticket['memberId'] ?? "",
|
||||||
|
"claimNo" => "",
|
||||||
|
"claimRefNo" => $ticket['claimRefNo'] ?? "",
|
||||||
|
];
|
||||||
|
|
||||||
|
// dd($body);
|
||||||
|
|
||||||
|
// $body = [
|
||||||
|
// "policyNo" => "97000063250400000031",
|
||||||
|
// "startDate" => "",
|
||||||
|
// "endDate" => "",
|
||||||
|
// "employeeCode" => "CITPL120193",
|
||||||
|
// "memberID" => "",
|
||||||
|
// "claimNo" => "",
|
||||||
|
// "claimRefNo" => "HOSP4078102577_16092025111030"
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// CALL API
|
||||||
|
$response = call_third_party_api($url, $method, $headers, $body);
|
||||||
|
|
||||||
|
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
|
||||||
|
log_message('error', 'Claim status API failed for ticket ID: ' . $claimId);
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'message' => 'API call failed.',
|
||||||
|
'data' => $response
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract claim status
|
||||||
|
$claimData = $response['data']['claimsData'][0];
|
||||||
|
$currentStatus = $claimData['claim_Current_Status'] ?? '';
|
||||||
|
|
||||||
|
// VALID STATUS LIST
|
||||||
|
$validStatuses = [
|
||||||
|
"Claim Received",
|
||||||
|
"In Progress",
|
||||||
|
"Processed",
|
||||||
|
"Claim Paid",
|
||||||
|
"Denied",
|
||||||
|
"Cancelled",
|
||||||
|
"Information Awaited",
|
||||||
|
"Confirmation Awaited",
|
||||||
|
"Information Awaited Reminder",
|
||||||
|
"Information Awaited Final Reminder",
|
||||||
|
"Insurer Concurrence Awaited",
|
||||||
|
"Closed",
|
||||||
|
"Physical Documents Awaited",
|
||||||
|
"Processed - Payment Initiated",
|
||||||
|
"Processed - Transaction Failed",
|
||||||
|
"Processed - Account Details Updated",
|
||||||
|
"Processed - Debit Note Raised With Insurer for Payment",
|
||||||
|
"Processed - Payment Initiated by Insurer",
|
||||||
|
"Payment - Refunded to Insurer",
|
||||||
|
"Processed - Processing Payment",
|
||||||
|
"Processed - Physical Documents Awaited",
|
||||||
|
];
|
||||||
|
|
||||||
|
// Validate Status
|
||||||
|
if (!in_array($currentStatus, $validStatuses)) {
|
||||||
|
log_message('error', "Invalid claim status received: $currentStatus for ticket ID: $claimId");
|
||||||
|
$currentStatus = "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
// UPDATE ticket_master
|
||||||
|
$this->db->table('ticket_master')
|
||||||
|
->where('id', $claimId)
|
||||||
|
->update([
|
||||||
|
'tpa_claim_status' => $currentStatus,
|
||||||
|
'updated_at' => date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
|
||||||
|
// LOG UPDATE
|
||||||
|
log_message('info', "Updated ticket ID $claimId with claim status: $currentStatus");
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => true,
|
||||||
|
'message' => 'Claim status updated.',
|
||||||
|
'updated_status' => $currentStatus,
|
||||||
|
'api_response' => $response
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public function ClaimDetail2 ($claimId = null)
|
||||||
|
// {
|
||||||
|
|
||||||
// $postData = $this->request->getJSON(true);
|
|
||||||
|
|
||||||
// helper('api');
|
// helper('api');
|
||||||
|
|
||||||
// $url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/GetBenefDetails';
|
// $url = getenv('MEDI_ASSIST_API_BASE_URL_CLAIMSTATUS');
|
||||||
// $method = 'POST';
|
// $method = 'POST';
|
||||||
|
|
||||||
// $headers = [
|
// $headers = [
|
||||||
@ -468,25 +595,33 @@ class MediAssistApiController extends BaseController
|
|||||||
// 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD').'',
|
// 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD').'',
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// $body = [
|
// // Fetch the data from DB
|
||||||
// "policyNo" => $$postData['policy_no'],
|
// $data = $this->db->table('ticket_master tm')
|
||||||
// "startDate" => "",
|
// ->select('
|
||||||
// "endDate" => "",
|
// tm.id,
|
||||||
// "isDeActivedata" => false,
|
// tm.tpa_no as memberId,
|
||||||
// "startIndex" => 0,
|
// tm.tpa_claim_push_reference_no as claimRefNo,
|
||||||
// "range" => 100 ,
|
// cp.policy_no as policyNo,
|
||||||
// "employeeId" => ""
|
// cp.policy_start_date as startDate,
|
||||||
// ];
|
// cp.policy_end_date as endDate,
|
||||||
|
// e.id as empId,
|
||||||
|
// e.emp_code as employeeCode,
|
||||||
|
// ')
|
||||||
|
// ->join('employees e', 'e.id = tm.emp_id', 'left')
|
||||||
|
// ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left')
|
||||||
|
// ->where('tm.id', $claimId)
|
||||||
|
// ->get()
|
||||||
|
// ->getRowArray(); // single record
|
||||||
|
|
||||||
// // $body = [
|
// $body = [
|
||||||
// // "policyNo" => "97000063250400000031",
|
// "policyNo" => "97000063250400000031",
|
||||||
// // "startDate" => "",
|
// "startDate" => "",
|
||||||
// // "endDate" => "",
|
// "endDate" => "",
|
||||||
// // "isDeActivedata" => false,
|
// "employeeCode" => "CITPL120193",
|
||||||
// // "startIndex" => 0,
|
// "memberID" => "",
|
||||||
// // "range" => 100 ,
|
// "claimNo" => "",
|
||||||
// // "employeeId" => ""
|
// "claimRefNo" => "HOSP4078102577_16092025111030"
|
||||||
// // ];
|
// ];
|
||||||
|
|
||||||
// $response = call_third_party_api($url, $method, $headers, $body);
|
// $response = call_third_party_api($url, $method, $headers, $body);
|
||||||
|
|
||||||
@ -499,32 +634,58 @@ class MediAssistApiController extends BaseController
|
|||||||
// ]);
|
// ]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// $claimStatuses = [
|
||||||
|
// "Claim Received",
|
||||||
|
// "In Progress",
|
||||||
|
// "Processed",
|
||||||
|
// "Claim Paid",
|
||||||
|
// "Denied",
|
||||||
|
// "Cancelled",
|
||||||
|
// "Information Awaited",
|
||||||
|
// "Confirmation Awaited",
|
||||||
|
// "Information Awaited Reminder",
|
||||||
|
// "Information Awaited Final Reminder",
|
||||||
|
// "Insurer Concurrence Awaited",
|
||||||
|
// "Closed",
|
||||||
|
// "Physical Documents Awaited",
|
||||||
|
// "Processed - Payment Initiated",
|
||||||
|
// "Processed - Transaction Failed",
|
||||||
|
// "Processed - Account Details Updated",
|
||||||
|
// "Processed - Debit Note Raised With Insurer for Payment",
|
||||||
|
// "Processed - Payment Initiated by Insurer",
|
||||||
|
// "Payment - Refunded to Insurer",
|
||||||
|
// "Processed - Processing Payment",
|
||||||
|
// "Processed - Physical Documents Awaited",
|
||||||
|
// ];
|
||||||
|
|
||||||
|
|
||||||
// return $this->response->setJSON($response);
|
// return $this->response->setJSON($response);
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function ClaimDetail (){
|
public function IRSubmission ($claimId = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$postData = $this->request->getJSON(true);
|
||||||
|
|
||||||
helper('api');
|
helper('api');
|
||||||
|
|
||||||
$url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/ClaimDetail';
|
// $url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/ClaimAPIServiceUAT/Claim/IRSubmission';
|
||||||
|
$url = "https://apiintegration.mediassist.in/ClaimAPIServiceUAT/Claim/IRSubmission";
|
||||||
$method = 'POST';
|
$method = 'POST';
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
'Username:'. getenv('MEDI_ASSIST_API_USERNAME').'',
|
'Username:' .'NhanceUsr',
|
||||||
'Password:'. getenv('MEDI_ASSIST_API_PASSWORD').'',
|
'Password:' .'NhU$p&Cc5wGQbr2',
|
||||||
];
|
];
|
||||||
|
|
||||||
$body = [
|
$body = [
|
||||||
"policyNo" => "97000063250400000031",
|
"ClaimID" => "134431104",
|
||||||
"startDate" => "",
|
"Attachments" => [
|
||||||
"endDate" => "",
|
"AttachmentName" => "Test.pdf",
|
||||||
"employeeCode" => "CITPL120193",
|
"AttachmentPath" => "https://apiintegration.mediassist.in/IntegrationEcard/DownloadEcard/4078613742/Senthil Kumar P/556/5386"
|
||||||
"memberID" => "",
|
]
|
||||||
"claimNo" => "",
|
|
||||||
"claimRefNo" => ""
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = call_third_party_api($url, $method, $headers, $body);
|
$response = call_third_party_api($url, $method, $headers, $body);
|
||||||
@ -547,6 +708,35 @@ class MediAssistApiController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function HospitalNetwork (){
|
public function HospitalNetwork (){
|
||||||
|
|
||||||
$postData = $this->request->getJSON(true);
|
$postData = $this->request->getJSON(true);
|
||||||
@ -627,44 +817,7 @@ class MediAssistApiController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function IRSubmission (){
|
|
||||||
|
|
||||||
$postData = $this->request->getJSON(true);
|
|
||||||
|
|
||||||
helper('api');
|
|
||||||
|
|
||||||
// $url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/ClaimAPIServiceUAT/Claim/IRSubmission';
|
|
||||||
$url = "https://apiintegration.mediassist.in/ClaimAPIServiceUAT/Claim/IRSubmission";
|
|
||||||
$method = 'POST';
|
|
||||||
|
|
||||||
$headers = [
|
|
||||||
'Content-Type: application/json',
|
|
||||||
'Username:' .'NhanceUsr',
|
|
||||||
'Password:' .'NhU$p&Cc5wGQbr2',
|
|
||||||
];
|
|
||||||
|
|
||||||
$body = [
|
|
||||||
"ClaimID" => "134431104",
|
|
||||||
"Attachments" => [
|
|
||||||
"AttachmentName" => "Test.pdf",
|
|
||||||
"AttachmentPath" => "https://apiintegration.mediassist.in/IntegrationEcard/DownloadEcard/4078613742/Senthil Kumar P/556/5386"
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = call_third_party_api($url, $method, $headers, $body);
|
|
||||||
|
|
||||||
|
|
||||||
if($response['status'] != true){
|
|
||||||
return $this->response->setJSON([
|
|
||||||
'status' => false,
|
|
||||||
'message' => 'failed.',
|
|
||||||
'data' => $response
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response->setJSON($response);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function fileDownload()
|
public function fileDownload()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user