mirror of
https://github.com/complexcaresolutions/dak.c2s.git
synced 2026-03-17 20:43: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
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from sqlalchemy import and_, func
|
from sqlalchemy import Integer, and_, func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.models.case import Case, CaseICDCode
|
from app.models.case import Case, CaseICDCode
|
||||||
|
|
@ -124,9 +124,9 @@ def calculate_sheet1_data(db: Session, jahr: int) -> dict:
|
||||||
db.query(
|
db.query(
|
||||||
Case.kw,
|
Case.kw,
|
||||||
func.count(Case.id).label("erstberatungen"),
|
func.count(Case.id).label("erstberatungen"),
|
||||||
func.sum(Case.unterlagen.cast(int)).label("unterlagen"),
|
func.sum(Case.unterlagen.cast(Integer)).label("unterlagen"),
|
||||||
func.sum(Case.ablehnung.cast(int)).label("ablehnungen"),
|
func.sum(Case.ablehnung.cast(Integer)).label("ablehnungen"),
|
||||||
func.sum(Case.gutachten.cast(int)).label("gutachten"),
|
func.sum(Case.gutachten.cast(Integer)).label("gutachten"),
|
||||||
)
|
)
|
||||||
.filter(Case.jahr == jahr)
|
.filter(Case.jahr == jahr)
|
||||||
.group_by(Case.kw)
|
.group_by(Case.kw)
|
||||||
|
|
@ -203,7 +203,7 @@ def calculate_sheet2_data(db: Session, jahr: int) -> dict:
|
||||||
Case.kw,
|
Case.kw,
|
||||||
Case.fallgruppe,
|
Case.fallgruppe,
|
||||||
func.count(Case.id).label("anzahl"),
|
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)
|
.filter(Case.jahr == jahr)
|
||||||
.group_by(Case.kw, Case.fallgruppe)
|
.group_by(Case.kw, Case.fallgruppe)
|
||||||
|
|
@ -273,7 +273,7 @@ def calculate_sheet3_data(db: Session, jahr: int) -> dict:
|
||||||
Case.fallgruppe,
|
Case.fallgruppe,
|
||||||
func.count(Case.id).label("gutachten"),
|
func.count(Case.id).label("gutachten"),
|
||||||
func.sum(
|
func.sum(
|
||||||
(Case.gutachten_typ == "Alternative").cast(int)
|
(Case.gutachten_typ == "Alternative").cast(Integer)
|
||||||
).label("alternative"),
|
).label("alternative"),
|
||||||
)
|
)
|
||||||
.filter(Case.jahr == jahr, Case.gutachten == True) # noqa: E712
|
.filter(Case.jahr == jahr, Case.gutachten == True) # noqa: E712
|
||||||
|
|
@ -347,14 +347,14 @@ def calculate_sheet4_data(db: Session, jahr: int) -> dict:
|
||||||
Case.kw,
|
Case.kw,
|
||||||
func.count(Case.id).label("gutachten"),
|
func.count(Case.id).label("gutachten"),
|
||||||
func.sum(
|
func.sum(
|
||||||
(Case.therapieaenderung == "Ja").cast(int)
|
(Case.therapieaenderung == "Ja").cast(Integer)
|
||||||
).label("ta_ja"),
|
).label("ta_ja"),
|
||||||
func.sum(
|
func.sum(
|
||||||
(Case.therapieaenderung == "Nein").cast(int)
|
(Case.therapieaenderung == "Nein").cast(Integer)
|
||||||
).label("ta_nein"),
|
).label("ta_nein"),
|
||||||
func.sum(Case.ta_diagnosekorrektur.cast(int)).label("diagnosekorrektur"),
|
func.sum(Case.ta_diagnosekorrektur.cast(Integer)).label("diagnosekorrektur"),
|
||||||
func.sum(Case.ta_unterversorgung.cast(int)).label("unterversorgung"),
|
func.sum(Case.ta_unterversorgung.cast(Integer)).label("unterversorgung"),
|
||||||
func.sum(Case.ta_uebertherapie.cast(int)).label("uebertherapie"),
|
func.sum(Case.ta_uebertherapie.cast(Integer)).label("uebertherapie"),
|
||||||
)
|
)
|
||||||
.filter(Case.jahr == jahr, Case.gutachten == True) # noqa: E712
|
.filter(Case.jahr == jahr, Case.gutachten == True) # noqa: E712
|
||||||
.group_by(Case.kw)
|
.group_by(Case.kw)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue