GlucoseIQ

Conversions, A1C & GMI

Unit conversions and A1C / eAG / GMI estimation.

15 functions

Generated from the source TSDoc — every signature, parameter, and example is the real thing.

a1cDelta

a1cDelta(current: number, previous: number): number

Calculates the change (delta) between two A1C values.

ParameterDescription
currentCurrent A1C
previousPrevious A1C

Returns — Delta (current - previous)

Throws — If either value is invalid


a1cToGMI

a1cToGMI(a1c: number): number

Converts A1C to Glucose Management Indicator (GMI).

ParameterDescription
a1cA1C value

Returns — GMI value

See: https://diatribe.org/glucose-management-indicator-gmi


a1cTrend

a1cTrend(readings: number[]): "increasing" | "decreasing" | "stable" | "insufficient data"

Determines the trend of A1C values over time.

ParameterDescription
readingsArray of A1C values (chronological order)

Returns — 'increasing' | 'decreasing' | 'stable' | 'insufficient data'


convertGlucoseUnit

convertGlucoseUnit(__namedParameters: { … }): ConversionResult

Converts clinical glucose value between mg/dL and mmol/L. Used for clinical interoperability and analytics.

Returns — Object with converted value and new unit

Throws — If value is not a finite number or is negative/zero

Throws — If unit is not a supported glucose unit

See: https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2021/DataFiles/BIOPRO_L.htm


estimateA1CFromAverage

estimateA1CFromAverage(avgGlucose: number, unit?: GlucoseUnit): number

Estimates A1C from average glucose.

ParameterDescription
avgGlucoseAverage glucose value
unitGlucose unit (mg/dL or mmol/L)

Returns — Estimated A1C

See: https://www.cdc.gov/diabetes/managing/managing-blood-sugar/a1c.html


estimateA1CFromAvgGlucose

estimateA1CFromAvgGlucose(avgMgDl: number): number

Converts clinical average glucose (mg/dL) to estimated A1C (percentage). Used for clinical analytics and patient reporting.

ParameterDescription
avgMgDlAverage glucose in mg/dL

Returns — Estimated A1C value (percentage)

See: https://www.cdc.gov/diabetes/managing/managing-blood-sugar/a1c.html


estimateAvgGlucoseFromA1C

estimateAvgGlucoseFromA1C(a1c: number): number

Converts clinical A1C value (percentage) to estimated average glucose (mg/dL). Used for clinical analytics and patient reporting.

ParameterDescription
a1cA1C value (percentage)

Returns — Estimated average glucose in mg/dL

See: https://www.cdc.gov/diabetes/managing/managing-blood-sugar/a1c.html


estimateEAG

estimateEAG(a1c: number): number

Estimates eAG (estimated average glucose, mg/dL) from clinical A1C value. Throws if input is negative. Used for clinical and research reporting.

ParameterDescription
a1cA1C value (percentage)

Returns — Estimated average glucose (mg/dL)

Throws — If a1c is negative

See: https://www.cdc.gov/diabetes/managing/managing-blood-sugar/a1c.html


estimateGMI

estimateGMI(valueOrOptions: string | number | EstimateGMIOptions, unit?: GlucoseUnit): number

Estimate Glucose Management Indicator (GMI) from average glucose.

ParameterDescription
valueOrOptionsGlucose value, string, or options object
unitGlucose unit (if value is a number)

Returns — GMI value

Throws — If unit is required but not provided when input is a number.

Throws — If the glucose unit is unsupported.

Throws — If the glucose value is not a positive number.

See: https://diatribe.org/glucose-management-indicator-gmi


formatA1C

formatA1C(val: number): string

Formats a clinical A1C value as a percent string (e.g., "7.2%"). Used for clinical reporting and display.

ParameterDescription
valA1C value (percentage)

Returns — A1C as string with percent sign


getA1CCategory

getA1CCategory(a1c: number, thresholds?: { … }): "normal" | "prediabetes" | "diabetes" | "invalid"

Returns the clinical category for an A1C value (normal, prediabetes, diabetes, or invalid). Uses ADA thresholds by default, but allows custom cutoffs for research or population-specific use.

ParameterDescription
a1cA1C value (percentage)
thresholdsOptional custom thresholds: { normalMax?: number; prediabetesMax?: number }

Returns — 'normal' | 'prediabetes' | 'diabetes' | 'invalid'


isA1CInTarget

isA1CInTarget(a1c: number, target?: [number, number], thresholds?: { … }): boolean

Checks if an A1C value is within a target range.

ParameterDescription
a1cA1C value
target[min, max] range (default: [6.5, 7.0])
thresholdsOptional custom thresholds: { min?: number; max?: number }

Returns — True if in target range


isValidA1C

isValidA1C(value: unknown): boolean

Validates a clinical A1C value (percentage). Ensures value is within physiologically plausible range for clinical analytics.

ParameterDescription
valueCandidate A1C value

Returns — True if value is a valid A1C percentage


mgDlToMmolL

mgDlToMmolL(val: number): number

Converts clinical glucose value from mg/dL to mmol/L. Used for international interoperability and reporting.

ParameterDescription
valGlucose value in mg/dL

Returns — Value in mmol/L

Throws — If val is not a finite number or is negative/zero

const result = mgDlToMmolL(180)
console.log(result) // 10.0

See: https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2021/DataFiles/BIOPRO_L.htm


mmolLToMgDl

mmolLToMgDl(val: number): number

Converts clinical glucose value from mmol/L to mg/dL. Used for international interoperability and reporting.

ParameterDescription
valGlucose value in mmol/L

Returns — Value in mg/dL

Throws — If val is not a finite number or is negative/zero

const result = mmolLToMgDl(5.5)
console.log(result) // 99

See: https://wwwn.cdc.gov/Nchs/Data/Nhanes/Public/2021/DataFiles/BIOPRO_L.htm

On this page