const IN_TO_CM = 2.54; // exact, international inch module.exports = { slug: "ideal-body-weight-devine", title: "Ideal body weight (Devine formula)", deck_category: "health", description: "Estimates ideal body weight in kilograms from sex and height using the Devine formula.", inputs: [ { name: "sex", type: "string", required: true, description: "Biological sex used by the equation", enum: ["male", "female"] }, { name: "height", type: "number", unit: "cm or in", required: true, description: "Height", min: 0 }, { name: "height_unit", type: "string", required: true, description: "Unit of the height value", enum: ["cm", "in"] } ], outputs: [ { name: "ideal_body_weight_kg", unit: "kg", description: "Estimated ideal body weight" } ], steps: [ "Convert height to inches: in = cm / 2.54 if given in centimeters.", "The Devine formula is defined for height at or above 60 inches (5 feet); heights below that use 60 inches as the base per the original formula's construction.", "For males: ideal_body_weight_kg = 50 + 2.3 * (height_in - 60).", "For females: ideal_body_weight_kg = 45.5 + 2.3 * (height_in - 60).", "Round the result to 1 decimal place." ], constants: [ { name: "in_to_cm", value: 2.54, unit: "cm per in", source: 1 }, { name: "male_base_kg", value: 50, unit: "kg", source: 0 }, { name: "female_base_kg", value: 45.5, unit: "kg", source: 0 }, { name: "per_inch_over_five_feet", value: 2.3, unit: "kg per in", source: 0 }, { name: "base_height_in", value: 60, unit: "in", source: 0 } ], sources: [ { kind: "edition_page", value: "Devine BJ. Gentamicin therapy. Drug Intell Clin Pharm. 1974;8:650-655.", title: "Original publication of the Devine ideal body weight formula", publisher: "Drug Intelligence and Clinical Pharmacy", retrieved_utc: "2026-09-30T19:15:00Z", note: "Source of the 50/45.5 base and 2.3 kg per inch coefficients." }, { kind: "edition_page", value: "International Yard and Pound Agreement, 1959", title: "Exact inch to centimeter conversion factor", publisher: "NIST Handbook 44, Appendix C", retrieved_utc: "2026-09-30T19:15:00Z", note: "Defines 1 in = 2.54 cm exactly." } ], disclaimer: "General formula only. Not medical advice. Dosing decisions belong to a licensed clinician and the product's label.", questionText(inputs) { return `What is the Devine ideal body weight for a ${inputs.sex} who is ${inputs.height} ${inputs.height_unit} tall?`; }, run(inputs) { const { sex, height, height_unit } = inputs; if (sex !== "male" && sex !== "female") throw new Error("sex must be male or female"); if (typeof height !== "number" || height <= 0) throw new Error("height must be a positive number"); let heightIn; if (height_unit === "cm") heightIn = height / IN_TO_CM; else if (height_unit === "in") heightIn = height; else throw new Error("height_unit must be cm or in"); const heightInForFormula = Math.max(heightIn, 60); const base = sex === "male" ? 50 : 45.5; const ibwRaw = base + 2.3 * (heightInForFormula - 60); const ibw = Math.round(ibwRaw * 10) / 10; return { answer: `${ibw.toFixed(1)} kg`, values: { ideal_body_weight_kg: ibw } }; }, examples: [ { name: "worked example", inputs: { sex: "male", height: 180, height_unit: "cm" }, expected: { answer: "75.0 kg" }, check: "180 / 2.54 = 70.86614 in; 70.86614 - 60 = 10.86614; 10.86614 * 2.3 = 24.99212; 50 + 24.99212 = 74.99212, rounds to 75.0." }, { name: "test vector: female, inches", inputs: { sex: "female", height: 64, height_unit: "in" }, expected: { answer: "54.7 kg" }, check: "64 - 60 = 4; 4 * 2.3 = 9.2; 45.5 + 9.2 = 54.7." } ] };