mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 19:33:41 +00:00
fix: use SQLAlchemy Integer type in .cast() calls in report_service
.cast(int) uses Python's builtin int, which lacks SQLAlchemy's _isnull attribute. Replace all occurrences with .cast(Integer). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0e4d19e8bc
commit
5ee1cff0d6
1 changed files with 11 additions and 11 deletions
|
|
@ -14,7 +14,7 @@ from __future__ import annotations
|
|||
import logging
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import and_, func
|
||||
from sqlalchemy import Integer, and_, func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.models.case import Case, CaseICDCode
|
||||
|
|
@ -124,9 +124,9 @@ def calculate_sheet1_data(db: Session, jahr: int) -> dict:
|
|||
db.query(
|
||||
Case.kw,
|
||||
func.count(Case.id).label("erstberatungen"),
|
||||
func.sum(Case.unterlagen.cast(int)).label("unterlagen"),
|
||||
func.sum(Case.ablehnung.cast(int)).label("ablehnungen"),
|
||||
func.sum(Case.gutachten.cast(int)).label("gutachten"),
|
||||
func.sum(Case.unterlagen.cast(Integer)).label("unterlagen"),
|
||||
func.sum(Case.ablehnung.cast(Integer)).label("ablehnungen"),
|
||||
func.sum(Case.gutachten.cast(Integer)).label("gutachten"),
|
||||
)
|
||||
.filter(Case.jahr == jahr)
|
||||
.group_by(Case.kw)
|
||||
|
|
@ -203,7 +203,7 @@ def calculate_sheet2_data(db: Session, jahr: int) -> dict:
|
|||
Case.kw,
|
||||
Case.fallgruppe,
|
||||
func.count(Case.id).label("anzahl"),
|
||||
func.sum(Case.gutachten.cast(int)).label("gutachten"),
|
||||
func.sum(Case.gutachten.cast(Integer)).label("gutachten"),
|
||||
)
|
||||
.filter(Case.jahr == jahr)
|
||||
.group_by(Case.kw, Case.fallgruppe)
|
||||
|
|
@ -273,7 +273,7 @@ def calculate_sheet3_data(db: Session, jahr: int) -> dict:
|
|||
Case.fallgruppe,
|
||||
func.count(Case.id).label("gutachten"),
|
||||
func.sum(
|
||||
(Case.gutachten_typ == "Alternative").cast(int)
|
||||
(Case.gutachten_typ == "Alternative").cast(Integer)
|
||||
).label("alternative"),
|
||||
)
|
||||
.filter(Case.jahr == jahr, Case.gutachten == True) # noqa: E712
|
||||
|
|
@ -347,14 +347,14 @@ def calculate_sheet4_data(db: Session, jahr: int) -> dict:
|
|||
Case.kw,
|
||||
func.count(Case.id).label("gutachten"),
|
||||
func.sum(
|
||||
(Case.therapieaenderung == "Ja").cast(int)
|
||||
(Case.therapieaenderung == "Ja").cast(Integer)
|
||||
).label("ta_ja"),
|
||||
func.sum(
|
||||
(Case.therapieaenderung == "Nein").cast(int)
|
||||
(Case.therapieaenderung == "Nein").cast(Integer)
|
||||
).label("ta_nein"),
|
||||
func.sum(Case.ta_diagnosekorrektur.cast(int)).label("diagnosekorrektur"),
|
||||
func.sum(Case.ta_unterversorgung.cast(int)).label("unterversorgung"),
|
||||
func.sum(Case.ta_uebertherapie.cast(int)).label("uebertherapie"),
|
||||
func.sum(Case.ta_diagnosekorrektur.cast(Integer)).label("diagnosekorrektur"),
|
||||
func.sum(Case.ta_unterversorgung.cast(Integer)).label("unterversorgung"),
|
||||
func.sum(Case.ta_uebertherapie.cast(Integer)).label("uebertherapie"),
|
||||
)
|
||||
.filter(Case.jahr == jahr, Case.gutachten == True) # noqa: E712
|
||||
.group_by(Case.kw)
|
||||
|
|
|
|||
Loading…
Reference in a new issue