GlucoseIQ
API Reference@glucoseiq/core

Episodes

Timestamp-grouped hypoglycemia and hyperglycemia episode candidates.

detectEpisodes

Import: @glucoseiq/core/metrics

detectEpisodes(readings: GlucoseReading[], options?: EpisodeOptions): EpisodeResult

Groups hypo- and hyperglycemia episode candidates from a series of readings.

Consecutive beyond-threshold timestamps less than endDurationMin apart remain grouped. Non-excursion and missing readings are not retained, so a candidate does not prove observed recovery or continuous sensor coverage.

Returns: Hypo and hyper episode candidates plus a summary

import { type GlucoseReading } from '@glucoseiq/core'
import { detectEpisodes } from '@glucoseiq/core/metrics'

const readings: GlucoseReading[] = [
  { value: 65, unit: 'mg/dL', timestamp: '2024-01-01T08:00:00Z' },
  { value: 60, unit: 'mg/dL', timestamp: '2024-01-01T08:10:00Z' },
  { value: 62, unit: 'mg/dL', timestamp: '2024-01-01T08:20:00Z' },
]
const { hypoEvents, summary } = detectEpisodes(readings)
const firstEpisode = hypoEvents[0]
if (firstEpisode) firstEpisode.durationMinutes
summary.hypoCount
ParameterDescription
readingsGlucose readings with ISO 8601 timestamps
optionsThresholds, minimum candidate duration, and separating gap

On this page