Spaces:
Running
Running
fix: Add missing core_classes module
Browse files- src/core/core_classes.py +91 -0
src/core/core_classes.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# core_classes.py
|
| 2 |
+
"""
|
| 3 |
+
Core data classes for Simplified Medical App.
|
| 4 |
+
|
| 5 |
+
Minimal implementation of required classes for backward compatibility.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from dataclasses import dataclass, field
|
| 9 |
+
from typing import List, Optional
|
| 10 |
+
from datetime import datetime
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@dataclass
|
| 14 |
+
class ClinicalBackground:
|
| 15 |
+
"""Patient clinical background information."""
|
| 16 |
+
patient_name: str = "Test Patient"
|
| 17 |
+
age: Optional[int] = None
|
| 18 |
+
conditions: List[str] = field(default_factory=list)
|
| 19 |
+
primary_goal: str = ""
|
| 20 |
+
exercise_preferences: str = ""
|
| 21 |
+
exercise_limitations: str = ""
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@dataclass
|
| 25 |
+
class ChatMessage:
|
| 26 |
+
"""Single chat message."""
|
| 27 |
+
timestamp: str
|
| 28 |
+
role: str # "user" or "assistant"
|
| 29 |
+
message: str
|
| 30 |
+
mode: str = "medical"
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@dataclass
|
| 34 |
+
class SessionState:
|
| 35 |
+
"""Session state tracking."""
|
| 36 |
+
active: bool = False
|
| 37 |
+
start_time: Optional[str] = None
|
| 38 |
+
message_count: int = 0
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class PatientDataLoader:
|
| 42 |
+
"""Load patient data."""
|
| 43 |
+
|
| 44 |
+
@staticmethod
|
| 45 |
+
def load_clinical_background() -> ClinicalBackground:
|
| 46 |
+
"""Load clinical background from file or return test data."""
|
| 47 |
+
try:
|
| 48 |
+
import json
|
| 49 |
+
if os.path.exists("clinical_background.json"):
|
| 50 |
+
with open("clinical_background.json", "r") as f:
|
| 51 |
+
data = json.load(f)
|
| 52 |
+
return ClinicalBackground(**data)
|
| 53 |
+
except Exception:
|
| 54 |
+
pass
|
| 55 |
+
|
| 56 |
+
# Return test data
|
| 57 |
+
return ClinicalBackground(
|
| 58 |
+
patient_name="Test Patient",
|
| 59 |
+
age=None,
|
| 60 |
+
conditions=[],
|
| 61 |
+
primary_goal="",
|
| 62 |
+
exercise_preferences="",
|
| 63 |
+
exercise_limitations=""
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class MedicalAssistant:
|
| 68 |
+
"""Medical assistant for dialog."""
|
| 69 |
+
|
| 70 |
+
def __init__(self, api):
|
| 71 |
+
"""Initialize medical assistant."""
|
| 72 |
+
self.api = api
|
| 73 |
+
|
| 74 |
+
def conduct_dialog(self, message: str, context: List[str]) -> str:
|
| 75 |
+
"""Conduct medical dialog."""
|
| 76 |
+
return "I'm here to help. Could you tell me more?"
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class SoftMedicalTriage:
|
| 80 |
+
"""Soft medical triage manager."""
|
| 81 |
+
|
| 82 |
+
def __init__(self, api):
|
| 83 |
+
"""Initialize soft medical triage."""
|
| 84 |
+
self.api = api
|
| 85 |
+
|
| 86 |
+
def conduct_triage(self, message: str, background: ClinicalBackground, history: List) -> str:
|
| 87 |
+
"""Conduct soft medical triage."""
|
| 88 |
+
return "Thank you for sharing. How can I help you today?"
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
import os
|