# 🏥 JARVIS Gesundheits-System — Konzept & Architektur

**Version:** 2.0
**Datum:** 08. Mai 2026
**Status:** ✅ Vollständig deployed

---

## 1. Rollenprofil

### JARVIS (Haupt-Agent)
- **Rolle:** Chief Medical Officer (CMO)
- **Aufgaben:**
  - Primärer Ansprechpartner für Sir
  - Entscheidungsfindung und medizinische Beratung
  - Delegierung an den Gesundheitsmanager
  - Überwachung des Gesamtsystems

### CHIEF MEDICAL DATA OFFICER (Gesundheitsmanager)
- **Rolle:** Dedizierter Subagent für Gesundheitsdaten
- **Aufgaben:**
  - Verarbeitung und Analyse aller Gesundheitsdaten
  - PDF-Extraktion (Camelot, pdfplumber, PyMuPDF)
  - Statistische Auswertungen (pandas, scipy, statsmodels)
  - Visualisierung (matplotlib, seaborn, plotly)
  - Automatische PDF-Verarbeitung (Watchdog)

---

## 2. System-Architektur

```
┌─────────────────────────────────────────────────────────────┐
│                    JARVIS (Haupt-Agent)                      │
│  ┌──────────────────────────────────────────────────────┐   │
│  │  CHIEF MEDICAL DATA OFFICER                         │   │
│  │  ┌────────────┐  ┌──────────┐  ┌─────────────────┐ │   │
│  │  │ Watchdog   │  │ Pandas   │  │ scipy/statsmodels│ │   │
│  │  │ PDF-Erk.   │  │ DataFr.  │  │ Korrelationen    │ │   │
│  │  └────────────┘  └──────────┘  └─────────────────┘ │   │
│  │  ┌────────────┐  ┌──────────┐  ┌─────────────────┐ │   │
│  │  │ matplotlib │  │ plotly   │  │ ydata-profiling │ │   │
│  │  │ Heatmaps   │  │ Dash.    │  │ Profil-Reports  │ │   │
│  │  └────────────┘  └──────────┘  └─────────────────┘ │   │
│  └──────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼
┌─────────────────────────────────────────────────────────────┐
│               health_data.db (SQLite)                       │
│  laborwerte | dokumente | symptoms | medications | ...       │
└─────────────────────────────────────────────────────────────┘
```

---

## 3. Datenstruktur

### Datenbank (12 Tabellen)
- **laborwerte**: 237 Einträge, 92 Parameter
- **dokumente**: 55 Dokumente (LABOR, BEFUNDE, SONSTIGES)
- **events**: 239 Health Events
- **medications**: 3 Medikamente (Colchicine, Eliquis, Prednison)
- **vital_signs**: Vitalzeichen
- **nutrition**: Ernährungsdaten
- **symptoms**: Symptome
- **doctor_visits**: Arztbesuche
- **lab_correlations**: Korrelations-Ergebnisse
- **alerts**: Alarme
- **processing_log**: Verarbeitungsprotokoll
- **settings**: System-Einstellungen

### Dateisystem
```
~/.hermes/assets/Gesundheit/
├── health_data.db          # Master-Datenbank
├── inbox/                  # Neue Dokumente (Watchdog überwacht)
├── processed/              # Verarbeitete Dokumente
├── archive/
│   ├── laborberichte/      # Laborberichte (19)
│   ├── befunde/            # Befunde (19)
│   └── sonstiges/          # Sonstige Dokumente (17)
├── reports/                # Generierte Reports
├── knowledge/              # Medizinisches Wissen
├── logs/                   # System-Logs
└── scripts/                # Alle Skripte
```

---

## 4. Werkzeug-Stack

### Datenverarbeitung
- **pandas**: DataFrames, Pivot-Tables, Aggregationen
- **numpy**: Vektorisierte Berechnungen
- **sqlalchemy**: Komplexe SQL-Abfragen

### Statistik & Analyse
- **scipy.stats**: P-Werte, t-Tests, Korrelationen
- **statsmodels**: Lag-Analyse, Time-Series, Regression
- **ydata-profiling**: Automatische Datenprofilierung

### Visualisierung
- **matplotlib/seaborn**: Heatmaps, Zeitreihen, Boxplots
- **plotly**: Interaktive HTML-Dashboards
- **camelot**: PDF-Tabellen-Extraktion
- **PyMuPDF (fitz)**: Fließtext-Extraktion

### Automatisierung
- **watchdog**: Echtzeit-Ordnerüberwachung
- **pdfplumber**: PDF-Text-Extraktion
- **pytesseract**: OCR für gescannte Dokumente

---

## 5. Automatisierung (Watchdog)

### Funktion
- Überwacht `~/Gesundheit/inbox/` auf neue PDFs
- Extrahiert Laborwerte mit Camelot/pdfplumber
- Speichert in `health_data.db`
- Bewegt verarbeitete PDFs zu `processed/`
- Läuft als Hintergrund-Daemon

### Start/Stop
```bash
# Starten
bash ~/.hermes/assets/Gesundheit/scripts/health_watchdog.sh start

# Stoppen
bash ~/.hermes/assets/Gesundheit/scripts/health_watchdog.sh stop

# Status
bash ~/.hermes/assets/Gesundheit/scripts/health_watchdog.sh status
```

---

## 6. Analyse-Fokus (Behçet-Syndrom)

### Priorisierte Laborparameter
1. **CRP** — Entzündungsmarker (Peak: 16.9 mg/l)
2. **Blutbild** — Erythrozyten, Leukozyten, Thrombozyten
3. **Gerinnung** — Faktor VIII, D-Dimere (Eliquis-Monitoring)
4. **Cholesterin** — LDL/HDL-Profile
5. **Leberwerte** — ALT, AST, GGT

### Korrelationsanalyse
- CRP-Verlauf vs. Colchicine-Dosis
- Entzündungsschübe vs. Ernährungsanpassungen
- Thrombose-Risiko vs. Gerinnungswerte
- Histamin-Intoleranz vs. Entzündungsmarker

### Proaktive Warnungen
- CRP > 10 mg/l → Warnung
- CRP > 20 mg/l → Alarm
- Faktor VIII > 150% → Thrombose-Risiko
- Neue Symptom-Einträge → Auswertung

---

## 7. Reports

### Generierte Reports
- **crp_trend.png** — CRP-Verlauf mit Trendlinie
- **cholesterin_profile.png** — Cholesterin-Profile
- **labor_dashboard.html** — Interaktives Plotly-Dashboard
- **health_profile.html** — ydata-profiling Gesamtprofil

### Auf Anfrage
- Korrelationsanalyse für spezifische Parameter
- Heatmaps von Laborparametern
- Zeitreihen-Analysen mit statsmodels
- Ernährungs- vs. Symptom-Korrelationen

---

## 8. Verwendung

### Sir fragt: "Wie sieht mein CRP aus?"
→ JARVIS delegiert an Gesundheitsmanager → CRP-Diagramm + Trendanalyse

### Sir fragt: "Welche Korrelationen gibt es?"
→ JARVIS delegiert → scipy/Statsmodels-Analyse + Heatmap

### Sir legt PDF in inbox/
→ Watchdog erkennt → Camelot-Extraktion → DB-Update → Bestätigung

### Sir fragt: "Gib mir einen Gesamt-Report"
→ JARVIS delegiert → ydata-profiling + Plotly-Dashboard

---

## 9. System-Status

| Komponente | Status |
|------------|--------|
| Python Libraries | ✅ Alle installiert |
| Datenbank (12 Tabellen) | ✅ 237 Laborwerte |
| HealthManager | ✅ CRP-Trend: fallend |
| Watchdog | ✅ Daemon läuft (PID 144737) |
| Reports | ✅ 4 Dateien generiert |
| OCR-Tools | ✅ Camelot, pdfplumber, PyMuPDF |

**Status: ALLE SYSTEME BETRIEBSBEREIT** ✅

---

*Erstellt von JARVIS — 08. Mai 2026*
