diff options
| author | Leonard Kugis <leonard@kug.is> | 2025-12-23 04:10:47 +0100 |
|---|---|---|
| committer | Leonard Kugis <leonard@kug.is> | 2025-12-23 04:10:47 +0100 |
| commit | 14ca19e54756a9940adcfc75b7d7d0a2823e0b3e (patch) | |
| tree | 0ec7d83bed8e76a8a94cf94505111547ae8f7b2e | |
| parent | 9e1f202b2101be32f2eb5b1a30f041f1e25553cd (diff) | |
| download | xembu-14ca19e54756a9940adcfc75b7d7d0a2823e0b3e.tar.gz | |
| -rw-r--r-- | modules/drug.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/drug.py b/modules/drug.py index 9b6c390..82754b8 100644 --- a/modules/drug.py +++ b/modules/drug.py @@ -10,8 +10,12 @@ import matplotlib.dates as mdates from matplotlib.axes import Axes from matplotlib.font_manager import FontProperties +import logging + from .base import Frame, BigFrame, ModuleResult +logger = logging.getLogger("xembu.drug") + class SubstanceModel: key: str = "" supported_applications: set[str] = set() @@ -288,20 +292,19 @@ class DrugModule: work["flag"] = work["group_flag"].astype(str).str.strip().str.upper() work = work[work["flag"] == "U"].copy() - warnings: List[str] = [] events: List[Dict[str, Any]] = [] for _, row in work.iterrows(): tup = _extract_module_tuple(row, "drug") if not tup or len(tup) < 5: - warnings.append(f"Missing/invalid drug params at {row.get('date')} ({row.get('debitor')})") + logger.warning("Missing or invalid drug params at {} ({})".format(row.get('date'), row.get('debitor'))) continue substance = _clean_str(tup[0]) application = _clean_str(tup[3]).lower() if substance != "Ethanol" or application != "oral": - warnings.append(f"Unsupported: ({substance}, {application}) at {row.get('date')} ({row.get('debitor')})") + logger.warning("Unsupported: ({}, {}) at {} ({})".format(substance, application, row.get('date'), row.get('debitor'))) continue try: @@ -343,8 +346,6 @@ class DrugModule: if not events: summary = ["# DrugModule", "", "(no supported Ethanol/oral events found)"] - if warnings: - summary += ["", "Warnings:"] + [f"- {w}" for w in warnings[:50]] return ModuleResult(summary_text="\n".join(summary), frames=[], bigframes=[], pages=[]) ev = pd.DataFrame(events) |
