Spaces:
Sleeping
Sleeping
File size: 12,812 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 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 |
# visual_separation_manager.py
"""
Visual Separation Manager for Enhanced UI Display.
This module provides visual separation and styling management for different
content types in the enhanced results display system.
Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
"""
from typing import Dict, List, Optional
from dataclasses import dataclass
from enum import Enum
class ContentType(Enum):
"""Types of content for visual styling."""
AI_ANALYSIS = "ai_analysis"
PATIENT_MESSAGE = "patient_message"
PROVIDER_SUMMARY = "provider_summary"
SECTION_SEPARATOR = "section_separator"
CONTENT_DIVIDER = "content_divider"
@dataclass
class VisualStyle:
"""Visual styling configuration for content types."""
background_color: str
border_color: str
border_width: str = "2px"
border_radius: str = "8px"
padding: str = "15px"
margin: str = "10px 0"
text_color: str = "#333333"
icon_color: str = "#666666"
class VisualSeparationManager:
"""
Visual Separation Manager for enhanced content display.
Provides consistent visual styling and separation for different types
of content in the enhanced results display system.
Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
"""
def __init__(self):
"""Initialize the visual separation manager with default styles."""
self._initialize_default_styles()
def _initialize_default_styles(self) -> None:
"""Initialize default visual styles for different content types."""
self.styles = {
ContentType.AI_ANALYSIS: VisualStyle(
background_color="#fafafa",
border_color="#6c757d",
text_color="#333333",
icon_color="#6c757d"
),
ContentType.PATIENT_MESSAGE: VisualStyle(
background_color="#f0f7ff",
border_color="#4a90e2",
text_color="#333333",
icon_color="#4a90e2"
),
ContentType.PROVIDER_SUMMARY: VisualStyle(
background_color="#fff8f0",
border_color="#dc3545",
text_color="#333333",
icon_color="#dc3545"
)
}
# Classification-specific colors
self.classification_colors = {
"RED": "#dc3545",
"YELLOW": "#ffc107",
"GREEN": "#28a745"
}
# Urgency-specific colors
self.urgency_colors = {
"IMMEDIATE": "#dc3545",
"URGENT": "#fd7e14",
"STANDARD": "#28a745"
}
def create_ai_analysis_styling(self) -> Dict[str, str]:
"""
Create styling configuration for AI analysis sections.
Returns:
Dictionary of CSS styling properties
Requirements: 7.1, 7.3
"""
style = self.styles[ContentType.AI_ANALYSIS]
return {
"container": f"""
border: {style.border_width} solid {style.border_color};
border-radius: {style.border_radius};
padding: {style.padding};
margin: {style.margin};
background-color: {style.background_color};
""",
"header": f"""
display: flex;
align-items: center;
margin-bottom: 10px;
color: {style.text_color};
font-weight: bold;
""",
"icon": f"""
font-size: 1.2em;
margin-right: 8px;
color: {style.icon_color};
""",
"content": f"""
color: {style.text_color};
line-height: 1.4;
"""
}
def create_patient_message_styling(self) -> Dict[str, str]:
"""
Create styling configuration for patient message sections.
Returns:
Dictionary of CSS styling properties
Requirements: 7.2, 7.3
"""
style = self.styles[ContentType.PATIENT_MESSAGE]
return {
"container": f"""
border: {style.border_width} solid {style.border_color};
border-radius: {style.border_radius};
padding: {style.padding};
margin: {style.margin};
background-color: {style.background_color};
""",
"header": f"""
display: flex;
align-items: center;
margin-bottom: 10px;
color: {style.border_color};
font-weight: bold;
""",
"icon": f"""
font-size: 1.2em;
margin-right: 8px;
color: {style.icon_color};
""",
"message_box": f"""
padding: 8px;
background-color: white;
border-radius: 4px;
border-left: 4px solid {style.border_color};
color: {style.text_color};
"""
}
def create_provider_summary_styling(self) -> Dict[str, str]:
"""
Create styling configuration for provider summary sections.
Returns:
Dictionary of CSS styling properties
Requirements: 7.1, 7.2, 7.3
"""
style = self.styles[ContentType.PROVIDER_SUMMARY]
return {
"container": f"""
border: {style.border_width} solid {style.border_color};
border-radius: {style.border_radius};
padding: {style.padding};
margin: {style.margin};
background-color: {style.background_color};
""",
"header": f"""
display: flex;
align-items: center;
margin-bottom: 10px;
color: {style.border_color};
font-weight: bold;
""",
"icon": f"""
font-size: 1.2em;
margin-right: 8px;
color: {style.icon_color};
""",
"info_box": f"""
margin: 10px 0;
padding: 8px;
background-color: #f8f9fa;
border-radius: 4px;
""",
"urgency_box": f"""
margin: 5px 0;
padding: 8px;
background-color: #fff3cd;
border-radius: 4px;
border-left: 4px solid {style.border_color};
"""
}
def generate_section_separators(self) -> Dict[str, str]:
"""
Generate different types of section separators.
Returns:
Dictionary of separator HTML strings
Requirements: 7.4, 7.5
"""
return {
"light": """
<div style='margin: 15px 0; border-top: 1px solid #e0e0e0;'></div>
""",
"medium": """
<div style='margin: 20px 0; text-align: center;'>
<hr style='border: none; border-top: 2px solid #d0d0d0; width: 80%; margin: 0 auto;'>
</div>
""",
"heavy": """
<div style='margin: 30px 0; text-align: center;'>
<div style='display: inline-block; padding: 8px 16px; background-color: #f0f0f0; border-radius: 20px; color: #666; font-size: 0.8em;'>
● ● ●
</div>
</div>
""",
"section_break": """
<div style='margin: 25px 0; text-align: center;'>
<hr style='border: none; border-top: 3px solid #ccc; width: 60%; margin: 0 auto;'>
<div style='margin: 10px 0; color: #666; font-size: 0.9em; font-weight: bold;'>---</div>
</div>
"""
}
def apply_consistent_formatting(self, sections: List[Dict[str, str]]) -> str:
"""
Apply consistent formatting to multiple content sections.
Args:
sections: List of section dictionaries with 'type' and 'content' keys
Returns:
Combined HTML with consistent formatting and separation
Requirements: 7.1, 7.2, 7.4, 7.5
"""
if not sections:
return "<div style='padding: 20px; text-align: center; color: #666;'>No content to display</div>"
formatted_sections = []
separators = self.generate_section_separators()
for i, section in enumerate(sections):
section_type = section.get('type', 'unknown')
content = section.get('content', '')
# Apply appropriate styling based on section type
if section_type == 'ai_analysis':
styling = self.create_ai_analysis_styling()
elif section_type == 'patient_message':
styling = self.create_patient_message_styling()
elif section_type == 'provider_summary':
styling = self.create_provider_summary_styling()
else:
# Default styling for unknown types
styling = {
"container": "padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px;"
}
# Wrap content in styled container
formatted_content = f"""
<div style='{styling.get("container", "")}'>
{content}
</div>
"""
formatted_sections.append(formatted_content)
# Add separator between sections (but not after the last one)
if i < len(sections) - 1:
formatted_sections.append(separators["section_break"])
return "".join(formatted_sections)
def get_classification_styling(self, classification: str) -> Dict[str, str]:
"""
Get styling specific to a classification level.
Args:
classification: The classification level (RED/YELLOW/GREEN)
Returns:
Dictionary of classification-specific styling
Requirements: 7.3
"""
color = self.classification_colors.get(classification.upper(), "#666666")
return {
"badge": f"""
display: inline-block;
padding: 4px 8px;
background-color: {color};
color: white;
border-radius: 12px;
font-size: 0.8em;
font-weight: bold;
text-transform: uppercase;
""",
"border": f"""
border-color: {color};
""",
"text": f"""
color: {color};
""",
"background": f"""
background-color: {color}15;
"""
}
def get_urgency_styling(self, urgency_level: str) -> Dict[str, str]:
"""
Get styling specific to an urgency level.
Args:
urgency_level: The urgency level (IMMEDIATE/URGENT/STANDARD)
Returns:
Dictionary of urgency-specific styling
Requirements: 7.3
"""
color = self.urgency_colors.get(urgency_level.upper(), "#666666")
return {
"badge": f"""
display: inline-block;
padding: 4px 8px;
background-color: {color};
color: white;
border-radius: 12px;
font-size: 0.8em;
font-weight: bold;
text-transform: uppercase;
""",
"border": f"""
border-color: {color};
""",
"text": f"""
color: {color};
""",
"accent": f"""
border-left: 4px solid {color};
"""
}
def create_icon_styling(self, content_type: ContentType) -> str:
"""
Create icon styling for different content types.
Args:
content_type: The type of content for icon styling
Returns:
CSS styling string for icons
Requirements: 7.3, 7.5
"""
base_style = "font-size: 1.2em; margin-right: 8px;"
if content_type in self.styles:
color = self.styles[content_type].icon_color
return f"{base_style} color: {color};"
return f"{base_style} color: #666666;" |