Files
HealthLog/src/lib/cycle/index.ts
T
Marc-André Bombeck 2c225ce094 feat(cycle): fold a positive LH/OPK surge into the ovulation estimate
A stored positive ovulation test (LH surge) was ignored by the
predictor. Wire it in as a Marquette/Fehring anchor: a positive surge
predicts ovulation ~24-36h later, so the estimated ovulation is set one
day after the last positive LH test in the current window, sharpening the
estimate over the calendar back-calculation — most valuable in the
thin-data (<3 cycle) case where the median/luteal back-calc is weak.

The LH surge is a SIGNAL that refines, never a sole assertion: it
re-anchors the still-estimated ovulation but never flips
`ovulationConfirmed` (a single indicator is not the symptothermal
double-check), and a confirmed symptothermal/temperature-trend ovulation
always wins over it. The still-learning gate and the un-confirmed status
are preserved. A stale prior-cycle surge whose next-start lands in the
past is rejected.

Citation: Fehring R.J. — Marquette Method; urinary LH peaks ~1 day before
ovulation.
2026-06-14 15:06:55 +02:00

27 lines
672 B
TypeScript

/**
* Cycle prediction + phase engine — public surface.
*
* Pure, deterministic, DB-free. The iOS team re-implements this 1:1 in Swift
* from `.planning/v1.15-cycle/algorithm.md`; the unit-test fixtures under
* `__tests__/` are the shared parity contract.
*/
export * from "./types";
export * from "./day-math";
export {
predictCycle,
estimateCycleLength,
estimatePeriodLength,
observedPeriodLength,
detectTempShift,
detectMucusPeak,
confirmSymptothermal,
detectTemperatureTrend,
detectLhSurgeOvulation,
median,
mad,
resolveLuteal,
clampLuteal,
} from "./prediction";
export { phaseForDay, phaseSeries, type PhaseCycle } from "./phase";