"""Handle attachment queries."""
import json
from ..data import PatientDataLoader
def handle_get_attachment(
patient_id: str,
attachment_id: str,
loader: PatientDataLoader
) -> str:
"""Get attachment content by ID."""
if not loader.patient_exists(patient_id):
return json.dumps({"error": f"Patient {patient_id} not found"})
content = loader.get_attachment(patient_id, attachment_id)
if content is None:
return json.dumps({"error": f"Attachment {attachment_id} not found"})
return json.dumps({
"attachment_id": attachment_id,
"content": content
}, indent=2)