fix(medications): offer a new course only on a day the start accepts

canStartCourse answered true on the day a course was ended with End
course, while a course starting that day shares its last day and the
start refused it with 422 overlap. The start is now offered from the
day after the last course's end, the first day validation and the
engine accept.

A course ended at an instant is over for every rule that asks about
today, whatever the zone it is read from: after a move west the course
rows read CURRENT while the medication's own status read ENDED. The
course rows, the coach summary, the overlap rule and the previous-end
read take the instant-aware reading.

Refs #1280
This commit is contained in:
Marc-André Bombeck committed 2026-10-25 00:26:55 +02:00
1 parent 8b66f647cb
commit f0b6854a91
8 files changed
+156 -32

No files matched your search

+8 -4
View File
@@ -53956,8 +53956,10 @@ components:
canStartCourse:
type: boolean
description: "v1.40 — whether `POST /api/medications/{id}/courses` may start a new course now: the medication is active,
not one-time, has a course and every course has ended, and the caller is the record's owner (starting a
course is not delegable, so a delegate always reads false)."
not one-time, has a course and every course's last day is before today (a course ended today with `POST
/api/medications/{id}/courses/end` is over, but a course starting today would share its last day, so the
start is offered from the next day), and the caller is the record's owner (starting a course is not
delegable, so a delegate always reads false)."
nextDueScheduleId:
description: The schedule `nextDueAt` belongs to; null when nothing is due.
type:
@@ -54417,8 +54419,10 @@ components:
canStartCourse:
type: boolean
description: "v1.40 — whether `POST /api/medications/{id}/courses` may start a new course now: the medication is active,
not one-time, has a course and every course has ended, and the caller is the record's owner (starting a
course is not delegable, so a delegate always reads false)."
not one-time, has a course and every course's last day is before today (a course ended today with `POST
/api/medications/{id}/courses/end` is over, but a course starting today would share its last day, so the
start is offered from the next day), and the caller is the record's owner (starting a course is not
delegable, so a delegate always reads false)."
courseStatus:
type: string
enum: