import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from '@/components/ui/table' const FALLGRUPPEN_LABELS: Record = { onko: 'Onkologie', kardio: 'Kardiologie', intensiv: 'Intensivmedizin', galle: 'Gallenblase', sd: 'Schilddrüse', } const FALLGRUPPEN_KEYS = ['onko', 'kardio', 'intensiv', 'galle', 'sd'] as const function fmt(n: number): string { return n.toLocaleString('de-DE') } function NoData() { return (

Keine Daten verfügbar.

) } // --------------------------------------------------------------------------- // Sheet 1 — KW gesamt // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-explicit-any function Sheet1({ data }: { data: any }) { if (!data?.weekly?.length) return const COLS = [ { key: 'erstberatungen', label: 'Erstberatungen' }, { key: 'unterlagen', label: 'Unterlagen' }, { key: 'ablehnungen', label: 'Ablehnungen' }, { key: 'keine_rm', label: 'Keine Rückmeldung' }, { key: 'gutachten', label: 'Gutachten' }, ] as const // eslint-disable-next-line @typescript-eslint/no-explicit-any const rows = (data.weekly as any[]).filter((row) => COLS.some((c) => (row[c.key] ?? 0) !== 0), ) const totals = COLS.reduce( (acc, c) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any acc[c.key] = rows.reduce((s: number, r: any) => s + (r[c.key] ?? 0), 0) return acc }, {} as Record, ) return ( KW {COLS.map((c) => ( {c.label} ))} {rows.map((row) => ( KW {row.kw} {COLS.map((c) => ( {fmt(row[c.key] ?? 0)} ))} ))} Gesamt {COLS.map((c) => ( {fmt(totals[c.key])} ))}
) } // --------------------------------------------------------------------------- // Sheet 2 — Fachgebiete // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-explicit-any function Sheet2({ data, fallgruppen }: { data: any; fallgruppen: readonly string[] }) { if (!data?.weekly?.length) return const SUB_COLS = ['anzahl', 'gutachten', 'keine_rm'] as const const SUB_LABELS: Record = { anzahl: 'Anzahl', gutachten: 'Gutachten', keine_rm: 'Keine RM', } // eslint-disable-next-line @typescript-eslint/no-explicit-any const isRowEmpty = (row: any) => fallgruppen.every((fg) => SUB_COLS.every((sc) => (row[fg]?.[sc] ?? 0) === 0), ) // eslint-disable-next-line @typescript-eslint/no-explicit-any const rows = (data.weekly as any[]).filter((row) => !isRowEmpty(row)) const totals = fallgruppen.reduce( (acc, fg) => { acc[fg] = SUB_COLS.reduce( (sub, sc) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any sub[sc] = rows.reduce((s: number, r: any) => s + (r[fg]?.[sc] ?? 0), 0) return sub }, {} as Record, ) return acc }, {} as Record>, ) return ( KW {fallgruppen.map((fg) => ( {FALLGRUPPEN_LABELS[fg] ?? fg} ))} {fallgruppen.map((fg) => SUB_COLS.map((sc) => ( {SUB_LABELS[sc]} )), )} {rows.map((row) => ( KW {row.kw} {fallgruppen.map((fg) => SUB_COLS.map((sc) => ( {fmt(row[fg]?.[sc] ?? 0)} )), )} ))} Gesamt {fallgruppen.map((fg) => SUB_COLS.map((sc) => ( {fmt(totals[fg][sc])} )), )}
) } // --------------------------------------------------------------------------- // Sheet 3 — Gutachten // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-explicit-any function Sheet3({ data, fallgruppen }: { data: any; fallgruppen: readonly string[] }) { if (!data?.weekly?.length) return const SUB_COLS = ['gutachten', 'alternative', 'bestaetigung'] as const const SUB_LABELS: Record = { gutachten: 'Gutachten', alternative: 'Alternative', bestaetigung: 'Bestätigung', } const GROUP_KEYS = ['gesamt', ...fallgruppen] as const const GROUP_LABELS: Record = { gesamt: 'Gesamt', ...FALLGRUPPEN_LABELS, } // eslint-disable-next-line @typescript-eslint/no-explicit-any const isRowEmpty = (row: any) => GROUP_KEYS.every((grp) => SUB_COLS.every((sc) => (row[grp]?.[sc] ?? 0) === 0), ) // eslint-disable-next-line @typescript-eslint/no-explicit-any const rows = (data.weekly as any[]).filter((row) => !isRowEmpty(row)) const totals = GROUP_KEYS.reduce( (acc, grp) => { acc[grp] = SUB_COLS.reduce( (sub, sc) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any sub[sc] = rows.reduce((s: number, r: any) => s + (r[grp]?.[sc] ?? 0), 0) return sub }, {} as Record, ) return acc }, {} as Record>, ) return ( KW {GROUP_KEYS.map((grp) => ( {GROUP_LABELS[grp] ?? grp} ))} {GROUP_KEYS.map((grp) => SUB_COLS.map((sc) => ( {SUB_LABELS[sc]} )), )} {rows.map((row) => ( KW {row.kw} {GROUP_KEYS.map((grp) => SUB_COLS.map((sc) => ( {fmt(row[grp]?.[sc] ?? 0)} )), )} ))} Gesamt {GROUP_KEYS.map((grp) => SUB_COLS.map((sc) => ( {fmt(totals[grp][sc])} )), )}
) } // --------------------------------------------------------------------------- // Sheet 4 — Therapieänderungen // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-explicit-any function Sheet4({ data }: { data: any }) { if (!data?.weekly?.length) return const COLS = [ { key: 'gutachten', label: 'Gutachten' }, { key: 'ta_ja', label: 'Therapieänderung Ja' }, { key: 'ta_nein', label: 'Therapieänderung Nein' }, { key: 'diagnosekorrektur', label: 'Diagnosekorrektur' }, { key: 'unterversorgung', label: 'Unterversorgung' }, { key: 'uebertherapie', label: 'Übertherapie' }, ] as const // eslint-disable-next-line @typescript-eslint/no-explicit-any const rows = (data.weekly as any[]).filter((row) => COLS.some((c) => (row[c.key] ?? 0) !== 0), ) const totals = COLS.reduce( (acc, c) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any acc[c.key] = rows.reduce((s: number, r: any) => s + (r[c.key] ?? 0), 0) return acc }, {} as Record, ) return ( KW {COLS.map((c) => ( {c.label} ))} {rows.map((row) => ( KW {row.kw} {COLS.map((c) => ( {fmt(row[c.key] ?? 0)} ))} ))} Gesamt {COLS.map((c) => ( {fmt(totals[c.key])} ))}
) } // --------------------------------------------------------------------------- // Sheet 5 — ICD onko // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-explicit-any function Sheet5({ data }: { data: any }) { if (!data?.icd_codes?.length) return // eslint-disable-next-line @typescript-eslint/no-explicit-any const rows = data.icd_codes as any[] const total = rows.reduce((s: number, r) => s + (r.count ?? 0), 0) return ( ICD-Code Anzahl {rows.map((row) => ( {row.icd} {fmt(row.count ?? 0)} ))} Gesamt {fmt(total)}
) } // --------------------------------------------------------------------------- // ReportViewer — Main Component // --------------------------------------------------------------------------- // eslint-disable-next-line @typescript-eslint/no-explicit-any export function ReportViewer({ data }: { data: Record }) { const fallgruppen: readonly string[] = data?.fallgruppen ?? FALLGRUPPEN_KEYS const hasOnko = fallgruppen.includes('onko') return ( KW gesamt Fachgebiete Gutachten Therapieänderungen {hasOnko && ICD onko} {hasOnko && ( )} ) }