from fastapi import APIRouter
import os

router = APIRouter()

BASE_REPORT_DIR = "/home/air/sos/templates"

def report_exists(prefix: str, patient_no: int) -> bool:
    filename = f"{prefix}_{patient_no}.pdf"
    path = os.path.join(BASE_REPORT_DIR, filename)
    return os.path.exists(path)

@router.get("/sos/api/report_status/{patient_no}")
def get_report_status(patient_no: int):
    """
    각 환자별로 A/B/C/triage 보고서 파일이 있는지 여부를 반환
    """
    return {
        "A":      report_exists("reportA", patient_no),
        "B":      report_exists("reportB", patient_no),
        "C":      report_exists("reportC", patient_no),
        "triage": report_exists("report_triage", patient_no),
    }
