Posts

Showing posts from June, 2026

[Debug] Fix Repeat Cadence Timeline Patient View

Date: June 9, 2026 Scope: 6 files changed (+264 / −65 lines) — bug fix + tests The Problem Rehab and survey assignments that repeat on a cadence (e.g. “every 4 days”) were showing up on the wrong days in two places: Patient app — items appeared when they shouldn’t, or disappeared when they should be visible Plan Builder timeline — recurring bars were drawn on incorrect dates A concrete example: a PCSS symptom survey assigned to start on June 9 at midnight, with a patient day reset at 3:00 AM, was visible at 2:00 AM — one patient-day too early. It should only appear after the day reset. Root Causes 1. Backend: patientHandler.ts The API that builds the patient’s rehabArray had several date-handling issues: The SQL MOD(...) repeat-cadence calculation applied the day-reset offset incorrectly to the assignment start date Timestamps from Postgres were parsed with new Date(), which introduced timezone and midnight-boundary drift No guard when repeat_every_x_days was 0 Items outside their star...