# Issue #52: Blutdruck-Ziele benötigen zwei Zielfelder **Status:** 🔲 OFFEN **Erstellt:** 27.03.2026 **Priorität:** Medium **Typ:** Enhancement **Labels:** goals, blood-pressure, enhancement **Aufwand:** 2-3h --- ## Problem **Aktuell:** - Blutdruck-Ziele (goal_type = 'bp') haben nur EIN Zielfeld (`target_value`) - Blutdruck besteht aber aus ZWEI Werten: Systolisch + Diastolisch - Beispiel-Ziel: "Blutdruck senken auf 120/80 mmHg" - Systolisch (oberer Wert): 120 - Diastolisch (unterer Wert): 80 **Konsequenz:** - User kann nur einen Wert als Ziel eingeben - Unvollständige Zieldefinition - Progress-Tracking ungenau --- ## Lösung ### Option A: Dual Target Fields (empfohlen) **Schema-Änderung:** ```sql -- Migration 033 ALTER TABLE goals ADD COLUMN target_value_secondary DECIMAL(10,2); ALTER TABLE goals ADD COLUMN current_value_secondary DECIMAL(10,2); ALTER TABLE goals ADD COLUMN start_value_secondary DECIMAL(10,2); COMMENT ON COLUMN goals.target_value_secondary IS 'Secondary target (e.g., diastolic BP for bp goal type)'; ``` **Anwendung:** - `bp` goal type: - `target_value` = Systolisch (120) - `target_value_secondary` = Diastolisch (80) - Andere goal types: `target_value_secondary` = NULL **UI-Anpassung:** ```jsx // GoalForm - conditional rendering {formData.goal_type === 'bp' && (
)} ``` **Progress-Berechnung:** ```python def calculate_bp_progress(goal): """ Berechnet Progress für Blutdruck-Ziele. Nimmt Durchschnitt von systolischem und diastolischem Progress. """ systolic_progress = calculate_single_progress( goal.current_value, goal.start_value, goal.target_value ) diastolic_progress = calculate_single_progress( goal.current_value_secondary, goal.start_value_secondary, goal.target_value_secondary ) return (systolic_progress + diastolic_progress) / 2 ``` **Display:** ``` 🎯 Blutdruck ━━━━━━━━━━━━━━━━━━━━ Ziel: 120/80 mmHg Aktuell: 135/88 mmHg Fortschritt: 68% (sys: 60%, dia: 75%) ━━━━━━━━━━━━━━━━━━━━ ``` --- ### Option B: JSON Target (flexibler, komplexer) ```sql ALTER TABLE goals ADD COLUMN target_json JSONB; -- Beispiel: { "systolic": 120, "diastolic": 80, "unit": "mmHg" } ``` **Nachteil:** Komplexer zu abfragen, weniger SQL-freundlich. --- ## Betroffene Dateien **Backend:** - `backend/migrations/033_dual_target_fields.sql` (NEU) - `backend/routers/goals.py` - Progress-Berechnung erweitern - `backend/routers/goal_utils.py` - `_get_current_value_for_goal_type()` für BP **Frontend:** - `frontend/src/pages/GoalsPage.jsx` - Form conditional rendering - `frontend/src/pages/GoalsPage.jsx` - Display conditional rendering - `frontend/src/pages/CustomGoalsPage.jsx` - Dual input für BP --- ## Acceptance Criteria - [ ] Migration 033 erstellt und angewandt - [ ] GoalForm zeigt zwei Felder für BP-Ziele (Systolisch/Diastolisch) - [ ] Progress-Berechnung berücksichtigt beide Werte - [ ] Display zeigt "120/80 mmHg" Format - [ ] CustomGoalsPage erlaubt Eingabe beider Werte - [ ] Backward compatible (alte BP-Ziele mit nur target_value funktionieren noch) --- ## Verwandte Issues - Issue #50: Goals System v1 ✅ - Issue #51: Dynamic Focus Areas v2.0 ✅ - Migration 022: goals table (Basis) --- ## Timeline **Geschätzt:** 2-3 Stunden - Migration: 30 min - Backend Logic: 1h - Frontend UI: 1-1.5h - Testing: 30 min --- **Erstellt von:** Claude Code **Review benötigt:** Vor Implementierung mit User abstimmen (Option A vs. B)