From b98528d3e3629eb00ddc70f39434eb6e2808178c Mon Sep 17 00:00:00 2001 From: Antigravity Date: Thu, 19 Nov 2026 14:43:24 +0530 Subject: [PATCH] fix(print): enable full multi-page report printing, unconstrain viewport scrollbars, and add executive hospital letterhead --- .../src/components/DataTable/DataTable.tsx | 47 ++++---- frontend/src/index.css | 90 +++++++++++----- frontend/src/pages/AIReportPage.tsx | 101 +++++++++++++++++- frontend/src/pages/ReportDetailPage.tsx | 10 +- 4 files changed, 196 insertions(+), 52 deletions(-) diff --git a/frontend/src/components/DataTable/DataTable.tsx b/frontend/src/components/DataTable/DataTable.tsx index b8f75f3..b3736f6 100644 --- a/frontend/src/components/DataTable/DataTable.tsx +++ b/frontend/src/components/DataTable/DataTable.tsx @@ -289,11 +289,11 @@ export function DataTable({ {flexRender(header.column.columnDef.header, header.getContext())} {header.column.getCanSort() && ( header.column.getIsSorted() === "asc" ? ( - + ) : header.column.getIsSorted() === "desc" ? ( - + ) : ( - + ) )} @@ -335,23 +335,30 @@ export function DataTable({ ) : ( - visibleRows.map((row) => ( - onRowClick?.(row.original)} - > - {row.getVisibleCells().map((cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - - )) + (() => { + const visibleRowIdSet = new Set(visibleRows.map((r) => r.id)); + return filteredRows.map((row) => { + const isVisibleOnScreen = visibleRowIdSet.has(row.id); + return ( + onRowClick?.(row.original)} + > + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + ); + }); + })() )} diff --git a/frontend/src/index.css b/frontend/src/index.css index 38b452c..6b63c56 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -21,12 +21,50 @@ .print-only { display: none !important; } + .print-table-row { + display: none !important; + } } @media print { @page { size: A4 landscape; - margin: 8mm 10mm; + margin: 8mm 8mm; + } + + /* Unconstrain viewport and scroll containers so full multi-page content flows naturally */ + html, + body { + height: auto !important; + min-height: 0 !important; + max-height: none !important; + overflow: visible !important; + background: #ffffff !important; + color: #102C52 !important; + font-size: 9.5px !important; + line-height: 1.35 !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; + } + + #root, + #root > div, + .h-screen, + .overflow-hidden, + .overflow-y-auto, + .overflow-x-auto, + main { + height: auto !important; + min-height: 0 !important; + max-height: none !important; + overflow: visible !important; + position: static !important; + display: block !important; + width: 100% !important; + max-width: 100% !important; + padding: 0 !important; + margin: 0 !important; + box-shadow: none !important; } aside, @@ -40,23 +78,11 @@ display: block !important; } - body { - background: #ffffff !important; - color: #0f172a !important; - -webkit-print-color-adjust: exact !important; - print-color-adjust: exact !important; - font-size: 10px !important; - line-height: 1.35 !important; + .print-table-row { + display: table-row !important; } - main { - padding: 0 !important; - margin: 0 !important; - overflow: visible !important; - max-width: 100% !important; - } - - /* Prevent elements from breaking across PDF pages */ + /* Prevent elements from breaking awkwardly across pages */ .print-break-inside-avoid { break-inside: avoid !important; page-break-inside: avoid !important; @@ -67,7 +93,7 @@ page-break-before: always !important; } - /* Clean up card shadows and borders for crisp PDF generation */ + /* Clean up card shadows and borders for crisp printing */ .shadow-sm, .shadow, .shadow-md, @@ -75,11 +101,12 @@ box-shadow: none !important; } - /* High-fidelity PDF Table Styling */ + /* High-fidelity PDF & Print Table Styling */ table { border-collapse: collapse !important; width: 100% !important; page-break-inside: auto; + table-layout: auto !important; } thead { @@ -96,28 +123,39 @@ } th { - background-color: #1e3a8a !important; + background-color: #102C52 !important; color: #ffffff !important; font-weight: 600 !important; - font-size: 9.5px !important; - padding: 5px 6px !important; - border: 1px solid #1e293b !important; - text-align: center !important; + font-size: 9px !important; + padding: 4px 6px !important; + border: 1px solid #102C52 !important; + text-align: left !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; } td { border: 1px solid #cbd5e1 !important; - font-size: 9px !important; - padding: 4px 6px !important; + font-size: 8.5px !important; + padding: 3.5px 5px !important; color: #0f172a !important; + -webkit-print-color-adjust: exact !important; + print-color-adjust: exact !important; } tbody tr:nth-child(even) td { background-color: #f8fafc !important; } - /* Force chart svg visibility */ + /* Ensure chart SVG visibility in print mode */ + .recharts-responsive-container { + width: 100% !important; + min-width: 100% !important; + height: 220px !important; + } + .recharts-wrapper { margin: 0 auto !important; + width: 100% !important; } } diff --git a/frontend/src/pages/AIReportPage.tsx b/frontend/src/pages/AIReportPage.tsx index 4187abe..55ccbe8 100644 --- a/frontend/src/pages/AIReportPage.tsx +++ b/frontend/src/pages/AIReportPage.tsx @@ -39,7 +39,7 @@ import { } from "@/api/ai"; import { categoriesApi, departmentsApi } from "@/api/masters"; import { useAuthStore } from "@/hooks/useAuth"; -import { formatINR } from "@/lib/format"; +import { formatDateTime, formatINR } from "@/lib/format"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; @@ -527,6 +527,64 @@ export function AIReportPage() { return (
+ {/* Print-Only Official Hospital Letterhead & Scope */} +
+
+
+ XYZ Hospital +
+
+ XYZ HOSPITAL +
+
+ NABH Accredited Tertiary Care Hospital • Department of Clinical Engineering +
+
+ 27, Sadashiv Peth, Pune, Maharashtra 411030 • Tel: +91 20 6609 6000 +
+
+
+
+
+ Executive AI & Cost Analysis +
+
+ Ref: XYZ-BME-AI-REP +
+
+ Date: {formatDateTime(new Date().toISOString())} IST +
+ {user?.name && ( +
+ Generated by: {user.name} ({user.role?.replace(/_/g, " ").toUpperCase()}) +
+ )} +
+
+ + {/* Print Filter / Scope summary bar */} +
+
+
+ Analysis:{" "} + AI Report & Cost Analysis +
+
+ Period:{" "} + {period.toUpperCase()} +
+
+ Summary Mode:{" "} + {statusChipLabel} +
+
+
+
+ {/* Header + Mode Segmented Toggle + Status Chip */}
@@ -1545,6 +1603,47 @@ export function AIReportPage() { All figures are calculated deterministically from hospital records. Summaries are advisory only and never replace clinical or administrative sign-off.
+ + {/* Hospital Tripartite Sign-off Block (Print / PDF Only) */} +
+
+ Hospital Engineering Audit & Verification Sign-off (NABH Chapter FMS) + XYZ Hospital +
+
+
+
1. PREPARED BY
+
+
+
Name: {user?.name || "Biomedical Engineer"}
+
Role: {user?.role?.replace(/_/g, " ").toUpperCase() || "BIOMEDICAL"}
+
Date: {new Date().toLocaleDateString("en-IN")}
+
+
+
+
2. VERIFIED BY
+
+
+
Name: __________________________
+
Role: HOD / Biomedical In-Charge
+
Date: ____ / ____ / ________
+
+
+
+
3. APPROVED BY
+
+
+
Name: __________________________
+
Role: Medical Superintendent / Director
+
Date: ____ / ____ / ________
+
+
+
+
+ Official Hospital Record • XYZ Hospital • Confidential • Retain for 7 Years + AMS Portal Generated • NABH Compliant +
+
); } diff --git a/frontend/src/pages/ReportDetailPage.tsx b/frontend/src/pages/ReportDetailPage.tsx index bb8e731..e37dc06 100644 --- a/frontend/src/pages/ReportDetailPage.tsx +++ b/frontend/src/pages/ReportDetailPage.tsx @@ -398,7 +398,7 @@ export function ReportDetailPage() { return (
{/* Print-Only Official Hospital Letterhead & Scope */} -
+
-
+
XYZ HOSPITAL
@@ -419,11 +419,11 @@ export function ReportDetailPage() {
-
+
Audit & Operational Record
- Ref: PHRC-BME-{key?.toUpperCase() ?? "REP"} + Ref: XYZ-BME-{key?.toUpperCase() ?? "REP"}
Date: {formatDateTime(new Date().toISOString())} IST @@ -1032,7 +1032,7 @@ export function ReportDetailPage() { /> {/* Hospital Tripartite Sign-off Block (Print / PDF Only) */} -
+
Hospital Engineering Audit & Verification Sign-off (NABH Chapter FMS) XYZ Hospital