Medi assist ir doc api : GWM
This commit is contained in:
parent
9ead4735ed
commit
feea89f3e9
@ -244,6 +244,31 @@ class ApiServiceController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// push Claim Files (IR submission)
|
||||||
|
public function pushClaimFiles($claimId)
|
||||||
|
{
|
||||||
|
|
||||||
|
$claimId = $this->request->getGet('claim_id');
|
||||||
|
|
||||||
|
$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 == $this->medi_assist_primary_key) { // MediAssist
|
||||||
|
$mediAssistController = new MediAssistApiController();
|
||||||
|
return $mediAssistController->IRSubmission($claimId);
|
||||||
|
}else{
|
||||||
|
log_message('error', "This ticket id ( {$claimId} ) TPA has no API service enabled. TPA ID : {$tpaID}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getWellnessUrl()
|
public function getWellnessUrl()
|
||||||
|
|||||||
@ -544,6 +544,7 @@ class MediAssistApiController extends BaseController
|
|||||||
// Extract claim status
|
// Extract claim status
|
||||||
$claimData = $response['data']['claimsData'][0];
|
$claimData = $response['data']['claimsData'][0];
|
||||||
$currentStatus = $claimData['claim_Current_Status'] ?? '';
|
$currentStatus = $claimData['claim_Current_Status'] ?? '';
|
||||||
|
$tpa_claim_no = $claimData['tpA_CLAIM_NO'] ?? '';
|
||||||
|
|
||||||
// VALID STATUS LIST
|
// VALID STATUS LIST
|
||||||
$validStatuses = [
|
$validStatuses = [
|
||||||
@ -588,9 +589,9 @@ class MediAssistApiController extends BaseController
|
|||||||
// Maping tpa claim status with local claim Status
|
// Maping tpa claim status with local claim Status
|
||||||
if (isset($validStatuses[$currentStatus]))
|
if (isset($validStatuses[$currentStatus]))
|
||||||
{
|
{
|
||||||
$updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'updated_at' => date('Y-m-d H:i:s')];
|
$updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no , 'updated_at' => date('Y-m-d H:i:s')];
|
||||||
}else{
|
}else{
|
||||||
$updateArray = ['tpa_claim_status' => $currentStatus , 'updated_at' => date('Y-m-d H:i:s')];
|
$updateArray = ['tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no , 'updated_at' => date('Y-m-d H:i:s')];
|
||||||
}
|
}
|
||||||
|
|
||||||
// UPDATE ticket_master
|
// UPDATE ticket_master
|
||||||
@ -607,15 +608,85 @@ class MediAssistApiController extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function IRSubmission ($claimId = null)
|
public function IRSubmission($claimId = null) // 585 this id for test
|
||||||
{
|
{
|
||||||
|
log_message('info', "IRSubmission INIT for ticket_id={$claimId}");
|
||||||
|
|
||||||
$postData = $this->request->getJSON(true);
|
// 1. FETCH TICKET DETAILS
|
||||||
|
$ticket = $this->db->table('ticket_master tm')
|
||||||
|
->select("
|
||||||
|
tm.id,
|
||||||
|
tm.tpa_no as memberId,
|
||||||
|
tm.tpa_claim_push_reference_no as claimRefNo,
|
||||||
|
tm.tpa_claim_id as ClaimID,
|
||||||
|
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 || empty($ticket['ClaimID'])) {
|
||||||
|
log_message('error', "IRSubmission FAILED → ClaimID NOT FOUND for ticket_id={$claimId}");
|
||||||
|
|
||||||
|
return $this->response->setJSON([
|
||||||
|
'status' => false,
|
||||||
|
'message' => "ClaimID not found for ticket {$claimId}"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. FETCH IR ATTACHMENTS
|
||||||
|
$fileData = $this->db->table('claim_files f')
|
||||||
|
->where('f.ticket_id', $claimId)
|
||||||
|
->where('f.docs_for_ir', 1)
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
$Attachments = [];
|
||||||
|
|
||||||
|
if (count($fileData)) {
|
||||||
|
foreach ($fileData as $file) {
|
||||||
|
|
||||||
|
if (!empty($file['url'])) {
|
||||||
|
$filename = basename($file['url']);
|
||||||
|
$fileDir = WRITEPATH . 'uploads/claim_files/' . $filename;
|
||||||
|
|
||||||
|
if (file_exists($fileDir)) {
|
||||||
|
$downloadUrl = base_url('fileDownload?file_path=') . $fileDir;
|
||||||
|
} else {
|
||||||
|
$downloadUrl = "";
|
||||||
|
log_message('error', "File NOT FOUND on server → {$fileDir}");
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('info', "IRSubmission Attachment Ready: {$filename} | URL={$downloadUrl}");
|
||||||
|
|
||||||
|
$Attachments[] = [
|
||||||
|
"AttachmentName" => $filename,
|
||||||
|
"AttachmentPath" => $downloadUrl
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
log_message('error', "IRSubmission Missing File URL → file_id={$file['id']}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. API REQUEST BODY
|
||||||
|
$body = [
|
||||||
|
"ClaimID" => $ticket['ClaimID'],
|
||||||
|
"Attachments" => $Attachments
|
||||||
|
];
|
||||||
|
|
||||||
|
log_message('info', "IRSubmission Request Body => " . json_encode($body));
|
||||||
|
|
||||||
|
// 4. SEND API CALL
|
||||||
helper('api');
|
helper('api');
|
||||||
|
// 'https://apiintegration.mediassist.in/ClaimAPIServiceUAT/Claim/IRSubmission' // dev url
|
||||||
// $url = ''. getenv('MEDI_ASSIST_API_BASE_URL').'/ClaimAPIServiceUAT/Claim/IRSubmission';
|
$url = env('MEDI_ASSIST_API_BASE_URL_IRSUBMISSION');
|
||||||
$url = "https://apiintegration.mediassist.in/ClaimAPIServiceUAT/Claim/IRSubmission";
|
|
||||||
$method = 'POST';
|
$method = 'POST';
|
||||||
|
|
||||||
$headers = [
|
$headers = [
|
||||||
@ -624,27 +695,31 @@ class MediAssistApiController extends BaseController
|
|||||||
'Password:' . getenv('MEDI_ASSIST_API_PASSWORD'),
|
'Password:' . getenv('MEDI_ASSIST_API_PASSWORD'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$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);
|
$response = call_third_party_api($url, $method, $headers, $body);
|
||||||
|
|
||||||
|
log_message('info', "IRSubmission API Response => " . json_encode($response));
|
||||||
|
|
||||||
if($response['status'] != true){
|
// 5. HANDLE RESPONSE
|
||||||
return $this->response->setJSON([
|
if (!$response['status']) {
|
||||||
|
log_message(
|
||||||
|
'error',
|
||||||
|
"IRSubmission FAILED for ClaimID={$ticket['ClaimID']} → Response=" . json_encode($response)
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
'status' => false,
|
'status' => false,
|
||||||
'message' => 'failed.',
|
'message' => 'IR Submission failed',
|
||||||
'data' => $response
|
'data' => $response
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->setJSON($response);
|
log_message('info', "IRSubmission SUCCESS → ClaimID={$ticket['ClaimID']}");
|
||||||
|
|
||||||
|
return [
|
||||||
|
'status' => true,
|
||||||
|
'message' => 'IR Submitted successfully',
|
||||||
|
'data' => $response
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -679,6 +754,7 @@ class MediAssistApiController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function HospitalNetwork (){
|
public function HospitalNetwork (){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user