1016 lines
44 KiB
PHP
1016 lines
44 KiB
PHP
<?php
|
||
/** @var array $report */
|
||
/** @var array $view_model */
|
||
/** @var int $policy_id */
|
||
/** @var string $pdf_url */
|
||
/** @var bool $embed */
|
||
|
||
use App\Libraries\MediAssistMisReportService as MaFmt;
|
||
|
||
$embed = $embed ?? false;
|
||
$report = $report ?? [];
|
||
$vm = $view_model ?? ($report['view_model'] ?? $report);
|
||
$meta = $report['meta'] ?? ($vm['meta'] ?? []);
|
||
$header = $report['header'] ?? ($vm['header'] ?? []);
|
||
|
||
$indexPolicies = $vm['index_policies'] ?? [];
|
||
$portfolioSummary = $vm['portfolio_summary'] ?? [];
|
||
$policyLives = $vm['policy_lives'] ?? [];
|
||
$policyPremium = $vm['policy_premium'] ?? [];
|
||
$claimStatusRows = $vm['claim_status_rows'] ?? [];
|
||
$claimTypeSections = $vm['claim_type_sections'] ?? [];
|
||
$ipClaimFrequency = $vm['ip_claim_frequency'] ?? [];
|
||
$claimsInError = $vm['claims_in_error'] ?? [];
|
||
$pendingIntro = is_string($vm['pending_intro'] ?? null) ? ($vm['pending_intro'] ?? '') : ($vm['pending_intro']['intro'] ?? '');
|
||
$claimsPendingWith = $vm['claims_pending_with'] ?? [];
|
||
$savings = $vm['savings'] ?? [];
|
||
$topProviders = $vm['top_providers'] ?? [];
|
||
$topAilments = $vm['top_ailments'] ?? [];
|
||
$beneficiary = $vm['beneficiary'] ?? [];
|
||
$ageBands = $vm['age_bands'] ?? [];
|
||
$utilEmployees = $vm['utilization_employees'] ?? [];
|
||
$utilDependents = $vm['utilization_dependents'] ?? [];
|
||
$amountCashless = $vm['amount_bands_cashless'] ?? [];
|
||
$amountReimb = $vm['amount_bands_reimbursement'] ?? [];
|
||
$pendingDetail = $vm['pending_detail'] ?? [];
|
||
$livesMovementSum = $vm['lives_movement_summary'] ?? [];
|
||
$premiumMovementSum = $vm['premium_movement_summary'] ?? [];
|
||
$livesMovementMonthly = $vm['lives_movement_monthly'] ?? [];
|
||
$premiumMovementMonthly = $vm['premium_movement_monthly'] ?? [];
|
||
$glossary = $vm['glossary'] ?? [];
|
||
|
||
$logoSrc = !empty($embed)
|
||
? (rtrim(ROOTPATH, '/\\') . '/public/assets/images/medi_assist.png')
|
||
: base_url('public/assets/images/medi_assist.png');
|
||
|
||
$isBlank = static fn ($v): bool => $v === null || $v === '' || (is_numeric($v) && (float) $v == 0.0);
|
||
|
||
$num = static function ($n, int $d = 0, bool $allowZero = false) use ($isBlank): string {
|
||
if (!$allowZero && $isBlank($n)) {
|
||
return '';
|
||
}
|
||
return MaFmt::fmtNum($n, $d);
|
||
};
|
||
$rs = static function ($n, bool $allowZero = false) use ($isBlank): string {
|
||
if (!$allowZero && $isBlank($n)) {
|
||
return '';
|
||
}
|
||
return MaFmt::fmtRs($n);
|
||
};
|
||
$pct = static function ($n, int $d = 2, bool $allowZero = false) use ($isBlank): string {
|
||
if (!$allowZero && $isBlank($n)) {
|
||
return '';
|
||
}
|
||
return MaFmt::fmtPct($n, $d);
|
||
};
|
||
$lakh = static function ($amount) use ($num): string {
|
||
if ($amount === null || $amount === '' || (is_numeric($amount) && (float) $amount == 0.0)) {
|
||
return '';
|
||
}
|
||
return '₹' . $num((float) $amount / 100000, 2) . ' Lakh';
|
||
};
|
||
|
||
$statusKeys = ['paid', 'doc_shortfall', 'policy_exclusion', 'processed', 'in_process'];
|
||
$statusNums = ['paid' => 1, 'doc_shortfall' => 2, 'policy_exclusion' => 3, 'processed' => 4, 'in_process' => 5];
|
||
$relations = ['Self', 'Spouse', 'Child', 'Parent', 'Others'];
|
||
$ageBandList = [
|
||
'0-5', '6-10', '11-15', '16-20', '21-25', '26-30', '31-35', '36-40',
|
||
'41-45', '46-50', '51-55', '56-60', '61-65', '66-70', '71-more', 'Not classified',
|
||
];
|
||
$utilBuckets = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Above 10'];
|
||
$amountBandList = [
|
||
'Upto 10000', '10001 - 25000', '25001 – 50000', '50001 – 75000', '75001 – 100000',
|
||
'100001 – 200000', '200001 – 300000', '300001 – 400000', '400001 - 500000',
|
||
'500001 - 750000', '750001 - 1000000', 'Above 1000000',
|
||
];
|
||
$livesRelCols = [
|
||
'employee' => 'Employee', 'spouse' => 'Spouse', 'children' => 'Children',
|
||
'father' => 'Father/Father in Law', 'mother' => 'Mother/Mother in Law',
|
||
'siblings' => 'Siblings', 'others' => 'Others',
|
||
];
|
||
|
||
$renderMaFooter = static function () use ($meta): void {
|
||
$by = trim((string) ($meta['generated_by'] ?? ''));
|
||
$at = trim((string) ($meta['upload_at'] ?? $meta['generated_at'] ?? ''));
|
||
echo '<div class="page-footer">Report generated';
|
||
if ($by !== '') {
|
||
echo ' by ' . esc($by);
|
||
}
|
||
if ($at !== '') {
|
||
echo ' at ' . esc($at);
|
||
}
|
||
echo '</div>';
|
||
};
|
||
|
||
$renderMaHeader = static function (array $meta, array $header, string $logoSrc): void {
|
||
?>
|
||
<div class="page-header">
|
||
<div>
|
||
<div class="brand">
|
||
<img src="<?= esc($logoSrc) ?>" alt="Medi Assist" class="brand-logo">
|
||
</div>
|
||
<div class="meta-left">
|
||
<div><span class="label">Insurer :</span> <?= esc($header['insurer_name'] ?? '') ?></div>
|
||
<div><span class="label">Corporate** :</span> <?= esc($header['corporate_name'] ?? '') ?></div>
|
||
</div>
|
||
</div>
|
||
<div class="meta-right">
|
||
<div class="title">Portfolio Analysis Report</div>
|
||
<div class="row"><span class="label">Report as on:</span> <?= esc($meta['report_as_on'] ?? '') ?></div>
|
||
<div class="row"><span class="label">Units in :</span> <?= esc($meta['units'] ?? 'Actuals') ?></div>
|
||
</div>
|
||
</div>
|
||
<?php
|
||
};
|
||
|
||
$renderMetricRow = static function (array $row, bool $isTotal = false, string $prefix = '3.') use ($num, $rs, $pct, $statusNums): void {
|
||
$cls = $isTotal ? ' class="total-row"' : '';
|
||
$label = $row['label'] ?? '';
|
||
if (!$isTotal && isset($row['key']) && isset($statusNums[$row['key']])) {
|
||
$label = $prefix . $statusNums[$row['key']] . ' ' . $label;
|
||
}
|
||
?>
|
||
<tr<?= $cls ?>>
|
||
<td><?= esc($label) ?></td>
|
||
<td><?= esc($num($row['count'] ?? 0, 0, $isTotal)) ?></td>
|
||
<td><?= esc($isTotal ? '' : $pct($row['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($row['claim_amount'] ?? 0, $isTotal)) ?></td>
|
||
<td><?= esc($isTotal ? '' : $pct($row['claim_amount_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($row['incurred'] ?? 0, $isTotal)) ?></td>
|
||
<td><?= esc($isTotal ? '' : $pct($row['incurred_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php
|
||
};
|
||
|
||
$renderClaimTypeBlock = static function (
|
||
int $sectionNum,
|
||
string $mode,
|
||
array $section,
|
||
array $statusKeys,
|
||
array $statusNums
|
||
) use ($num, $rs, $pct): void {
|
||
$modeLabel = $mode === 'cashless' ? 'Cashless' : 'Reimbursement';
|
||
$pad = 'padding-left:14px;';
|
||
?>
|
||
<tr class="group-row"><td style="<?= $pad ?>"><?= (int) $sectionNum ?> <?= esc($modeLabel) ?></td><td colspan="6"></td></tr>
|
||
<?php
|
||
foreach ($statusKeys as $sk) {
|
||
$sr = $section['status_rows'][$sk] ?? [];
|
||
$subNum = $statusNums[$sk] ?? 0;
|
||
?>
|
||
<tr>
|
||
<td style="padding-left:28px;"><?= (int) $sectionNum ?>.<?= (int) $subNum ?> <?= esc($sr['label'] ?? $sk) ?></td>
|
||
<td><?= esc($num($sr['count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($sr['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($sr['claim_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($sr['claim_amount_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($sr['incurred'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($sr['incurred_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php
|
||
}
|
||
$sub = $section['subtotal'] ?? [];
|
||
?>
|
||
<tr class="total-row">
|
||
<td style="<?= $pad ?>">Subtotal</td>
|
||
<td><?= esc($num($sub['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($sub['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($sub['claim_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($sub['claim_amount_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($sub['incurred'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($sub['incurred_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
<?php
|
||
};
|
||
|
||
$renderPendingParty = static function (array $party, bool $allowZero = false) use ($num, $rs): void {
|
||
$c = (int) ($party['count'] ?? 0);
|
||
$a = (float) ($party['amount'] ?? 0);
|
||
if (!$allowZero && $c <= 0 && $a <= 0) {
|
||
echo '<td></td><td></td>';
|
||
return;
|
||
}
|
||
echo '<td>' . esc($num($c, 0, true)) . '</td><td>' . esc($rs($a, true)) . '</td>';
|
||
};
|
||
|
||
$renderAmountBandRow = static function (array $row, array $relations) use ($num, $rs, $pct): void {
|
||
?>
|
||
<tr>
|
||
<td><?= esc($row['band'] ?? '') ?></td>
|
||
<?php foreach ($relations as $rel):
|
||
$r = $row['relations'][$rel] ?? ['count' => 0, 'amount' => 0];
|
||
$hasData = ((int) ($r['count'] ?? 0)) > 0 || ((float) ($r['amount'] ?? 0)) > 0;
|
||
?>
|
||
<td><?= esc($hasData ? $num($r['count'] ?? 0, 0, true) : '') ?></td>
|
||
<td><?= esc($hasData ? $rs($r['amount'] ?? 0, true) : '') ?></td>
|
||
<?php endforeach;
|
||
$t = $row['total'] ?? [];
|
||
$hasTotal = ((int) ($t['count'] ?? 0)) > 0 || ((float) ($t['amount'] ?? 0)) > 0;
|
||
?>
|
||
<td><?= esc($hasTotal ? $num($t['count'] ?? 0, 0, true) : '') ?></td>
|
||
<td><?= esc($hasTotal ? $pct($t['pct'] ?? 0, 2, true) : '') ?></td>
|
||
<td><?= esc($hasTotal ? $rs($t['amount'] ?? 0, true) : '') ?></td>
|
||
</tr>
|
||
<?php
|
||
};
|
||
|
||
$livesInception = 0;
|
||
$livesAddInception = 0;
|
||
$livesAddNew = 0;
|
||
$livesDeletion = 0;
|
||
$livesCurrent = (int) ($policyLives['current'] ?? $header['lives'] ?? 0);
|
||
foreach ($livesMovementSum['rows'] ?? [] as $lmRow) {
|
||
$p = (string) ($lmRow['particular'] ?? '');
|
||
if ($p === 'Inception Lives') {
|
||
$livesInception = (int) ($lmRow['inception_addition'] ?? 0);
|
||
} elseif ($p === 'Addition - Inception Lives') {
|
||
$livesAddInception = (int) ($lmRow['inception_addition'] ?? 0);
|
||
} elseif ($p === 'Addition - New') {
|
||
$livesAddNew = (int) ($lmRow['inception_addition'] ?? 0);
|
||
} elseif ($p === 'Deletion') {
|
||
$livesDeletion = (int) ($lmRow['deletion'] ?? 0);
|
||
}
|
||
}
|
||
$livesAtInceptionAndAddition = $livesInception + $livesAddInception + $livesAddNew;
|
||
if ($livesAtInceptionAndAddition <= 0) {
|
||
$livesAtInceptionAndAddition = (int) ($policyLives['inception'] ?? 0) + (int) ($policyLives['addition'] ?? 0);
|
||
$livesAddInception = (int) ($policyLives['inception'] ?? 0);
|
||
$livesAddNew = (int) ($policyLives['addition'] ?? 0);
|
||
$livesDeletion = (int) ($policyLives['deletion'] ?? 0);
|
||
}
|
||
if ($livesCurrent <= 0) {
|
||
$livesCurrent = (int) ($header['lives'] ?? 0);
|
||
}
|
||
|
||
$savingsTotal = 0.0;
|
||
foreach ($savings as $sv) {
|
||
$savingsTotal += (float) ($sv['amount'] ?? 0);
|
||
}
|
||
|
||
$indexTotals = ['lives' => 0, 'total_premium' => 0.0, 'earned_premium' => 0.0, 'policy_run_days' => 0];
|
||
foreach ($indexPolicies as $ip) {
|
||
$indexTotals['lives'] += (int) ($ip['lives'] ?? 0);
|
||
$indexTotals['total_premium'] += (float) ($ip['total_premium'] ?? 0);
|
||
$indexTotals['earned_premium'] += (float) ($ip['earned_premium'] ?? 0);
|
||
$indexTotals['policy_run_days'] = max($indexTotals['policy_run_days'], (int) ($ip['policy_run_days'] ?? 0));
|
||
}
|
||
|
||
$pageBreak = !empty($embed) ? ' page-break' : '';
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>Medi Assist - Portfolio Analysis Report</title>
|
||
<style>
|
||
:root{
|
||
--blue:#1f4e9c;
|
||
--lightblue:#eaf1fb;
|
||
--header-blue:#dbe7f8;
|
||
--border:#9fb8dd;
|
||
--row-alt:#f4f7fc;
|
||
--red:#e94b5c;
|
||
--text:#222;
|
||
--muted:#555;
|
||
}
|
||
*{box-sizing:border-box;}
|
||
body{
|
||
font-family: DejaVu Sans, 'Segoe UI', Arial, sans-serif;
|
||
color:var(--text);
|
||
background:#f0f2f5;
|
||
margin:0;
|
||
padding:24px;
|
||
}
|
||
.page{
|
||
max-width:1050px;
|
||
background:#fff;
|
||
margin:0 auto 24px auto;
|
||
padding:32px 40px 40px 40px;
|
||
border:1px solid #ddd;
|
||
box-shadow:0 1px 4px rgba(0,0,0,0.06);
|
||
}
|
||
.page-header{
|
||
display:flex;
|
||
justify-content:space-between;
|
||
align-items:flex-start;
|
||
border-bottom:2px solid var(--blue);
|
||
padding-bottom:14px;
|
||
margin-bottom:20px;
|
||
}
|
||
.brand{display:flex;align-items:center;gap:10px;}
|
||
.brand-logo{height:100px;width:auto;max-width:340px;display:block;}
|
||
.meta-left{margin-top:6px;font-size:13px;color:var(--text);}
|
||
.meta-left .label{color:var(--muted);display:inline-block;width:90px;}
|
||
.meta-right{text-align:right;font-size:13px;padding-top:4px;}
|
||
.meta-right .title{font-size:20px;font-weight:700;color:var(--blue);margin-bottom:8px;}
|
||
.meta-right .row{margin-top:3px;}
|
||
.meta-right .label{color:var(--muted);margin-right:6px;}
|
||
h2.section-title{text-align:center;font-size:17px;color:var(--blue);text-decoration:underline;margin:26px 0 14px 0;}
|
||
h3.sub-title{font-size:14px;color:var(--blue);text-decoration:underline;margin:22px 0 10px 0;}
|
||
p.summary-line{font-size:13px;line-height:1.6;color:var(--text);margin:10px 0 20px 0;}
|
||
table{width:100%;border-collapse:collapse;font-size:12.5px;margin-bottom:18px;}
|
||
th,td{border:1px solid var(--border);padding:5px 8px;text-align:right;}
|
||
th:first-child,td:first-child{text-align:left;}
|
||
thead th{background:var(--header-blue);color:var(--blue);font-weight:700;}
|
||
tr.total-row td,tr.total-row th{font-weight:700;background:var(--lightblue);}
|
||
tr.group-row td{font-weight:700;background:#f8fafd;}
|
||
tbody tr:nth-child(even){background:var(--row-alt);}
|
||
.two-col{display:flex;gap:24px;flex-wrap:wrap;}
|
||
.two-col > div{flex:1;min-width:320px;}
|
||
.footnote{font-size:11px;color:var(--muted);margin-top:-8px;margin-bottom:16px;}
|
||
.page-footer{margin-top:30px;padding-top:10px;border-top:1px solid #ddd;font-size:10px;color:#999;text-align:center;}
|
||
.band-table th,.band-table td{font-size:11px;padding:4px 5px;}
|
||
.page-break{page-break-before:always;}
|
||
.table-narrow{max-width:700px;margin:0 auto;}
|
||
.table-narrow.mb{margin:0 auto 24px auto;}
|
||
@media print{body{background:#fff;padding:0;}.page{box-shadow:none;border:none;margin:0 auto;}}
|
||
<?php if (!empty($embed)): ?>
|
||
body{background:#fff;padding:0;}
|
||
.page{max-width:none;margin:0;padding:14px 16px;box-shadow:none;border:none;}
|
||
.page-break{page-break-before:always;}
|
||
.page-header{display:table;width:100%;}
|
||
.page-header > div{display:table-cell;vertical-align:top;}
|
||
.page-header > div:last-child{text-align:right;}
|
||
.two-col{display:table;width:100%;border-spacing:12px 0;}
|
||
.two-col > div{display:table-cell;vertical-align:top;width:50%;}
|
||
h2.section-title{margin:14px 0 10px 0;font-size:16px;}
|
||
h3.sub-title{margin:14px 0 8px 0;font-size:13px;}
|
||
table{font-size:9.5px;table-layout:fixed;page-break-inside:avoid;}
|
||
th,td{padding:4px 3px;word-wrap:break-word;}
|
||
.band-table th,.band-table td{font-size:8.5px;padding:3px 2px;}
|
||
.brand-logo{height:92px;width:auto;max-width:310px;}
|
||
p.summary-line{font-size:11px;}
|
||
.footnote{font-size:9px;}
|
||
<?php endif; ?>
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<!-- PAGE 1: INDEX -->
|
||
<div class="page">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
|
||
<p style="font-weight:700;font-size:13px;">This report has been generated for the following policies:</p>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Policy Number</th>
|
||
<th>Policy Holder</th>
|
||
<th>Policy Start Date</th>
|
||
<th>Policy End Date</th>
|
||
<th>Lives</th>
|
||
<th>Total Premium</th>
|
||
<th>Earned Premium</th>
|
||
<th>Policy Run Days</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($indexPolicies as $ip): ?>
|
||
<tr>
|
||
<td><?= esc($ip['policy_number'] ?? '') ?></td>
|
||
<td><?= esc($ip['policy_holder'] ?? '') ?></td>
|
||
<td><?= esc($ip['policy_start'] ?? '') ?></td>
|
||
<td><?= esc($ip['policy_end'] ?? '') ?></td>
|
||
<td><?= esc($num($ip['lives'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($rs($ip['total_premium'] ?? 0, true)) ?></td>
|
||
<td><?= esc($rs($ip['earned_premium'] ?? 0, true)) ?></td>
|
||
<td><?= esc($num($ip['policy_run_days'] ?? 0, 0, true)) ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td><td></td><td></td><td></td>
|
||
<td><?= esc($num($indexTotals['lives'], 0, true)) ?></td>
|
||
<td><?= esc($rs($indexTotals['total_premium'], true)) ?></td>
|
||
<td><?= esc($rs($indexTotals['earned_premium'], true)) ?></td>
|
||
<td><?= esc($num($indexTotals['policy_run_days'], 0, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
|
||
<!-- PAGE 2: PORTFOLIO REPORT -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
|
||
<h2 class="section-title">Portfolio Report</h2>
|
||
<p class="summary-line">
|
||
As of <?= esc($portfolioSummary['report_date'] ?? $meta['report_as_on'] ?? '') ?>, the portfolio covers
|
||
<?= esc($num($portfolioSummary['lives'] ?? $livesCurrent, 0, true)) ?> lives. Premium updated in our system is
|
||
<?= esc($lakh($portfolioSummary['premium'] ?? $header['total_premium'] ?? 0)) ?>.
|
||
A total of <?= esc($num($portfolioSummary['claims_count'] ?? 0, 0, true)) ?> claims have been reported, with Incurred Amount of
|
||
<?= esc($lakh($portfolioSummary['incurred'] ?? 0)) ?>.
|
||
The Incurred Claims Ratio (ICR) is <?= esc($pct($portfolioSummary['icr_premium'] ?? 0, 2, true)) ?> on premium updated and
|
||
<?= esc($pct($portfolioSummary['icr_earned'] ?? 0, 2, true)) ?> on Earned Premium.
|
||
The claim incidence rate is <?= esc($pct($portfolioSummary['frequency'] ?? 0, 2, true)) ?> (Incurred Hospitalization claims per 100 lives).
|
||
Ratios based on premium in Insurer's System would prevail.
|
||
</p>
|
||
|
||
<div class="two-col">
|
||
<div>
|
||
<h3 class="sub-title">1.0 Policy Lives</h3>
|
||
<table>
|
||
<thead><tr><th>Category</th><th>Count</th></tr></thead>
|
||
<tbody>
|
||
<tr class="group-row"><td>1.1 At Inception* & Addition</td><td><?= esc($num($livesAtInceptionAndAddition, 0, true)) ?></td></tr>
|
||
<tr><td style="padding-left:18px;">1.1.1 At Inception *</td><td><?= esc($num($livesAddInception, 0, true)) ?></td></tr>
|
||
<tr><td style="padding-left:18px;">1.1.2 Addition</td><td><?= esc($num($livesAddNew, 0, true)) ?></td></tr>
|
||
<tr class="group-row"><td>1.2 Deletion</td><td><?= esc($livesDeletion != 0 ? $num($livesDeletion, 0, true) : '') ?></td></tr>
|
||
<tr class="total-row"><td>Current Lives</td><td><?= esc($num($livesCurrent, 0, true)) ?></td></tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote">* Inception Lives inclusive of lives added with policy or subsequently, with coverage date from policy start date</div>
|
||
</div>
|
||
<div>
|
||
<h3 class="sub-title">2 Policy Premium</h3>
|
||
<table>
|
||
<thead><tr><th>Category</th><th>Amount (₹)</th></tr></thead>
|
||
<tbody>
|
||
<tr><td>2.1 First Time</td><td><?= esc($num($policyPremium['first_time'] ?? 0, 0, true)) ?></td></tr>
|
||
<tr><td>2.2 Addition</td><td><?= esc($num($policyPremium['addition'] ?? 0, 0, true)) ?></td></tr>
|
||
<tr><td>2.3 Deletion</td><td><?= esc($num($policyPremium['deletion'] ?? 0, 0, true)) ?></td></tr>
|
||
<tr class="total-row"><td>2.4 Total Premium</td><td><?= esc($num($policyPremium['total'] ?? 0, 0, true)) ?></td></tr>
|
||
<tr class="total-row"><td>2.5 Earned Premium (EP)</td><td><?= esc($num($policyPremium['earned'] ?? 0, 0, true)) ?></td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<h3 class="sub-title">3 By Claim Status</h3>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Claim Status</th><th>Claim Count</th><th>% Claim Count</th><th>Claim Amount (₹)</th><th>% Claim Amount</th><th>Incurred Amount (₹)</th><th>%Incurred Amount</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($statusKeys as $sk):
|
||
$row = $claimStatusRows[$sk] ?? [];
|
||
$renderMetricRow($row, false, '3.');
|
||
endforeach;
|
||
$statusTotal = $claimStatusRows['total'] ?? [];
|
||
$renderMetricRow($statusTotal, true);
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h3 class="sub-title">Claim Type</h3>
|
||
<table>
|
||
<thead>
|
||
<tr><th>Claim Type</th><th>Claim Count</th><th>% Claim Count</th><th>Claim Amount (₹)</th><th>% Claim Amount</th><th>Incurred Amount (₹)</th><th>%Incurred Amount</th></tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr class="group-row"><td>IP</td><td colspan="6"></td></tr>
|
||
<?php
|
||
$ipSection = $claimTypeSections['ip'] ?? [];
|
||
$renderClaimTypeBlock(4, 'cashless', $ipSection['cashless'] ?? [], $statusKeys, $statusNums);
|
||
$renderClaimTypeBlock(5, 'reimb', $ipSection['reimb'] ?? [], $statusKeys, $statusNums);
|
||
$ipTotal = $ipSection['total'] ?? [];
|
||
?>
|
||
<tr class="total-row"><td>Total (IP)</td>
|
||
<td><?= esc($num($ipTotal['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($ipTotal['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($ipTotal['claim_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($ipTotal['claim_amount_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($ipTotal['incurred'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($ipTotal['incurred_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
|
||
<tr class="group-row"><td>OP</td><td colspan="6"></td></tr>
|
||
<?php
|
||
$opSection = $claimTypeSections['op'] ?? [];
|
||
$renderClaimTypeBlock(6, 'cashless', $opSection['cashless'] ?? [], $statusKeys, $statusNums);
|
||
$renderClaimTypeBlock(7, 'reimb', $opSection['reimb'] ?? [], $statusKeys, $statusNums);
|
||
$opTotal = $opSection['total'] ?? [];
|
||
?>
|
||
<tr class="total-row"><td>Total (OP)</td>
|
||
<td><?= esc($num($opTotal['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($opTotal['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($opTotal['claim_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($opTotal['claim_amount_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($opTotal['incurred'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($opTotal['incurred_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
<?php $grandTotal = $claimTypeSections['grand_total'] ?? []; ?>
|
||
<tr class="total-row"><td>Grand Total</td>
|
||
<td><?= esc($num($grandTotal['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($grandTotal['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($grandTotal['claim_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($grandTotal['claim_amount_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($grandTotal['incurred'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($grandTotal['incurred_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="two-col">
|
||
<div>
|
||
<h3 class="sub-title">8 IP Claim Type</h3>
|
||
<table>
|
||
<thead><tr><th>Type</th><th>8.1 No. of IP Claims</th><th>8.2 Claims made per 100 Lives Insured</th></tr></thead>
|
||
<tbody>
|
||
<tr><td>Cashless</td><td><?= esc($num($ipClaimFrequency['cashless_count'] ?? 0)) ?></td><td><?= esc($pct($ipClaimFrequency['cashless_rate'] ?? 0)) ?></td></tr>
|
||
<tr><td>Reimbursement</td><td><?= esc($num($ipClaimFrequency['reimb_count'] ?? 0)) ?></td><td><?= esc($pct($ipClaimFrequency['reimb_rate'] ?? 0)) ?></td></tr>
|
||
<tr class="total-row"><td>Total</td><td><?= esc($num($ipClaimFrequency['total'] ?? 0, 0, true)) ?></td><td><?= esc($pct($ipClaimFrequency['total_rate'] ?? 0, 2, true)) ?></td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div>
|
||
<h3 class="sub-title">10 Claims that are in Error</h3>
|
||
<table>
|
||
<thead><tr><th>Status</th><th>Claim Count</th></tr></thead>
|
||
<tbody>
|
||
<tr><td>Processed</td><td><?= esc($num($claimsInError['count'] ?? 0)) ?></td></tr>
|
||
<tr class="total-row"><td>Total</td><td><?= esc($num($claimsInError['count'] ?? 0, 0, true)) ?></td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<?php if ($pendingIntro !== ''): ?>
|
||
<p class="summary-line"><?= esc($pendingIntro) ?></p>
|
||
<?php endif; ?>
|
||
|
||
<h3 class="sub-title">9 Claims Pending With</h3>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th rowspan="2">Category</th>
|
||
<th colspan="2">Medi Assist</th><th colspan="2">Insurer</th><th colspan="2">Member</th><th colspan="2">Provider</th><th colspan="2">Total</th>
|
||
</tr>
|
||
<tr>
|
||
<th>Claim Count</th><th>Incurred Amount (₹)</th>
|
||
<th>Claim Count</th><th>Incurred Amount (₹)</th>
|
||
<th>Claim Count</th><th>Incurred Amount (₹)</th>
|
||
<th>Claim Count</th><th>Incurred Amount (₹)</th>
|
||
<th>Claim Count</th><th>Incurred Amount (₹)</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($claimsPendingWith as $pw):
|
||
$isTotal = (($pw['label'] ?? '') === 'Total');
|
||
$isGroup = str_contains((string) ($pw['label'] ?? ''), '9.1 IP') || str_contains((string) ($pw['label'] ?? ''), '9.2 OP');
|
||
$pad = '';
|
||
if (str_contains((string) ($pw['label'] ?? ''), '9.1.1') || str_contains((string) ($pw['label'] ?? ''), '9.1.2') || str_contains((string) ($pw['label'] ?? ''), '9.2.1') || str_contains((string) ($pw['label'] ?? ''), '9.2.2')) {
|
||
$pad = 'padding-left:20px;';
|
||
}
|
||
$rowCls = $isTotal || $isGroup ? ' class="' . ($isTotal ? 'total-row' : 'group-row') . '"' : '';
|
||
?>
|
||
<tr<?= $rowCls ?>>
|
||
<td<?= $pad !== '' ? ' style="' . esc($pad, 'attr') . '"' : '' ?>><?= esc($pw['label'] ?? '') ?></td>
|
||
<?php $renderPendingParty($pw['medi_assist'] ?? [], $isTotal); ?>
|
||
<?php $renderPendingParty($pw['insurer'] ?? [], $isTotal); ?>
|
||
<?php $renderPendingParty($pw['member'] ?? [], $isTotal); ?>
|
||
<?php $renderPendingParty($pw['provider'] ?? [], $isTotal); ?>
|
||
<?php $renderPendingParty($pw['total'] ?? [], true); ?>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="footnote">**Please see the policy details page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
|
||
<!-- PAGE 3: SAVINGS -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<h2 class="section-title">Savings Summary</h2>
|
||
<p class="summary-line" style="text-align:center;">Total Savings for the portfolio from Proportionate Deduction, Defined Benefit, Copay, Hospital Discounts, FWA, and Case Management is <?= esc($lakh($savingsTotal)) ?></p>
|
||
<table class="table-narrow">
|
||
<thead><tr><th>Classification</th><th>Claim Count</th><th>Savings (₹)</th></tr></thead>
|
||
<tbody>
|
||
<?php
|
||
$lastGroup = null;
|
||
foreach ($savings as $sv):
|
||
$group = (string) ($sv['group'] ?? '');
|
||
if ($group !== $lastGroup):
|
||
$lastGroup = $group;
|
||
?>
|
||
<tr class="group-row"><td><?= esc($group) ?></td><td></td><td></td></tr>
|
||
<?php endif; ?>
|
||
<tr><td style="padding-left:20px;"><?= esc($sv['label'] ?? '') ?></td><td><?= esc($num($sv['count'] ?? 0)) ?></td><td><?= esc($rs($sv['amount'] ?? 0)) ?></td></tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote" style="text-align:center;">* Includes Claims awaiting for insurer concurrence</div>
|
||
<div class="footnote">**Please see the index page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
<!-- PAGE 4: PROVIDERS & AILMENTS -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<h3 class="sub-title" style="text-align:center;">Top 10 Distribution Across Providers (In-Patient Claims)</h3>
|
||
<table>
|
||
<thead><tr><th>Ranking name</th><th>Claim Count</th><th>% Claim Count</th><th>Approved Amount (₹)</th><th>% Approved Amount</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($topProviders['rows'] ?? [] as $pr): ?>
|
||
<tr>
|
||
<td><?= esc($pr['name'] ?? '') ?></td>
|
||
<td><?= esc($num($pr['count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($pr['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($pr['approved_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($pr['amount_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$pt = $topProviders['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<td><?= esc($num($pt['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($pt['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($pt['approved_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($pt['amount_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote">*Based on Settled/Processed Hospitalization Claims Incurred</div>
|
||
|
||
<h3 class="sub-title" style="text-align:center;">Top 10 Ailment Group wise Summary (In-Patient Claims)</h3>
|
||
<table>
|
||
<thead><tr><th>Ailment Name</th><th>Claim Count</th><th>%Claim Count</th><th>Approved Amount (₹)</th><th>% Approved Amount</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($topAilments['rows'] ?? [] as $ar): ?>
|
||
<tr>
|
||
<td><?= esc($ar['name'] ?? '') ?></td>
|
||
<td><?= esc($num($ar['count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ar['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($ar['approved_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ar['amount_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$at = $topAilments['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<td><?= esc($num($at['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($at['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($at['approved_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($at['amount_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote">*Based on Settled/Processed Hospitalization Claims Counts</div>
|
||
<div class="footnote">**Please see the index page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
<!-- PAGE 5: BENEFICIARY & AGE -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<h3 class="sub-title" style="text-align:center;">Distribution Across Beneficiary and Age Wise Summary (In-Patient Claims)</h3>
|
||
<table class="table-narrow mb">
|
||
<thead><tr><th>Relation Type</th><th>Claim Count</th><th>% Claim Count</th><th>Approved Amount (₹)</th><th>% Approved Amount</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($beneficiary['rows'] ?? [] as $br): ?>
|
||
<tr>
|
||
<td><?= esc($br['relation'] ?? '') ?></td>
|
||
<td><?= esc($num($br['count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($br['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($br['approved_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($br['amount_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$bt = $beneficiary['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<td><?= esc($num($bt['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($bt['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($bt['approved_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($bt['amount_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h3 class="sub-title" style="text-align:center;">Age Wise Summary (In-Patient Claims)</h3>
|
||
<table>
|
||
<thead><tr><th>Age Band Bucket</th><th>Lives</th><th>Claim Count</th><th>% Claim Count</th><th>Approved Amount (₹)</th><th>% Approved Amount</th></tr></thead>
|
||
<tbody>
|
||
<?php
|
||
$ageRowsByBand = [];
|
||
foreach ($ageBands['rows'] ?? [] as $ab) {
|
||
$ageRowsByBand[$ab['band'] ?? ''] = $ab;
|
||
}
|
||
foreach ($ageBandList as $band):
|
||
$ab = $ageRowsByBand[$band] ?? ['band' => $band, 'lives' => 0, 'count' => 0, 'count_pct' => 0, 'approved_amount' => 0, 'amount_pct' => 0];
|
||
?>
|
||
<tr>
|
||
<td><?= esc($band) ?></td>
|
||
<td><?= esc($num($ab['lives'] ?? 0)) ?></td>
|
||
<td><?= esc($num($ab['count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ab['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($ab['approved_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ab['amount_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$abt = $ageBands['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<td><?= esc($num($abt['lives'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($num($abt['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($abt['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($abt['approved_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($abt['amount_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote">**Please see the index page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
|
||
<!-- PAGE 6: UTILIZATION -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<h3 class="sub-title" style="text-align:center;">Utilization Report for Employees (In-Patient Claims)</h3>
|
||
<table class="table-narrow mb">
|
||
<thead><tr><th>No. of Claims</th><th>Employees Claim Count</th><th>% Claim Count</th><th>Approved Amount (₹)</th><th>% Approved Amount</th></tr></thead>
|
||
<tbody>
|
||
<?php
|
||
$utilEmpRows = [];
|
||
foreach ($utilEmployees['rows'] ?? [] as $ur) {
|
||
$utilEmpRows[$ur['label'] ?? ''] = $ur;
|
||
}
|
||
foreach ($utilBuckets as $bucket):
|
||
$ur = $utilEmpRows[$bucket] ?? ['label' => $bucket, 'member_count' => 0, 'count_pct' => 0, 'approved_amount' => 0, 'amount_pct' => 0];
|
||
?>
|
||
<tr>
|
||
<td><?= esc($bucket) ?></td>
|
||
<td><?= esc($num($ur['member_count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ur['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($ur['approved_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ur['amount_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$uet = $utilEmployees['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<td><?= esc($num($uet['member_count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($uet['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($uet['approved_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($uet['amount_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h3 class="sub-title" style="text-align:center;">Utilization Report for Dependents (In-Patient Claims)</h3>
|
||
<table class="table-narrow mb">
|
||
<thead><tr><th>No. of Claims</th><th>Dependents Claim Count</th><th>% Claim Count</th><th>Approved Amount (₹)</th><th>% Approved Amount</th></tr></thead>
|
||
<tbody>
|
||
<?php
|
||
$utilDepRows = [];
|
||
foreach ($utilDependents['rows'] ?? [] as $ur) {
|
||
$utilDepRows[$ur['label'] ?? ''] = $ur;
|
||
}
|
||
foreach ($utilBuckets as $bucket):
|
||
$ur = $utilDepRows[$bucket] ?? ['label' => $bucket, 'member_count' => 0, 'count_pct' => 0, 'approved_amount' => 0, 'amount_pct' => 0];
|
||
?>
|
||
<tr>
|
||
<td><?= esc($bucket) ?></td>
|
||
<td><?= esc($num($ur['member_count'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ur['count_pct'] ?? 0)) ?></td>
|
||
<td><?= esc($rs($ur['approved_amount'] ?? 0)) ?></td>
|
||
<td><?= esc($pct($ur['amount_pct'] ?? 0)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$udt = $utilDependents['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<td><?= esc($num($udt['member_count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($udt['count_pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($udt['approved_amount'] ?? 0, true)) ?></td>
|
||
<td><?= esc($pct($udt['amount_pct'] ?? 0, 2, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote">**Please see the index page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
<!-- PAGE 7: AMOUNT BANDS -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
|
||
<?php
|
||
$renderAmountBandsTable = static function (string $title, array $bandsData) use (
|
||
$renderMaHeader, $meta, $header, $logoSrc, $amountBandList, $relations, $renderAmountBandRow, $num, $rs, $pct
|
||
): void {
|
||
?>
|
||
<h3 class="sub-title" style="text-align:center;"><?= esc($title) ?></h3>
|
||
<table class="band-table">
|
||
<thead>
|
||
<tr>
|
||
<th rowspan="2">Amount Band</th>
|
||
<th colspan="2">Self</th><th colspan="2">Spouse</th><th colspan="2">Child</th><th colspan="2">Parent</th><th colspan="2">Others</th>
|
||
<th colspan="3">Total</th>
|
||
</tr>
|
||
<tr>
|
||
<th>Count</th><th>Amount</th><th>Count</th><th>Amount</th><th>Count</th><th>Amount</th><th>Count</th><th>Amount</th><th>Count</th><th>Amount</th>
|
||
<th>Count</th><th>%</th><th>Amount</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php
|
||
$rowsByBand = [];
|
||
foreach ($bandsData['rows'] ?? [] as $br) {
|
||
$rowsByBand[$br['band'] ?? ''] = $br;
|
||
}
|
||
foreach ($amountBandList as $band) {
|
||
$renderAmountBandRow($rowsByBand[$band] ?? ['band' => $band, 'relations' => array_fill_keys($relations, ['count' => 0, 'amount' => 0]), 'total' => ['count' => 0, 'amount' => 0, 'pct' => 0]], $relations);
|
||
}
|
||
$bandTotal = $bandsData['total'] ?? [];
|
||
?>
|
||
<tr class="total-row">
|
||
<td>Total</td>
|
||
<?php foreach ($relations as $rel):
|
||
$r = $bandTotal['relations'][$rel] ?? ['count' => 0, 'amount' => 0];
|
||
$has = ((int) ($r['count'] ?? 0)) > 0 || ((float) ($r['amount'] ?? 0)) > 0;
|
||
?>
|
||
<td><?= esc($has ? $num($r['count'] ?? 0, 0, true) : '') ?></td>
|
||
<td><?= esc($has ? $rs($r['amount'] ?? 0, true) : '') ?></td>
|
||
<?php endforeach; ?>
|
||
<td><?= esc($num($bandTotal['count'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($pct($bandTotal['pct'] ?? 0, 2, true)) ?></td>
|
||
<td><?= esc($rs($bandTotal['amount'] ?? 0, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<?php
|
||
};
|
||
$renderAmountBandsTable('Distribution Across Amount Bands (In-Patient Cashless Claims)', $amountCashless);
|
||
$renderAmountBandsTable('Distribution Across Amount Bands (In-Patient Reimbursement Claims)', $amountReimb);
|
||
?>
|
||
<div class="footnote">**Please see the index page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
|
||
<!-- PAGE 8: PENDING DETAIL -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<table style="font-size:11px;">
|
||
<thead><tr><th>No. of Claims Pending with</th><th>Medi Assist</th><th>Insurer</th><th>Member</th><th>Provider</th><th>Total</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($pendingDetail['rows'] ?? [] as $pd):
|
||
$counts = $pd['counts'] ?? [];
|
||
$isGroup = !empty($pd['is_group']);
|
||
$pad = '';
|
||
$label = (string) ($pd['label'] ?? '');
|
||
if (!$isGroup && $label !== 'Subtotal') {
|
||
$pad = 'padding-left:24px;';
|
||
} elseif ($isGroup && !in_array($label, ['IP', 'OP', 'Subtotal', 'Total (IP)', 'Total (OP)', 'Grand Total'], true) && $label !== 'Cashless' && $label !== 'Reimbursement') {
|
||
// mode group headers
|
||
}
|
||
if ($label === 'Cashless' || $label === 'Reimbursement') {
|
||
$pad = 'padding-left:14px;';
|
||
}
|
||
$cls = $isGroup ? ' class="group-row"' : '';
|
||
if (in_array($label, ['Subtotal', 'Total (IP)', 'Total (OP)', 'Grand Total'], true)) {
|
||
$cls = ' class="total-row"';
|
||
}
|
||
?>
|
||
<tr<?= $cls ?>>
|
||
<td<?= $pad !== '' ? ' style="' . esc($pad, 'attr') . '"' : '' ?>><?= esc($label) ?></td>
|
||
<td><?= esc($num($counts['medi_assist'] ?? 0)) ?></td>
|
||
<td><?= esc($num($counts['insurer'] ?? 0)) ?></td>
|
||
<td><?= esc($num($counts['member'] ?? 0)) ?></td>
|
||
<td><?= esc($num($counts['provider'] ?? 0)) ?></td>
|
||
<td><?= esc($num($counts['total'] ?? 0, 0, in_array($label, ['Subtotal', 'Total (IP)', 'Total (OP)', 'Grand Total'], true))) ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
<!-- PAGE 9: LIVES MOVEMENT -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<table class="table-narrow">
|
||
<thead><tr><th>Particulars</th><th>Inception/Addition</th><th>Deletion</th><th>Current Lives</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($livesMovementSum['rows'] ?? [] as $lr): ?>
|
||
<tr>
|
||
<td><?= esc($lr['particular'] ?? '') ?></td>
|
||
<td><?= esc($num($lr['inception_addition'] ?? null)) ?></td>
|
||
<td><?= esc($lr['deletion'] !== null && $lr['deletion'] !== '' ? $num($lr['deletion'], 0, true) : '') ?></td>
|
||
<td><?= esc($num($lr['current'] ?? null)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$lmt = $livesMovementSum['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td></td>
|
||
<td><?= esc($num($lmt['inception_addition'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($lmt['deletion'] !== null && $lmt['deletion'] !== '' ? $num($lmt['deletion'], 0, true) : '') ?></td>
|
||
<td><?= esc($num($lmt['current'] ?? 0, 0, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<table style="font-size:10.5px;">
|
||
<thead>
|
||
<tr>
|
||
<th rowspan="2">Month</th><th rowspan="2">Particulars</th>
|
||
<th colspan="2">Employee</th><th colspan="2">Spouse</th><th colspan="2">Children</th>
|
||
<th colspan="2">Father/Father in Law</th><th colspan="2">Mother/Mother in Law</th>
|
||
<th colspan="2">Siblings</th><th colspan="2">Others</th>
|
||
</tr>
|
||
<tr>
|
||
<th>Add</th><th>Del</th><th>Add</th><th>Del</th><th>Add</th><th>Del</th><th>Add</th><th>Del</th><th>Add</th><th>Del</th><th>Add</th><th>Del</th><th>Add</th><th>Del</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($livesMovementMonthly['rows'] ?? [] as $mr): ?>
|
||
<tr>
|
||
<td><?= esc($mr['month'] ?? '') ?></td>
|
||
<td><?= esc($mr['particular'] ?? '') ?></td>
|
||
<?php foreach (array_keys($livesRelCols) as $relKey): ?>
|
||
<td><?= esc($num($mr[$relKey . '_add'] ?? null)) ?></td>
|
||
<td><?= esc($mr[$relKey . '_del'] !== null && $mr[$relKey . '_del'] !== '' ? $num($mr[$relKey . '_del'], 0, true) : '') ?></td>
|
||
<?php endforeach; ?>
|
||
</tr>
|
||
<?php endforeach;
|
||
$mmt = $livesMovementMonthly['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td colspan="2">Total</td>
|
||
<?php foreach (array_keys($livesRelCols) as $relKey): ?>
|
||
<td><?= esc($num($mmt[$relKey . '_add'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($num($mmt[$relKey . '_del'] ?? 0, 0, true)) ?></td>
|
||
<?php endforeach; ?>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
<!-- PAGE 10: PREMIUM MOVEMENT -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<?php $renderMaHeader($meta, $header, $logoSrc); ?>
|
||
<table class="table-narrow">
|
||
<thead><tr><th>Particulars</th><th>Premium</th><th>Refund</th><th>Total</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($premiumMovementSum['rows'] ?? [] as $pr): ?>
|
||
<tr>
|
||
<td><?= esc($pr['particular'] ?? '') ?></td>
|
||
<td><?= esc($num($pr['premium'] ?? null)) ?></td>
|
||
<td><?= esc($pr['refund'] !== null && $pr['refund'] !== '' ? $num($pr['refund'], 0, true) : '') ?></td>
|
||
<td><?= esc($num($pr['total'] ?? null, 0, true)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$pmt = $premiumMovementSum['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td>Closing Premium</td>
|
||
<td><?= esc($num($pmt['premium'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($num($pmt['refund'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($num($pmt['total'] ?? 0, 0, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<table class="table-narrow">
|
||
<thead><tr><th>Month</th><th>Particulars</th><th>Premium</th><th>Refund</th><th>Total</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($premiumMovementMonthly['rows'] ?? [] as $pr): ?>
|
||
<tr>
|
||
<td><?= esc($pr['month'] ?? '') ?></td>
|
||
<td><?= esc($pr['particular'] ?? '') ?></td>
|
||
<td><?= esc($num($pr['premium'] ?? null)) ?></td>
|
||
<td><?= esc($pr['refund'] !== null && $pr['refund'] !== '' ? $num($pr['refund'], 0, true) : '') ?></td>
|
||
<td><?= esc($num($pr['total'] ?? null, 0, true)) ?></td>
|
||
</tr>
|
||
<?php endforeach;
|
||
$pmmt = $premiumMovementMonthly['total'] ?? []; ?>
|
||
<tr class="total-row">
|
||
<td><?= esc($pmmt['month'] ?? '') ?></td>
|
||
<td><?= esc($pmmt['particular'] ?? 'Closing Premium') ?></td>
|
||
<td><?= esc($num($pmmt['premium'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($num($pmmt['refund'] ?? 0, 0, true)) ?></td>
|
||
<td><?= esc($num($pmmt['total'] ?? 0, 0, true)) ?></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
<!-- PAGE 11: GLOSSARY -->
|
||
<div class="page<?= esc($pageBreak) ?>">
|
||
<div style="text-align:right;font-size:12px;color:var(--muted);margin-bottom:20px;">Report as on: <?= esc($meta['report_as_on'] ?? '') ?></div>
|
||
<h2 class="section-title">Glossary</h2>
|
||
<table>
|
||
<thead><tr><th>Label</th><th style="text-align:left;">Description</th></tr></thead>
|
||
<tbody>
|
||
<?php foreach ($glossary as $g): ?>
|
||
<tr>
|
||
<td><?= esc($g['label'] ?? '') ?></td>
|
||
<td style="text-align:left;"><?= esc($g['description'] ?? '') ?></td>
|
||
</tr>
|
||
<?php endforeach; ?>
|
||
</tbody>
|
||
</table>
|
||
<div class="footnote">**Please see the index page for more information on the policies that were used to generate this report.</div>
|
||
<?php $renderMaFooter(); ?>
|
||
</div>
|
||
|
||
</body>
|
||
</html>
|