mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 21:53:41 +00:00
Adds report_type support across the full stack: - Backend: REPORT_TYPES mapping, fallgruppen filter in all 5 sheet calculations, dynamic Excel columns, report_type DB column with Alembic migration 007 - Frontend: report type dropdown in generation form, type column in reports table, dynamic fallgruppen in ReportViewer Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
192 lines
5.8 KiB
Python
192 lines
5.8 KiB
Python
"""Weekly report and yearly summary models."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import datetime as dt
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import (
|
|
Date,
|
|
DateTime,
|
|
ForeignKey,
|
|
Index,
|
|
Integer,
|
|
SmallInteger,
|
|
String,
|
|
UniqueConstraint,
|
|
func,
|
|
)
|
|
from sqlalchemy.dialects.mysql import JSON
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class WeeklyReport(Base):
|
|
__tablename__ = "weekly_reports"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
jahr: Mapped[int] = mapped_column(SmallInteger, nullable=False)
|
|
kw: Mapped[int] = mapped_column(SmallInteger, nullable=False)
|
|
report_type: Mapped[str] = mapped_column(
|
|
String(50), nullable=False, server_default="gesamt"
|
|
)
|
|
report_date: Mapped[dt.date] = mapped_column(Date, nullable=False)
|
|
report_file_path: Mapped[Optional[str]] = mapped_column(
|
|
String(500), nullable=True
|
|
)
|
|
report_data: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
|
generated_by: Mapped[Optional[int]] = mapped_column(
|
|
Integer, ForeignKey("users.id"), nullable=True
|
|
)
|
|
generated_at: Mapped[dt.datetime] = mapped_column(
|
|
DateTime, nullable=False, server_default=func.now()
|
|
)
|
|
|
|
# Relationships
|
|
generated_by_user: Mapped[Optional["User"]] = relationship(
|
|
foreign_keys=[generated_by]
|
|
)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("jahr", "kw", "report_type", name="uk_jahr_kw_type"),
|
|
)
|
|
|
|
|
|
class YearlySummary(Base):
|
|
__tablename__ = "yearly_summary"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
jahr: Mapped[int] = mapped_column(SmallInteger, nullable=False)
|
|
kw: Mapped[int] = mapped_column(SmallInteger, nullable=False)
|
|
|
|
# Overall counts
|
|
erstberatungen: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
ablehnungen: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
unterlagen: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
keine_rueckmeldung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
gutachten_gesamt: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
gutachten_alternative: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
gutachten_bestaetigung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Per-Fallgruppe counts: onko
|
|
onko_anzahl: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
onko_gutachten: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
onko_keine_rm: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Per-Fallgruppe counts: kardio
|
|
kardio_anzahl: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
kardio_gutachten: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
kardio_keine_rm: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Per-Fallgruppe counts: intensiv
|
|
intensiv_anzahl: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
intensiv_gutachten: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
intensiv_keine_rm: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Per-Fallgruppe counts: galle
|
|
galle_anzahl: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
galle_gutachten: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
galle_keine_rm: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Per-Fallgruppe counts: sd
|
|
sd_anzahl: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
sd_gutachten: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
sd_keine_rm: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Gutachten-Typ per Fallgruppe
|
|
onko_alternative: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
onko_bestaetigung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
kardio_alternative: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
kardio_bestaetigung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
intensiv_alternative: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
intensiv_bestaetigung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
galle_alternative: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
galle_bestaetigung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
sd_alternative: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
sd_bestaetigung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
# Therapieaenderung counts
|
|
ta_ja: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
ta_nein: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
ta_diagnosekorrektur: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
ta_unterversorgung: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
ta_uebertherapie: Mapped[Optional[int]] = mapped_column(
|
|
Integer, server_default="0"
|
|
)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint("jahr", "kw", name="uk_jahr_kw"),
|
|
)
|