Compare two periods side by side
compare_periodsCompare two diabetes data windows to answer before/after questions about glucose control, insulin use, and CGM coverage after a therapy or settings change.
Instructions
Compares two windows in one call, for before/after questions such as "how has my control changed since I switched to a fully closed-loop mode (CamAPS Liberty)", a new sensor, or a settings change. Pass period A (the earlier or baseline window) and period B (the later one); each is summarised the same way get_diabetes_summary does.
Returns: periodA and periodB, each with range, averageBG, gmiEstimatedA1c, stdDev, coefficientOfVariation, timeInRange, timeLow, timeHigh, cgmReadingCount, coveragePercent, bolusUnitsPerDay, bolusEventsPerDay, averageBasalUnitsPerDay, totalUnitsPerDay, basalPercent and carbsPerDay; and delta (period B minus period A for each, null when either side lacks it). The two windows can be different lengths, every figure is a rate or percentage, not a total. It does NOT include loop-mode usage: if get_camaps_pump_mode_breakdown is available, call it for each window to see how much of each was spent in automatic/Liberty/etc. Fewer boluses and carb entries in a fully closed-loop window may be expected, rather than missing data. coveragePercent is the share of each window that actually has CGM data: TIR is the share of the readings that exist, so when it is well below 100 (say under 70) the TIR covers only part of that period, and a comparison against a fuller period is weaker. A window with no CGM readings has null glucose metrics and null deltas, it is never treated as 0% time in range. Windows with very few days are noisy: say so when comparing under about a week.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endA | Yes | Period A (baseline) end, ISO 8601 wall-clock. | |
| endB | Yes | Period B (comparison) end, ISO 8601 wall-clock. | |
| lower | No | Optional. Low (hypo) boundary in the chosen unit; readings below it count as time-low. Omit to use the server default (OMNI_LOWER). Pass only to override for this one call, e.g. to ask about time under a different threshold. | |
| units | No | Optional. Glucose unit for this call. Omit to use the unit configured on the server (OMNI_UNITS). One of: "mmol" (mmol/L) or "mgdl" (mg/dL). Pass only to override the configured unit for this one call. | |
| upper | No | Optional. High (hyper) boundary in the chosen unit; readings above it count as time-high. Omit to use the server default (OMNI_UPPER). Pass only to override for this one call. | |
| startA | Yes | Period A (baseline) start, ISO 8601 wall-clock. Required. Window start as an ISO 8601 timestamp, e.g. 2026-06-19T00:00:00.000Z. IMPORTANT: despite the trailing "Z", this is plain WALL CLOCK time, not true UTC — Glooko records only the literal date/time the patient's device showed, with no timezone attached. Use the patient's own wall-clock digits directly (no conversion): resolve "yesterday" or "last 3 weeks" straight into the matching wall-clock date and time. Treated as inclusive. | |
| startB | Yes | Period B (comparison) start, ISO 8601 wall-clock. |