nhance/app/Views/claims_mis_abhi.php
2026-08-07 10:19:31 +05:30

773 lines
33 KiB
PHP

<?php
/** @var array $report */
/** @var array $view_model */
/** @var int $policy_id */
/** @var string $pdf_url */
/** @var bool $embed */
$embed = $embed ?? false;
$report = $report ?? [];
$view_model = $view_model ?? ($report['view_model'] ?? []);
$header = $report['header'] ?? [];
$summary = $report['summary'] ?? [];
$meta = $report['meta'] ?? [];
$vm = $view_model;
$charts = $charts ?? [];
$fmt = static fn ($n, $d = 0) => number_format((float) $n, $d);
$logoSrc = !empty($embed)
? (rtrim(ROOTPATH, '/\\') . '/public/assets/images/abhi.png')
: base_url('public/assets/images/abhi.png');
include APPPATH . 'Views/partials/claims_mis_abhi_helpers.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ABH MIS Report — Policy <?= esc($header['policy_number'] ?? $policy_id) ?></title>
<style>
:root{
--red:#C8102E;
--red-dark:#9c0c22;
--navy:#152A54;
--blue:#2E86DE;
--blue-dark:#1B3F8C;
--orange:#E8862C;
--purple:#6A3D9A;
--gold:#D9A441;
--bg:#f6f1ee;
--panel:#FFFFFF;
--line:#eee0e0;
--text:#2b2020;
--muted:#8a7676;
--maroon-900:#4a0e10;
--maroon-700:#7a1116;
--maroon-600:#9c151b;
--maroon-500:#b91c23;
--maroon-050:#fbecec;
}
*{box-sizing:border-box;}
body{
margin:0;
background:var(--bg);
font-family:"Segoe UI", Arial, sans-serif;
color:var(--text);
padding:28px 48px;
}
.wrap{max-width:1580px;margin:0 auto;}
/* ---- Header (unified card) ---- */
.header{
background:var(--panel);
border-radius:16px;
border:1px solid var(--line);
box-shadow:0 1px 3px rgba(74,14,16,0.06);
display:flex;
align-items:stretch;
overflow:hidden;
margin-bottom:18px;
}
.brand{
display:flex;
align-items:center;
gap:14px;
padding:18px 24px;
border-right:1px solid var(--line);
min-width:280px;
flex-shrink:0;
}
.brand-logo{
display:block;
height:64px;
width:auto;
max-width:260px;
object-fit:contain;
object-position:left center;
}
.hdr-stats{
flex:1;
display:flex;
align-items:center;
min-width:0;
}
.hdr-stat{
flex:1;
padding:16px 20px;
display:flex;
align-items:center;
gap:12px;
border-right:1px solid var(--line);
min-width:0;
}
.hdr-stat:last-child{border-right:none;}
.hdr-stat-icon{
width:36px;
height:36px;
border-radius:10px;
background:var(--maroon-050);
color:var(--maroon-600);
display:flex;
align-items:center;
justify-content:center;
flex-shrink:0;
}
.hdr-stat-icon svg{width:18px;height:18px;}
.hdr-stat-body{min-width:0;}
.hdr-stat-value{
font-size:14px;
font-weight:700;
color:var(--text);
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.hdr-stat-label{
font-size:11px;
color:var(--muted);
margin-top:2px;
letter-spacing:0.3px;
}
/* ---- Panel ---- */
.panel{
background:var(--panel);
border-radius:10px;
overflow:hidden;
box-shadow:0 1px 3px rgba(0,0,0,.08);
margin-bottom:16px;
}
.panel h2{
background:var(--red);
color:#fff;
font-size:13px;
font-weight:700;
margin:0;
padding:9px 16px;
text-align:center;
letter-spacing:.3px;
}
.panel .body{padding:14px 16px;}
table{width:100%;border-collapse:collapse;font-size:12.5px;}
th,td{padding:7px 10px;text-align:left;}
thead th{
background:var(--red);
color:#fff;
font-size:12px;
font-weight:700;
}
tbody tr:nth-child(even){background:#F7F7F9;}
tbody tr:hover{background:#FDEDEF;}
td.num, th.num{text-align:right;}
tfoot td{font-weight:700;background:#F0F0F3;border-top:2px solid var(--red);}
.kv-table td:first-child{font-weight:600;color:var(--navy);width:55%;}
.kv-table td:last-child{font-weight:600;}
.kv-block{margin-bottom:16px;}
.kv-block-title{
font-size:14px;
font-weight:700;
font-style:italic;
color:#111;
margin:0 0 8px 2px;
}
.kv-block .panel{margin-bottom:0;}
.kv-block .panel .body{padding:0;}
.kv-block table{margin:0;}
.kv-block thead th{text-align:left;}
.kv-block thead th:last-child{text-align:left;}
.kv-block tbody td{border-bottom:1px solid var(--line);}
.kv-block tbody tr:last-child td{border-bottom:none;}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:16px;}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:16px;}
.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;}
.stat-panel{
background:var(--panel);
border-radius:10px;
box-shadow:0 1px 3px rgba(0,0,0,.08);
padding:20px;
display:flex;
align-items:center;
justify-content:space-around;
text-align:center;
}
.stat-num{font-size:26px;font-weight:800;color:var(--navy);}
.stat-label{font-size:12px;font-weight:700;color:var(--muted);margin-top:2px;}
.stat-icon{font-size:34px;}
.chart-wrap{position:relative;height:260px;}
.chart-wrap canvas{width:100% !important;height:100% !important;display:block;}
.chart-wrap.short{height:220px;}
.chart-wrap.medium{height:280px;}
.chart-wrap.tall{height:400px;}
.center-metric{
position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
text-align:center;font-size:12px;font-weight:700;color:var(--navy);
}
.pct-hero{
font-size:28px;font-weight:800;color:var(--blue);text-align:center;margin-top:20px;
}
.section-title{
font-size:15px;font-weight:800;color:var(--navy);
margin:26px 0 10px 2px;
border-left:5px solid var(--red);
padding-left:10px;
}
.legend-row{display:flex;gap:14px;justify-content:center;flex-wrap:wrap;font-size:11.5px;margin-bottom:6px;}
.legend-row span{display:inline-flex;align-items:center;gap:5px;}
.dot{width:10px;height:10px;border-radius:50%;display:inline-block;}
.subhead{
background:#F0F0F3;
font-weight:700;
font-size:12.5px;
color:var(--navy);
}
.scroll-y{max-height:420px;overflow-y:auto;}
@media(max-width:1100px){
body{padding:24px 28px;}
.header{flex-wrap:wrap;}
.brand{width:100%;border-right:none;border-bottom:1px solid var(--line);min-width:0;}
.hdr-stats{flex-wrap:wrap;}
.hdr-stat{min-width:50%;border-bottom:1px solid var(--line);}
.grid2,.grid3,.grid4{grid-template-columns:1fr;}
}
.chart-img{display:block;width:100%;max-width:100%;height:auto;margin:0 auto;}
<?php if (!empty($embed)): ?>
/* DomPDF-safe overrides (no CSS variables / flex / grid) */
body{background:#f6f1ee;color:#2b2020;font-family:DejaVu Sans, Arial, sans-serif;padding:12px 18px;}
.wrap{max-width:100%;}
.header{display:table;width:100%;margin-bottom:12px;background:#fff;border:1px solid #eee0e0;border-radius:10px;}
.brand,.hdr-stats{display:table-cell;vertical-align:middle;}
.brand{width:220px;padding:10px 12px;border-right:1px solid #eee0e0;}
.brand-logo{height:48px;width:auto;max-width:200px;}
.hdr-stats{padding:0;}
.hdr-stat{display:inline-block;vertical-align:middle;padding:8px 10px;width:24%;}
.hdr-stat-icon{display:none;}
.hdr-stat-value{font-size:11px;font-weight:700;color:#2b2020;}
.hdr-stat-label{font-size:9px;color:#8a7676;}
.panel{background:#fff;border-radius:8px;overflow:hidden;box-shadow:none;border:1px solid #E2E2E6;margin-bottom:10px;}
.panel h2,.kv-block-title{background:#C8102E;color:#fff;font-size:12px;font-weight:700;margin:0;padding:7px 10px;text-align:center;}
.kv-block-title{background:transparent;color:#111;font-style:italic;text-align:left;padding:0 0 4px;}
.panel .body{padding:8px 10px;}
table{width:100%;border-collapse:collapse;font-size:10px;}
th,td{padding:5px 6px;text-align:left;border:1px solid #E2E2E6;}
thead th{background:#C8102E;color:#fff;font-weight:700;}
tbody tr:nth-child(even){background:#F7F7F9;}
td.num,th.num{text-align:right;}
tfoot td{font-weight:700;background:#F0F0F3;border-top:2px solid #C8102E;}
.kv-table td:first-child{font-weight:600;color:#152A54;width:55%;}
.grid2,.grid3,.grid4{display:table;width:100%;table-layout:fixed;border-collapse:separate;border-spacing:8px;margin:0 -8px 8px;}
.grid2 > .panel,.grid3 > .panel,.grid4 > .panel{display:table-cell;vertical-align:top;margin:0;}
.grid2 > .panel{width:50%;}
.grid3 > .panel{width:33.33%;}
.grid4 > .panel{width:25%;}
.section-title{font-size:13px;font-weight:800;color:#152A54;margin:12px 0 6px;border-left:4px solid #C8102E;padding-left:8px;}
.chart-wrap,.chart-wrap.short,.chart-wrap.medium,.chart-wrap.tall{height:auto !important;min-height:0;}
.scroll-y{max-height:none;overflow:visible;}
.stat-panel{display:block;text-align:center;padding:12px;}
.stat-num{font-size:20px;font-weight:800;color:#152A54;}
.stat-label{font-size:11px;font-weight:700;color:#6B6B75;}
.stat-icon{display:none;}
.legend-row{font-size:10px;margin-bottom:4px;}
.dot{background:#2E86DE;}
<?php endif; ?>
</style>
</head>
<body>
<div class="wrap">
<!-- HEADER -->
<div class="header">
<div class="brand">
<img class="brand-logo" src="<?= esc($logoSrc) ?>" alt="Aditya Birla Capital Health Insurance">
</div>
<div class="hdr-stats">
<div class="hdr-stat">
<div class="hdr-stat-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M8 4v5"/></svg>
</div>
<div class="hdr-stat-body">
<div class="hdr-stat-value" title="<?= esc($header['policy_number'] ?? '') ?>"><?= esc($header['policy_number'] ?? '') ?></div>
<div class="hdr-stat-label">Policy number</div>
</div>
</div>
<div class="hdr-stat">
<div class="hdr-stat-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-6 8-6s8 2 8 6"/></svg>
</div>
<div class="hdr-stat-body">
<div class="hdr-stat-value" title="<?= esc($meta['client_name'] ?? '') ?>"><?= esc($meta['client_name'] ?? '') ?></div>
<div class="hdr-stat-label">Client name</div>
</div>
</div>
<div class="hdr-stat">
<div class="hdr-stat-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2 3 7v6c0 5 4 8 9 9 5-1 9-4 9-9V7l-9-5z"/></svg>
</div>
<div class="hdr-stat-body">
<div class="hdr-stat-value" title="<?= esc($meta['tpa_name'] ?? ($header['claim_processor'] ?? '')) ?>"><?= esc($meta['tpa_name'] ?? ($header['claim_processor'] ?? '')) ?></div>
<div class="hdr-stat-label">TPA name</div>
</div>
</div>
<div class="hdr-stat">
<div class="hdr-stat-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 3"/></svg>
</div>
<div class="hdr-stat-body">
<div class="hdr-stat-value"><?= esc($meta['last_refresh'] ?? date('d-M-Y')) ?></div>
<div class="hdr-stat-label">Last refresh</div>
</div>
</div>
</div>
</div>
<!-- PREMIUM / CLAIM SUMMARY -->
<div class="grid2">
<div class="panel">
<h2>Premium</h2>
<div class="body">
<table class="kv-table">
<thead><tr><th>Parameter</th><th>Value</th></tr></thead>
<tbody>
<tr><td>Insurer Name</td><td><?= esc($header['insurer_name'] ?? '') ?></td></tr>
<tr><td>Claim processing team</td><td><?= esc($header['claim_processor'] ?? '') ?></td></tr>
<tr><td>Policy Number</td><td><?= esc($header['policy_number'] ?? '') ?></td></tr>
<tr><td>Policy Start Date</td><td><?= esc($header['policy_start_date'] ?? '') ?></td></tr>
<tr><td>Policy End Date</td><td><?= esc($header['policy_end_date'] ?? '') ?></td></tr>
<tr><td>Lives as on date</td><td><?= esc($fmt($header['lives'] ?? 0, 0)) ?></td></tr>
<tr><td>Premium paid as on date</td><td><?= esc($fmt($header['premium_paid'] ?? 0)) ?></td></tr>
</tbody>
</table>
</div>
</div>
<div class="panel">
<h2>Claim</h2>
<div class="body">
<table class="kv-table">
<thead><tr><th>Parameter</th><th>Value</th></tr></thead>
<tbody>
<tr><td>Claim Paid + Outstanding</td><td><?= esc($fmt($summary['claim_paid_outstanding'] ?? 0)) ?></td></tr>
<tr><td>Claims paid Amount</td><td><?= esc($fmt($summary['claims_paid_amount'] ?? 0)) ?></td></tr>
<tr><td>Claim Outstanding Amount</td><td><?= esc($fmt($summary['claim_outstanding_amount'] ?? 0)) ?></td></tr>
<tr><td>ACS IPD Claim</td><td><?= esc($fmt($summary['acs_ipd_claim'] ?? 0)) ?></td></tr>
<tr><td>No. of claims paid</td><td><?= esc($fmt($summary['claims_paid_count'] ?? 0, 0)) ?></td></tr>
<tr><td>No. of claims Outstanding</td><td><?= esc($fmt($summary['claims_outstanding_count'] ?? 0, 0)) ?></td></tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- DASHBOARD ROW 1 -->
<div class="grid2">
<div class="panel">
<h2>Total Claim Count/Amount</h2>
<div class="body">
<div class="legend-row">
<span><i class="dot" style="background:#2E86DE"></i>Reported</span>
<span><i class="dot" style="background:#1B3F8C"></i>Settled</span>
<span><i class="dot" style="background:#E8862C"></i>Outstanding</span>
<span><i class="dot" style="background:#6A3D9A"></i>Rejected</span>
</div>
<div class="chart-wrap"><?= $chartHtml('donut', 'chartDonut1') ?></div>
</div>
</div>
<div class="panel">
<h2>Pre-Auth TAT By Claim Count</h2>
<div class="body">
<div class="legend-row">
<span><i class="dot" style="background:#2E86DE"></i>With in 2 Hours %</span>
<span><i class="dot" style="background:#1B3F8C"></i>Above 2 Hours %</span>
</div>
<div class="chart-wrap short"><?= $chartHtml('preAuth', 'chartPreAuth') ?></div>
</div>
</div>
</div>
<div class="grid3">
<div class="panel">
<h2>Claim Status</h2>
<div class="body scroll-y">
<table>
<thead><tr><th>Claim Status</th><th class="num">Number</th><th class="num">Reported Amount</th><th class="num">Incurred Amount</th></tr></thead>
<tbody id="tblClaimStatus">
<?php foreach ($vm['claimStatus'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['status'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['number'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($fmt($r['reported'] ?? 0)) ?></td>
<td class="num"><?= esc($fmt($r['incurred'] ?? 0)) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<div class="panel">
<h2>Policy Premium</h2>
<div class="body">
<table>
<thead><tr><th>SrNo</th><th>Amount</th><th class="num">Value</th></tr></thead>
<tbody id="tblPolicyPremium">
<?php foreach ($vm['policyPremium'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['sr'] ?? '') ?></td>
<td><?= esc($r['label'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amount'] ?? 0)) ?></td>
</tr>
<?php endforeach; ?>
<tr style="font-weight:700;background:#F0F0F3;"><td colspan="2">Total</td><td class="num"><?= esc($fmt($vm['policyPremiumTotal'] ?? 0)) ?></td></tr>
</tbody>
</table>
</div>
</div>
<div class="panel">
<h2>&nbsp;</h2>
<div class="body">
<div class="stat-panel">
<div>
<div class="stat-icon">👥</div>
<div class="stat-num"><?= esc($fmt($vm['lives'] ?? ($header['lives'] ?? 0), 0)) ?></div>
<div class="stat-label">Lives</div>
</div>
<div>
<div class="stat-icon">📊</div>
<div class="stat-num"><?= esc(number_format((float) ($vm['icr'] ?? ($summary['icr_pct'] ?? 0)), 2)) ?>%</div>
<div class="stat-label">ICR</div>
</div>
</div>
</div>
</div>
</div>
<div class="grid2">
<div class="panel">
<h2>Reimbursement TAT By Claim Count</h2>
<div class="body">
<table>
<thead><tr><th>Date Difference</th><th class="num">Claim Count</th><th class="num">TAT %</th></tr></thead>
<tbody id="tblReimbTAT">
<?php foreach ($vm['reimbTAT'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['range'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['pct'] ?? 0) ?></td>
</tr>
<?php endforeach; ?>
<tr style="font-weight:700;background:#F0F0F3;">
<td>Total</td>
<td class="num"><?= esc($fmt($vm['reimbTATTotal']['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($vm['reimbTATTotal']['pct'] ?? 0) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel">
<h2>Premium, Earn Premium and Claim Incurred Amount</h2>
<div class="body">
<div class="chart-wrap"><?= $chartHtml('premiumBars', 'chartPremiumBars') ?></div>
</div>
</div>
</div>
<!-- GENDER -->
<div class="section-title">Gender-wise Claims</div>
<div class="grid3">
<div class="panel">
<h2>Total Claim Number</h2>
<div class="body"><div class="chart-wrap medium"><?= $chartHtml('genderCount', 'chartGenderCount') ?></div></div>
</div>
<div class="panel">
<h2>Total Claim Amount</h2>
<div class="body"><div class="chart-wrap medium"><?= $chartHtml('genderAmt', 'chartGenderAmt') ?></div></div>
</div>
<div class="panel">
<h2>Gender Incurred</h2>
<div class="body">
<table>
<thead><tr><th>Gender</th><th class="num">Claim Count</th><th class="num">Claim Incurred Amount</th></tr></thead>
<tbody id="tblGender">
<?php foreach (['Male', 'Female'] as $gLabel):
$grow = null;
foreach ($vm['gender'] ?? [] as $g) {
if (($g['label'] ?? '') === $gLabel) { $grow = $g; break; }
}
$grow = $grow ?: ['label' => $gLabel, 'count' => 0, 'amount' => 0];
?>
<tr>
<td><?= esc($grow['label']) ?></td>
<td class="num"><?= esc($fmt($grow['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($fmt($grow['amount'] ?? 0)) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblGenderCountTotal"><?= esc($fmt($vm['genderTotal']['count'] ?? 0, 0)) ?></td><td class="num" id="tblGenderAmtTotal"><?= esc($fmt($vm['genderTotal']['incurred_amount'] ?? 0)) ?></td></tr></tfoot>
</table>
</div>
</div>
</div>
<!-- CLAIM TYPE -->
<div class="panel">
<h2>Claim Type</h2>
<div class="body">
<table>
<thead><tr><th>Claim Type</th><th class="num">Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Amount</th><th class="num">Claim Amount %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblClaimType">
<?php foreach ($vm['claimType'] ?? [] as $r): ?>
<tr<?= !empty($r['header']) ? ' class="subhead"' : '' ?>>
<td><?= !empty($r['header']) ? '' : '&nbsp;&nbsp;&nbsp;' ?><?= esc($r['type'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['countPct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amount'] ?? 0)) ?></td>
<td class="num"><?= esc($r['amtPct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['incurred'] ?? 0)) ?></td>
<td class="num"><?= esc($r['incPct'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblClaimTypeCount"><?= esc($fmt($vm['claimTypeTotal']['count'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblClaimTypeAmt"><?= esc($fmt($vm['claimTypeTotal']['amount'] ?? 0)) ?></td><td class="num">100.00</td><td class="num" id="tblClaimTypeInc"><?= esc($fmt($vm['claimTypeTotal']['incurred'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
<!-- RELATION / MEMBER TYPE -->
<div class="grid2">
<div class="panel">
<h2>Relation</h2>
<div class="body">
<table>
<thead><tr><th>Relation</th><th class="num">Incurred Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblRelation">
<?php foreach ($vm['relation'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['label'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['cpct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amt'] ?? 0)) ?></td>
<td class="num"><?= esc($r['apct'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblRelationCount"><?= esc($fmt($vm['relationTotal']['count'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblRelationAmt"><?= esc($fmt($vm['relationTotal']['incurred_amount'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
<div class="panel">
<h2>Member Type</h2>
<div class="body">
<table>
<thead><tr><th>Member Type</th><th class="num">Incurred Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblMemberType">
<?php foreach ($vm['memberType'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['label'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['cpct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amt'] ?? 0)) ?></td>
<td class="num"><?= esc($r['apct'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblMemberCount"><?= esc($fmt($vm['memberTypeTotal']['count'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblMemberAmt"><?= esc($fmt($vm['memberTypeTotal']['incurred_amount'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
</div>
<!-- AGE / DIAGNOSIS -->
<div class="grid2">
<div class="panel">
<h2>Age</h2>
<div class="body">
<table>
<thead><tr><th>Age</th><th class="num">Incurred Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblAge">
<?php foreach ($vm['age'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['band'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['cpct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amt'] ?? 0)) ?></td>
<td class="num"><?= esc($r['apct'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblAgeCount"><?= esc($fmt($vm['ageTotal']['count'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblAgeAmt"><?= esc($fmt($vm['ageTotal']['incurred_amount'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
<div class="panel">
<h2>Diagnosis</h2>
<div class="body scroll-y">
<table>
<thead><tr><th>Diagnosis</th><th class="num">Count</th><th class="num">Count %</th><th class="num">Amount</th><th class="num">Amt %</th><th class="num">ACS</th><th class="num">LR %</th></tr></thead>
<tbody id="tblDiagnosis">
<?php foreach ($vm['diagnosis'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['name'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['cpct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amt'] ?? 0)) ?></td>
<td class="num"><?= esc($r['apct'] ?? '') ?></td>
<td class="num"><?= esc(!empty($r['acs']) ? $fmt($r['acs']) : '') ?></td>
<td class="num"><?= esc($r['lr'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblDiagCount"><?= esc($fmt($vm['diagnosisTotal']['count'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblDiagAmt"><?= esc($fmt($vm['diagnosisTotal']['amt'] ?? 0)) ?></td><td class="num">100.00</td><td class="num" id="tblDiagAcs"><?= esc($fmt($vm['diagnosisTotal']['acs'] ?? 0)) ?></td><td class="num" id="tblDiagLr"><?= esc($vm['diagnosisTotal']['lr'] ?? '') ?></td></tr></tfoot>
</table>
</div>
</div>
</div>
<!-- UTILIZATION REPORTS -->
<div class="grid2">
<div class="panel">
<h2>Utilization Report for Employees (In-Patient Claims)</h2>
<div class="body">
<table>
<thead><tr><th>No. Of Claim</th><th class="num">Beneficiaries Count</th><th class="num">Incurred Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblUtilEmp">
<?php
$utilEmp = $vm['utilizationEmployees'] ?? [];
$utilEmpRows = $utilEmp['rows'] ?? (is_array($utilEmp) && isset($utilEmp[0]) ? $utilEmp : []);
foreach ($utilEmpRows as $r):
?>
<tr>
<td><?= esc($r['claims'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['beneficiaries'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($fmt($r['incurredCount'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['countPct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amount'] ?? 0)) ?></td>
<td class="num"><?= esc($r['amountPct'] ?? '') ?></td>
</tr>
<?php endforeach; $utEmp = $utilEmp['total'] ?? []; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblUtilEmpBen"><?= esc($fmt($utEmp['beneficiaries'] ?? 0, 0)) ?></td><td class="num" id="tblUtilEmpCnt"><?= esc($fmt($utEmp['incurredCount'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblUtilEmpAmt"><?= esc($fmt($utEmp['amount'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
<div class="panel">
<h2>Utilization Report for Dependent (In-Patient Claims)</h2>
<div class="body">
<table>
<thead><tr><th>No. of Claims</th><th class="num">Beneficiaries Count</th><th class="num">Incurred Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblUtilDep">
<?php
$utilDep = $vm['utilizationDependents'] ?? [];
$utilDepRows = $utilDep['rows'] ?? (is_array($utilDep) && isset($utilDep[0]) ? $utilDep : []);
foreach ($utilDepRows as $r):
?>
<tr>
<td><?= esc($r['claims'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['beneficiaries'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($fmt($r['incurredCount'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['countPct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amount'] ?? 0)) ?></td>
<td class="num"><?= esc($r['amountPct'] ?? '') ?></td>
</tr>
<?php endforeach; $utDep = $utilDep['total'] ?? []; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblUtilDepBen"><?= esc($fmt($utDep['beneficiaries'] ?? 0, 0)) ?></td><td class="num" id="tblUtilDepCnt"><?= esc($fmt($utDep['incurredCount'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblUtilDepAmt"><?= esc($fmt($utDep['amount'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
</div>
<!-- HOSPITAL NAME -->
<div class="panel">
<h2>Hospital Name</h2>
<div class="body scroll-y">
<table>
<thead><tr><th>Hospital Name</th><th class="num">Incurred Claim Count</th><th class="num">Claim Count %</th><th class="num">Claim Incurred Amount</th><th class="num">Claim Incurred Amount %</th></tr></thead>
<tbody id="tblHospital">
<?php foreach ($vm['hospitals'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['name'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($r['cpct'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['amt'] ?? 0)) ?></td>
<td class="num"><?= esc($r['apct'] ?? '') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblHospitalCount"><?= esc($fmt($vm['hospitalTotal']['count'] ?? 0, 0)) ?></td><td class="num">100.00</td><td class="num" id="tblHospitalAmt"><?= esc($fmt($vm['hospitalTotal']['incurred_amount'] ?? 0)) ?></td><td class="num">100.00</td></tr></tfoot>
</table>
</div>
</div>
<!-- CLAIM PAID / TYPE CHARTS -->
<div class="grid4">
<div class="panel">
<h2>Claim Paid Count By Claim Type</h2>
<div class="body"><div class="chart-wrap medium"><?= $chartHtml('paidCount', 'chartPaidCount') ?></div></div>
</div>
<div class="panel">
<h2>Claim Paid Amount and ACS</h2>
<div class="body"><div class="chart-wrap medium"><?= $chartHtml('paidAmtAcs', 'chartPaidAmtACS') ?></div></div>
</div>
<div class="panel">
<h2>Claim Count By Claim Status</h2>
<div class="body"><div class="chart-wrap medium"><?= $chartHtml('countStatus', 'chartCountStatus') ?></div></div>
</div>
<div class="panel">
<h2>Claim Amount By Claim Status</h2>
<div class="body"><div class="chart-wrap medium"><?= $chartHtml('amtStatus', 'chartAmtStatus') ?></div></div>
</div>
</div>
<!-- HOSPITAL CITY -->
<div class="panel">
<h2>Hospital City</h2>
<div class="body scroll-y">
<table>
<thead><tr><th>Hospital City</th><th class="num">Claim Count</th><th class="num">Claim Amount</th><th class="num">Claim Paid Count</th><th class="num">Claim Paid Amount</th><th class="num">Claim Outstanding Count</th><th class="num">Claim Outstanding Amount</th><th class="num">Total ACS</th></tr></thead>
<tbody id="tblCity">
<?php foreach ($vm['cities'] ?? [] as $r): ?>
<tr>
<td><?= esc($r['city'] ?? '') ?></td>
<td class="num"><?= esc($fmt($r['count'] ?? 0, 0)) ?></td>
<td class="num"><?= esc($fmt($r['amt'] ?? 0)) ?></td>
<td class="num"><?= esc(($r['paidCount'] === '' || $r['paidCount'] === null) ? '—' : $fmt($r['paidCount'], 0)) ?></td>
<td class="num"><?= esc(($r['paidAmt'] === '' || $r['paidAmt'] === null) ? '—' : $fmt($r['paidAmt'])) ?></td>
<td class="num"><?= esc(($r['outCount'] === '' || $r['outCount'] === null) ? '—' : $fmt($r['outCount'], 0)) ?></td>
<td class="num"><?= esc(($r['outAmt'] === '' || $r['outAmt'] === null) ? '—' : $fmt($r['outAmt'])) ?></td>
<td class="num"><?= esc(($r['acs'] === '' || $r['acs'] === null) ? '—' : $fmt($r['acs'])) ?></td>
</tr>
<?php endforeach; $cty = $vm['cityTotals'] ?? []; ?>
</tbody>
<tfoot><tr><td>Total</td><td class="num" id="tblCityCount"><?= esc($fmt($cty['count'] ?? 0, 0)) ?></td><td class="num" id="tblCityAmt"><?= esc($fmt($cty['amt'] ?? 0)) ?></td><td class="num" id="tblCityPaidCnt"><?= esc($fmt($cty['paidCount'] ?? 0, 0)) ?></td><td class="num" id="tblCityPaidAmt"><?= esc($fmt($cty['paidAmt'] ?? 0)) ?></td><td class="num" id="tblCityOutCnt"><?= esc($fmt($cty['outCount'] ?? 0, 0)) ?></td><td class="num" id="tblCityOutAmt"><?= esc($fmt($cty['outAmt'] ?? 0)) ?></td><td class="num" id="tblCityAcs"><?= esc($fmt($cty['acs'] ?? 0)) ?></td></tr></tfoot>
</table>
</div>
</div>
<!-- REGISTRATION MONTH -->
<div class="grid2">
<div class="panel">
<h2>Claim Paid Count and Claim Outstanding Count by Registration Month</h2>
<div class="body"><div class="chart-wrap tall"><?= $chartHtml('monthCount', 'chartMonthCount') ?></div></div>
</div>
<div class="panel">
<h2>Claim Paid Amount, Claim Outstanding Amount by Registration Date</h2>
<div class="body"><div class="chart-wrap tall"><?= $chartHtml('monthAmt', 'chartMonthAmt') ?></div></div>
</div>
</div>
</div>
<?php if (!$embed): ?>
<script src="<?= base_url('assets/libs/chart.js/chart.umd.min.js') ?>"></script>
<?php include APPPATH . 'Views/partials/claims_mis_abhi_script.php'; ?>
<?php endif; ?>
</body>
</html>