Spaces:
Sleeping
Sleeping
| flowchart TD | |
| %% Стилізація | |
| classDef trigger fill:#e8f5e9,stroke:#4caf50,stroke-width:3px | |
| classDef classifier fill:#fff3e0,stroke:#ff9800,stroke-width:2px | |
| classDef prompt fill:#e3f2fd,stroke:#2196f3,stroke-width:2px | |
| classDef decision fill:#ffebee,stroke:#f44336,stroke-width:2px | |
| classDef lifestyle fill:#f3e5f5,stroke:#9c27b0,stroke-width:3px | |
| %% Три способи активації | |
| Start([Start]) | |
| Start --> CheckTriggers | |
| CheckTriggers{Checking triggers} | |
| %% ТРИГЕР 1: Scheduled | |
| CheckTriggers -->|"📅 Scheduled"| Trigger1["1️⃣ MRE Scheduled Basis<br/>(e.g., once per week)"]:::trigger | |
| Trigger1 --> LifestylePromptDirect1[["💚 LIFESTYLE PROMPT"]]:::lifestyle | |
| %% ТРИГЕР 2: Follow-up | |
| CheckTriggers -->|"🔄 Follow-up"| Trigger2["2️⃣ LLM requested follow-up<br/>in previous session"]:::trigger | |
| Trigger2 --> LifestylePromptDirect2[["💚 LIFESTYLE PROMPT"]]:::lifestyle | |
| %% ТРИГЕР 3: Patient Initiated | |
| CheckTriggers -->|"💬 Message"| Trigger3["3️⃣ Patient message"]:::trigger | |
| %% Детальна логіка для patient-initiated | |
| Trigger3 --> Step3_1["3.1 Check Lifestyle Trigger<br/>(keywords, patterns)"]:::classifier | |
| Step3_1 -->|"NO lifestyle markers"| RegularFlow["Regular Medical Flow"] | |
| Step3_1 -->|"YES lifestyle markers"| Step3_2 | |
| Step3_2["3.2 Gemini Classifier<br/>(type of MRE/CE message)"]:::classifier | |
| Step3_2 --> Step3_3 | |
| Step3_3["3.3 FIRST PROMPT<br/>Generate: Suggested message + Escalation flag"]:::prompt | |
| Step3_3 --> EscalationCheck | |
| EscalationCheck{"3.4 Check Escalation Flag"}:::decision | |
| %% Path 4.1: Escalation = TRUE | |
| EscalationCheck -->|"🚨 Escalation = TRUE"| Path4_1["4.1 Regular Medical Prompts<br/>+ Triage"]:::prompt | |
| Path4_1 --> AfterTriage | |
| AfterTriage{"After Triage:<br/>Is lifestyle still relevant?"}:::decision | |
| AfterTriage -->|"YES"| SetCheckIn["Set next check-in time<br/>OR activate immediately"] | |
| AfterTriage -->|"NO"| EndMedical["Continue Medical Flow"] | |
| SetCheckIn -.->|"Schedule next<br/>lifestyle session"| Trigger2 | |
| SetCheckIn -->|"Immediate"| LifestylePromptAfterTriage[["💚 LIFESTYLE PROMPT"]]:::lifestyle | |
| %% Path 4.2: Escalation = FALSE + Lifestyle = TRUE | |
| EscalationCheck -->|"✅ No Escalation +<br/>Lifestyle Trigger"| Path4_2["4.2 Direct to Lifestyle"] | |
| Path4_2 --> LifestylePromptDirect3[["💚 LIFESTYLE PROMPT"]]:::lifestyle | |
| %% Lifestyle Prompt Logic | |
| LifestylePromptDirect1 --> ProfileCheck | |
| LifestylePromptDirect2 --> ProfileCheck | |
| LifestylePromptDirect3 --> ProfileCheck | |
| LifestylePromptAfterTriage --> ProfileCheck | |
| ProfileCheck{"Patient Profile<br/>Exists?"}:::decision | |
| ProfileCheck -->|"❌ NO Profile"| GatherInfo["📋 GATHER INFORMATION<br/>• Limitations<br/>• Preferences<br/>• Goals<br/>• Medical conditions"]:::prompt | |
| ProfileCheck -->|"✅ HAS Profile"| LifestyleCoaching["💚 LIFESTYLE COACHING<br/>Based on existing profile"]:::lifestyle | |
| GatherInfo --> CreateProfile["Create Initial<br/>Patient Profile"] | |
| CreateProfile --> LifestyleCoaching | |
| LifestyleCoaching --> UpdateProfile["🔄 Update Profile<br/>with session data"] | |
| UpdateProfile --> SessionEnd["Session Complete"] | |