Spaces:
Sleeping
Sleeping
| from chatbot.intents import detect_intent | |
| from models.bart_explainer import generate_explanation | |
| def chatbot_response(question, note, risk_score): | |
| intent = detect_intent(question) | |
| if intent == "appointment": | |
| if "follow" in note.lower(): | |
| return "Your discharge summary mentions a follow-up. Please consult your provider for scheduling." | |
| return "No specific follow-up appointment is mentioned in the discharge summary." | |
| if intent == "severity": | |
| if risk_score > 0.6: | |
| level = "high" | |
| elif risk_score > 0.3: | |
| level = "moderate" | |
| else: | |
| level = "low" | |
| return f"Your readmission risk is considered {level}." | |
| if intent == "explanation": | |
| return generate_explanation(note, risk_score) | |
| return "I can help explain risk, follow-up, or discharge information. I cannot provide medical advice." | |