module.exports = { slug: "dose-by-weight", title: "Weight-based dose (general formula)", deck_category: "health", description: "Multiplies a body weight in kilograms by a per-kilogram dose to compute a total dose, general formula only, optionally capped at a maximum.", inputs: [ { name: "weight_kg", type: "number", unit: "kg", required: true, description: "Body weight in kilograms", min: 0 }, { name: "dose_per_kg", type: "number", unit: "as given by dose_per_kg_unit", required: true, description: "Dose amount per kilogram of body weight", min: 0 }, { name: "dose_per_kg_unit", type: "string", required: true, description: "Unit of dose_per_kg, for example mg/kg or mcg/kg", min: 1 }, { name: "max_dose", type: "number", unit: "same unit as the computed dose", required: false, description: "Optional maximum total dose cap", min: 0 } ], outputs: [ { name: "total_dose", unit: "same base unit as dose_per_kg_unit", description: "Computed total dose, capped at max_dose if provided and exceeded" } ], steps: [ "raw_dose = weight_kg * dose_per_kg.", "If max_dose is provided and raw_dose exceeds it, total_dose = max_dose; otherwise total_dose = raw_dose.", "Round the result to 2 decimal places." ], constants: [], sources: [ { kind: "edition_page", value: "Standard weight-based dosing arithmetic (dose = weight x dose-per-kilogram, capped at a maximum where clinically indicated)", title: "General pharmacology dosing-by-weight method", publisher: "Standard pharmacology reference practice (e.g. Goodman & Gilman's The Pharmacological Basis of Therapeutics, dosing chapter)", retrieved_utc: "2026-09-30T19:25:00Z", note: "This card performs only the general arithmetic; it never bakes in a drug-specific dose. The per-kilogram dose and any cap are supplied as inputs." } ], disclaimer: "General formula only. Not medical advice. Dosing decisions belong to a licensed clinician and the product's label.", questionText(inputs) { const capPart = (inputs.max_dose !== undefined && inputs.max_dose !== null) ? ` capped at a maximum of ${inputs.max_dose} ${inputs.dose_per_kg_unit.split("/")[0]}` : ""; return `Using this general formula, what is the total dose for a ${inputs.weight_kg} kg patient at ${inputs.dose_per_kg} ${inputs.dose_per_kg_unit}${capPart}?`; }, run(inputs) { const { weight_kg, dose_per_kg, dose_per_kg_unit, max_dose } = inputs; if (typeof weight_kg !== "number" || weight_kg <= 0) throw new Error("weight_kg must be a positive number"); if (typeof dose_per_kg !== "number" || dose_per_kg < 0) throw new Error("dose_per_kg must be a non-negative number"); if (typeof dose_per_kg_unit !== "string" || dose_per_kg_unit.length === 0) throw new Error("dose_per_kg_unit is required"); const rawDose = weight_kg * dose_per_kg; let totalDose = rawDose; if (max_dose !== undefined && max_dose !== null) { if (typeof max_dose !== "number" || max_dose < 0) throw new Error("max_dose must be a non-negative number if provided"); if (rawDose > max_dose) totalDose = max_dose; } const rounded = Math.round(totalDose * 100) / 100; const unitBase = dose_per_kg_unit.split("/")[0]; return { answer: `${rounded.toFixed(2)} ${unitBase}`, values: { total_dose: rounded, capped: totalDose < rawDose } }; }, examples: [ { name: "worked example", inputs: { weight_kg: 70, dose_per_kg: 5, dose_per_kg_unit: "mg/kg", max_dose: 500 }, expected: { answer: "350.00 mg" }, check: "70 * 5 = 350, which is below the 500 mg cap, so total_dose = 350.00." }, { name: "test vector: cap applies", inputs: { weight_kg: 120, dose_per_kg: 5, dose_per_kg_unit: "mg/kg", max_dose: 500 }, expected: { answer: "500.00 mg" }, check: "120 * 5 = 600, which exceeds the 500 mg cap, so total_dose is capped at 500.00." } ] };