Health risks
ctx.HEALTH_CALCULATOR.healthRisks works out screening risk scores in code from age, sex, BMI, and blood pressure. No bloods are needed, so a finished face scan plus a few answers is enough.
Input
| Field | Type | What it means |
|---|---|---|
age | number | Age in years. |
gender | "male" | "female" | Sex used by the risk models. |
bmi | number | Body mass index. |
systolic, diastolic | number | Blood pressure. |
isSmoker | boolean | Optional. Defaults to false. |
hasDiabetes | boolean | Optional. Defaults to false. |
isTreatedForHypertension | boolean | Optional. Defaults to false. |
Returns
{
tenYearCvdRiskPercent: 7.9,
vascularAgeYears: 52,
hypertensionRiskPercent: 21,
diabetesRiskPercent: 9,
fattyLiverRisk: "moderate",
basedOn: {
age: 46,
gender: "female",
bmi: 27.4,
bloodPressure: "132/84",
smoker: false,
diabetes: false,
treatedForHypertension: false,
},
note: "...",
}vascularAgeYears is the heart age: the age of someone with healthy risk factors and the same 10-year risk.
Use it
import { workflow } from "@loops/sdk";
type Answers = {
patientId: string;
age: number;
gender: "male" | "female";
smoker: boolean;
};
type ScanVitals = {
systolic_blood_pressure_mmhg: number;
diastolic_blood_pressure_mmhg: number;
height_cm: number;
weight_kg: number;
};
export const heartAgeWorkflow = workflow<Answers>({
id: "heart-age",
execute: async ({ step, event }) => {
await step.do("Create the scan", ({ ctx }) =>
ctx.FACIAL_SCAN.create({ metadata: { patientId: event.body.patientId } }),
);
const scan = await step.waitForScan<ScanVitals>({ timeout: "30 minutes" });
const vitals = scan.results;
return step.do("Work out the heart age", async ({ ctx }) => {
const { bmi } = await ctx.HEALTH_CALCULATOR.bmi({
heightCm: vitals.height_cm,
weightKg: vitals.weight_kg,
});
return ctx.HEALTH_CALCULATOR.healthRisks({
age: event.body.age,
gender: event.body.gender,
bmi,
systolic: vitals.systolic_blood_pressure_mmhg,
diastolic: vitals.diastolic_blood_pressure_mmhg,
isSmoker: event.body.smoker,
});
});
},
});What it won’t invent
The 10-year risk uses the Framingham general cardiovascular model, which covers ages 30 to 74. Outside that range tenYearCvdRiskPercent and vascularAgeYears are null. Smoking, diabetes, and treatment count as “no” when left out, so ask before you call it if they matter. It is an educational screening, not a diagnosis.
Last updated on