Swift-Query / utils /blueprints /enhancer.py
Darshan Kumar R
Deploy to Hugging Face Spaces (Clean)
ed0b977
Raw History Blame Contribute Delete
843 Bytes
from flask import Blueprint, jsonify, current_app
from ai_agents.clinical_summarizer import ClinicalNoteEnhancer
from utils.db.db import mongo
enhancer_bp = Blueprint("enhancer", __name__, url_prefix="/api/enhancer")
@enhancer_bp.route("/enhance_patient/<int:patient_id>", methods=["POST"])
def enhance_patient_records(patient_id):
"""
API endpoint to trigger the enhancement of a patient's clinical notes.
"""
try:
enhancer = ClinicalNoteEnhancer(mongo)
result = enhancer.enhance_patient_records(patient_id)
return jsonify(result), 200
except ValueError as e:
return jsonify({"error": str(e)}), 404
except Exception as e:
current_app.logger.error(f"An unexpected error occurred during enhancement: {e}")
return jsonify({"error": "An unexpected error occurred."}), 500