Spaces:
Sleeping
Sleeping
File size: 18,812 Bytes
24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc 09d251c 1d0741a be1b5d2 1d0741a be1b5d2 3512660 1d0741a be1b5d2 09d251c 3512660 09d251c 3512660 09d251c 1d0741a be1b5d2 1d0741a be1b5d2 1d0741a be1b5d2 1d0741a 09d251c 24214fc 09d251c 24214fc 09d251c 24214fc be1b5d2 24214fc 09d251c 24214fc 3512660 24214fc 3512660 09d251c 3512660 09d251c 24214fc 09d251c 24214fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
"""
Help content for the Medical Assistant with Spiritual Support interface.
This file contains the comprehensive user guide displayed in the Help tab.
"""
HELP_CONTENT = """
# π Medical Assistant with Spiritual Support - User Guide
## π₯ What This System Does
This is an **advanced Medical Assistant** with **intelligent spiritual care monitoring**. The system provides comprehensive medical support while automatically detecting emotional and spiritual distress in the background.
**Key Features:**
- π¬ Natural medical conversations
- π Automatic spiritual distress detection
- π¦ Three-tier classification system (GREEN/YELLOW/RED)
- π§ Advanced prompt optimization with session-level testing
- π Comprehensive verification and export capabilities
---
## π Quick Start Guide
### For Medical Conversations (Primary Use)
1. **Open the Chat tab** π¬
2. **Ask your medical question** (symptoms, medications, treatment, lifestyle)
3. **Receive personalized medical guidance**
4. **System automatically monitors** for spiritual distress in the background
5. **If distress detected**, system may ask gentle follow-up questions
### For Testing & Quality Assurance
1. **Enhanced Verification** π - Test individual messages or upload CSV files
2. **Conversation Verification** π§Ύ - Review and export chat-derived sessions
3. **Edit Prompts** π§ - Test prompt modifications in real-time
4. **Model Settings** βοΈ - Configure AI models for different tasks
---
## π§ Spiritual Distress Classification System
The system continuously monitors all conversations using **enhanced classification logic** based on medical professional feedback and classifies them into three categories:
### π’ GREEN (No Spiritual Distress)
**Normal medical conversation continues**
- Medical symptoms and treatments
- Routine health questions
- Medication inquiries
- Lifestyle and wellness topics
- Recovery and rehabilitation
- **Clear positive statements** like "I am fine" (now correctly classified)
### π‘ YELLOW (Potential Spiritual Distress - Needs Clarification)
**System asks 2-3 gentle clarifying questions**
- **Simple sadness without spiritual context** (improved classification)
- Stress, anxiety, or sleep issues
- Grief and loss experiences (without expressed distress)
- Existential or meaning-of-life questions
- Spiritual disconnection or doubt
- Feelings of isolation or loneliness
- Loss of interest in previously enjoyed activities
- **Ambiguous situations** requiring further investigation
**What happens:**
1. System detects potential distress indicators
2. Asks gentle, targeted questions to understand better
3. Evaluates responses to determine if support is needed
4. Either returns to medical conversation (GREEN) or escalates (RED)
### π΄ RED (Active Spiritual Distress - Immediate Attention)
**System prioritizes safety and requests consent for referral**
**Updated RED Definition:** Patient's situation appears to be **caused by or actively causing** emotional or spiritual distress (broader than crisis-only)
**Explicit RED Indicators (Always RED):**
- **Complex grief**
- **Loss of a loved one** (when patient expresses emotional distress)
- **Doubt about meaning of life** (e.g., "Life has no meaning anymore")
- **Doubt about meaning of suffering**
- **Doubt about personal dignity**
- **Loss of meaning and purpose**
- Suicidal thoughts or ideation
- Severe hopelessness or despair
- Spiritual crisis or complete loss of faith
- Anger at God or higher power
- Moral injury or guilt
**What happens:**
1. System detects severe distress indicators
2. Provides immediate compassionate response
3. **Asks for your consent** before sharing information
4. If you consent, generates Medical Brain Compatible Summary for spiritual care team
5. Summary appears in right panel with download option
6. System generates professional summary for medical provider handoff
---
## π¬ Medical Brain Compatible Summary Generation
### What is the Medical Brain Compatible Summary?
When a RED flag case is detected and you consent to a referral, the system **automatically generates** a **Medical Brain compatible summary** - the primary and only format for provider handoffs:
**π Medical Brain Compatible Summary (LLM-Generated)**
- **Single coherent paragraph format** - Compatible with Medical Brain system
- **Demographic information** (name, age, gender)
- **Medical history and conditions** from patient profile
- **Spiritual concerns and indicators** that triggered RED classification
- **Classification rationale** and consent status
- **All patient inputs** throughout the conversation (not just final message)
- **Patient quotes** (actual words from entire conversation)
- **Professional, clinical tone** suitable for medical providers
- **No phone numbers** (team has direct access in application)
### β¨ Automatic Generation (New in v2.3)
**Enhanced Provider Summary Workflow:**
1. **RED flag detected** β System asks for consent
2. **Patient gives consent** β Summary **automatically appears** in Provider Summary panel
3. **No manual action required** β Summary is immediately available for review
4. **Instant access** β Spiritual care team can review and comment immediately
**Key Improvements:**
- **Automatic display** - No need to click "π Check Status & Summary" button
- **Complete conversation context** - Includes all patient inputs, not just final message
- **Streamlined workflow** - Summary appears instantly when consent is given
- **Enhanced content** - Comprehensive patient quotes from entire interaction
### Enhanced Classification System
Based on medical professional feedback, the system now uses **improved classification criteria**:
**π΄ RED Flag Definition (Updated):**
- **Previous:** "Severe distress or crisis"
- **Current:** "Patient's situation appears to be caused by or actively causing emotional or spiritual distress"
- **Broader scope** includes active spiritual distress, not just crisis situations
**Explicit RED Indicators (Always RED):**
- Complex grief
- Loss of a loved one (with expressed distress)
- Doubt about meaning of life
- Doubt about meaning of suffering
- Doubt about personal dignity
- Loss of meaning and purpose
### Customizing Medical Brain Summaries
You can customize how these summaries are generated:
**Edit the Prompt (π§ Edit Prompts tab):**
1. Select **π¬ Spiritual Care Message** from dropdown
2. Modify the system prompt to adjust format, content, or focus
3. Test changes in your current session
4. Promote to file if you want permanent changes
**Choose the AI Model (βοΈ Model Settings tab):**
1. Select model for **π¬ Medical Brain Summary Generator**
2. Default: Claude Sonnet 4.5 (structured, professional language)
3. Alternative: Gemini models for different formatting style
4. Changes apply to your session only
### Summary Features:
- **Medical Brain Integration** - Designed for seamless integration with Medical Brain system
- **Single paragraph format** - Follows Medical Brain notification standards
- **Patient-centered** - Emphasizes patient's actual words and concerns
- **Actionable** - Clear urgency and follow-up timeline
- **Professional tone** - Appropriate for medical provider handoffs
---
## π§ Advanced Prompt Optimization System
### Session-Level Prompt Testing
The **Edit Prompts** tab provides powerful capabilities for testing and optimizing system behavior:
**Key Features:**
- **Real-time editing** of 5 system prompts
- **Session isolation** - changes apply only to your current session
- **Live validation** with immediate feedback on syntax and structure
- **Visual indicators** showing prompt sources (session vs default)
- **Promote to File** workflow for permanent adoption of tested changes
### How to Use Edit Prompts:
1. **Select a prompt** from the dropdown (Spiritual Monitor, Triage Questions, etc.)
2. **Load the current prompt** using the Load button
3. **Make your modifications** in the code editor
4. **Apply changes** to test in your current session
5. **Validate** your changes for syntax and structure
6. **Promote to File** if you want to make changes permanent (creates automatic backup)
7. **Reset to Default** anytime to restore original prompts
### Prompt Types Available:
- π **Spiritual Monitor** - Classifies messages into GREEN/YELLOW/RED (enhanced with medical feedback)
- π‘ **Soft Spiritual Triage** - Generates gentle follow-up questions
- π **Triage Response Evaluator** - Evaluates patient responses to triage questions
- π₯ **Medical Assistant** - Provides medical guidance and support
- π©Ί **Soft Medical Triage** - Handles medical triage and assessment
- π¬ **Medical Brain Summary Generator** - Generates Medical Brain compatible summaries (single format)
---
## βοΈ AI Model Configuration
### Model Settings Tab
Configure which AI models are used for different tasks:
**Available Models:**
- **Gemini 2.5 Flash** - Fast, efficient processing with excellent performance
- **Gemini 2.0 Flash** - Balanced performance and reliability
- **Gemini 3.0 Flash Preview** - Latest Gemini model with enhanced capabilities (preview)
- **Claude Sonnet 4.5** - Advanced reasoning and empathy for complex tasks (20250929)
- **Claude Sonnet 4.0** - Reliable performance with strong reasoning (20250514)
- **Claude 3.7 Sonnet** - Enhanced conversational abilities and nuanced understanding (20250219)
**Task-Specific Configuration:**
- **Spiritual Monitor** - Distress classification (default: Gemini 2.5 Flash)
- **Soft Spiritual Triage** - Question generation (default: Claude Sonnet 4.5)
- **Triage Response Evaluator** - Response analysis (default: Gemini 2.5 Flash)
- **Medical Assistant** - Medical guidance (default: Claude Sonnet 4.5)
- **Soft Medical Triage** - Medical assessment (default: Claude Sonnet 4.5)
- **Medical Brain Summary Generator** - Medical Brain compatible summary generation (default: Claude Sonnet 4.5)
**Session Scope:** Model changes apply only to your current browser session.
---
## π Enhanced Verification System
### Manual Input Mode
**Perfect for testing individual messages:**
1. Enter a test message in the input field
2. Click **Run Classification** to analyze
3. Review detailed results including:
- Classification (GREEN/YELLOW/RED)
- Confidence scores
- Reasoning and indicators detected
- Triage questions (if applicable)
4. **Save verification** to include in session data
5. **Export results** as CSV or JSON
### File Upload Mode
**Ideal for batch testing multiple scenarios:**
1. **Download CSV template** from the interface
2. **Fill in test messages** in the template
3. **Upload completed CSV** file
4. **Start batch classification** with one click
5. **Monitor progress** with real-time updates
6. **Review comprehensive results** with statistics
7. **Export detailed reports** in multiple formats
---
## π§Ύ Conversation Verification
### Chat-Derived Verification
Transform your chat conversations into structured verification sessions:
1. **Have a conversation** in the Chat tab
2. **Go to Conversation Verification** tab
3. **Click Generate** to create verification session from chat
4. **Review each exchange** individually:
- Mark as β
**Correct** or β **Incorrect**
- Add comments for incorrect classifications
- Specify what the correct classification should be
5. **Navigate** between exchanges using Previous/Next buttons
6. **Download results** as JSON or CSV when complete
---
## πΎ Data Export & Download Options
### Chat Tab Exports:
- **π₯ Download JSON** - Complete conversation with all metadata, classifications, and system reasoning
- **π Download CSV** - Conversation in spreadsheet format for analysis
- **π₯ Download Summary** - Provider summary (RED cases only) as text file
### Verification Exports:
- **Enhanced Verification** - Test results with detailed analysis and statistics
- **Conversation Verification** - Reviewed chat sessions with accuracy assessments
- **Session Data** - Complete verification session with all metadata
### Export Features:
- **Multiple Formats** - CSV for spreadsheets, JSON for detailed data
- **Comprehensive Metadata** - Timestamps, confidence scores, reasoning
- **Analysis Ready** - Formatted for statistical analysis and reporting
- **Privacy Compliant** - No PHI stored, only classification data
---
## π₯ Patient Profiles for Testing
### Predefined Scenarios
The **Patient Profiles** tab includes comprehensive test scenarios:
**Distress Level Profiles:**
- π’ **GREEN profiles** - Healthy patients with no spiritual distress
- π‘ **YELLOW profiles** - Various types of potential distress (grief, existential questions, etc.)
- π΄ **RED profiles** - Severe distress scenarios (crisis, hopelessness, spiritual crisis)
**Medical Condition Profiles:**
- Cardiac patients with specific exercise limitations
- Diabetic patients with dietary considerations
- Post-surgery recovery scenarios
- Mental health focused interactions
- Elderly patient considerations
- Athletic patient profiles
---
## π Privacy, Security & Safety
### Data Protection:
- β **No PHI Storage** - Protected Health Information is never stored
- π **Session Isolation** - Each user session is completely separate
- π **Secure API Keys** - Stored locally in environment files only
- π **Audit Logging** - All interactions logged for quality assurance
### Safety Measures:
- π‘οΈ **Conservative Classification** - System errs on the side of caution
- π€ **Consent-Based Referrals** - Spiritual care referrals only with explicit consent
- π¨ **Emergency Protocols** - Clear guidance to contact emergency services
- π₯ **Professional Oversight** - Designed for use with spiritual care team support
### Important Disclaimers:
- **Not a replacement** for professional medical or mental health care
- **Emergency situations** require immediate contact with local emergency services
- **Spiritual care referrals** are recommendations, not mandatory
- **System accuracy** is continuously monitored and improved
---
## π Emergency Information
### If You're in Crisis:
- **Call 911** (US) or your local emergency number immediately
- **National Suicide Prevention Lifeline**: 988 (US)
- **Crisis Text Line**: Text HOME to 741741
- **Go to your nearest emergency room**
### This System:
- **Provides support** but is not emergency intervention
- **Can help identify** when professional help is needed
- **Facilitates referrals** to appropriate spiritual care
- **Complements** but does not replace professional care
---
## π― System Status & Quality
### Current Implementation:
- β
**65+ comprehensive tests** - All passing
- β
**Property-based validation** - 9 correctness properties verified
- β
**Enhanced classification accuracy** - Based on medical professional feedback
- β
**Critical bug fixes** - JSON parsing and classification logic corrected
- β
**Medical Brain integration** - Streamlined provider summary format
- β
**Production ready** - Fully functional and tested
- β
**Advanced features** - Prompt optimization, session management
- β
**Quality assurance** - Continuous monitoring and improvement
### Version Information:
- **System Version**: 2.3
- **Test Coverage**: 65/65 tests passing
- **Last Updated**: January 7, 2026
- **Status**: Production Ready with Enhanced Provider Summary
- **Recent Updates**:
- β
**Automatic provider summary generation** (no manual intervention required)
- β
**Enhanced summary content** (all patient inputs, no phone numbers)
- β
**Improved user experience** (instant summary display on consent)
- β
**Fixed HTML badge rendering** (clean text formatting)
- β
**Fixed critical classification bug** ("I am fine" now correctly β GREEN)
- β
**Enhanced RED flag definition** (broader than crisis-only)
- β
**Added explicit RED indicators** for consistent classification
- β
**Improved simple sadness handling** ("I feel sad" β YELLOW)
- β
**Streamlined Medical Brain integration** (single format)
---
## π Support & Troubleshooting
### Common Issues:
1. **Prompts not loading** - Try refreshing the page or clearing browser cache
2. **Model not responding** - Check that API keys are configured correctly
3. **Export not working** - Ensure you have data to export (completed conversations/verifications)
4. **Session changes lost** - Remember that prompt/model changes are session-only
### Getting Help:
- **Built-in validation** - System provides immediate feedback on issues
- **Reset options** - Use "Reset to Defaults" buttons to restore original settings
- **Test suite** - Run system tests to verify functionality
- **Documentation** - Comprehensive guides available in each tab
### Best Practices:
- **Test changes** in Edit Prompts before promoting to permanent files
- **Use verification modes** to validate system accuracy
- **Export data regularly** for analysis and backup
- **Review provider summaries** before they're sent to spiritual care team
This system represents a comprehensive approach to medical assistance with integrated spiritual care support, designed to provide compassionate, accurate, and safe healthcare guidance.
---
## π§ Recent Classification Improvements
### Critical Bug Fixes (January 2026)
Based on medical professional feedback from `review/Or_2.txt`, the following critical issues have been resolved:
**β
Fixed JSON Parsing Bug:**
- **Issue:** LLM returned `"classification"` field but parser expected `"state"` field
- **Solution:** Updated parser to handle both field formats
- **Impact:** Eliminated classification errors due to parsing failures
**β
Enhanced RED Flag Definition:**
- **Previous:** Limited to "severe distress or crisis"
- **Current:** Broader definition includes "active spiritual distress"
- **Benefit:** More accurate detection of patients needing spiritual care
**β
Added Explicit RED Indicators:**
- Complex grief β Always RED
- Loss of loved one (with distress) β Always RED
- Doubt about meaning of life β Always RED
- Doubt about meaning of suffering β Always RED
- Doubt about personal dignity β Always RED
**β
Improved Specific Case Handling:**
- **"I am fine"** now correctly classified as π’ GREEN (was incorrectly YELLOW)
- **"I feel sad"** now correctly classified as π‘ YELLOW (simple sadness without context)
- **"Life has no meaning"** now correctly classified as π΄ RED (explicit meaning loss)
### Validation Results:
```
β
"I am fine" β π’ GREEN (confidence: 1.0)
β
"I feel sad" β π‘ YELLOW (confidence: 0.9)
β
"Life has no meaning anymore" β π΄ RED (confidence: 1.0)
```
All test cases now pass according to medical professional recommendations.
"""
|