diff --git a/CLAUDE.md b/CLAUDE.md index a786756..d90334d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,10 +51,10 @@ Default login after first start: `admin` / `admin` (created automatically by `in The product owner specified a pivot away from the original **central multi-patient service** (any logged-in user could see all patients) toward three changes: 1. **Per-account patient isolation** — ✅ implemented. Data model: 1 `nutzer` = 1 account, `patienten.nutzer_id` FK, `admin` role exempt (sees everything). See "Patient isolation" above for the enforcement mechanism. Verified end-to-end (two non-admin accounts cannot see or directly access each other's patients; admin sees all). -2. **No-AI interview flow** — not started. A plain web-form "interview" for onboarding a new patient, aimed at non-technical relatives, replacing/supplementing the current `pgNeu()` single-form patient creation. +2. **No-AI interview flow** — ✅ implemented. `pgNeu()` in `templates/index.html` is now a 6-step guided wizard (`neuWiz` state object, `neuRender()`/`neuNext()`/`neuBack()`/`neuCollect()`) that fully replaced the old single-form dialog: persönliche Daten → Kontakt & Adresse → Krankenversicherung → Pflegesituation → Einschätzung & Pflegeperson → Übersicht. Step 4 asks 5 plain-language situational questions (`NEU_FRAGEN`) plus a Zielgruppe question (`NEU_ZG_OPTIONEN`); `neuSchaetzung()` sums the answers into a **rule-based, non-AI** Pflegegrad range shown with a prominent disclaimer that it's not an official determination (only the Medizinischer Dienst's Begutachtung is). Server enforces a hard cap of 3 patients per non-admin account in `api_neuer_patient` (admin exempt). 3. **Admin dashboard** — not started. Lock/delete accounts, and export archived patient data under lawful (attorney/court) order, with GDPR (DSGVO) compliance as a hard requirement. -The user has asked to be asked clarifying questions about architecture/data model before each piece of this refactor — confirmed decisions so far: 1 nutzer = 1 account (no separate `familien` entity), admin bypasses isolation entirely, backend isolation was built before the interview flow or admin dashboard. Apply the same "ask before assuming" approach to the remaining two pieces. +The user has asked to be asked clarifying questions about architecture/data model before each piece of this refactor. Confirmed decisions so far: 1 nutzer = 1 account (no separate `familien` entity), admin bypasses isolation entirely, interview flow requires login (no public pre-account onboarding), interview fully replaced the old form rather than existing alongside it, 3-patient cap is hard-enforced server-side. Apply the same "ask before assuming" approach to the remaining admin-dashboard piece. ## Known constraints worth knowing before touching auth/security-sensitive code diff --git a/pflegepilot_alpha_v2/pflegepilot/app.py b/pflegepilot_alpha_v2/pflegepilot/app.py index 668d65b..d9fa687 100644 --- a/pflegepilot_alpha_v2/pflegepilot/app.py +++ b/pflegepilot_alpha_v2/pflegepilot/app.py @@ -406,6 +406,14 @@ def api_neuer_patient(): db = get_db() d = request.json u = _get_current_user() + if u and u["rolle"] != "admin": + anzahl = db.execute( + "SELECT COUNT(*) FROM patienten WHERE nutzer_id=?", (u["id"],) + ).fetchone()[0] + if anzahl >= 3: + return jsonify({ + "error": "Maximal 3 Patienten pro Konto. Bitte wenden Sie sich an den Betreiber, falls Sie mehr Angehörige verwalten müssen." + }), 400 cur = db.execute(""" INSERT INTO patienten (vorname,nachname,geburtsdatum,strasse,plz,ort, telefon,email,krankenkasse,versichertennummer,versicherungsart, diff --git a/pflegepilot_alpha_v2/pflegepilot/templates/index.html b/pflegepilot_alpha_v2/pflegepilot/templates/index.html index 01edf4d..7796d6d 100644 --- a/pflegepilot_alpha_v2/pflegepilot/templates/index.html +++ b/pflegepilot_alpha_v2/pflegepilot/templates/index.html @@ -170,6 +170,20 @@ textarea{resize:vertical;min-height:80px} .zg-pill{display:flex;align-items:center;gap:6px;padding:7px 14px;border-radius:20px;border:1px solid var(--border2);cursor:pointer;font-size:13px;color:var(--muted);transition:all .12s} .zg-pill.on{border-color:var(--green);background:var(--gbg);color:var(--gdk);font-weight:500} .zg-pill i{font-size:15px} +.wiz-steps{display:flex;align-items:center;gap:6px;margin-bottom:18px} +.wiz-dot{width:26px;height:26px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:11.5px;font-weight:500;border:1px solid var(--border2);color:var(--muted);background:var(--surface);flex-shrink:0} +.wiz-dot.on{border-color:var(--green);background:var(--green);color:#fff} +.wiz-dot.done{border-color:var(--green);background:var(--gbg);color:var(--gdk)} +.wiz-line{flex:1;height:1px;background:var(--border)} +.wiz-title{font-size:16px;font-weight:500;margin-bottom:4px} +.wiz-hint{font-size:12.5px;color:var(--muted);margin-bottom:16px;line-height:1.5} +.ans-pill{display:flex;align-items:flex-start;gap:10px;padding:11px 14px;border-radius:var(--r);border:1px solid var(--border2);cursor:pointer;font-size:13.5px;color:var(--text);margin-bottom:8px;transition:all .12s} +.ans-pill:hover{background:var(--bg)} +.ans-pill.on{border-color:var(--green);background:var(--gbg);color:var(--gdk);font-weight:500} +.ans-pill .dot{width:16px;height:16px;border-radius:50%;border:1px solid var(--border2);flex-shrink:0;margin-top:1px} +.ans-pill.on .dot{border-color:var(--green);background:var(--green)} +.estimate-box{background:var(--gbg);border:1px solid var(--green);border-radius:var(--rl);padding:14px 16px;margin-bottom:16px} +.estimate-box .big{font-size:20px;font-weight:500;color:var(--gdk)} .hidden{display:none!important} .fl{display:flex}.ic{align-items:center}.g8{gap:8px}.g12{gap:12px}.mla{margin-left:auto} .mt2{margin-top:8px}.mt3{margin-top:12px}.mt4{margin-top:16px} @@ -1256,58 +1270,191 @@ async function loadPat(id){ } // ── Neuer Patient ───────────────────────────────────────── -function pgNeu(){ - R('