Commit graph

67 commits

Author SHA1 Message Date
0e4d19e8bc fix: use savepoints for row-by-row error isolation in Excel import
Prevents a single duplicate fall_id from rolling back the entire
import session. Each row insert now uses db.begin_nested() so
constraint violations are isolated to the offending row.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 09:01:42 +00:00
93884f3c8d fix: add missing cases API, import router, and case schemas
These files were created by a subagent but not included in the commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 08:49:55 +00:00
3f8f96097d fix: URL-encode DB password in connection string
Passwords with special characters (@, &, etc.) broke the SQLAlchemy
connection URL parsing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 08:48:28 +00:00
1748379253 feat: Excel export in Berichtswesen format + historical import
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 08:07:28 +00:00
d6fb04d5a7 feat: coding queue, reports API, Excel sync
- Add coding_service.py with queue retrieval, single + batch coding updates
- Add report schemas (DashboardKPIs, WeeklyDataPoint, ReportMeta)
- Add coding API router with /queue, PUT /{case_id}, POST /batch endpoints
- Add reports API router with /dashboard, /weekly, /generate, /download, /list
- Add excel_sync.py for bidirectional Abrechnung DB<->XLSX sync
- Register coding and reports routers in main.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 08:03:17 +00:00
72b6f784fc feat: report service — all 5 sheet calculations + year-over-year
Implements report_service.py with:
- Sheet 1: Auswertung KW gesamt (weekly totals + year summary)
- Sheet 2: Auswertung nach Fachgebieten (per-KW per-Fallgruppe)
- Sheet 3: Auswertung Gutachten (alternative/bestaetigung per group)
- Sheet 4: Auswertung Therapieaenderungen (TA metrics per KW)
- Sheet 5: Auswertung ICD onko (ICD code frequency for onko)
- Dashboard KPIs (total_cases, pending_icd, pending_coding, etc.)
- generate_full_report() for all 5 sheets combined

Implements vorjahr_service.py with:
- Cached year-over-year comparison via yearly_summary table
- get_vorjahr_summary() for Sheet 1 comparison columns
- get_vorjahr_detail() for full previous-year breakdown
- refresh_vorjahr_cache() for cache invalidation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 08:02:53 +00:00
f4afea7f85 feat: historical Excel import (Abrechnung_DAK.xlsx)
Add service and standalone script to import all cases from the master
Excel workbook into the database. Handles 5 year-sheets (2020-2022,
2023, 2024, 2025, 2026) with dynamic column mapping, fallgruppe
normalization, boolean/date parsing, phone number formatting, and
duplicate detection. Supports dry-run mode and per-sheet import.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:58:04 +00:00
e793bad01f feat: notification service — in-app + SMTP email
Adds notification_service.py with:
- send_email() for SMTP SSL delivery via complexcaresolutions.de
- create_notification() for in-app + optional email notifications
- notify_all_users_with_role() for role-based bulk notifications
- Convenience functions for all 5 notification types:
  new_cases_uploaded, icd_entered, icd_uploaded,
  report_ready, coding_completed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:52:24 +00:00
78c2c682a4 feat: import service with duplicate detection and fall_id generation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:49:15 +00:00
498cb7048d feat: ICD service — normalize, split, validate, coding template
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:49:05 +00:00
df26b51e14 feat: admin API, audit logging, notifications, create_admin script
Add audit_service for compliance logging, admin endpoints (user CRUD,
invitation management, audit log), notification endpoints (list, mark
read), and interactive create_admin script.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:48:41 +00:00
518de3da27 feat: auth system — login, register, refresh, MFA, domain whitelist
Add complete authentication layer:
- Pydantic v2 schemas for auth requests/responses and user representation
- Auth service with login (account locking, MFA), registration (invitation
  tokens + domain whitelist), token management, MFA setup/activation, and
  password change
- FastAPI router with 8 endpoints: login, register, refresh, logout,
  mfa/setup, mfa/verify, change-password, me
- Router registered in main.py under /api/auth

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:46:04 +00:00
84d11822e0 feat: CRM CSV parser with pipe-delimited contact parsing
Parse CRM CSV exports (UTF-8-BOM, comma-delimited) with:
- Pipe-delimited Hauptkontakt field (Nachname|Vorname|Geburtsdatum|KVNR)
- German date formats (DD.MM.YYYY, DD.MM.YY, HH:MM)
- Modul-to-Fallgruppe mapping
- Graceful handling of missing KVNR, bad dates, empty fields, spam rows
- 19 tests (synthetic + all 4 real CSV files)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:45:34 +00:00
178d40d036 feat: JWT auth, bcrypt, MFA, dependency injection, security tests
Add core security layer:
- security.py: password hashing (bcrypt), JWT access/refresh tokens,
  SHA-256 token hashing, TOTP MFA (generate, verify, provisioning URI),
  plus passlib/bcrypt 5.x compatibility patch
- dependencies.py: FastAPI deps for get_current_user (Bearer JWT) and
  require_admin (role check)
- exceptions.py: domain-specific HTTP exceptions (CaseNotFound,
  DuplicateCase, InvalidImportFile, ICDValidation, AccountLocked,
  InvalidCredentials)
- test_security.py: 9 tests covering all security functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:41:35 +00:00
e0ca8c31c3 feat: utility functions — fallgruppe mapping, KW calc, ICD/KVNR validation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:41:09 +00:00
e7befe78b6 feat: SQLAlchemy models for users, cases, reports, audit
11 models across 4 files matching the MariaDB schema:
- user.py: User, RefreshToken, InvitationLink, AllowedDomain
- case.py: Case, CaseICDCode
- report.py: WeeklyReport, YearlySummary
- audit.py: ImportLog, AuditLog, Notification

All CHECK constraints, indexes (incl. prefix index), foreign keys,
and server defaults match the SQL DDL specification exactly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:28:33 +00:00
5d57b1f349 feat: project scaffolding with FastAPI, config, database connection
- Initialize project structure with backend/app/ package layout
- Add FastAPI app with CORS middleware and health check endpoint
- Add Pydantic Settings config with DB, JWT, SMTP, and app settings
- Add SQLAlchemy database engine and session management
- Add requirements.txt with all dependencies (FastAPI, SQLAlchemy, Alembic, etc.)
- Add .env.example template and .gitignore
- Add empty frontend/ and backend test scaffolding
- Include project specification and design/implementation plans

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 07:24:00 +00:00