feat(backend): dose scheduling + health stats zero-knowledge

Backend changes (frontend + tests follow in next commit):

Dose scheduling:
- New DoseSchedule struct (times_per_day + days_of_week) as a top-level
  plaintext field on Medication. Create/update requests accept it.
- Revised get_adherence: computes scheduled_doses from the schedule over the
  period (days_of_week filtering), so missed doses are now reflected.
  Falls back to taken/total_logged when no schedule.

Health stats zero-knowledge:
- HealthStatistic model now uses opaque encrypted_data blob (like medications).
  Only recorded_at stays plaintext (filterable/sortable).
- HealthStatResponse wire type. Handlers echo opaque blobs.
- Removed the trends endpoint (server can't compute trends on ciphertext;
  frontend computes them client-side after decrypting).
- Deleted the dead HealthData model (kept EncryptedField which it defined).

Verified: backend 24 tests, 0 clippy warnings.
This commit is contained in:
goose 2026-07-04 08:41:48 -03:00
parent 69faa43a72
commit 09589b3bb2
8 changed files with 270 additions and 200 deletions

View file

@ -17,8 +17,7 @@ pub use appointments::{
pub use auth::{login, logout, recover_password, recovery_info, refresh, register};
pub use health::{health_check, ready_check};
pub use health_stats::{
create_health_stat, delete_health_stat, get_health_stat, get_health_trends, list_health_stats,
update_health_stat,
create_health_stat, delete_health_stat, get_health_stat, list_health_stats, update_health_stat,
};
pub use interactions::{check_interactions, check_new_medication};
pub use medications::{