Health metrics
ctx.HEALTH_CALCULATOR works out an adult health metric in code and places it in a range. Each method takes its own input. It is a screening, not a diagnosis.
Methods
| Method | Input | Returns |
|---|---|---|
bmi | { heightCm, weightKg } | { bmi, category, source } |
bloodPressure | { systolic, diastolic } | { category, urgency, source } |
restingHeartRate | { bpm } | { category, note } |
breathingRate | { breathsPerMinute } | { category, note } |
oxygenSaturation | { percent } | { category, note } |
alcoholUnits | { volumeMl, abvPercent } | { units, formula, note } |
Categories
| Method | category |
|---|---|
bmi | "underweight", "healthy_weight", "overweight", "obesity" (CDC adult bands) |
bloodPressure | "normal", "elevated", "high_blood_pressure_stage_1", "high_blood_pressure_stage_2", "hypertensive_crisis_range" (American Heart Association) |
restingHeartRate | "very_low", "low", "typical_resting_range", "high", "very_high" |
breathingRate | "very_low", "typical_adult_resting_range", "mildly_high", "high" |
oxygenSaturation | "typical_range", "lower_than_expected", "urgent_range" |
Returns
{
bmi: 27.4,
category: "overweight",
source: "CDC adult BMI categories; BMI is a screening measure and not a diagnosis.",
}Use it
import { workflow } from "@loops/sdk";
type Measurements = { heightCm: number; weightKg: number };
export const bmiWorkflow = workflow<Measurements>({
id: "bmi-check",
execute: async ({ step, event }) =>
step.do("Calculate BMI", ({ ctx }) =>
ctx.HEALTH_CALCULATOR.bmi({
heightCm: event.body.heightCm,
weightKg: event.body.weightKg,
}),
),
});What it won’t invent
The ranges are adult ranges. Alcohol units are UK units (millilitres × ABV% ÷ 1000), which vary by country. Readings in an urgent range come back with a note to seek care, not a diagnosis.
Last updated on