FHIRPath Calculation Gallery for FHIR Questionnaires

Writing a clinical calculation in FHIRPath by hand — item references, unit conversions, edge cases — is slow and error-prone. The FHIR Questionnaire Builder ships a gallery of ready-made calculations: choose one, say which questionnaire item supplies each input, and the builder inserts a working calculatedExpression you can keep editing.

How it works

  1. In the Builder, open an item's expression editor and choose Choose from gallery.
  2. Pick a calculation and select the questionnaire item for each input (with unit conversion where it applies).
  3. Insert it — the result is ordinary FHIRPath, exported in the standard SDC calculated-expression extension.

Calculations give no result until their inputs are answered, rather than guessing a value. They are reference calculations to save authoring effort, not medical advice — check each formula against its source for your use case.

Calculations in the gallery

BMI (Body Mass Index)

weight ÷ height² — pick the weight and height items, with optional unit conversion.

Inputs

Source: Quetelet index (weight kg ÷ height m²)

BMI (imperial: lb, inches)

weight(lb) × 703 ÷ height(in)² — the standard US imperial BMI formula.

Inputs

Source: Imperial BMI formula (weight lb × 703 ÷ height in²)

BMI Category (WHO)

BMI mapped to its WHO weight category — pick the weight and height items, with optional unit conversion.

Result: Underweight · Normal weight · Overweight · Obese

Inputs

Source: WHO adult BMI classification

Age from birthdate (whole years)

Whole years since a birthdate item — correctly handles a birthday not yet reached this year.

Inputs

Source: Calendar-year difference with birthday adjustment

Unit conversion

Convert a single numeric item between common clinical units.

Inputs

Source: Standard unit conversion factors

GAD-7 total + severity

Sums the 7 GAD-7 items (each scored 0–3) and maps the total to its anxiety severity band.

Result: Minimal anxiety · Mild anxiety · Moderate anxiety · Severe anxiety

Inputs

Source: Spitzer et al. 2006, Arch Intern Med 166:1092

PHQ-9 total + severity

Sums the 9 PHQ-9 items (each scored 0–3) and maps the total to its depression severity band.

Result: Minimal depression · Mild depression · Moderate depression · Moderately severe depression · Severe depression

Inputs

Source: Kroenke, Spitzer & Williams 2001, J Gen Intern Med 16:606

CHA₂DS₂-VASc stroke risk score

Stroke risk score for atrial fibrillation — pick the yes/no item for each criterion (max 9 points).

Inputs

Source: Lip et al. 2010, Chest 137:263

Sum of items

Add as many numeric items as you need — their values (with optional unit conversion) are added together.

Inputs

Source: Plain sum of the picked items

Charlson Comorbidity Index

Add one row per comorbidity the patient has — each contributes its fixed weight (1–6), plus an automatic age-based bonus.

Inputs

Source: Charlson et al. 1987, J Chronic Dis 40:373 (with the Charlson/Deyo age adjustment)

Count of Yes answers

How many of the picked yes/no items are answered Yes — add one row per item.

Inputs

Source: Plain count of the picked items answered Yes

Percent change

(new − baseline) ÷ baseline × 100, rounded to 1 decimal — e.g. weight change since the first visit.

Inputs

Source: Standard relative change: (new − baseline) ÷ baseline × 100

PHQ-2 screen

Sums the 2 PHQ-2 items (each scored 0–3); a total of 3 or more is a positive depression screen.

Result: Negative screen · Positive screen

Inputs

Source: Kroenke, Spitzer & Williams 2003, Med Care 41:1284

Glasgow Coma Scale

Adds the eye (1–4), verbal (1–5) and motor (1–6) responses and maps the total (3–15) to its severity band.

Result: Severe (GCS 3–8) · Moderate (GCS 9–12) · Mild (GCS 13–15)

Inputs

Source: Teasdale & Jennett 1974, Lancet 2:81

Apgar score

Sums the 5 Apgar criteria (each scored 0–2) and maps the total (0–10) to its band.

Result: Low (0–3) · Moderately abnormal (4–6) · Reassuring (7–10)

Inputs

Source: Apgar 1953; AAP/ACOG score bands

qSOFA sepsis screen

Counts the 3 qSOFA criteria that are present; 2 or more means high risk of poor outcome.

Result: Lower risk · High risk

Inputs

Source: Singer et al. 2016 (Sepsis-3), JAMA 315:801

Body surface area (Mosteller)

√(height cm × weight kg ÷ 3600), in m² — pick the height and weight items, with optional unit conversion.

Inputs

Source: Mosteller 1987, N Engl J Med 317:1098

Mean arterial pressure

(systolic + 2 × diastolic) ÷ 3 in mmHg, rounded to 1 decimal.

Inputs

Source: Standard estimate: (systolic + 2 × diastolic) ÷ 3

Serum anion gap

Na − (Cl + HCO₃), all in mEq/L — pick the three lab items.

Inputs

Source: Standard potassium-free form: Na − (Cl + HCO₃)

eGFR (CKD-EPI 2021)

Estimated GFR in mL/min/1.73 m² from creatinine, age and sex — set the answer code that means female if your sex item does not use “female”.

Inputs

Source: Inker et al. 2021, N Engl J Med 385:1737 (race-free CKD-EPI)

Creatinine clearance (Cockcroft–Gault)

(140 − age) × weight ÷ (72 × creatinine), × 0.85 if female, in mL/min — set the answer code that means female if your sex item does not use “female”.

Inputs

Source: Cockcroft & Gault 1976, Nephron 16:31

Expected delivery date (LMP + 280 days)

Last menstrual period + 280 days (40 weeks), assuming a regular 28-day cycle.

Inputs

Source: Naegele's rule, 280-day form (regular 28-day cycle)

Date plus interval

A date item plus a fixed interval — e.g. a follow-up or next-due date.

Inputs

Source: FHIRPath calendar arithmetic

Age at a date (whole years)

Whole years between a birthdate and another date item — e.g. age at the visit or at diagnosis.

Inputs

Source: Calendar-year difference with birthday adjustment

Age in months at a date

Whole months between a birthdate and another date item — for infant and paediatric questionnaires.

Inputs

Source: Calendar-month difference with day-of-month adjustment

Corrected calcium (albumin)

Total calcium adjusted for low albumin, in mg/dL: Ca + 0.8 × (4.0 − albumin).

Inputs

Source: Payne et al. 1973, BMJ 4:643

LDL cholesterol (Friedewald)

Total − HDL − triglycerides ÷ 5, in mg/dL; no result when triglycerides are 400 mg/dL or more.

Inputs

Source: Friedewald et al. 1972, Clin Chem 18:499

HOMA-IR (insulin resistance)

Fasting glucose × fasting insulin ÷ 405 (glucose in mg/dL, insulin in µU/mL), rounded to 2 decimals.

Inputs

Source: Matthews et al. 1985, Diabetologia 28:412

FIB-4 liver fibrosis index

Age × AST ÷ (platelets × √ALT), mapped to low / indeterminate / high risk of advanced fibrosis (cut-offs 1.3 and 2.67).

Result: Low risk (< 1.3) · Indeterminate (1.3–2.67) · High risk (> 2.67)

Inputs

Source: Shah et al. 2009, Clin Gastroenterol Hepatol 7:1104 (cut-offs 1.3 / 2.67)

QTc (Bazett)

QT interval corrected for heart rate: QT ÷ √RR, in ms — over-corrects at fast heart rates.

Inputs

Source: Bazett 1920

QTc (Fridericia)

QT interval corrected for heart rate: QT ÷ RR¹ᐟ³, in ms — steadier than Bazett at fast or slow rates.

Inputs

Source: Fridericia 1920

Ideal body weight (Devine)

Male 50 kg / female 45.5 kg + 2.3 kg per inch over 5 feet — set the answer code that means female if your sex item does not use “female”.

Inputs

Source: Devine 1974, Drug Intell Clin Pharm 8:650

Waist-to-hip ratio

Waist circumference ÷ hip circumference (same unit), rounded to 2 decimals.

Inputs

Source: WHO Expert Consultation 2008, Waist circumference and waist–hip ratio (Geneva)

Days between two dates

Whole days from a start date item to an end date item — e.g. length of stay. Negative if the end is before the start.

Inputs

Source: Calendar day count (Gregorian calendar, leap years included)

Gestational age (completed weeks)

Completed weeks from the last menstrual period to a visit date item; no result if the visit is before the LMP.

Inputs

Source: Standard LMP dating (completed weeks since the first day of the last period)