Medi assist claim pull duplicate entry handled : GWM
This commit is contained in:
parent
1582202798
commit
abbe5abc13
@ -629,6 +629,7 @@ class MediAssistApiController extends BaseController
|
|||||||
"RETURNED" => 14,
|
"RETURNED" => 14,
|
||||||
"UNDER PROCESS - TPA" => 61,
|
"UNDER PROCESS - TPA" => 61,
|
||||||
"DENIAL REVIEW AWAITED" => 66,
|
"DENIAL REVIEW AWAITED" => 66,
|
||||||
|
"Pre-Auth Processed" => 9,
|
||||||
];
|
];
|
||||||
|
|
||||||
$updateArray = [
|
$updateArray = [
|
||||||
@ -1197,6 +1198,7 @@ class MediAssistApiController extends BaseController
|
|||||||
"RETURNED" => 14,
|
"RETURNED" => 14,
|
||||||
"UNDER PROCESS - TPA" => 61,
|
"UNDER PROCESS - TPA" => 61,
|
||||||
"DENIAL REVIEW AWAITED" => 66,
|
"DENIAL REVIEW AWAITED" => 66,
|
||||||
|
"Pre-Auth Processed" => 9,
|
||||||
];
|
];
|
||||||
|
|
||||||
$updateArray = [
|
$updateArray = [
|
||||||
@ -1328,6 +1330,7 @@ class MediAssistApiController extends BaseController
|
|||||||
"RETURNED" => 14,
|
"RETURNED" => 14,
|
||||||
"UNDER PROCESS - TPA" => 61,
|
"UNDER PROCESS - TPA" => 61,
|
||||||
"DENIAL REVIEW AWAITED" => 66,
|
"DENIAL REVIEW AWAITED" => 66,
|
||||||
|
"Pre-Auth Processed" => 9,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($TicketData as $ticket) {
|
foreach ($TicketData as $ticket) {
|
||||||
@ -1616,17 +1619,17 @@ class MediAssistApiController extends BaseController
|
|||||||
$relationship = 'self';
|
$relationship = 'self';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$claimNumber = $value['tpA_CLAIM_NO'] ?? null;
|
||||||
|
|
||||||
|
// Same TPA claim number → update existing ticket (avoid duplicate when amount/dates change)
|
||||||
|
$ticket = null;
|
||||||
|
if (!empty($claimNumber)) {
|
||||||
$ticket = $this->db->table('ticket_master tm')->select("tm.id")
|
$ticket = $this->db->table('ticket_master tm')->select("tm.id")
|
||||||
->where('tm.policy_no', $value['policY_NUMBER'])
|
->where('tm.claim_number', $claimNumber)
|
||||||
->where('tm.emp_code', $value['employeE_NO'])
|
->where('tm.claim_created_by', 'TPA')
|
||||||
->where('tm.claim_amount', $value['estimateD_CLAIM_AMOUNT'])
|
|
||||||
->where('tm.doa', $this->mediDate($value['datE_OF_ADMISSION'] ?? null))
|
|
||||||
// ->where('tm.claim_number', $value['tpA_CLAIM_NO'])
|
|
||||||
->get()
|
->get()
|
||||||
->getRowArray();
|
->getRowArray();
|
||||||
|
}
|
||||||
if(!$ticket)
|
|
||||||
{
|
|
||||||
|
|
||||||
// VALID STATUS LIST
|
// VALID STATUS LIST
|
||||||
$validStatuses = [
|
$validStatuses = [
|
||||||
@ -1654,7 +1657,6 @@ class MediAssistApiController extends BaseController
|
|||||||
"Payment - Refunded to Insurer" => 14,
|
"Payment - Refunded to Insurer" => 14,
|
||||||
"Processed - Processing Payment" => 10,
|
"Processed - Processing Payment" => 10,
|
||||||
"Processed - Physical Documents Awaited" => 9,
|
"Processed - Physical Documents Awaited" => 9,
|
||||||
"Pre-Auth Processed" => 8,
|
|
||||||
|
|
||||||
// Extra Mappings (based on your DB list)
|
// Extra Mappings (based on your DB list)
|
||||||
"NON ID" => 1,
|
"NON ID" => 1,
|
||||||
@ -1667,6 +1669,7 @@ class MediAssistApiController extends BaseController
|
|||||||
"RETURNED" => 14,
|
"RETURNED" => 14,
|
||||||
"UNDER PROCESS - TPA" => 61,
|
"UNDER PROCESS - TPA" => 61,
|
||||||
"DENIAL REVIEW AWAITED" => 66,
|
"DENIAL REVIEW AWAITED" => 66,
|
||||||
|
"Pre-Auth Processed" => 9,
|
||||||
];
|
];
|
||||||
|
|
||||||
$currentStatus = trim($value['claim_Current_Status'] ?? '');
|
$currentStatus = trim($value['claim_Current_Status'] ?? '');
|
||||||
@ -1678,6 +1681,45 @@ class MediAssistApiController extends BaseController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($ticket) {
|
||||||
|
|
||||||
|
// Update existing TPA claim with latest sync data
|
||||||
|
$updateData = [
|
||||||
|
'claim_status_id' => $claimStatusId,
|
||||||
|
'tpa_claim_status' => $currentStatus,
|
||||||
|
'tpa_claim_id' => $claimNumber,
|
||||||
|
'claim_amount' => $value['estimateD_CLAIM_AMOUNT']
|
||||||
|
?? $value['finaL_BILL_AMOUNT']
|
||||||
|
?? null,
|
||||||
|
'approved_amount' => $value['claiM_APPROVED_AMOUNT'] ?? null,
|
||||||
|
'doa' => $this->mediDate($value['datE_OF_ADMISSION'] ?? null),
|
||||||
|
'dod' => $this->mediDate($value['datE_OF_DISCHARGE'] ?? null),
|
||||||
|
'raised_date' => $this->mediDate($value['claiM_REGISTERED_DATE'] ?? null),
|
||||||
|
'approved_date' => $this->mediDate($value['approved_Date'] ?? null),
|
||||||
|
'settled_date' => $this->mediDate($value['paiD_DATE'] ?? null),
|
||||||
|
'hospital_name' => $value['hospitaL_NAME'] ?? null,
|
||||||
|
'hospital_address' => $value['hospitaL_ADDRESS'] ?? null,
|
||||||
|
'hospital_state' => $value['hospitaL_STATE'] ?? null,
|
||||||
|
'hospital_city' => $value['hospitaL_CITY'] ?? null,
|
||||||
|
'hospital_pin_code' => $value['hosP_PINCODE'] ?? null,
|
||||||
|
'utr_details' => $value['banK_CHEQUE_NO'] ?? null,
|
||||||
|
'settle_letter' => $value['settlement_LetterLink'] ?? null,
|
||||||
|
'tpa_claim_type' => $value['typE_OF_CLAIM'] ?? null,
|
||||||
|
'tpa_ailments' => ($value['ailment'] ?? '') . ' - ' . ($value['ailmenT_DESC'] ?? ''),
|
||||||
|
'tpa_claim_push_reference_no' => $value['clM_COMP_REFNO'] ?? null,
|
||||||
|
'updated_at' => date('Y-m-d H:i:s'),
|
||||||
|
'last_updated_by' => 'API',
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->db->table('ticket_master')->where('id', $ticket['id'])->update($updateData);
|
||||||
|
|
||||||
|
log_message(
|
||||||
|
'error',
|
||||||
|
'MEDI_ASSIST - Sync TPA Claims | Existing claim updated | TicketID: '.$ticket['id'].' | Claim: '.$claimNumber
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
$clientpolicy = $this->db->table('client_policy cp')
|
$clientpolicy = $this->db->table('client_policy cp')
|
||||||
->select("
|
->select("
|
||||||
cp.id as client_policy_id,
|
cp.id as client_policy_id,
|
||||||
@ -1710,15 +1752,13 @@ class MediAssistApiController extends BaseController
|
|||||||
->get()
|
->get()
|
||||||
->getRowArray();
|
->getRowArray();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$claimData = [
|
$claimData = [
|
||||||
// Core
|
// Core
|
||||||
'ticket_type_id' => 1,
|
'ticket_type_id' => 1,
|
||||||
'claim_status_id' => $claimStatusId,
|
'claim_status_id' => $claimStatusId,
|
||||||
'policy_no' => $value['policY_NUMBER'] ?? null,
|
'policy_no' => $value['policY_NUMBER'] ?? null,
|
||||||
'claim_number' => $value['tpA_CLAIM_NO'] ?? null,
|
'claim_number' => $claimNumber,
|
||||||
'tpa_claim_id' => $value['tpA_CLAIM_NO'] ?? null,
|
'tpa_claim_id' => $claimNumber,
|
||||||
|
|
||||||
// local promary id
|
// local promary id
|
||||||
'tpa_id' => $clientpolicy['tpa_id'] ?? null,
|
'tpa_id' => $clientpolicy['tpa_id'] ?? null,
|
||||||
@ -1771,7 +1811,6 @@ class MediAssistApiController extends BaseController
|
|||||||
'claim_created_by' => 'TPA',
|
'claim_created_by' => 'TPA',
|
||||||
'tpa_claim_push_reference_no' => $value['clM_COMP_REFNO'] ?? null,
|
'tpa_claim_push_reference_no' => $value['clM_COMP_REFNO'] ?? null,
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->db->table('ticket_master')->insert($claimData);
|
$this->db->table('ticket_master')->insert($claimData);
|
||||||
|
|||||||
@ -435,10 +435,6 @@ class DigitExecutorService
|
|||||||
protected function vehicleRowFromInput(array $input, int $quoteId): array
|
protected function vehicleRowFromInput(array $input, int $quoteId): array
|
||||||
{
|
{
|
||||||
$plate = strtoupper(preg_replace('/\s+/', '', (string) ($input['license_plate_number'] ?? '')));
|
$plate = strtoupper(preg_replace('/\s+/', '', (string) ($input['license_plate_number'] ?? '')));
|
||||||
$authority = $input['registration_authority'] ?? null;
|
|
||||||
if (!$authority && strlen($plate) >= 4) {
|
|
||||||
$authority = substr($plate, 0, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'quote_id' => $quoteId,
|
'quote_id' => $quoteId,
|
||||||
@ -449,7 +445,6 @@ class DigitExecutorService
|
|||||||
'engine_number' => $input['engine_number'] ?? null,
|
'engine_number' => $input['engine_number'] ?? null,
|
||||||
'manufacture_date' => $input['manufacture_date'] ?? date('Y-m-d'),
|
'manufacture_date' => $input['manufacture_date'] ?? date('Y-m-d'),
|
||||||
'registration_date' => $input['registration_date'] ?? date('Y-m-d'),
|
'registration_date' => $input['registration_date'] ?? date('Y-m-d'),
|
||||||
'registration_authority' => $authority,
|
|
||||||
'idv' => $input['idv'] ?? 0,
|
'idv' => $input['idv'] ?? 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,30 +18,11 @@ class MotorQuoteModel extends Model
|
|||||||
'previous_insurer_code', 'previous_policy_expiry_date', 'external_policy_number',
|
'previous_insurer_code', 'previous_policy_expiry_date', 'external_policy_number',
|
||||||
'is_ncb_transfer', 'start_date', 'end_date', 'pincode',
|
'is_ncb_transfer', 'start_date', 'end_date', 'pincode',
|
||||||
'coverage_details', 'premium', 'idv', 'status',
|
'coverage_details', 'premium', 'idv', 'status',
|
||||||
'created_by', 'updated_by', 'created_at', 'updated_at',
|
'created_at', 'updated_at',
|
||||||
];
|
];
|
||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
protected $createdField = 'created_at';
|
protected $createdField = 'created_at';
|
||||||
protected $updatedField = 'updated_at';
|
protected $updatedField = 'updated_at';
|
||||||
protected $allowCallbacks = true;
|
|
||||||
protected $beforeInsert = ['setCreatedBy'];
|
|
||||||
protected $beforeUpdate = ['setUpdatedBy'];
|
|
||||||
|
|
||||||
protected function setCreatedBy(array $data): array
|
|
||||||
{
|
|
||||||
if (function_exists('get_session_userid')) {
|
|
||||||
$data['data']['created_by'] = get_session_userid();
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setUpdatedBy(array $data): array
|
|
||||||
{
|
|
||||||
if (function_exists('get_session_userid')) {
|
|
||||||
$data['data']['updated_by'] = get_session_userid();
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getListWithVehicle(array $filters = []): array
|
public function getListWithVehicle(array $filters = []): array
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class MotorVehicleModel extends Model
|
|||||||
protected $allowedFields = [
|
protected $allowedFields = [
|
||||||
'quote_id', 'is_vehicle_new', 'vehicle_maincode', 'license_plate_number',
|
'quote_id', 'is_vehicle_new', 'vehicle_maincode', 'license_plate_number',
|
||||||
'vehicle_identification_number', 'engine_number', 'manufacture_date',
|
'vehicle_identification_number', 'engine_number', 'manufacture_date',
|
||||||
'registration_date', 'registration_authority',
|
'registration_date',
|
||||||
'idv', 'default_idv', 'minimum_idv', 'maximum_idv',
|
'idv', 'default_idv', 'minimum_idv', 'maximum_idv',
|
||||||
];
|
];
|
||||||
protected $useTimestamps = false;
|
protected $useTimestamps = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user