From ddb59320e32355f4b7542eb6bf207323eaa80a7e Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 5 Nov 2025 11:57:18 +0530 Subject: [PATCH] GWM : Medi assist api integration --- app/Config/Routes.php | 29 +- app/Controllers/ApiServiceController.php | 203 ++++++++ app/Controllers/EmployeeRestController.php | 58 ++- app/Controllers/ICICILombardController.php | 34 +- app/Controllers/MediAssistApiController.php | 538 ++++++++++++++++++++ app/Helpers/api_helper.php | 2 + 6 files changed, 842 insertions(+), 22 deletions(-) create mode 100644 app/Controllers/ApiServiceController.php create mode 100644 app/Controllers/MediAssistApiController.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 31453be4..06f81344 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -529,6 +529,8 @@ $routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationCont $routes->get("employeeRest/getClientDetails", "EmployeeRestController::getClientDetails"); + + $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity"); @@ -567,6 +569,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) { $routes->get("getFEContent", "EmployeeRestController::getFEContent"); $routes->get("getAdvertisementImage", "EmployeeRestController::getAdvertisementImage"); $routes->get("getWellnessURL", "EmployeeRestController::getWellnessURL"); + $routes->get("getEcardURL", "EmployeeRestController::getEcardURL"); //$routes->post('postDataForTicket',"EmployeeRestController::postDataForTicket"); @@ -675,9 +678,6 @@ $routes->get('createEnrollmentBatch','ICICILombardController::createEnrollmentBa $routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBatchStatus'); $routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails'); -$routes->get('testTracelog','TestBusinessController::a'); -$routes->get("claimView", "EmployeeRestController::claimView"); - //Third party Vidal Api Call $routes->post('hospitalNetwork','VidalApiController::hospitalNetwork'); @@ -686,6 +686,29 @@ $routes->post('claimStatusCheck','VidalApiController::claimStatusCheck'); $routes->post('newClaim','VidalApiController::newClaim'); $routes->post('enrollment','VidalApiController::enrollment'); +//Third party MediAssist Api Call + +$routes->get('EcardRequest','MediAssistApiController::EcardRequest'); +$routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork'); +$routes->get('GetBenefDetails','MediAssistApiController::GetBenefDetails'); +$routes->get('ClaimDetail','MediAssistApiController::ClaimDetail'); +$routes->get('SubmitClaim','MediAssistApiController::SubmitClaim'); +$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim'); +$routes->get('IRSubmission','MediAssistApiController::IRSubmission'); + + +// API service +$routes->post("ecardRequest", "ApiServiceController::ecardRequest"); +$routes->post("getTPAID", "ApiServiceController::getTPAID"); +$routes->get('fileDownload','MediAssistApiController::fileDownload'); + + + + + +$routes->get('testTracelog','TestBusinessController::a'); +$routes->get("claimView", "EmployeeRestController::claimView"); + // General Tickets $routes->post("ticketSave", "ThzController::ticketSave"); diff --git a/app/Controllers/ApiServiceController.php b/app/Controllers/ApiServiceController.php new file mode 100644 index 00000000..6fb81863 --- /dev/null +++ b/app/Controllers/ApiServiceController.php @@ -0,0 +1,203 @@ +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{ + + $id = $this->request->getPost('id'); + $emp_code = $this->request->getPost('emp_code'); + $client_policy_id = $this->request->getPost('client_policy_id'); + $policy_no = $this->request->getPost('policy_no'); + + $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'; + } + + } else { + $data['eCardDownload'] = null; + } + }else{ + $data['eCardDownload'] = null; + } + + + return $this->respond(['status' => true,'message' => '','data' => $data]); + + } catch(\Exception $e){ + + } + } + + // Get TPAID + public function getTPAID() + { + + $tpa_id = $this->request->getPost('tpa_id'); + $policy_no = $this->request->getPost('policy_no'); + + if ($tpa_id == 2) // MediAssist + { + + $mediAssistController = new MediAssistApiController(); + $mediAssistController->GetBenefDetails( [ 'polict_no' => $policy_no ] ); + + return $this->respond(['status' => true,'message' => 'Action Triggered','data' => [] ]); + + }else{ + return $this->respond(['status' => true,'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(); + } + } +} diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 1b7310b6..ff7bfdf7 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -12,6 +12,10 @@ use Psr\Log\LoggerInterface; use App\Helpers\sendMailNotification; +use App\Controllers\VidalApiController; +use App\Controllers\ICICILombardController; +use App\Controllers\MediAssistApiController; + use App\Models\EmployeeModel; use App\Models\EmployeePolicyModel; @@ -3862,8 +3866,11 @@ class EmployeeRestController extends AdminController $userParams['employeeId'] = $row['employeeId']; $userParams['policyStartDate']= $row['policyStartDate']; $userParams['policyEndDate'] = $row['policyEndDate']; - $userParams['policyName'] = 'Nhance ' . $row['policy_type']; - $userParams['planId'] = 'NHANCE-PLAN-' . $row['policy_type']; + // $userParams['policyName'] = 'Nhance ' . $row['policy_type']; + // $userParams['planId'] = 'NHANCE-PLAN-' . $row['policy_type']; + $userParams['policyName'] = $row['policy_type']; + $userParams['planId'] = env('VISIT_PLAN_ID'); + $userParams['moduleName'] = 'home'; break; // stop after first GMC match } @@ -4398,4 +4405,51 @@ class EmployeeRestController extends AdminController } } + + public function getEcardURL() + { + try{ + + $id = $this->request->getGet('id'); + $emp_code = $this->request->getGet('emp_code'); + $client_policy_id = $this->request->getGet('client_policy_id'); + $policy_no = $this->request->getGet('policy_no'); + + $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'; + } + + } else { + $data['eCardDownload'] = null; + } + }else{ + $data['eCardDownload'] = null; + } + + + return $this->respond(['status' => true,'message' => '','data' => $data]); + + } catch(\Exception $e){ + + } + } + } \ No newline at end of file diff --git a/app/Controllers/ICICILombardController.php b/app/Controllers/ICICILombardController.php index 5c5bc627..a91cc147 100644 --- a/app/Controllers/ICICILombardController.php +++ b/app/Controllers/ICICILombardController.php @@ -87,32 +87,32 @@ class ICICILombardController extends AdminController $body = [ - "PolicyNumber" => "4016/A/O/53130557/00/000", + "PolicyNumber" => "4016/PPN/A/O/53167743/00/000", "CDBGAccountNumber" => "CD-MUM-0026", - "CorrelationId" => "550e8400-e29b-41d4-a716-446655440010", + "CorrelationId" => "550e8400-e29b-41d4-a716-446655440012", "MemberDetails" => [ [ - "MemberEmpId" => "EMPID3625557", + "MemberEmpId" => "EMPID3625559", "DOJ" => "21-MAR-2019", - "InsuredName" => "Kumar", - "DOB" => "7-JUL-1983", + "InsuredName" => "Gowtham", + "DOB" => "7-JUL-1993", "Relationship" => "SELF", "Gender" => "MALE", - "DOC" => "05-SEP-2025", + "DOC" => '2025-10-27', "SumInsured" => "400000", - "EmailId" => "KUMAR@GMAIL.COM", + "EmailId" => "Gowtham@GMAIL.COM", "FlagStatus" => "A" ], [ - "MemberEmpId" => "EMPID3625557", + "MemberEmpId" => "EMPID3625559", "DOJ" => "21-MAR-2019", - "InsuredName" => "Saranya", + "InsuredName" => "Lavanya", "DOB" => "8-AUG-1970", "Relationship" => "MOTHER", "Gender" => "FEMALE", - "DOC" => "05-SEP-2025", + "DOC" => '2025-10-27', "SumInsured" => "400000", - "EmailId" => "Saranya@GMAIL.COM", + "EmailId" => "Lavanya@GMAIL.COM", "FlagStatus" => "A" ], ] @@ -148,9 +148,9 @@ class ICICILombardController extends AdminController // dd($headers); $body = [ - "PolicyNumber" => "4016/A/O/53130557/00/000", - "BatchId" => "3658147", - "CorrelationId" => "550e8400-e29b-41d4-a716-446655440010" + "PolicyNumber" => "4016/PPN/A/O/53167743/00/000", + "BatchId" => "3672146", + "CorrelationId" => "550e8400-e29b-41d4-a716-446655440012" ]; $response = call_third_party_api($url, 'POST', $headers, $body, true); @@ -182,9 +182,9 @@ class ICICILombardController extends AdminController ]; $body = [ - "PolicyNumber" => "4016/A/51974976/00/000", - "IMID" => "2345617878", - "CorrelationId" => "86383c78-4c67-4e4d-9aa0-9f926fb0d55e" + "PolicyNumber" => "4016/PPN/A/O/53167743/00/000", + "IMID" => "3672145", + "CorrelationId" => "550e8400-e29b-41d4-a716-446655440011" ]; $response = call_third_party_api($url, 'POST', $headers, $body, true); diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php new file mode 100644 index 00000000..4eeeebae --- /dev/null +++ b/app/Controllers/MediAssistApiController.php @@ -0,0 +1,538 @@ +table('ticket_master tm') + ->select(' + tm.id, + tm.emp_mobile as mobileNo, + tm.emp_mail as emailId, + tm.doa as claimDateOfAdmission, + tm.dod as claimDateOfDischarge, + tm.hospital_name as hospName, + tm.claim_amount as claimAmount, + cp.policy_no as policyNo, + e.id as empId, + e.emp_code as memberId, + tn.note as disease, + tn.note as reasonForHospitalization, + cf.doc_name as fileName, + cf.url as filePath + ') + ->join('employees e', 'e.id = tm.emp_id', 'left') + ->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left') + ->join('ticket_notes tn', 'tn.ticket_id = tm.id', 'left') + ->join('claim_files cf', 'cf.ticket_id = tm.id AND cf.file_type = 2', 'left') + ->where('tm.id', $claimId) + ->get() + ->getRowArray(); // single record + + + // Map DB result to request body + if ($data) { + + $filePath = $data['filePath'] ?? ''; + + $filename = basename($filePath); + + $fileDir = WRITEPATH . 'uploads/claim_files/'.$filename; + + + if ($fileDir) { + $downloadUrl = base_url('fileDownload?file_path=').$fileDir; + } else { + $downloadUrl = ''; + } + + $body = [ + "policyNo" => $data['policyNo'] ?? "", + "memberId" => $data['empId'] ?? "", + "mobileNo" => $data['mobileNo'] ?? "", + "emailId" => $data['emailId'] ?? "", + "claimDateOfAdmission" => $data['claimDateOfAdmission'] ?? "", + "claimDateOfDischarge" => $data['claimDateOfDischarge'] ?? "", + "hospName" => $data['hospName'] ?? "", + "hospAddress" => $data['hospName'] ?? "", // If hospAddress not available, reuse hospName + "reasonForHospitalization" => $data['reasonForHospitalization'] ?? "", + "disease" => $data['disease'] ?? "", + "claimAmount" => (float)($data['claimAmount'] ?? 0), + "claimType" => "HOSPITALIZATION", // static value + "claimSubmissionAttachments" => [ + "fileName" => $data['fileName'] ?? "", + "filePath" => $downloadUrl ?? "" + ] + ]; + } else { + $body = []; + } + + // dd($body); + + // $body = [ + // "policyNo" => "570000/48/2025/286", + // "memberId" => 4078919887, + // "mobileNo" => "95000XXXXX", + // "emailId" => "test@Medi.com", + // "claimDateOfAdmission" => "2023-12-14", + // "claimDateOfDischarge" => "2023-12-16", + // "hospName" => "TestHosp", + // "hospAddress" => "Testhosp", + // "reasonForHospitalization" => "test", + // "disease" => "testkediney", + // "claimAmount" => 10, + // "claimType" => "HOSPITALIZATION", + // "claimSubmissionAttachments" => [ + // "fileName" => "Test.pdf", + // "filePath" => "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){ + + log_message('error', 'TPA CLAIM PUSH FAILED | claimId: '.$claimId.' | response: '.json_encode($response)); + return; + } + + // return $this->response->setJSON($response); + + $claimRef = $response['data']['claimReferenceNo'] ?? null; + + if(!empty($claimRef)){ + + log_message('error', 'TPA CLAIM PUSH SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef); + + $db->table('ticket_master') + ->where('id',$claimId) + ->update([ 'tpa_claim_push_reference_no' => $claimRef ]); + + return; + + } else { + log_message('error', 'TPA CLAIM PUSH SUCCESS BUT claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response)); + return; + } + + } + + public function EcardRequest ($employeeId = null, $policyNo = null){ + + helper('api'); + + $url = ''. getenv('MEDI_ASSIST_API_BASE_URL_LIVE').'/EcardUrl'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Username:'. getenv('MEDI_ASSIST_API_USERNAME_LIVE').'', + 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD_LIVE').'', + ]; + + $body = [ + "employeeId" => $employeeId, + "policyNo" => $policyNo + ]; + + // $body = [ + // "employeeId" => "CITPL120006", + // "policyNo" => "97000063250400000031" + // ]; + + $response = call_third_party_api($url, $method, $headers, $body); + + if($response['status'] != true){ + log_message('error', 'Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response)); + return null; + } + + $ecardUrl = $response['data']['ecardUrl'] ?? null; + + if(!empty($ecardUrl)){ + log_message('error', 'Ecard Request PUSH SUCCESS | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | ecardUrl: '.$ecardUrl); + return $ecardUrl; + } else { + log_message('error', 'Ecard Request SUCCESS BUT ecardUrl EMPTY | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response)); + return null; + } + + + } + + + public function GetBenefDetails($requestData) + { + + helper('api'); + + $url = getenv('MEDI_ASSIST_API_BASE_URL_LIVE') . '/GetBenefDetails'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Username:' . getenv('MEDI_ASSIST_API_USERNAME_LIVE'), + 'Password:' . getenv('MEDI_ASSIST_API_PASSWORD_LIVE'), + ]; + + $policyNo = $requestData['policy_no'] ?? null; + + if (empty($policyNo)) { + log_message('error', 'GetBenefDetails: policy_no missing in request'); + return $this->response->setJSON(['status' => false,'message' => 'policy_no required']); + } + + log_message('error', "GetBenefDetails called for policy_no: {$policyNo}"); + + $allBenef = []; + $startIndex = 0; + $range = 100; + $totalCount = 0; + + do { + $body = [ + "policyNo" => $policyNo, + "startDate" => "", + "endDate" => "", + "isDeActivedata" => false, + "startIndex" => $startIndex, + "range" => $range, + "employeeId" => "" + ]; + + log_message('error', "GetBenefDetails API Request (startIndex={$startIndex}): " . json_encode($body)); + + $response = call_third_party_api($url, $method, $headers, $body); + + if ($response['status'] != true) { + log_message('error', 'GetBenefDetails API failed: ' . json_encode($response)); + return $this->response->setJSON([ 'status' => false,'message' => 'API call failed','data' => $response]); + } + + $data = $response['data'] ?? []; + + if (!isset($data['benefDetails'])) { + log_message('error', "GetBenefDetails: 'benefDetails' missing in API response: " . json_encode($data)); + break; + } + + $count = $data['count'] ?? 0; + $totalCount = $count; + $fetchedCount = count($data['benefDetails']); + + log_message('error', "Fetched {$fetchedCount} records (startIndex={$startIndex}) of total {$count}"); + + $allBenef = array_merge($allBenef, $data['benefDetails']); + + $startIndex += $range; + + } while ($startIndex < $totalCount); + + // now update DB + $db = \Config\Database::connect(); + $updated = 0; + + + + foreach ($allBenef as $row) { + + // $update = $db->table('employee_polices') + // ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id AND client_policy.policy_no = ' . $db->escape($row['polNo']), 'left') + // ->join( + // 'employees', + // 'employee_polices.employee_id = employees.id + // AND employees.emp_code = ' . $db->escape($row['priBenefEmpCode']) . ' + // AND employees.relationship = ' . $db->escape($row['relName']), + // 'left' + // ) + // ->where('employee_polices.tpa_id IS NULL') + // ->update(['employee_polices.tpa_id' => $row['benefMediAssistID']]); + + $update = $db->table('employee_polices') + ->join('client_policy', 'employee_polices.client_policy_id = client_policy.id', 'left') + ->join('employees', 'employee_polices.employee_id = employees.id', 'left') + ->where('client_policy.policy_no', $row['polNo']) + ->where('employees.emp_code', $row['priBenefEmpCode']) + ->where('employees.relationship', $row['relName']) + ->where('employee_polices.tpa_id IS NULL', null, false) + ->update(['employee_polices.tpa_id' => $row['benefMediAssistID']]); + + + + if ($db->affectedRows() > 0) { + $updated++; + log_message('error', "Updated tpa_id for emp_code={$row['priBenefEmpCode']}, policy={$row['polNo']}"); + } + } + + log_message('error', "GetBenefDetails completed. Total fetched={$totalCount}, updated={$updated}"); + + return $this->response->setJSON([ + 'status' => true, + 'message' => 'Updated successfully', + 'total_fetched' => $totalCount, + 'total_updated' => $updated + ]); + } + + + // public function GetBenefDetails (){ + + // $postData = $this->request->getJSON(true); + + // helper('api'); + + // $url = ''. getenv('MEDI_ASSIST_API_BASE_URL_LIVE').'/GetBenefDetails'; + // $method = 'POST'; + + // $headers = [ + // 'Content-Type: application/json', + // 'Username:'. getenv('MEDI_ASSIST_API_USERNAME_LIVE').'', + // 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD_LIVE').'', + // ]; + + // $body = [ + // "policyNo" => $$postData['policy_no'], + // "startDate" => "", + // "endDate" => "", + // "isDeActivedata" => false, + // "startIndex" => 0, + // "range" => 100 , + // "employeeId" => "" + // ]; + + // // $body = [ + // // "policyNo" => "97000063250400000031", + // // "startDate" => "", + // // "endDate" => "", + // // "isDeActivedata" => false, + // // "startIndex" => 0, + // // "range" => 100 , + // // "employeeId" => "" + // // ]; + + // $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 ClaimDetail (){ + + + helper('api'); + + $url = ''. getenv('MEDI_ASSIST_API_BASE_URL_LIVE').'/ClaimDetail'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Username:'. getenv('MEDI_ASSIST_API_USERNAME_LIVE').'', + 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD_LIVE').'', + ]; + + $body = [ + "policyNo" => "97000063250400000031", + "startDate" => "", + "endDate" => "", + "employeeCode" => "CITPL120193", + "memberID" => "", + "claimNo" => "", + "claimRefNo" => "" + ]; + + $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 HospitalNetwork (){ + + $postData = $this->request->getJSON(true); + + helper('api'); + + $url = ''. getenv('MEDI_ASSIST_API_BASE_URL_LIVE').'/NetworkHospital'; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Username:'. getenv('MEDI_ASSIST_API_USERNAME_LIVE').'', + 'Password:'. getenv('MEDI_ASSIST_API_PASSWORD_LIVE').'', + ]; + + $body = [ + "startIndex" => 0, + "endIndex" => 10, + "policyNumber" => "97000063250400000031" + ]; + + $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 IntimateClaim (){ + + $postData = $this->request->getJSON(true); + + helper('api'); + + // $url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/ClaimAPIServiceUAT/Claim/IntimateClaim'; + $url = "https://apiintegration.mediassist.in/ClaimAPIServiceUAT/Claim/IntimateClaim"; + $method = 'POST'; + + $headers = [ + 'Content-Type: application/json', + 'Username:' .'NhanceUsr', + 'Password:' .'NhU$p&Cc5wGQbr2', + ]; + + + $p = 'NhU$p&Cc5wGQbr2'; + $body = [ + "Username" => "NhanceUsr", + "Password" => $p, + "policyNo" => "570000/48/2025/286", + "memberId" => 4078919887, + "DateOfAdmisssion" => date('Y-m-d', strtotime('2023-12-14')), + "HospitalName" => "test", + "AilmentDescription" => "Kidney", + "ContactNo" => "78745XXXXX" + ]; + + $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 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() + { + + $filePath = $this->request->getGet('file_path'); + $filename = basename($filePath); + + // Return file as download + return $this->response->download($filePath, null)->setFileName($filename); + } + + + + +} diff --git a/app/Helpers/api_helper.php b/app/Helpers/api_helper.php index 95096fdb..ad25d3b4 100644 --- a/app/Helpers/api_helper.php +++ b/app/Helpers/api_helper.php @@ -58,6 +58,8 @@ if (!function_exists('call_third_party_api')) { ]; } + // echo ($response); die; + $decoded = json_decode($response, true); return [