Bundle IDcom.apple. """ amlodipine_reference.py Mô hình PK amlodipine + kiểm tra tương tác thuốc. Chỉ để tham khảo giáo dục. """ from __future__ import annotations import math from dataclasses import dataclass, field from enum import Enum, auto from typing import Iterable class Severity(Enum): MINOR = 1 MODERATE = 2 MAJOR = 3 CONTRAINDICATED = 4 @dataclass(frozen=True) class Interaction: substance: str severity: Severity mechanism: str recommendation: str INTERACTIONS: tuple[Interaction, ...] = ( Interaction("Rượu", Severity.MAJOR, "Giãn mạch cộng gộp, giảm co bóp cơ tim", "Tránh hoàn toàn — nguy cơ tụt huyết áp nặng và ngất."), Interaction("Simvastatin", Severity.MODERATE, "Amlodipine ức chế CYP3A4, tăng nồng độ simvastatin", "Giới hạn simvastatin 20 mg/ngày hoặc đổi statin khác."), Interaction("Clarithromycin", Severity.MODERATE, "Ức chế CYP3A4 làm tăng amlodipine", "Theo dõi huyết áp, cân nhắc giảm liều."), Interaction("Rifampicin", Severity.MODERATE, "Cảm ứng CYP3A4 làm giảm amlodipine", "Theo dõi mất tác dụng hạ huyết áp."), ) @dataclass class Pharmacokinetics: dose_mg: float bioavailability: float = 0.64 ka_per_h: float = 0.5 ke_per_h: float = 0.0175 # T1/2 ~ 40h vd_l_per_kg: float = 21.0 weight_kg: float = 70.0 @property def half_life_h(self) -> float: return math.log(2) / self.ke_per_h def plasma_concentration(self, t_hours: float) -> float: if t_hours < 0: raise ValueError("thời gian không âm") vd = self.vd_l_per_kg * self.weight_kg dose = self.dose_mg * self.bioavailability c = (dose * self.ka_per_h) / (vd * (self.ka_per_h - self.ke_per_h)) return c * (math.exp(-self.ke_per_h * t_hours) - math.exp(-self.ka_per_h * t_hours)) def steady_state_peak(self, interval_h: float = 24.0) -> float: r = math.exp(-self.ke_per_h * interval_h) t_peak = math.log(self.ka_per_h / self.ke_per_h) / (self.ka_per_h - self.ke_per_h) return self.plasma_concentration(t_peak) / (1 - r) class InteractionChecker: def __init__(self, items: Iterable[Interaction]) -> None: self._index = {i.substance.lower(): i for i in items} def report(self, substances: Iterable[str]) -> str: hits = sorted( (self._index[s.lower()] for s in substances if s.lower() in self._index), key=lambda i: i.severity.value, reverse=True, ) if not hits: return "Không có tương tác trong danh mục tham khảo." return "\n".join( f"[{h.severity.name}] {h.substance}: {h.mechanism} -> {h.recommendation}" for h in hits ) if __name__ == "__main__": pk = Pharmacokinetics(dose_mg=5.0) print(f"T1/2: {pk.half_life_h:.1f} h") print(f"Nồng độ đỉnh lúc 2h: {pk.plasma_concentration(2):.4f} mg/L") print(f"Đỉnh steady-state: {pk.steady_state_peak():.4f} mg/L") print(InteractionChecker(INTERACTIONS).report(["rượu", "simvastatin", "metformin"]))
Version1.6.0
Size7.2 MB