Show annotated and unannotated series counts
This commit is contained in:
@@ -350,7 +350,7 @@ def studies(_: str = Depends(require_auth), q: str = "", limit: int = 200) -> li
|
||||
SELECT
|
||||
ct_number, batch_name, target_folder_name, source_patient_name, patient_name_dicom,
|
||||
patient_id, study_date, study_time, modality, dicom_file_count,
|
||||
processed_path, needs_ct_number_fix, status
|
||||
series_count, processed_path, needs_ct_number_fix, status
|
||||
FROM public.{PGTABLE}
|
||||
{where}
|
||||
ORDER BY study_date DESC NULLS LAST, study_time DESC NULLS LAST, ct_number
|
||||
@@ -361,14 +361,20 @@ def studies(_: str = Depends(require_auth), q: str = "", limit: int = 200) -> li
|
||||
"""
|
||||
SELECT ct_number, count(*)::int AS annotated_series
|
||||
FROM public.pacs_dicom_series_annotations
|
||||
WHERE skipped IS NOT TRUE AND jsonb_array_length(body_parts) > 0
|
||||
WHERE skipped IS TRUE
|
||||
OR jsonb_array_length(body_parts) > 0
|
||||
OR plain_ct IS TRUE
|
||||
OR NULLIF(notes, '') IS NOT NULL
|
||||
OR ai_result IS NOT NULL
|
||||
GROUP BY ct_number
|
||||
""",
|
||||
timeout=8,
|
||||
)
|
||||
annotation_map = {row["ct_number"]: row["annotated_series"] for row in annotations}
|
||||
for row in rows:
|
||||
row["annotated_series"] = annotation_map.get(row["ct_number"], 0)
|
||||
total_series = int(row.get("series_count") or 0)
|
||||
row["annotated_series"] = min(total_series, int(annotation_map.get(row["ct_number"], 0)))
|
||||
row["unannotated_series"] = max(0, total_series - int(row["annotated_series"]))
|
||||
return rows
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user