feat(medications): show the change at the start as a segmented fit

The efficacy tab keeps its before/after comparison and gains, per metric
target, the level change and the change in weekly trend at the start,
each with a 95 % interval. The fit covers up to 90 days before and 180
after the start and ends before the first dose change. After the start,
days are left out when fewer than 80 % of the doses of the preceding 14
days were taken (cadence-aware, from the dose ledger) or when the
medication was paused or between courses. Other medications that
started, stopped, changed dose or paused inside the window are listed.
Below 14 days with readings across 21 days on either side the view says
what is missing instead of showing numbers.

The efficacy response gains a nullable segmented block per target.
This commit is contained in:
Marc-André Bombeck committed 2026-10-21 21:50:27 +02:00
1 parent cb8ed92d78
commit 1cf0582603
18 files changed
+1607 -18

No files matched your search

+211
View File
@@ -52711,6 +52711,216 @@ components:
- present
additionalProperties: false
- type: "null"
segmented:
anyOf:
- type: object
properties:
present:
type: boolean
reason:
type: string
enum:
- no_start
- insufficient_before
- insufficient_after
- fit_failed
level:
type: number
window:
anyOf:
- type: object
properties:
from:
type: string
to:
type: string
endReason:
type: string
enum:
- today
- window
- dose_change
required:
- from
- to
- endReason
additionalProperties: false
- type: "null"
days:
type: object
properties:
before:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
after:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
excludedLowAdherence:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
excludedNotTaking:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
required:
- before
- after
- excludedLowAdherence
- excludedNotTaking
additionalProperties: false
adherence:
type: object
properties:
status:
type: string
enum:
- tracked
- not_tracked
floorPct:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
lookbackDays:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
required:
- status
- floorPct
- lookbackDays
additionalProperties: false
levelChange:
anyOf:
- type: object
properties:
estimate:
type: number
ciLow:
type: number
ciHigh:
type: number
standardError:
type: number
includesZero:
type: boolean
required:
- estimate
- ciLow
- ciHigh
- standardError
- includesZero
additionalProperties: false
- type: "null"
slopeChangePerWeek:
anyOf:
- type: object
properties:
estimate:
type: number
ciLow:
type: number
ciHigh:
type: number
standardError:
type: number
includesZero:
type: boolean
required:
- estimate
- ciLow
- ciHigh
- standardError
- includesZero
additionalProperties: false
- type: "null"
preSlopePerWeek:
anyOf:
- type: object
properties:
estimate:
type: number
ciLow:
type: number
ciHigh:
type: number
standardError:
type: number
includesZero:
type: boolean
required:
- estimate
- ciLow
- ciHigh
- standardError
- includesZero
additionalProperties: false
- type: "null"
fit:
anyOf:
- type: object
properties:
n:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
df:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
rSquared:
type: number
residualAutocorrelation:
type: number
hacLag:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
required:
- n
- df
- rSquared
- residualAutocorrelation
- hacLag
additionalProperties: false
- type: "null"
confounders:
type: array
items:
type: object
properties:
medicationName:
type: string
event:
type: string
enum:
- started
- stopped
- dose_change
- paused
- resumed
date:
type: string
required:
- medicationName
- event
- date
additionalProperties: false
required:
- present
- level
- window
- days
- adherence
- levelChange
- slopeChangePerWeek
- preSlopePerWeek
- fit
- confounders
additionalProperties: false
- type: "null"
required:
- kind
- key
@@ -52721,6 +52931,7 @@ components:
- series
- beforeAfter
- levelShift
- segmented
additionalProperties: false
adherence:
type: array