mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 14:53:41 +00:00
feat: add year filter to Coding queue
Add jahr parameter to the coding queue API endpoint and frontend filter, allowing admins to filter the coding queue by year. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d5b357b60d
commit
2e41242c9e
3 changed files with 27 additions and 8 deletions
|
|
@ -19,6 +19,7 @@ router = APIRouter()
|
|||
@router.get("/queue", response_model=CaseListResponse)
|
||||
def coding_queue(
|
||||
fallgruppe: str | None = Query(None),
|
||||
jahr: int | None = Query(None),
|
||||
page: int = Query(1, ge=1),
|
||||
per_page: int = Query(50, ge=1, le=200),
|
||||
db: Session = Depends(get_db),
|
||||
|
|
@ -26,9 +27,9 @@ def coding_queue(
|
|||
):
|
||||
"""Return cases that need coding (gutachten=True, gutachten_typ=NULL).
|
||||
|
||||
Admin only. Supports optional fallgruppe filter and pagination.
|
||||
Admin only. Supports optional fallgruppe and jahr filters with pagination.
|
||||
"""
|
||||
cases, total = get_coding_queue(db, fallgruppe, page, per_page)
|
||||
cases, total = get_coding_queue(db, fallgruppe, jahr, page, per_page)
|
||||
return CaseListResponse(
|
||||
items=[CaseResponse.model_validate(c) for c in cases],
|
||||
total=total,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ settings = get_settings()
|
|||
def get_coding_queue(
|
||||
db: Session,
|
||||
fallgruppe: str | None = None,
|
||||
jahr: int | None = None,
|
||||
page: int = 1,
|
||||
per_page: int = 50,
|
||||
) -> tuple[list[Case], int]:
|
||||
|
|
@ -32,6 +33,8 @@ def get_coding_queue(
|
|||
)
|
||||
if fallgruppe:
|
||||
query = query.filter(Case.fallgruppe == fallgruppe)
|
||||
if jahr:
|
||||
query = query.filter(Case.jahr == jahr)
|
||||
|
||||
total = query.count()
|
||||
cases = (
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ function getInitialFormState(c: Case): CodingFormState {
|
|||
}
|
||||
|
||||
export function CodingPage() {
|
||||
const currentYear = new Date().getFullYear()
|
||||
const years = Array.from({ length: 5 }, (_, i) => currentYear - i)
|
||||
const [jahr, setJahr] = useState<string>('__all__')
|
||||
const [fallgruppe, setFallgruppe] = useState<string>('__all__')
|
||||
const [page, setPage] = useState(1)
|
||||
const [data, setData] = useState<CaseListResponse | null>(null)
|
||||
|
|
@ -63,6 +66,7 @@ export function CodingPage() {
|
|||
setLoading(true)
|
||||
const params: Record<string, string | number> = { page, per_page: 50 }
|
||||
if (fallgruppe !== '__all__') params.fallgruppe = fallgruppe
|
||||
if (jahr !== '__all__') params.jahr = Number(jahr)
|
||||
|
||||
api.get<CaseListResponse>('/coding/queue', { params, signal: controller.signal })
|
||||
.then((res) => {
|
||||
|
|
@ -84,7 +88,7 @@ export function CodingPage() {
|
|||
})
|
||||
|
||||
return () => controller.abort()
|
||||
}, [page, fallgruppe])
|
||||
}, [page, fallgruppe, jahr])
|
||||
|
||||
const updateFormField = (caseId: number, field: keyof CodingFormState, value: unknown) => {
|
||||
setFormStates((prev) => ({
|
||||
|
|
@ -136,9 +140,9 @@ export function CodingPage() {
|
|||
? data.items.filter((c) => savedIds.has(c.id) || c.gutachten_typ !== null).length
|
||||
: 0
|
||||
const grandTotal = data?.total ?? 0
|
||||
const activeFilterLabel = fallgruppe !== '__all__'
|
||||
? FALLGRUPPEN_LABELS[fallgruppe] || fallgruppe
|
||||
: null
|
||||
const activeFilters: string[] = []
|
||||
if (fallgruppe !== '__all__') activeFilters.push(FALLGRUPPEN_LABELS[fallgruppe] || fallgruppe)
|
||||
if (jahr !== '__all__') activeFilters.push(jahr)
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
|
|
@ -148,8 +152,8 @@ export function CodingPage() {
|
|||
{!loading && data && (
|
||||
<p className="text-sm text-muted-foreground mt-0.5">
|
||||
{grandTotal} {grandTotal === 1 ? 'Fall' : 'Fälle'} offen
|
||||
{activeFilterLabel && (
|
||||
<> — gefiltert nach <span className="font-medium text-foreground">{activeFilterLabel}</span></>
|
||||
{activeFilters.length > 0 && (
|
||||
<> — gefiltert nach <span className="font-medium text-foreground">{activeFilters.join(', ')}</span></>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
|
|
@ -158,6 +162,17 @@ export function CodingPage() {
|
|||
<Badge variant="outline" className="text-sm py-1 px-3">
|
||||
{codedCount} / {data?.items.length ?? 0} auf dieser Seite codiert
|
||||
</Badge>
|
||||
<Select value={jahr} onValueChange={(v) => { setJahr(v); setPage(1) }}>
|
||||
<SelectTrigger className="w-[130px]">
|
||||
<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-[180px]">
|
||||
<SelectValue placeholder="Fallgruppe" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue