feat: BIO_NORMALS 33 analytes + interprétations cliniques + cohérence DAS/bio étendue

- BIO_NORMALS passe de 13 à 33 tests (cardio, infectio, métabo, thyroïde, hémato, hépatique)
- _BIO_INTERPRETATION synchronisé (33 entrées, 3 clés high/low/normal chacune)
- _DAS_BIO_CHECKS étendu de 13 à 38 patterns (sepsis, infarctus, EP, diabète, thyroïde, etc.)
- lab_value_sanity.yaml étendu avec 20 garde-fous plausibilité nouveaux tests
- tests/test_bio_normals.py : 32 tests (complétude, concordance, _is_abnormal)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dom
2026-02-20 11:00:53 +01:00
parent 3c070f3c1d
commit 1a3c523987
4 changed files with 318 additions and 9 deletions

View File

@@ -165,18 +165,48 @@ def _build_tagged_context(dossier: DossierMedical) -> tuple[str, dict[str, str]]
# Interprétations cliniques pour le résumé bio déterministe
_BIO_INTERPRETATION: dict[str, dict[str, str]] = {
"CRP": {"high": "infection/inflammation active", "low": "normal", "normal": "pas d'inflammation"},
"Hémoglobine": {"high": "polyglobulie", "low": "anémie", "normal": "pas d'anémie"},
"Plaquettes": {"high": "thrombocytose", "low": "thrombopénie", "normal": "numération normale"},
"Leucocytes": {"high": "hyperleucocytose", "low": "leucopénie", "normal": "numération normale"},
"Créatinine": {"high": "insuffisance rénale", "low": "normal", "normal": "fonction rénale conservée"},
"Potassium": {"high": "hyperkaliémie", "low": "hypokaliémie", "normal": "kaliémie normale"},
"Sodium": {"high": "hypernatrémie", "low": "hyponatrémie", "normal": "natrémie normale"},
# --- Hépatique / digestif ---
"Lipasémie": {"high": "pancréatite probable", "low": "normal", "normal": "pas de pancréatite"},
"ASAT": {"high": "cytolyse hépatique", "low": "normal", "normal": "pas de cytolyse"},
"ALAT": {"high": "cytolyse hépatique", "low": "normal", "normal": "pas de cytolyse"},
"GGT": {"high": "cholestase/atteinte hépatique", "low": "normal", "normal": "pas de cholestase"},
"PAL": {"high": "cholestase/atteinte osseuse", "low": "normal", "normal": "pas de cholestase"},
"Bilirubine totale": {"high": "ictère/cholestase", "low": "normal", "normal": "pas d'ictère"},
"Bilirubine directe": {"high": "cholestase/obstruction biliaire", "low": "normal", "normal": "pas de cholestase"},
"LDH": {"high": "cytolyse/hémolyse", "low": "normal", "normal": "pas de cytolyse"},
# --- Inflammatoire ---
"CRP": {"high": "infection/inflammation active", "low": "normal", "normal": "pas d'inflammation"},
"VS": {"high": "inflammation", "low": "normal", "normal": "pas d'inflammation"},
# --- Ionogramme ---
"Sodium": {"high": "hypernatrémie", "low": "hyponatrémie", "normal": "natrémie normale"},
"Potassium": {"high": "hyperkaliémie", "low": "hypokaliémie", "normal": "kaliémie normale"},
# --- Hématologie ---
"Hémoglobine": {"high": "polyglobulie", "low": "anémie", "normal": "pas d'anémie"},
"Plaquettes": {"high": "thrombocytose", "low": "thrombopénie", "normal": "numération normale"},
"Leucocytes": {"high": "hyperleucocytose", "low": "leucopénie", "normal": "numération normale"},
"TP": {"high": "normal", "low": "insuffisance hépatique/CIVD", "normal": "coagulation normale"},
"TCA": {"high": "hypocoagulabilité", "low": "normal", "normal": "coagulation normale"},
"Ferritine": {"high": "surcharge en fer/inflammation", "low": "carence en fer", "normal": "réserves en fer normales"},
# --- Rénal ---
"Créatinine": {"high": "insuffisance rénale", "low": "normal", "normal": "fonction rénale conservée"},
"Urée": {"high": "insuffisance rénale/catabolisme", "low": "normal", "normal": "fonction rénale conservée"},
# --- Cardiologie ---
"Troponine": {"high": "nécrose myocardique (SCA/IDM)", "low": "normal", "normal": "pas de souffrance myocardique"},
"BNP": {"high": "insuffisance cardiaque", "low": "normal", "normal": "pas d'insuffisance cardiaque"},
"NT-proBNP": {"high": "insuffisance cardiaque", "low": "normal", "normal": "pas d'insuffisance cardiaque"},
"D-dimères": {"high": "activation coagulation (EP/TVP possible)", "low": "normal", "normal": "EP/TVP peu probable"},
"INR": {"high": "hypocoagulabilité/surdosage AVK", "low": "hypercoagulabilité", "normal": "coagulation normale"},
"Fibrinogène": {"high": "inflammation/risque thrombotique", "low": "CIVD/insuffisance hépatique", "normal": "normal"},
# --- Infectiologie ---
"Procalcitonine": {"high": "infection bactérienne", "low": "normal", "normal": "pas d'infection bactérienne"},
"Lactate": {"high": "hypoperfusion/choc", "low": "normal", "normal": "pas d'hypoperfusion"},
# --- Métabolisme ---
"Glycémie": {"high": "hyperglycémie/diabète", "low": "hypoglycémie", "normal": "glycémie normale"},
"HbA1c": {"high": "diabète mal équilibré", "low": "normal", "normal": "équilibre glycémique correct"},
"Albumine": {"high": "déshydratation", "low": "dénutrition/insuffisance hépatique", "normal": "état nutritionnel conservé"},
"Acide urique": {"high": "hyperuricémie/goutte", "low": "normal", "normal": "uricémie normale"},
# --- Thyroïde ---
"TSH": {"high": "hypothyroïdie", "low": "hyperthyroïdie", "normal": "fonction thyroïdienne normale"},
}
@@ -243,6 +273,7 @@ def _check_das_bio_coherence(dossier: DossierMedical) -> list[str]:
# Patterns DAS → (test bio attendu, direction attendue)
_DAS_BIO_CHECKS: dict[str, tuple[str, str]] = {
# Hématologie
"leucocytose": ("Leucocytes", "high"),
"leucopénie": ("Leucocytes", "low"),
"leucopenie": ("Leucocytes", "low"),
@@ -254,8 +285,42 @@ def _check_das_bio_coherence(dossier: DossierMedical) -> list[str]:
"anémie": ("Hémoglobine", "low"),
"anemie": ("Hémoglobine", "low"),
"polyglobulie": ("Hémoglobine", "high"),
"carence en fer": ("Ferritine", "low"),
"carence martiale": ("Ferritine", "low"),
# Ionogramme
"hyperkaliémie": ("Potassium", "high"),
"hypokaliémie": ("Potassium", "low"),
"hypernatrémie": ("Sodium", "high"),
"hyponatrémie": ("Sodium", "low"),
"hyponatremie": ("Sodium", "low"),
# Rénal
"insuffisance rénale": ("Créatinine", "high"),
"insuffisance renale": ("Créatinine", "high"),
# Digestif
"pancréatite": ("Lipasémie", "high"),
"pancreatite": ("Lipasémie", "high"),
# Infectiologie
"sepsis": ("CRP", "high"),
"choc septique": ("Lactate", "high"),
# Cardiologie
"infarctus": ("Troponine", "high"),
"syndrome coronarien": ("Troponine", "high"),
"embolie pulmonaire": ("D-dimères", "high"),
"insuffisance cardiaque": ("BNP", "high"),
# Métabolisme / nutrition
"dénutrition": ("Albumine", "low"),
"denutrition": ("Albumine", "low"),
"diabète": ("Glycémie", "high"),
"diabete": ("Glycémie", "high"),
"hyperuricémie": ("Acide urique", "high"),
"goutte": ("Acide urique", "high"),
# Thyroïde
"hypothyroïdie": ("TSH", "high"),
"hypothyroidie": ("TSH", "high"),
"hyperthyroïdie": ("TSH", "low"),
"hyperthyroidie": ("TSH", "low"),
# Coagulation
"civd": ("Fibrinogène", "low"),
}
# Indexer les valeurs bio disponibles