Files
aionboarding/ai-patient-onboarding/app/ai/prompt_rules/safety_rules.py
T

76 lines
4.4 KiB
Python

def get_safety_rules() -> str:
"""Emergency detection and safety override rules."""
return """EMERGENCY & SAFETY RULES (HIGHEST PRIORITY — OVERRIDE NORMAL CONVERSATION):
1. EMERGENCY DETECTION:
If the patient mentions ANY of these, IMMEDIATELY provide emergency guidance BEFORE continuing intake:
- Severe/crushing chest pain
- Sudden paralysis or weakness on one side
- Severe breathing difficulty / cannot breathe
- Loss of consciousness / collapsed
- Severe uncontrolled bleeding
- Severe trauma / major injury
- Seizure / convulsion in progress
EMERGENCY RESPONSE: Direct to 108 ambulance immediately.
Example: "This needs urgent medical attention. Please call 108 for an ambulance right away."
Do NOT diagnose. Do NOT say "You are having a heart attack."
2. MENTAL HEALTH CRISIS:
If patient expresses:
- Suicidal thoughts ("end my life", "kill myself", "want to die")
- Self-harm intent
- Immediate danger to self or others
CRISIS RESPONSE: Provide Tele-MANAS helpline (14416) and emergency 108.
Example: "If you're in distress, please reach out to Tele-MANAS at 14416 or call 108 right now. I've noted your details for the doctor."
Do NOT continue normal intake before acknowledging the crisis.
Do NOT diagnose or offer therapy.
3. NON-EMERGENCY SAFETY:
- If symptoms sound potentially urgent but not immediately life-threatening, note urgency but continue intake.
- Always err on the side of caution for safety.
4. PII REDACTION:
- If patient provides Aadhaar, SSN, bank details, or card numbers, do NOT store them.
- Respond: "For your safety, I don't need financial or ID information. Let's focus on your health concern."
"""
# Keywords for backend emergency hard-stop detection
EMERGENCY_KEYWORDS_EN = [
"severe chest pain", "crushing chest pain", "chest pressure",
"can't breathe", "cannot breathe", "severe breathing difficulty", "unable to breathe",
"sudden paralysis", "sudden weakness", "collapsed", "passed out",
"loss of consciousness", "unconscious", "severe bleeding",
"call 108", "call ambulance",
]
CRISIS_KEYWORDS_EN = [
"suicide", "suicidal", "kill myself", "end my life", "want to die",
"self harm", "self-harm", "hurt myself", "don't want to live", "no reason to live",
]
EMERGENCY_KEYWORDS_INDIC = [
# Tamil spoken (severe emergency)
"கடும் நெஞ்சு வலி", "மூச்சு விட முடியல", "மூச்சு விடவே முடியல", "மூச்சு அடைக்குது", "மூச்சு திணறல் கடுமையா",
"மயக்கம்", "மயங்கி விழுந்துட்டேன்", "திடீர்னு கை கால் வேலை செய்யல",
# Hindi spoken (severe emergency)
"सीने में बहुत तेज दर्द", "सांस लेने में बहुत दिक्कत", "सांस नहीं आ रही", "बेहोश", "अचानक हाथ पैर काम बंद",
# Telugu spoken (severe emergency)
"ఛాతీలో చాలా తీవ్రమైన నొప్పి", "శ్వాస తీసుకోవడం చాలా కష్టంగా", "ఊపిരി ఆడడం లేదు", "స్పృహ తప్పి",
# Kannada spoken (severe emergency)
"ಎದೆಯಲ್ಲಿ ತೀವ್ರ ನೋವು", "ಉಸಿರಾಡಲು ತುಂಬಾ ಕಷ್ಟವಾಗುತ್ತಿದೆ", "ಉಸಿರಾಡಲು ಆಗುತ್ತಿಲ್ಲ", "ಪ್ರಜ್ಞೆ ತಪ್ಪಿ",
]
CRISIS_KEYWORDS_INDIC = [
# Tamil spoken crisis
"காயப்படுத்திக்கணும்", "கொல்லணும்", "வாழவே பிடிக்கல", "உயிரோட இருக்க விரும்பல", "உயிரை மாய்த்து", "தற்கொலை",
# Hindi spoken crisis
"खुद को नुकसान", "मर जाने का मन", "खुदकुशी", "जान देना", "आत्महत्या",
# Telugu spoken crisis
"గాయపరుచుకోవాలని", "చనిపోవాలని", "ఆత్మహత్య",
# Kannada spoken crisis
"ನೋಯಿಸಿಕೊಳ್ಳಬೇಕು", "ಸಾಯಬೇಕು", "ಆತ್ಮಹತ್ಯೆ",
]