25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
"""Deterministic clinical calculators.
|
||
|
||
Audit §7: a dose calculation or unit conversion must be a tested function, never
|
||
an LLM. Body surface area replaces Appendix 1's lookup table (Dược thư 2018,
|
||
printed page 1499) with the book's own DuBois formula, so a BSA-based dose is
|
||
*computed and traceable*, not read off a quarantined table crop.
|
||
"""
|
||
from __future__ import annotations
|
||
|
||
# Dược thư 2018, Phụ lục 1 (printed 1499), DuBois & DuBois (Arch Intern Med
|
||
# 1916;17:863-71): S(cm²) = W^0.425 × H^0.725 × 71.84, W in kg, H in cm.
|
||
_DUBOIS_COEFFICIENT = 71.84
|
||
|
||
|
||
def body_surface_area_m2(weight_kg: float, height_cm: float) -> float:
|
||
"""Body surface area in m² by the DuBois formula the formulary prints.
|
||
|
||
Raises ValueError on a non-positive input: a BSA from a zero or negative
|
||
weight/height is a data error, not a number to return silently.
|
||
"""
|
||
if weight_kg <= 0 or height_cm <= 0:
|
||
raise ValueError("weight_kg and height_cm must be positive")
|
||
area_cm2 = (weight_kg ** 0.425) * (height_cm ** 0.725) * _DUBOIS_COEFFICIENT
|
||
return area_cm2 / 10_000
|