Improve study status and sequence loading

This commit is contained in:
Codex
2026-05-27 12:52:03 +08:00
parent ddfee82b0b
commit cfd2b379b5
5 changed files with 305 additions and 22 deletions

View File

@@ -793,12 +793,38 @@ def scan_study(ct_number: str) -> dict[str, Any]:
return cached
def study_summary_payload(data: dict[str, Any]) -> dict[str, Any]:
series_list = data.get("series", [])
total = len(series_list)
annotated = sum(
1
for row in series_list
if row.get("annotation", {}).get("skipped")
or row.get("annotation", {}).get("plain_ct")
or row.get("annotation", {}).get("body_parts")
or row.get("annotation", {}).get("notes")
or row.get("annotation", {}).get("ai_model")
)
return {
"ct_number": data.get("study", {}).get("ct_number", ""),
"series_count": total,
"annotated_series": annotated,
"unannotated_series": max(0, total - annotated),
"summary_updated_at": time.strftime("%Y-%m-%d %H:%M:%S"),
}
@app.get("/api/studies/{ct_number}/series")
def series(ct_number: str, _: str = Depends(require_auth)) -> dict[str, Any]:
data = scan_study(ct_number)
return {"study": data["study"], "series": data["series"]}
@app.get("/api/studies/{ct_number}/summary")
def study_summary(ct_number: str, _: str = Depends(require_auth)) -> dict[str, Any]:
return study_summary_payload(scan_study(ct_number))
def get_series_files(ct_number: str, series_uid: str) -> list[Path]:
data = scan_study(ct_number)
files = data["files"].get(series_uid)