Glucose prediction
Use client.glucose to predict a user's glucose curve after a meal. These examples use the client from Authentication; each prediction uses the client's timezone.
Glucose predictions and profile inputs are health data. Keep request and response values out of analytics, crash reports, and general-purpose logs.
Predict
let request = PredictGlucoseRequest(
userProfile: GlucosePredictionProfile(
age: 35,
sex: .male,
height: Height(value: 70, unit: .inches),
weight: Weight(value: 175, unit: .pounds),
activityLevel: .moderatelyActive,
healthConditions: []
),
foods: [selectedFood],
startTime: Date()
)
let prediction = try await client.glucose.predict(request)foods takes the FoodSelection from a portion or an analyzed meal. You can also pass recent cgmData (CgmReading) and consumedFoods (ConsumedHistoricalFood).
Read the result
prediction: oneGlucosePredictionPointevery 15 minutes fromstartTime, withminutesafterstartTimeand the predicted glucosevaluein mg/dL.impact: aGlucoseImpact?, such as.lowImpact,.mediumImpact, or.highImpact. It can benil, or a value added in a later release, so don't assume those three are the only ones.chart.minandchart.max: suggested y-axis bounds in mg/dL, not the lowest or highest point of the curve. They mark a fixed target range;chart.maxis 180 whenhealthConditionsincludes.type2Diabetes, and 140 otherwise.
curve, scoring, minimum, and maximum are older aliases for prediction, impact, chart.min, and chart.max.
Height and weight
Height takes inches or centimeters, and Weight takes pounds or kilograms. For imperial height, show separate feet and inches fields and send the total in inches (feet * 12 + inches), not a single inches field. Let users switch between feet and inches and centimeters, and between pounds and kilograms.
Next: Voice capture.
Last updated
Was this helpful?