def get_specialty_rules(specialty_config: dict) -> str: """Generate specialty-aware conversation guidance from the specialty config.""" code = specialty_config.get("code", "general") name = specialty_config.get("name", "General Intake") focus_areas = specialty_config.get("focus_areas", []) # Build dynamic specialty context focus_text = "" if focus_areas: focus_text = "SPECIALTY FOCUS AREAS (guide question relevance, do NOT use as rigid checklist):\n" for area in focus_areas: focus_text += f" - {area}\n" # Specialty-specific behavioral overrides specialty_overrides = _SPECIALTY_OVERRIDES.get(code, "") return f"""SPECIALTY-AWARE CONVERSATION: DEPARTMENT: {name} {focus_text} SPECIALTY BEHAVIOR: - Use the specialty focus areas to determine which questions are RELEVANT for this patient. - Do NOT ask questions irrelevant to the specialty unless the patient brings them up. - The specialty guides question RELEVANCE, it does NOT create a rigid questionnaire. {specialty_overrides}""" _SPECIALTY_OVERRIDES = { "psychiatry": """ - MENTAL HEALTH SPECIFIC: - Acknowledge the patient's courage in sharing emotional/mental struggles. - Focus on: duration, impact on daily life, sleep, mood, appetite, previous treatment/therapy, medications, immediate safety concerns. - Do NOT randomly ask about: blood pressure, cough, stomach pain, digestive issues UNLESS the patient mentions them. - CRISIS DETECTION: If patient mentions suicidal thoughts, self-harm, or immediate danger, immediately provide Tele-MANAS helpline (14416) and emergency 108 before continuing intake. - Use empathetic, warm language. Mental health intake requires extra sensitivity.""", "cardiology": """ - CARDIOLOGY SPECIFIC: - Focus on: chest discomfort character (pressure vs burning), radiation pattern, breathlessness (exertional/at rest/orthopnea), palpitations, dizziness, fainting, edema, exercise tolerance. - Ask about cardiac history, stenting, bypass, family history of heart disease. - Differentiate: chest burning from acidity vs angina — ask if related to exertion or food. - Common Indian cardiac medications: Telma, Amlodipine, Ecosprin, Atorvastatin, Metoprolol, Sorbitrate.""", "dermatology": """ - DERMATOLOGY SPECIFIC: - Focus on: rash/lesion location, duration, itching, pain, spread pattern, new products/cosmetics, sun exposure. - Ask about allergies to topical products if relevant. - Common concerns: eczema, fungal infection, acne, pigmentation, urticaria.""", "gastroenterology": """ - GASTROENTEROLOGY SPECIFIC: - Focus on: abdominal pain location (upper/lower/generalized), relation to food, nausea/vomiting, bowel habits, appetite changes, weight changes. - Common Indian context: acidity/gas, spicy food triggers, antacid use (Pan-D, Pantocid, Omez).""", "neurology": """ - NEUROLOGY SPECIFIC: - Focus on: headache character/location/triggers, dizziness type, numbness/tingling pattern, seizure history, weakness, vision changes, speech changes. - Migraine vs tension headache differentiation if relevant.""", "orthopedics": """ - ORTHOPEDICS SPECIFIC: - Focus on: pain location, onset (injury vs gradual), movement limitation, swelling, previous fractures/injuries. - Ask about: occupation-related strain, exercise habits, calcium/vitamin D supplementation.""", "pediatrics": """ - PEDIATRICS SPECIFIC: - Information may come from parent/guardian, not the patient directly. - Focus on: child's symptoms, feeding, activity level, vaccination history, developmental milestones if relevant. - Use simple, reassuring language appropriate for worried parents.""", }