File size: 9,681 Bytes
be1b5d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
# enhanced_display_demo.py
"""
Demonstration of Enhanced Results Display Manager functionality.

This script shows how to use the enhanced display components to format
different types of content with improved visual separation and styling.

Requirements: 1.1, 1.2, 7.1, 7.2
"""

import sys
import os

# Add project root to Python path
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_root not in sys.path:
    sys.path.insert(0, project_root)

from src.interface.enhanced_display_integration import (
    create_enhanced_display_integration,
    example_format_ai_analysis_result,
    example_format_patient_message,
    example_format_complete_response
)
from src.interface.enhanced_results_display_manager import EnhancedDisplayConfig
from src.interface.provider_summary_formatter import PatientData, ClassificationData
from unittest.mock import Mock
from src.core.provider_summary_generator import ProviderSummary


def demo_ai_analysis_formatting():
    """Demonstrate AI analysis section formatting."""
    print("=" * 60)
    print("AI ANALYSIS SECTION FORMATTING DEMO")
    print("=" * 60)
    
    # Example 1: RED flag analysis
    red_result = example_format_ai_analysis_result(
        classification="RED",
        indicators=["Loss of meaning and purpose", "Spiritual crisis", "Hopelessness"],
        reasoning="Patient expressed deep existential concerns and loss of faith, indicating active spiritual distress requiring immediate attention.",
        confidence=0.92
    )
    
    print("RED Flag Analysis:")
    print(red_result)
    print("\n" + "-" * 40 + "\n")
    
    # Example 2: YELLOW flag analysis
    yellow_result = example_format_ai_analysis_result(
        classification="YELLOW",
        indicators=["Mild distress", "Uncertainty"],
        reasoning="Patient shows some signs of spiritual questioning but unclear if it constitutes distress.",
        confidence=0.65
    )
    
    print("YELLOW Flag Analysis:")
    print(yellow_result)
    print("\n" + "-" * 40 + "\n")
    
    # Example 3: GREEN flag analysis
    green_result = example_format_ai_analysis_result(
        classification="GREEN",
        indicators=[],
        reasoning="Normal medical conversation with no spiritual distress indicators detected."
    )
    
    print("GREEN Flag Analysis:")
    print(green_result)


def demo_patient_message_formatting():
    """Demonstrate patient message section formatting."""
    print("\n" + "=" * 60)
    print("PATIENT MESSAGE SECTION FORMATTING DEMO")
    print("=" * 60)
    
    # Example messages
    messages = [
        "I'm feeling lost and don't know what to believe anymore.",
        "The doctors say I'm getting better, but I feel empty inside.",
        "I just want to understand why this happened to me.",
        "Thank you for listening. It helps to talk about these things."
    ]
    
    for i, message in enumerate(messages, 1):
        print(f"Patient Message {i}:")
        result = example_format_patient_message(message)
        print(result)
        print("\n" + "-" * 40 + "\n")


def demo_provider_summary_formatting():
    """Demonstrate provider summary formatting."""
    print("\n" + "=" * 60)
    print("PROVIDER SUMMARY FORMATTING DEMO")
    print("=" * 60)
    
    integration = create_enhanced_display_integration()
    
    # Create sample patient data
    patient_data = PatientData(
        name="Sarah Johnson",
        age=34,
        gender="female",
        phone="(555) 234-5678",
        medical_history=["Breast cancer", "Chemotherapy treatment", "Anxiety"],
        expressed_concerns=["Fear of death", "Loss of faith", "Family burden"],
        patient_input="I don't understand why God would let this happen to me and my children"
    )
    
    classification_data = ClassificationData(
        classification="RED",
        spiritual_concern_type="existential crisis related to illness",
        consent_given=True
    )
    
    # Format as coherent paragraph
    coherent_summary = integration.summary_formatter.format_enhanced_summary(
        patient_data, classification_data
    )
    
    print("Medical Brain Summary:")
    print(coherent_summary)
    print("\n" + "-" * 40 + "\n")
    
    # Create mock provider summary for enhanced display
    mock_summary = Mock(spec=ProviderSummary)
    mock_summary.patient_name = "Sarah Johnson"
    mock_summary.patient_phone = "(555) 234-5678"
    mock_summary.urgency_level = "URGENT"
    mock_summary.follow_up_timeline = "Within 24 hours"
    mock_summary.situation_description = "Patient experiencing existential crisis related to cancer diagnosis"
    mock_summary.indicators = ["Fear of death", "Loss of faith", "Family burden"]
    
    # Format as enhanced display section
    enhanced_display = integration.display_manager.format_provider_summary_section(mock_summary)
    
    print("Enhanced Display Summary:")
    print(enhanced_display)


def demo_complete_response_formatting():
    """Demonstrate complete response formatting with all sections."""
    print("\n" + "=" * 60)
    print("COMPLETE RESPONSE FORMATTING DEMO")
    print("=" * 60)
    
    # Create mock provider summary
    mock_summary = Mock(spec=ProviderSummary)
    mock_summary.patient_name = "Michael Chen"
    mock_summary.patient_phone = "(555) 345-6789"
    mock_summary.urgency_level = "IMMEDIATE"
    mock_summary.follow_up_timeline = "Immediately"
    mock_summary.situation_description = "Patient expressing suicidal ideation and spiritual crisis"
    mock_summary.indicators = ["Suicidal thoughts", "Loss of hope", "Spiritual abandonment"]
    
    # Format complete response
    complete_response = example_format_complete_response(
        patient_message="I just can't take this anymore. What's the point of going on?",
        classification="RED",
        indicators=["Suicidal ideation", "Hopelessness", "Spiritual crisis"],
        reasoning="Patient expressing clear suicidal ideation combined with spiritual distress. Immediate intervention required.",
        provider_summary=mock_summary
    )
    
    print("Complete Response with All Sections:")
    print(complete_response)


def demo_visual_separation():
    """Demonstrate visual separation and styling features."""
    print("\n" + "=" * 60)
    print("VISUAL SEPARATION AND STYLING DEMO")
    print("=" * 60)
    
    integration = create_enhanced_display_integration()
    
    # Demonstrate classification badges
    print("Classification Badges:")
    red_badge = integration.get_classification_badge("RED")
    yellow_badge = integration.get_classification_badge("YELLOW")
    green_badge = integration.get_classification_badge("GREEN")
    
    print(f"RED: {red_badge}")
    print(f"YELLOW: {yellow_badge}")
    print(f"GREEN: {green_badge}")
    print("\n" + "-" * 40 + "\n")
    
    # Demonstrate urgency badges
    print("Urgency Badges:")
    immediate_badge = integration.get_urgency_badge("IMMEDIATE")
    urgent_badge = integration.get_urgency_badge("URGENT")
    standard_badge = integration.get_urgency_badge("STANDARD")
    
    print(f"IMMEDIATE: {immediate_badge}")
    print(f"URGENT: {urgent_badge}")
    print(f"STANDARD: {standard_badge}")
    print("\n" + "-" * 40 + "\n")
    
    # Demonstrate separators
    print("Content Separators:")
    separators = ["light", "medium", "heavy", "section_break"]
    
    for sep_type in separators:
        separator = integration.create_content_separator(sep_type)
        print(f"{sep_type.upper()} separator:")
        print(separator)
        print()


def demo_custom_configuration():
    """Demonstrate custom configuration options."""
    print("\n" + "=" * 60)
    print("CUSTOM CONFIGURATION DEMO")
    print("=" * 60)
    
    # Create custom configuration
    custom_config = EnhancedDisplayConfig(
        ai_analysis_icon="🔍",
        patient_message_icon="📝",
        provider_summary_icon="🏥",
        section_separator="***",
        use_color_coding=True,
        classification_colors={
            "RED": "#cc0000",
            "YELLOW": "#ff9900",
            "GREEN": "#009900"
        }
    )
    
    # Create integration with custom config
    custom_integration = create_enhanced_display_integration(custom_config)
    
    # Format example with custom styling
    custom_result = custom_integration.display_manager.format_ai_analysis_section(
        classification="RED",
        indicators=["Custom styling example"],
        reasoning="This demonstrates custom configuration options.",
        confidence=0.95
    )
    
    print("Custom Configuration Result:")
    print(custom_result)


def main():
    """Run all demonstration functions."""
    print("ENHANCED RESULTS DISPLAY MANAGER DEMONSTRATION")
    print("=" * 60)
    print("This demo shows the enhanced display components in action.")
    print("Note: HTML output is shown as raw HTML for demonstration purposes.")
    print("In a real application, this would be rendered in a web browser.")
    
    try:
        demo_ai_analysis_formatting()
        demo_patient_message_formatting()
        demo_provider_summary_formatting()
        demo_complete_response_formatting()
        demo_visual_separation()
        demo_custom_configuration()
        
        print("\n" + "=" * 60)
        print("DEMONSTRATION COMPLETE")
        print("=" * 60)
        print("All enhanced display components are working correctly!")
        
    except Exception as e:
        print(f"\nError during demonstration: {e}")
        import traceback
        traceback.print_exc()
        return 1
    
    return 0


if __name__ == "__main__":
    sys.exit(main())