mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 19:33:41 +00:00
feat: dashboard, cases, import, and ICD pages with full functionality
Implement the four core frontend pages for the DAK Zweitmeinungs-Portal: - DashboardPage: KPI cards, weekly stacked bar chart, fallgruppen donut chart, year selector - CasesPage: filterable/searchable paginated table with detail slide-out and inline ICD editing - ImportPage: CSV upload with preview/confirm, ICD Excel upload, import history log - IcdPage: reuses CasesPage with pending-icd-only filter Also adds shadcn/ui components (table, select, tabs, skeleton, scroll-area) and new TypeScript types for import log and ICD import responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0767e1ed18
commit
5cbef969fb
11 changed files with 1729 additions and 5 deletions
|
|
@ -4,12 +4,12 @@ import { ProtectedRoute } from '@/components/layout/ProtectedRoute'
|
||||||
import { AppLayout } from '@/components/layout/AppLayout'
|
import { AppLayout } from '@/components/layout/AppLayout'
|
||||||
import { LoginPage } from '@/pages/LoginPage'
|
import { LoginPage } from '@/pages/LoginPage'
|
||||||
import { RegisterPage } from '@/pages/RegisterPage'
|
import { RegisterPage } from '@/pages/RegisterPage'
|
||||||
|
import { DashboardPage } from '@/pages/DashboardPage'
|
||||||
|
import { CasesPage } from '@/pages/CasesPage'
|
||||||
|
import { ImportPage } from '@/pages/ImportPage'
|
||||||
|
import { IcdPage } from '@/pages/IcdPage'
|
||||||
|
|
||||||
// Placeholder pages for now
|
// Placeholder pages for features not yet implemented
|
||||||
function DashboardPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Dashboard</h1></div> }
|
|
||||||
function CasesPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Faelle</h1></div> }
|
|
||||||
function ImportPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Import</h1></div> }
|
|
||||||
function IcdPage() { return <div className="p-6"><h1 className="text-2xl font-bold">ICD-Eingabe</h1></div> }
|
|
||||||
function CodingPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Coding</h1></div> }
|
function CodingPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Coding</h1></div> }
|
||||||
function ReportsPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Berichte</h1></div> }
|
function ReportsPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Berichte</h1></div> }
|
||||||
function AdminUsersPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Benutzer</h1></div> }
|
function AdminUsersPage() { return <div className="p-6"><h1 className="text-2xl font-bold">Benutzer</h1></div> }
|
||||||
|
|
|
||||||
58
frontend/src/components/ui/scroll-area.tsx
Normal file
58
frontend/src/components/ui/scroll-area.tsx
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { ScrollArea as ScrollAreaPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function ScrollArea({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<ScrollAreaPrimitive.Root
|
||||||
|
data-slot="scroll-area"
|
||||||
|
className={cn("relative", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.Viewport
|
||||||
|
data-slot="scroll-area-viewport"
|
||||||
|
className="focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</ScrollAreaPrimitive.Viewport>
|
||||||
|
<ScrollBar />
|
||||||
|
<ScrollAreaPrimitive.Corner />
|
||||||
|
</ScrollAreaPrimitive.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ScrollBar({
|
||||||
|
className,
|
||||||
|
orientation = "vertical",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
|
||||||
|
return (
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||||
|
data-slot="scroll-area-scrollbar"
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"flex touch-none p-px transition-colors select-none",
|
||||||
|
orientation === "vertical" &&
|
||||||
|
"h-full w-2.5 border-l border-l-transparent",
|
||||||
|
orientation === "horizontal" &&
|
||||||
|
"h-2.5 flex-col border-t border-t-transparent",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaThumb
|
||||||
|
data-slot="scroll-area-thumb"
|
||||||
|
className="bg-border relative flex-1 rounded-full"
|
||||||
|
/>
|
||||||
|
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ScrollArea, ScrollBar }
|
||||||
190
frontend/src/components/ui/select.tsx
Normal file
190
frontend/src/components/ui/select.tsx
Normal file
|
|
@ -0,0 +1,190 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
|
||||||
|
import { Select as SelectPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Select({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
|
||||||
|
return <SelectPrimitive.Root data-slot="select" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectGroup({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
|
||||||
|
return <SelectPrimitive.Group data-slot="select-group" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectValue({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
|
||||||
|
return <SelectPrimitive.Value data-slot="select-value" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectTrigger({
|
||||||
|
className,
|
||||||
|
size = "default",
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
|
||||||
|
size?: "sm" | "default"
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.Trigger
|
||||||
|
data-slot="select-trigger"
|
||||||
|
data-size={size}
|
||||||
|
className={cn(
|
||||||
|
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<SelectPrimitive.Icon asChild>
|
||||||
|
<ChevronDownIcon className="size-4 opacity-50" />
|
||||||
|
</SelectPrimitive.Icon>
|
||||||
|
</SelectPrimitive.Trigger>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectContent({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
position = "item-aligned",
|
||||||
|
align = "center",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.Portal>
|
||||||
|
<SelectPrimitive.Content
|
||||||
|
data-slot="select-content"
|
||||||
|
className={cn(
|
||||||
|
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
||||||
|
position === "popper" &&
|
||||||
|
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
position={position}
|
||||||
|
align={align}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<SelectScrollUpButton />
|
||||||
|
<SelectPrimitive.Viewport
|
||||||
|
className={cn(
|
||||||
|
"p-1",
|
||||||
|
position === "popper" &&
|
||||||
|
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</SelectPrimitive.Viewport>
|
||||||
|
<SelectScrollDownButton />
|
||||||
|
</SelectPrimitive.Content>
|
||||||
|
</SelectPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectLabel({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.Label
|
||||||
|
data-slot="select-label"
|
||||||
|
className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectItem({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.Item
|
||||||
|
data-slot="select-item"
|
||||||
|
className={cn(
|
||||||
|
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
data-slot="select-item-indicator"
|
||||||
|
className="absolute right-2 flex size-3.5 items-center justify-center"
|
||||||
|
>
|
||||||
|
<SelectPrimitive.ItemIndicator>
|
||||||
|
<CheckIcon className="size-4" />
|
||||||
|
</SelectPrimitive.ItemIndicator>
|
||||||
|
</span>
|
||||||
|
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||||
|
</SelectPrimitive.Item>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectSeparator({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.Separator
|
||||||
|
data-slot="select-separator"
|
||||||
|
className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectScrollUpButton({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.ScrollUpButton
|
||||||
|
data-slot="select-scroll-up-button"
|
||||||
|
className={cn(
|
||||||
|
"flex cursor-default items-center justify-center py-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronUpIcon className="size-4" />
|
||||||
|
</SelectPrimitive.ScrollUpButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SelectScrollDownButton({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
|
||||||
|
return (
|
||||||
|
<SelectPrimitive.ScrollDownButton
|
||||||
|
data-slot="select-scroll-down-button"
|
||||||
|
className={cn(
|
||||||
|
"flex cursor-default items-center justify-center py-1",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ChevronDownIcon className="size-4" />
|
||||||
|
</SelectPrimitive.ScrollDownButton>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectLabel,
|
||||||
|
SelectScrollDownButton,
|
||||||
|
SelectScrollUpButton,
|
||||||
|
SelectSeparator,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
}
|
||||||
13
frontend/src/components/ui/skeleton.tsx
Normal file
13
frontend/src/components/ui/skeleton.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="skeleton"
|
||||||
|
className={cn("bg-accent animate-pulse rounded-md", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Skeleton }
|
||||||
114
frontend/src/components/ui/table.tsx
Normal file
114
frontend/src/components/ui/table.tsx
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
import * as React from "react"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Table({ className, ...props }: React.ComponentProps<"table">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="table-container"
|
||||||
|
className="relative w-full overflow-x-auto"
|
||||||
|
>
|
||||||
|
<table
|
||||||
|
data-slot="table"
|
||||||
|
className={cn("w-full caption-bottom text-sm", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
||||||
|
return (
|
||||||
|
<thead
|
||||||
|
data-slot="table-header"
|
||||||
|
className={cn("[&_tr]:border-b", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
||||||
|
return (
|
||||||
|
<tbody
|
||||||
|
data-slot="table-body"
|
||||||
|
className={cn("[&_tr:last-child]:border-0", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
||||||
|
return (
|
||||||
|
<tfoot
|
||||||
|
data-slot="table-footer"
|
||||||
|
className={cn(
|
||||||
|
"bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
||||||
|
return (
|
||||||
|
<tr
|
||||||
|
data-slot="table-row"
|
||||||
|
className={cn(
|
||||||
|
"hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
||||||
|
return (
|
||||||
|
<th
|
||||||
|
data-slot="table-head"
|
||||||
|
className={cn(
|
||||||
|
"text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
||||||
|
return (
|
||||||
|
<td
|
||||||
|
data-slot="table-cell"
|
||||||
|
className={cn(
|
||||||
|
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableCaption({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"caption">) {
|
||||||
|
return (
|
||||||
|
<caption
|
||||||
|
data-slot="table-caption"
|
||||||
|
className={cn("text-muted-foreground mt-4 text-sm", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Table,
|
||||||
|
TableHeader,
|
||||||
|
TableBody,
|
||||||
|
TableFooter,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
TableCaption,
|
||||||
|
}
|
||||||
89
frontend/src/components/ui/tabs.tsx
Normal file
89
frontend/src/components/ui/tabs.tsx
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
import { Tabs as TabsPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Tabs({
|
||||||
|
className,
|
||||||
|
orientation = "horizontal",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<TabsPrimitive.Root
|
||||||
|
data-slot="tabs"
|
||||||
|
data-orientation={orientation}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const tabsListVariants = cva(
|
||||||
|
"rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default: "bg-muted",
|
||||||
|
line: "gap-1 bg-transparent",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function TabsList({
|
||||||
|
className,
|
||||||
|
variant = "default",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TabsPrimitive.List> &
|
||||||
|
VariantProps<typeof tabsListVariants>) {
|
||||||
|
return (
|
||||||
|
<TabsPrimitive.List
|
||||||
|
data-slot="tabs-list"
|
||||||
|
data-variant={variant}
|
||||||
|
className={cn(tabsListVariants({ variant }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TabsTrigger({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
|
||||||
|
return (
|
||||||
|
<TabsPrimitive.Trigger
|
||||||
|
data-slot="tabs-trigger"
|
||||||
|
className={cn(
|
||||||
|
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
|
||||||
|
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 data-[state=active]:text-foreground",
|
||||||
|
"after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TabsContent({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TabsPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<TabsPrimitive.Content
|
||||||
|
data-slot="tabs-content"
|
||||||
|
className={cn("flex-1 outline-none", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
|
||||||
461
frontend/src/pages/CasesPage.tsx
Normal file
461
frontend/src/pages/CasesPage.tsx
Normal file
|
|
@ -0,0 +1,461 @@
|
||||||
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
||||||
|
import {
|
||||||
|
Search, ChevronLeft, ChevronRight, Save, CheckCircle, XCircle,
|
||||||
|
} from 'lucide-react'
|
||||||
|
import api from '@/services/api'
|
||||||
|
import type { Case, CaseListResponse } from '@/types'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Badge } from '@/components/ui/badge'
|
||||||
|
import {
|
||||||
|
Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
import {
|
||||||
|
Table, TableBody, TableCell, TableHead, TableHeader, TableRow,
|
||||||
|
} from '@/components/ui/table'
|
||||||
|
import {
|
||||||
|
Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription,
|
||||||
|
} from '@/components/ui/sheet'
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
|
import { Alert, AlertDescription } from '@/components/ui/alert'
|
||||||
|
|
||||||
|
const FALLGRUPPEN_LABELS: Record<string, string> = {
|
||||||
|
onko: 'Onkologie',
|
||||||
|
kardio: 'Kardiologie',
|
||||||
|
intensiv: 'Intensivmedizin',
|
||||||
|
galle: 'Gallenblase',
|
||||||
|
sd: 'Schilddrüse',
|
||||||
|
}
|
||||||
|
|
||||||
|
const FALLGRUPPEN_OPTIONS = [
|
||||||
|
{ value: '__all__', label: 'Alle Fallgruppen' },
|
||||||
|
{ value: 'onko', label: 'Onkologie' },
|
||||||
|
{ value: 'kardio', label: 'Kardiologie' },
|
||||||
|
{ value: 'intensiv', label: 'Intensivmedizin' },
|
||||||
|
{ value: 'galle', label: 'Gallenblase' },
|
||||||
|
{ value: 'sd', label: 'Schilddrüse' },
|
||||||
|
]
|
||||||
|
|
||||||
|
const ICD_OPTIONS = [
|
||||||
|
{ value: '__all__', label: 'Alle' },
|
||||||
|
{ value: 'true', label: 'Mit ICD' },
|
||||||
|
{ value: 'false', label: 'Ohne ICD' },
|
||||||
|
]
|
||||||
|
|
||||||
|
interface CasesPageProps {
|
||||||
|
/** When true, fetches from pending-icd endpoint instead */
|
||||||
|
pendingIcdOnly?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CasesPage({ pendingIcdOnly = false }: CasesPageProps) {
|
||||||
|
const currentYear = new Date().getFullYear()
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const [debouncedSearch, setDebouncedSearch] = useState('')
|
||||||
|
const [jahr, setJahr] = useState<string>('__all__')
|
||||||
|
const [fallgruppe, setFallgruppe] = useState<string>('__all__')
|
||||||
|
const [hasIcd, setHasIcd] = useState<string>('__all__')
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [perPage] = useState(50)
|
||||||
|
const [data, setData] = useState<CaseListResponse | null>(null)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [selectedCase, setSelectedCase] = useState<Case | null>(null)
|
||||||
|
const [sheetOpen, setSheetOpen] = useState(false)
|
||||||
|
|
||||||
|
// Debounce search
|
||||||
|
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||||
|
const handleSearchChange = useCallback((val: string) => {
|
||||||
|
setSearch(val)
|
||||||
|
if (debounceRef.current) clearTimeout(debounceRef.current)
|
||||||
|
debounceRef.current = setTimeout(() => {
|
||||||
|
setDebouncedSearch(val)
|
||||||
|
setPage(1)
|
||||||
|
}, 300)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (debounceRef.current) clearTimeout(debounceRef.current)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
// Fetch cases
|
||||||
|
useEffect(() => {
|
||||||
|
setLoading(true)
|
||||||
|
|
||||||
|
if (pendingIcdOnly) {
|
||||||
|
api.get<CaseListResponse>('/cases/pending-icd', {
|
||||||
|
params: { page, per_page: perPage },
|
||||||
|
})
|
||||||
|
.then((res) => setData(res.data))
|
||||||
|
.catch(() => setData(null))
|
||||||
|
.finally(() => setLoading(false))
|
||||||
|
} else {
|
||||||
|
const params: Record<string, string | number> = { page, per_page: perPage }
|
||||||
|
if (debouncedSearch) params.search = debouncedSearch
|
||||||
|
if (jahr !== '__all__') params.jahr = Number(jahr)
|
||||||
|
if (fallgruppe !== '__all__') params.fallgruppe = fallgruppe
|
||||||
|
if (hasIcd !== '__all__') params.has_icd = hasIcd
|
||||||
|
|
||||||
|
api.get<CaseListResponse>('/cases/', { params })
|
||||||
|
.then((res) => setData(res.data))
|
||||||
|
.catch(() => setData(null))
|
||||||
|
.finally(() => setLoading(false))
|
||||||
|
}
|
||||||
|
}, [page, perPage, debouncedSearch, jahr, fallgruppe, hasIcd, pendingIcdOnly])
|
||||||
|
|
||||||
|
const totalPages = data ? Math.ceil(data.total / perPage) : 0
|
||||||
|
const years = Array.from({ length: 5 }, (_, i) => currentYear - i)
|
||||||
|
|
||||||
|
const openDetail = (c: Case) => {
|
||||||
|
setSelectedCase(c)
|
||||||
|
setSheetOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleIcdSaved = (updated: Case) => {
|
||||||
|
setSelectedCase(updated)
|
||||||
|
// Refresh list
|
||||||
|
setData((prev) =>
|
||||||
|
prev
|
||||||
|
? {
|
||||||
|
...prev,
|
||||||
|
items: prev.items.map((c) => (c.id === updated.id ? updated : c)),
|
||||||
|
}
|
||||||
|
: prev,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-4">
|
||||||
|
<h1 className="text-2xl font-bold">
|
||||||
|
{pendingIcdOnly ? 'ICD-Eingabe' : 'Fälle'}
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
{/* Filter bar */}
|
||||||
|
{!pendingIcdOnly && (
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<div className="relative flex-1 min-w-[200px] max-w-sm">
|
||||||
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" />
|
||||||
|
<Input
|
||||||
|
placeholder="Suche nach Name, Fall-ID..."
|
||||||
|
value={search}
|
||||||
|
onChange={(e) => handleSearchChange(e.target.value)}
|
||||||
|
className="pl-9"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Select value={jahr} onValueChange={(v) => { setJahr(v); setPage(1) }}>
|
||||||
|
<SelectTrigger className="w-[120px]">
|
||||||
|
<SelectValue placeholder="Jahr" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="__all__">Alle Jahre</SelectItem>
|
||||||
|
{years.map((y) => (
|
||||||
|
<SelectItem key={y} value={String(y)}>{y}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<Select value={fallgruppe} onValueChange={(v) => { setFallgruppe(v); setPage(1) }}>
|
||||||
|
<SelectTrigger className="w-[170px]">
|
||||||
|
<SelectValue placeholder="Fallgruppe" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{FALLGRUPPEN_OPTIONS.map((o) => (
|
||||||
|
<SelectItem key={o.value} value={o.value}>{o.label}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<Select value={hasIcd} onValueChange={(v) => { setHasIcd(v); setPage(1) }}>
|
||||||
|
<SelectTrigger className="w-[130px]">
|
||||||
|
<SelectValue placeholder="ICD" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{ICD_OPTIONS.map((o) => (
|
||||||
|
<SelectItem key={o.value} value={o.value}>{o.label}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Table */}
|
||||||
|
{loading ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
{Array.from({ length: 8 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-10 w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : data && data.items.length > 0 ? (
|
||||||
|
<>
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>Fall-ID</TableHead>
|
||||||
|
<TableHead>Datum</TableHead>
|
||||||
|
<TableHead>Nachname</TableHead>
|
||||||
|
<TableHead>Vorname</TableHead>
|
||||||
|
<TableHead>Fallgruppe</TableHead>
|
||||||
|
<TableHead>ICD</TableHead>
|
||||||
|
<TableHead>Gutachten</TableHead>
|
||||||
|
<TableHead>Status</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{data.items.map((c) => (
|
||||||
|
<TableRow
|
||||||
|
key={c.id}
|
||||||
|
className="cursor-pointer"
|
||||||
|
onClick={() => openDetail(c)}
|
||||||
|
>
|
||||||
|
<TableCell className="font-mono text-sm">
|
||||||
|
{c.fall_id || '-'}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{formatDate(c.datum)}</TableCell>
|
||||||
|
<TableCell className="font-medium">{c.nachname}</TableCell>
|
||||||
|
<TableCell>{c.vorname || '-'}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Badge variant="outline">
|
||||||
|
{FALLGRUPPEN_LABELS[c.fallgruppe] || c.fallgruppe}
|
||||||
|
</Badge>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{c.icd ? (
|
||||||
|
<span className="font-mono text-sm">{c.icd}</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-muted-foreground">-</span>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{c.gutachten ? (
|
||||||
|
<CheckCircle className="size-4 text-green-600" />
|
||||||
|
) : (
|
||||||
|
<XCircle className="size-4 text-muted-foreground" />
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<StatusBadges c={c} />
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
{/* Pagination */}
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{data.total} Fälle insgesamt
|
||||||
|
</p>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
disabled={page <= 1}
|
||||||
|
onClick={() => setPage((p) => p - 1)}
|
||||||
|
>
|
||||||
|
<ChevronLeft className="size-4" />
|
||||||
|
</Button>
|
||||||
|
<span className="text-sm">
|
||||||
|
Seite {page} von {totalPages || 1}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
disabled={page >= totalPages}
|
||||||
|
onClick={() => setPage((p) => p + 1)}
|
||||||
|
>
|
||||||
|
<ChevronRight className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<p className="text-muted-foreground py-8 text-center">
|
||||||
|
Keine Fälle gefunden.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Detail Sheet */}
|
||||||
|
<Sheet open={sheetOpen} onOpenChange={setSheetOpen}>
|
||||||
|
<SheetContent className="w-full sm:max-w-lg overflow-y-auto">
|
||||||
|
{selectedCase && (
|
||||||
|
<CaseDetail
|
||||||
|
caseData={selectedCase}
|
||||||
|
onIcdSaved={handleIcdSaved}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</SheetContent>
|
||||||
|
</Sheet>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function StatusBadges({ c }: { c: Case }) {
|
||||||
|
return (
|
||||||
|
<div className="flex gap-1">
|
||||||
|
{c.unterlagen && <Badge variant="secondary" className="text-xs">Unterlagen</Badge>}
|
||||||
|
{c.gutachten && <Badge variant="secondary" className="text-xs">Gutachten</Badge>}
|
||||||
|
{c.abgerechnet && <Badge className="text-xs">Abgerechnet</Badge>}
|
||||||
|
{c.ablehnung && <Badge variant="destructive" className="text-xs">Abgelehnt</Badge>}
|
||||||
|
{c.abbruch && <Badge variant="destructive" className="text-xs">Abbruch</Badge>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CaseDetail({
|
||||||
|
caseData,
|
||||||
|
onIcdSaved,
|
||||||
|
}: {
|
||||||
|
caseData: Case
|
||||||
|
onIcdSaved: (updated: Case) => void
|
||||||
|
}) {
|
||||||
|
const [icdValue, setIcdValue] = useState(caseData.icd || '')
|
||||||
|
const [saving, setSaving] = useState(false)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const [success, setSuccess] = useState(false)
|
||||||
|
|
||||||
|
// Reset on case change
|
||||||
|
useEffect(() => {
|
||||||
|
setIcdValue(caseData.icd || '')
|
||||||
|
setError('')
|
||||||
|
setSuccess(false)
|
||||||
|
}, [caseData.id, caseData.icd])
|
||||||
|
|
||||||
|
const saveIcd = async () => {
|
||||||
|
if (!icdValue.trim()) return
|
||||||
|
setSaving(true)
|
||||||
|
setError('')
|
||||||
|
setSuccess(false)
|
||||||
|
try {
|
||||||
|
const res = await api.put<Case>(`/cases/${caseData.id}/icd`, { icd: icdValue.trim() })
|
||||||
|
onIcdSaved(res.data)
|
||||||
|
setSuccess(true)
|
||||||
|
} catch {
|
||||||
|
setError('Fehler beim Speichern des ICD-Codes.')
|
||||||
|
} finally {
|
||||||
|
setSaving(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SheetHeader>
|
||||||
|
<SheetTitle>
|
||||||
|
Fall {caseData.fall_id || `#${caseData.id}`}
|
||||||
|
</SheetTitle>
|
||||||
|
<SheetDescription>
|
||||||
|
{FALLGRUPPEN_LABELS[caseData.fallgruppe] || caseData.fallgruppe} — KW {caseData.kw}/{caseData.jahr}
|
||||||
|
</SheetDescription>
|
||||||
|
</SheetHeader>
|
||||||
|
|
||||||
|
<div className="px-4 space-y-4">
|
||||||
|
{/* Status badges */}
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<StatusBadges c={caseData} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Patient info */}
|
||||||
|
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||||
|
<DetailField label="Anrede" value={caseData.anrede} />
|
||||||
|
<DetailField label="Vorname" value={caseData.vorname} />
|
||||||
|
<DetailField label="Nachname" value={caseData.nachname} />
|
||||||
|
<DetailField label="Geburtsdatum" value={caseData.geburtsdatum ? formatDate(caseData.geburtsdatum) : null} />
|
||||||
|
<DetailField label="KVNR" value={caseData.kvnr} />
|
||||||
|
<DetailField label="Versicherung" value={caseData.versicherung} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Case details */}
|
||||||
|
<div className="border-t pt-3 grid grid-cols-2 gap-3 text-sm">
|
||||||
|
<DetailField label="Datum" value={formatDate(caseData.datum)} />
|
||||||
|
<DetailField label="KW / Jahr" value={`${caseData.kw} / ${caseData.jahr}`} />
|
||||||
|
<DetailField label="CRM-Ticket" value={caseData.crm_ticket_id} />
|
||||||
|
<DetailField label="Gutachter" value={caseData.gutachter} />
|
||||||
|
<DetailField label="Gutachten-Typ" value={caseData.gutachten_typ} />
|
||||||
|
<DetailField label="Therapieänderung" value={caseData.therapieaenderung} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ICD edit */}
|
||||||
|
<div className="border-t pt-3 space-y-2">
|
||||||
|
<label className="text-sm font-medium">ICD-Code</label>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Input
|
||||||
|
value={icdValue}
|
||||||
|
onChange={(e) => { setIcdValue(e.target.value); setSuccess(false) }}
|
||||||
|
placeholder="z.B. C50.9"
|
||||||
|
className="flex-1"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
onClick={saveIcd}
|
||||||
|
disabled={saving || !icdValue.trim()}
|
||||||
|
>
|
||||||
|
<Save className="size-4 mr-1" />
|
||||||
|
{saving ? 'Speichern...' : 'Speichern'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{error && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertDescription>{error}</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
{success && (
|
||||||
|
<p className="text-sm text-green-600">ICD-Code gespeichert.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description fields */}
|
||||||
|
{caseData.kurzbeschreibung && (
|
||||||
|
<div className="border-t pt-3 space-y-1">
|
||||||
|
<label className="text-sm font-medium">Kurzbeschreibung</label>
|
||||||
|
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{caseData.kurzbeschreibung}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{caseData.fragestellung && (
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label className="text-sm font-medium">Fragestellung</label>
|
||||||
|
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{caseData.fragestellung}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{caseData.kommentar && (
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label className="text-sm font-medium">Kommentar</label>
|
||||||
|
<p className="text-sm text-muted-foreground whitespace-pre-wrap">{caseData.kommentar}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="border-t pt-3 text-xs text-muted-foreground space-y-1">
|
||||||
|
<p>Importiert: {formatDateTime(caseData.imported_at)}</p>
|
||||||
|
<p>Aktualisiert: {formatDateTime(caseData.updated_at)}</p>
|
||||||
|
{caseData.import_source && <p>Quelle: {caseData.import_source}</p>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DetailField({ label, value }: { label: string; value: string | null | undefined }) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<span className="text-muted-foreground">{label}</span>
|
||||||
|
<p className="font-medium">{value || '-'}</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(dateStr: string): string {
|
||||||
|
try {
|
||||||
|
return new Date(dateStr).toLocaleDateString('de-DE', {
|
||||||
|
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return dateStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateTime(dateStr: string): string {
|
||||||
|
try {
|
||||||
|
return new Date(dateStr).toLocaleString('de-DE', {
|
||||||
|
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||||
|
hour: '2-digit', minute: '2-digit',
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return dateStr
|
||||||
|
}
|
||||||
|
}
|
||||||
220
frontend/src/pages/DashboardPage.tsx
Normal file
220
frontend/src/pages/DashboardPage.tsx
Normal file
|
|
@ -0,0 +1,220 @@
|
||||||
|
import { useState, useEffect } from 'react'
|
||||||
|
import {
|
||||||
|
BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend,
|
||||||
|
PieChart, Pie, Cell, ResponsiveContainer,
|
||||||
|
} from 'recharts'
|
||||||
|
import { FileText, Clock, Code, Stethoscope } from 'lucide-react'
|
||||||
|
import api from '@/services/api'
|
||||||
|
import type { DashboardResponse } from '@/types'
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||||
|
import {
|
||||||
|
Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
|
|
||||||
|
const FALLGRUPPEN_LABELS: Record<string, string> = {
|
||||||
|
onko: 'Onkologie',
|
||||||
|
kardio: 'Kardiologie',
|
||||||
|
intensiv: 'Intensivmedizin',
|
||||||
|
galle: 'Gallenblase',
|
||||||
|
sd: 'Schilddrüse',
|
||||||
|
}
|
||||||
|
|
||||||
|
const CHART_COLORS = [
|
||||||
|
'var(--chart-1)',
|
||||||
|
'var(--chart-2)',
|
||||||
|
'var(--chart-3)',
|
||||||
|
'var(--chart-4)',
|
||||||
|
'var(--chart-5)',
|
||||||
|
]
|
||||||
|
|
||||||
|
export function DashboardPage() {
|
||||||
|
const currentYear = new Date().getFullYear()
|
||||||
|
const [jahr, setJahr] = useState(currentYear)
|
||||||
|
const [data, setData] = useState<DashboardResponse | null>(null)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLoading(true)
|
||||||
|
api.get<DashboardResponse>('/reports/dashboard', { params: { jahr } })
|
||||||
|
.then((res) => setData(res.data))
|
||||||
|
.catch(() => setData(null))
|
||||||
|
.finally(() => setLoading(false))
|
||||||
|
}, [jahr])
|
||||||
|
|
||||||
|
const fallgruppenData = data
|
||||||
|
? Object.entries(data.kpis.fallgruppen).map(([key, value]) => ({
|
||||||
|
name: FALLGRUPPEN_LABELS[key] || key,
|
||||||
|
value,
|
||||||
|
}))
|
||||||
|
: []
|
||||||
|
|
||||||
|
const years = Array.from({ length: 5 }, (_, i) => currentYear - i)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-6">
|
||||||
|
{/* Header with year selector */}
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<h1 className="text-2xl font-bold">Dashboard</h1>
|
||||||
|
<Select value={String(jahr)} onValueChange={(v) => setJahr(Number(v))}>
|
||||||
|
<SelectTrigger className="w-[140px]">
|
||||||
|
<SelectValue placeholder="Jahr" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{years.map((y) => (
|
||||||
|
<SelectItem key={y} value={String(y)}>{y}</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* KPI Cards */}
|
||||||
|
{loading ? (
|
||||||
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
|
{[1, 2, 3, 4].map((i) => (
|
||||||
|
<Card key={i}>
|
||||||
|
<CardHeader className="pb-2">
|
||||||
|
<Skeleton className="h-4 w-24" />
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<Skeleton className="h-8 w-16" />
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : data ? (
|
||||||
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||||
|
<KpiCard
|
||||||
|
title="Fälle gesamt"
|
||||||
|
value={data.kpis.total_cases}
|
||||||
|
icon={<FileText className="size-5 text-muted-foreground" />}
|
||||||
|
/>
|
||||||
|
<KpiCard
|
||||||
|
title="Offene ICD"
|
||||||
|
value={data.kpis.pending_icd}
|
||||||
|
icon={<Clock className="size-5 text-muted-foreground" />}
|
||||||
|
/>
|
||||||
|
<KpiCard
|
||||||
|
title="Offene Codierung"
|
||||||
|
value={data.kpis.pending_coding}
|
||||||
|
icon={<Code className="size-5 text-muted-foreground" />}
|
||||||
|
/>
|
||||||
|
<KpiCard
|
||||||
|
title="Gutachten gesamt"
|
||||||
|
value={data.kpis.total_gutachten}
|
||||||
|
icon={<Stethoscope className="size-5 text-muted-foreground" />}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<p className="text-muted-foreground">Keine Daten verfügbar.</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Charts row */}
|
||||||
|
{data && (
|
||||||
|
<div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
|
||||||
|
{/* Weekly bar chart - takes 2 cols */}
|
||||||
|
<Card className="lg:col-span-2">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Wöchentliche Übersicht</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<ResponsiveContainer width="100%" height={350}>
|
||||||
|
<BarChart data={data.weekly}>
|
||||||
|
<CartesianGrid strokeDasharray="3 3" className="stroke-border" />
|
||||||
|
<XAxis
|
||||||
|
dataKey="kw"
|
||||||
|
tickFormatter={(v) => `KW ${v}`}
|
||||||
|
className="text-xs"
|
||||||
|
/>
|
||||||
|
<YAxis className="text-xs" />
|
||||||
|
<Tooltip
|
||||||
|
labelFormatter={(v) => `KW ${v}`}
|
||||||
|
contentStyle={{
|
||||||
|
backgroundColor: 'var(--popover)',
|
||||||
|
border: '1px solid var(--border)',
|
||||||
|
borderRadius: '8px',
|
||||||
|
color: 'var(--popover-foreground)',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Legend />
|
||||||
|
<Bar
|
||||||
|
dataKey="erstberatungen"
|
||||||
|
name="Erstberatungen"
|
||||||
|
stackId="a"
|
||||||
|
fill="var(--chart-1)"
|
||||||
|
radius={[0, 0, 0, 0]}
|
||||||
|
/>
|
||||||
|
<Bar
|
||||||
|
dataKey="unterlagen"
|
||||||
|
name="Unterlagen"
|
||||||
|
stackId="a"
|
||||||
|
fill="var(--chart-2)"
|
||||||
|
/>
|
||||||
|
<Bar
|
||||||
|
dataKey="gutachten"
|
||||||
|
name="Gutachten"
|
||||||
|
stackId="a"
|
||||||
|
fill="var(--chart-3)"
|
||||||
|
radius={[4, 4, 0, 0]}
|
||||||
|
/>
|
||||||
|
</BarChart>
|
||||||
|
</ResponsiveContainer>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{/* Fallgruppen pie chart */}
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Fallgruppen</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<ResponsiveContainer width="100%" height={350}>
|
||||||
|
<PieChart>
|
||||||
|
<Pie
|
||||||
|
data={fallgruppenData}
|
||||||
|
cx="50%"
|
||||||
|
cy="50%"
|
||||||
|
innerRadius={60}
|
||||||
|
outerRadius={100}
|
||||||
|
paddingAngle={3}
|
||||||
|
dataKey="value"
|
||||||
|
label={({ name, value }) => `${name}: ${value}`}
|
||||||
|
>
|
||||||
|
{fallgruppenData.map((_, idx) => (
|
||||||
|
<Cell
|
||||||
|
key={idx}
|
||||||
|
fill={CHART_COLORS[idx % CHART_COLORS.length]}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Pie>
|
||||||
|
<Tooltip
|
||||||
|
contentStyle={{
|
||||||
|
backgroundColor: 'var(--popover)',
|
||||||
|
border: '1px solid var(--border)',
|
||||||
|
borderRadius: '8px',
|
||||||
|
color: 'var(--popover-foreground)',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</PieChart>
|
||||||
|
</ResponsiveContainer>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function KpiCard({ title, value, icon }: { title: string; value: number; icon: React.ReactNode }) {
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
|
<CardTitle className="text-sm font-medium">{title}</CardTitle>
|
||||||
|
{icon}
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="text-3xl font-bold">{value.toLocaleString('de-DE')}</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
)
|
||||||
|
}
|
||||||
5
frontend/src/pages/IcdPage.tsx
Normal file
5
frontend/src/pages/IcdPage.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { CasesPage } from './CasesPage'
|
||||||
|
|
||||||
|
export function IcdPage() {
|
||||||
|
return <CasesPage pendingIcdOnly />
|
||||||
|
}
|
||||||
550
frontend/src/pages/ImportPage.tsx
Normal file
550
frontend/src/pages/ImportPage.tsx
Normal file
|
|
@ -0,0 +1,550 @@
|
||||||
|
import { useState, useEffect, useCallback, useRef } from 'react'
|
||||||
|
import {
|
||||||
|
Upload, FileUp, Check, AlertTriangle, ChevronLeft, ChevronRight, History,
|
||||||
|
} from 'lucide-react'
|
||||||
|
import api from '@/services/api'
|
||||||
|
import type {
|
||||||
|
ImportPreview, ImportResult, ICDImportResponse,
|
||||||
|
ImportLogEntry, ImportLogListResponse,
|
||||||
|
} from '@/types'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Badge } from '@/components/ui/badge'
|
||||||
|
import { Alert, AlertDescription } from '@/components/ui/alert'
|
||||||
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||||
|
import {
|
||||||
|
Table, TableBody, TableCell, TableHead, TableHeader, TableRow,
|
||||||
|
} from '@/components/ui/table'
|
||||||
|
import {
|
||||||
|
Tabs, TabsContent, TabsList, TabsTrigger,
|
||||||
|
} from '@/components/ui/tabs'
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
|
|
||||||
|
export function ImportPage() {
|
||||||
|
return (
|
||||||
|
<div className="p-6 space-y-6">
|
||||||
|
<h1 className="text-2xl font-bold">Import</h1>
|
||||||
|
<Tabs defaultValue="csv">
|
||||||
|
<TabsList>
|
||||||
|
<TabsTrigger value="csv">
|
||||||
|
<FileUp className="size-4 mr-1.5" />
|
||||||
|
CSV-Import
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="icd">
|
||||||
|
<Upload className="size-4 mr-1.5" />
|
||||||
|
ICD-Import
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="log">
|
||||||
|
<History className="size-4 mr-1.5" />
|
||||||
|
Import-Verlauf
|
||||||
|
</TabsTrigger>
|
||||||
|
</TabsList>
|
||||||
|
|
||||||
|
<TabsContent value="csv" className="mt-4">
|
||||||
|
<CsvImportTab />
|
||||||
|
</TabsContent>
|
||||||
|
<TabsContent value="icd" className="mt-4">
|
||||||
|
<IcdImportTab />
|
||||||
|
</TabsContent>
|
||||||
|
<TabsContent value="log" className="mt-4">
|
||||||
|
<ImportLogTab />
|
||||||
|
</TabsContent>
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// CSV Import Tab
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function CsvImportTab() {
|
||||||
|
const [file, setFile] = useState<File | null>(null)
|
||||||
|
const [uploading, setUploading] = useState(false)
|
||||||
|
const [confirming, setConfirming] = useState(false)
|
||||||
|
const [preview, setPreview] = useState<ImportPreview | null>(null)
|
||||||
|
const [result, setResult] = useState<ImportResult | null>(null)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
|
const handleDrop = useCallback((e: React.DragEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const f = e.dataTransfer.files[0]
|
||||||
|
if (f && f.name.toLowerCase().endsWith('.csv')) {
|
||||||
|
setFile(f)
|
||||||
|
setPreview(null)
|
||||||
|
setResult(null)
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const f = e.target.files?.[0]
|
||||||
|
if (f) {
|
||||||
|
setFile(f)
|
||||||
|
setPreview(null)
|
||||||
|
setResult(null)
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadPreview = async () => {
|
||||||
|
if (!file) return
|
||||||
|
setUploading(true)
|
||||||
|
setError('')
|
||||||
|
try {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
const res = await api.post<ImportPreview>('/import/csv', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
})
|
||||||
|
setPreview(res.data)
|
||||||
|
} catch (err: unknown) {
|
||||||
|
const msg = err instanceof Error ? err.message : 'Upload fehlgeschlagen'
|
||||||
|
setError(msg)
|
||||||
|
} finally {
|
||||||
|
setUploading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmImport = async () => {
|
||||||
|
if (!file) return
|
||||||
|
setConfirming(true)
|
||||||
|
setError('')
|
||||||
|
try {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
const res = await api.post<ImportResult>('/import/csv/confirm', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
})
|
||||||
|
setResult(res.data)
|
||||||
|
setPreview(null)
|
||||||
|
} catch (err: unknown) {
|
||||||
|
const msg = err instanceof Error ? err.message : 'Import fehlgeschlagen'
|
||||||
|
setError(msg)
|
||||||
|
} finally {
|
||||||
|
setConfirming(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const reset = () => {
|
||||||
|
setFile(null)
|
||||||
|
setPreview(null)
|
||||||
|
setResult(null)
|
||||||
|
setError('')
|
||||||
|
if (fileInputRef.current) fileInputRef.current.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{/* Drop zone */}
|
||||||
|
{!preview && !result && (
|
||||||
|
<div
|
||||||
|
onDragOver={(e) => e.preventDefault()}
|
||||||
|
onDrop={handleDrop}
|
||||||
|
className="border-2 border-dashed rounded-lg p-10 text-center cursor-pointer hover:border-primary/50 transition-colors"
|
||||||
|
onClick={() => fileInputRef.current?.click()}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
ref={fileInputRef}
|
||||||
|
type="file"
|
||||||
|
accept=".csv"
|
||||||
|
className="hidden"
|
||||||
|
onChange={handleFileSelect}
|
||||||
|
/>
|
||||||
|
<Upload className="size-10 mx-auto text-muted-foreground mb-3" />
|
||||||
|
{file ? (
|
||||||
|
<p className="text-sm">
|
||||||
|
<span className="font-medium">{file.name}</span>
|
||||||
|
<span className="text-muted-foreground ml-2">
|
||||||
|
({(file.size / 1024).toFixed(1)} KB)
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
|
<p className="font-medium">CSV-Datei hierhin ziehen</p>
|
||||||
|
<p className="text-sm text-muted-foreground mt-1">
|
||||||
|
oder klicken zum Auswählen
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{file && !preview && !result && (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button onClick={uploadPreview} disabled={uploading}>
|
||||||
|
{uploading ? 'Wird hochgeladen...' : 'Vorschau laden'}
|
||||||
|
</Button>
|
||||||
|
<Button variant="outline" onClick={reset}>Abbrechen</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertTriangle className="size-4" />
|
||||||
|
<AlertDescription>{error}</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Preview */}
|
||||||
|
{preview && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="text-lg">
|
||||||
|
Vorschau: {preview.filename}
|
||||||
|
</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="flex gap-6 text-sm">
|
||||||
|
<div>
|
||||||
|
<span className="text-muted-foreground">Zeilen gesamt:</span>{' '}
|
||||||
|
<span className="font-medium">{preview.total_rows}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span className="text-muted-foreground">Neue Fälle:</span>{' '}
|
||||||
|
<span className="font-medium text-green-600">{preview.new_cases}</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span className="text-muted-foreground">Duplikate:</span>{' '}
|
||||||
|
<span className="font-medium text-amber-600">{preview.duplicates}</span>
|
||||||
|
</div>
|
||||||
|
{preview.errors.length > 0 && (
|
||||||
|
<div>
|
||||||
|
<span className="text-muted-foreground">Fehler:</span>{' '}
|
||||||
|
<span className="font-medium text-destructive">{preview.errors.length}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{preview.errors.length > 0 && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertTriangle className="size-4" />
|
||||||
|
<AlertDescription>
|
||||||
|
<ul className="list-disc list-inside space-y-1">
|
||||||
|
{preview.errors.map((e, i) => <li key={i}>{e}</li>)}
|
||||||
|
</ul>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Preview table */}
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>#</TableHead>
|
||||||
|
<TableHead>Nachname</TableHead>
|
||||||
|
<TableHead>Vorname</TableHead>
|
||||||
|
<TableHead>Fallgruppe</TableHead>
|
||||||
|
<TableHead>Datum</TableHead>
|
||||||
|
<TableHead>Status</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{preview.rows.map((row) => (
|
||||||
|
<TableRow key={row.row_number}>
|
||||||
|
<TableCell>{row.row_number}</TableCell>
|
||||||
|
<TableCell className="font-medium">{row.nachname}</TableCell>
|
||||||
|
<TableCell>{row.vorname || '-'}</TableCell>
|
||||||
|
<TableCell>{row.fallgruppe}</TableCell>
|
||||||
|
<TableCell>{row.datum}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{row.is_duplicate ? (
|
||||||
|
<Badge variant="outline" className="text-amber-600 border-amber-300">
|
||||||
|
Duplikat
|
||||||
|
</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge variant="secondary" className="text-green-600">
|
||||||
|
Neu
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button onClick={confirmImport} disabled={confirming || preview.new_cases === 0}>
|
||||||
|
{confirming ? 'Wird importiert...' : `${preview.new_cases} Fälle importieren`}
|
||||||
|
</Button>
|
||||||
|
<Button variant="outline" onClick={reset}>Abbrechen</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Result */}
|
||||||
|
{result && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Alert>
|
||||||
|
<Check className="size-4" />
|
||||||
|
<AlertDescription>
|
||||||
|
Import abgeschlossen: {result.imported} importiert, {result.skipped} übersprungen, {result.updated} aktualisiert.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
{result.errors.length > 0 && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertTriangle className="size-4" />
|
||||||
|
<AlertDescription>
|
||||||
|
<ul className="list-disc list-inside space-y-1">
|
||||||
|
{result.errors.map((e, i) => <li key={i}>{e}</li>)}
|
||||||
|
</ul>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
<Button onClick={reset}>Neuen Import starten</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// ICD Import Tab
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function IcdImportTab() {
|
||||||
|
const [file, setFile] = useState<File | null>(null)
|
||||||
|
const [uploading, setUploading] = useState(false)
|
||||||
|
const [result, setResult] = useState<ICDImportResponse | null>(null)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
|
const handleDrop = useCallback((e: React.DragEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const f = e.dataTransfer.files[0]
|
||||||
|
if (f && (f.name.toLowerCase().endsWith('.xlsx') || f.name.toLowerCase().endsWith('.xls'))) {
|
||||||
|
setFile(f)
|
||||||
|
setResult(null)
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const f = e.target.files?.[0]
|
||||||
|
if (f) {
|
||||||
|
setFile(f)
|
||||||
|
setResult(null)
|
||||||
|
setError('')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const upload = async () => {
|
||||||
|
if (!file) return
|
||||||
|
setUploading(true)
|
||||||
|
setError('')
|
||||||
|
try {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
const res = await api.post<ICDImportResponse>('/import/icd-xlsx', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
})
|
||||||
|
setResult(res.data)
|
||||||
|
} catch (err: unknown) {
|
||||||
|
const msg = err instanceof Error ? err.message : 'Upload fehlgeschlagen'
|
||||||
|
setError(msg)
|
||||||
|
} finally {
|
||||||
|
setUploading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const reset = () => {
|
||||||
|
setFile(null)
|
||||||
|
setResult(null)
|
||||||
|
setError('')
|
||||||
|
if (fileInputRef.current) fileInputRef.current.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
{!result && (
|
||||||
|
<div
|
||||||
|
onDragOver={(e) => e.preventDefault()}
|
||||||
|
onDrop={handleDrop}
|
||||||
|
className="border-2 border-dashed rounded-lg p-10 text-center cursor-pointer hover:border-primary/50 transition-colors"
|
||||||
|
onClick={() => fileInputRef.current?.click()}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
ref={fileInputRef}
|
||||||
|
type="file"
|
||||||
|
accept=".xlsx,.xls"
|
||||||
|
className="hidden"
|
||||||
|
onChange={handleFileSelect}
|
||||||
|
/>
|
||||||
|
<Upload className="size-10 mx-auto text-muted-foreground mb-3" />
|
||||||
|
{file ? (
|
||||||
|
<p className="text-sm">
|
||||||
|
<span className="font-medium">{file.name}</span>
|
||||||
|
<span className="text-muted-foreground ml-2">
|
||||||
|
({(file.size / 1024).toFixed(1)} KB)
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
|
<p className="font-medium">Excel-Datei (.xlsx) hierhin ziehen</p>
|
||||||
|
<p className="text-sm text-muted-foreground mt-1">
|
||||||
|
oder klicken zum Auswählen
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{file && !result && (
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button onClick={upload} disabled={uploading}>
|
||||||
|
{uploading ? 'Wird hochgeladen...' : 'ICD-Codes importieren'}
|
||||||
|
</Button>
|
||||||
|
<Button variant="outline" onClick={reset}>Abbrechen</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertTriangle className="size-4" />
|
||||||
|
<AlertDescription>{error}</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{result && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Alert>
|
||||||
|
<Check className="size-4" />
|
||||||
|
<AlertDescription>
|
||||||
|
ICD-Import abgeschlossen: {result.updated} Fälle aktualisiert.
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
{result.errors.length > 0 && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertTriangle className="size-4" />
|
||||||
|
<AlertDescription>
|
||||||
|
<ul className="list-disc list-inside space-y-1">
|
||||||
|
{result.errors.map((e, i) => <li key={i}>{e}</li>)}
|
||||||
|
</ul>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
<Button onClick={reset}>Neuen Import starten</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Import Log Tab
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function ImportLogTab() {
|
||||||
|
const [logs, setLogs] = useState<ImportLogEntry[]>([])
|
||||||
|
const [total, setTotal] = useState(0)
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
const perPage = 20
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLoading(true)
|
||||||
|
api.get<ImportLogListResponse>('/import/log', {
|
||||||
|
params: { page, per_page: perPage },
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setLogs(res.data.items)
|
||||||
|
setTotal(res.data.total)
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setLogs([])
|
||||||
|
setTotal(0)
|
||||||
|
})
|
||||||
|
.finally(() => setLoading(false))
|
||||||
|
}, [page])
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(total / perPage)
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<div className="space-y-2">
|
||||||
|
{Array.from({ length: 5 }).map((_, i) => (
|
||||||
|
<Skeleton key={i} className="h-10 w-full" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logs.length === 0) {
|
||||||
|
return <p className="text-muted-foreground py-8 text-center">Keine Import-Einträge vorhanden.</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>Datum</TableHead>
|
||||||
|
<TableHead>Dateiname</TableHead>
|
||||||
|
<TableHead>Typ</TableHead>
|
||||||
|
<TableHead className="text-right">Importiert</TableHead>
|
||||||
|
<TableHead className="text-right">Übersprungen</TableHead>
|
||||||
|
<TableHead className="text-right">Fehler</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{logs.map((log) => (
|
||||||
|
<TableRow key={log.id}>
|
||||||
|
<TableCell>{formatDateTime(log.imported_at)}</TableCell>
|
||||||
|
<TableCell className="font-mono text-sm">{log.filename}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Badge variant="outline">{log.import_type}</Badge>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-right">{log.imported_rows}</TableCell>
|
||||||
|
<TableCell className="text-right">{log.skipped_rows}</TableCell>
|
||||||
|
<TableCell className="text-right">
|
||||||
|
{log.error_count > 0 ? (
|
||||||
|
<span className="text-destructive font-medium">{log.error_count}</span>
|
||||||
|
) : (
|
||||||
|
'0'
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
{totalPages > 1 && (
|
||||||
|
<div className="flex items-center justify-end gap-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
disabled={page <= 1}
|
||||||
|
onClick={() => setPage((p) => p - 1)}
|
||||||
|
>
|
||||||
|
<ChevronLeft className="size-4" />
|
||||||
|
</Button>
|
||||||
|
<span className="text-sm">
|
||||||
|
Seite {page} von {totalPages}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
disabled={page >= totalPages}
|
||||||
|
onClick={() => setPage((p) => p + 1)}
|
||||||
|
>
|
||||||
|
<ChevronRight className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateTime(dateStr: string): string {
|
||||||
|
try {
|
||||||
|
return new Date(dateStr).toLocaleString('de-DE', {
|
||||||
|
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||||
|
hour: '2-digit', minute: '2-digit',
|
||||||
|
})
|
||||||
|
} catch {
|
||||||
|
return dateStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -131,3 +131,27 @@ export interface ReportMeta {
|
||||||
report_date: string
|
report_date: string
|
||||||
generated_at: string
|
generated_at: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ICDImportResponse {
|
||||||
|
updated: number
|
||||||
|
errors: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ImportLogEntry {
|
||||||
|
id: number
|
||||||
|
filename: string
|
||||||
|
import_type: string
|
||||||
|
total_rows: number
|
||||||
|
imported_rows: number
|
||||||
|
skipped_rows: number
|
||||||
|
error_count: number
|
||||||
|
imported_by: number
|
||||||
|
imported_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ImportLogListResponse {
|
||||||
|
items: ImportLogEntry[]
|
||||||
|
total: number
|
||||||
|
page: number
|
||||||
|
per_page: number
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue