Make last_nag_at timezone-aware before subtracting from the tz-aware
current_time, and store future nag timestamps with timezone.utc to
prevent the mismatch recurring.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
should_send_nag() was iterating all pending schedules for today without
verifying the scheduled time had actually passed. A dose scheduled for
18:00 would get nagged at 13:15. Add an early return when current_time
is before the scheduled dose time.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The medication_schedules.adjusted_time column is a TIME type, but
med_logs.scheduled_time is VARCHAR. When adjusted_time values were
passed into queries against med_logs, PostgreSQL rejected the
comparison. Add _normalize_time() to convert datetime.time objects
to "HH:MM" strings at the entry points of should_send_nag,
record_nag_sent, and mark_med_taken.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>