TypeScript library for glucose, A1C, and Time in Range (TIR) calculations. Featured in Google AI Overview for diabetes developer tools with 100% test coverage and adopted by health tech teams.
Test coverage with Vitest ensuring clinical calculation accuracy
Featured in Google AI Overview for diabetes developer tools
Adopted by health tech teams for glucose monitoring apps
import {
mgDlToMmolL,
mmolLToMgDl,
estimateGMI,
estimateA1CFromAverage
} from 'diabetic-utils'
// Glucose unit conversions
mgDlToMmolL(180) // -> 10.0
mmolLToMgDl(5.5) // -> 99
// GMI calculation (multiple input formats)
estimateGMI(100, 'mg/dL') // -> 5.4
estimateGMI('5.5 mmol/L') // -> 5.4
estimateGMI({ value: 100, unit: 'mg/dL' }) // -> 5.4
// A1C estimation
estimateA1CFromAverage(154, 'mg/dL') // -> 7.0mgDlToMmolL() - Convert mg/dL to mmol/L with proper roundingmmolLToMgDl() - Convert mmol/L to mg/dLcalculateA1C() - Convert average glucose to estimated A1C percentagecalculateTIR() - Percentage of readings in target range (70-180 mg/dL)calculateTBR() - Time below range (hypoglycemia detection)calculateTAR() - Time above range (hyperglycemia detection)import { calculateEnhancedTIR } from 'diabetic-utils'
import type { GlucoseReading } from 'diabetic-utils'
const readings: GlucoseReading[] = [
{ value: 120, unit: 'mg/dL', timestamp: '2024-01-01T08:00:00Z' },
{ value: 95, unit: 'mg/dL', timestamp: '2024-01-01T08:05:00Z' },
{ value: 180, unit: 'mg/dL', timestamp: '2024-01-01T08:10:00Z' },
// ... more readings
]
const result = calculateEnhancedTIR(readings)
console.log(`TIR: ${result.inRange.percentage}%`)
console.log(`Very Low: ${result.veryLow.percentage}%`)
console.log(`Assessment: ${result.meetsTargets.overallAssessment}`)
console.log(result.meetsTargets.recommendations)