Posts

Showing posts from June, 2026

React / Next.js

 revalidatePath — Server-side function that purges the Next.js cache for a given route so the next request re-fetches fresh data.  "use server" — Directive marking a function/file as a Server Action, callable from the client but executed on the server.  useFormStatus — Client hook that reads the pending/submitting state of the nearest parent <form>. useActionState — Client hook that wires a form to a Server Action and tracks its return value and pending state.  useOptimistic — Client hook that shows an immediate optimistic UI update, then reconciles with the real server result.  startTransition — React API that marks a state update as non-urgent so it won't block the UI (and can run async actions). 307 (Temporary Redirect) — Redirects to another URL while preserving the original HTTP method and body (e.g. POST stays POST), unlike 302 which can downgrade to GET.

[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...