Offline behavior and caching
References: OFFLINE_FIRST_AND_CLIENT_SYNC.md, SPEC.md §2, AI offline note.
1. Principles
The patient app is online-first for clinical writes and sensitive reads. Cached data is read-only convenience, not a second source of truth.
- Writes (booking, demographics request, messages): require connectivity; queue only if product explicitly adds an idempotent outbox later—default is fail with retry UI.
- Reads: TanStack Query (or equivalent) may cache GET responses with short
staleTime; show last updated or pull to refresh on Home and lists.
2. Degradation
- When offline: show banner; disable booking and send; allow viewing cached appointments and messages if already fetched (stale indicator).
- AI-assisted features: offline behavior per SPEC.md AI subsection—disable or show static education only.
3. PHI on device
- Minimize persistence; use encrypted storage if caching sensitive JSON; clear on logout.
- Align with COMPLIANCE_SECURITY.md §7 for device-level expectations.
4. Sync conflicts
- Booking conflicts (409) are resolved by user choosing another slot—no silent merge (patient-portal-requirements-doc.md AC-Book-2).