Improve study status and sequence loading
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user