def get_extraction_rules() -> str: """Rules for comprehensive clinical information extraction from patient messages.""" return """EXTRACTION RULES — COMPREHENSIVE CLINICAL DATA CAPTURE: 1. CONTEXTUAL ANSWER RULE (ANSWER TO QUESTION != NEW SYMPTOM): - When the patient's message answers the previous AI question, classify it as an ATTRIBUTE of the existing clinical entity rather than a new symptom. - Example 1 (Duration): If AI asked "How long have you had this problem?" / "இந்த பிரச்சனை எத்தனை நாளா இருக்கு?", and patient says "10 டேஸா இருக்கு" / "பத்து நாளா" / "10 days-ah", extract duration="10 days" on the EXISTING symptom. DO NOT create a new symptom {"name": "10 டேஸா இருக்கு"}! - Example 2 (Severity): If AI asked about pain severity, and patient says "ரொம்ப severe-ஆ இருக்கு", extract severity="severe" on the existing symptom. DO NOT create a new symptom {"name": "severe"}. - Example 3 (Location): If AI asked where it hurts, and patient says "வலது பக்கத்துல" / "on the right side", extract location="right side" on the existing symptom. - Example 4 (Medication): If AI asked about medications, and patient says "Metformin 500", extract into medications list. - Example 5 (Allergy): If AI asked about allergies, and patient says "Penicillin, rash வரும்", extract into allergies list. 2. TAMIL / TANGLISH / INDIC DURATION NORMALIZATION: - "10 டேஸா", "10 டேஸ்", "10 days-ah", "10 naala", "பத்து நாளா", "ஒரு பத்து நாளா", "ஒரு 10 டேஸா இருக்கு" -> duration: "10 days" - "ரெண்டு நாளா", "2 days-ah", "இரண்டு நாட்களாக" -> duration: "2 days" - "ஒரு வாரமா", "1 week-ah", "ஒரு வாரம்" -> duration: "1 week" - "ரெண்டு மாசமா", "2 months-ah" -> duration: "2 months" - "நேத்துல இருந்து", "நேற்று முதல்", "since yesterday" -> duration: "since yesterday" - Always attach duration to the primary/relevant existing symptom in CURRENT INTAKE STATE. 3. CASUAL SPEECH & NEGATIVE FILTER: - "நான் bus-ல வந்தேன், தலைவலி பத்து நாளா இருக்கு" -> Extract symptom: "தலைவலி", duration: "10 days". IGNORE "bus-ல வந்தேன்". - "எனக்கு வேற எதுவும் இல்ல" / "nothing else" / "no" -> DO NOT extract as a symptom. Treat as completion indicator. 4. EXTRACT EVERYTHING CLINICALLY RELEVANT FROM EVERY MESSAGE: - Multiple symptoms from one sentence: "fever, headache, and body pain" → 3 separate symptoms. - Duration, severity, location when mentioned: "severe headache on the front for 2 days" → name, severity, location, duration. - Medications with dosage: "Metformin 500 mg twice a day" → name, dosage, frequency. - Allergies with reactions: "allergic to penicillin, causes rash" → name, reaction. - Medical history: "I have diabetes for 8 years" → condition, duration. - Surgical history: "I had surgery last year" → procedure description, approximate time. - Previous episodes: "same problem three months ago" → description, time. - Family history: "My father had heart disease" → condition, relationship. - Functional impact: "couldn't sleep", "couldn't eat" → category, value. 5. STRUCTURED EXTRACTION FORMAT: Use these fields when extracting symptoms: - name (required), duration, severity, location, onset, frequency, pattern, triggers, relieving_factors, aggravating_factors Use these fields for medications: - name (required), dosage, frequency, duration Use these fields for allergies: - name (required), type, reaction Use these fields for medical history: - condition (required), duration, status 6. DEDUPLICATION & NULL PRESERVATION: - When providing state_updates, enrich existing entries rather than duplicating them. - Never replace known values with null. If duration was already known, preserve it."""