Drug Interactions
Check drugs against OpenFDA warning labels easily.
1. Checking Interactions
MedKit automatically checks drugs against the FDA's database for adverse events. You can use this to show interaction alerts directly to your users before they prescribe anything.
import asyncio
from medkit import AsyncMedKit
async def main():
async with AsyncMedKit() as med:
# Cross-reference an arbitrary number of compounds
drug_list = ["Aspirin", "Warfarin", "Ibuprofen"]
# Resolves to a List of Dictionaries containing the drugs compared and their warning
warnings = await med.interactions(drug_list)
for w in warnings:
# Pydantic model with .severity, .risk, and .evidence
warning_obj = w["warning"]
drugs_checked = " + ".join(w["drugs"])
print(f"[{warning_obj.severity.upper()}] {drugs_checked}")
print(f"Message: {warning_obj.risk}")
print(f"FDA Evidence Link: {warning_obj.evidence}\n")
if __name__ == "__main__":
asyncio.run(main())
2. CLI Usage Example
You can instantly check a prescription cocktail directly from the terminal:
$ medkit interactions "Aspirin, Warfarin"
Drug-Drug Interactions
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Drugs ┃ Severity ┃ Risk ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Aspirin + Warfarin │ High │ Increased risk of bleeding events, in… │
└────────────────────┴──────────┴─────────────────────────────────────────┘
3. Under The Hood: The Engine
When you check interactions, the engine does a few things behind the scenes:
- It sequentially forms permutations of the target list (A+B, A+C, B+C).
- Fires off highly parallelized async sub-queries using
httpx. - Checks for the presence of your drugs within the explicitly defined
drug_interactionsandboxed_warningsJSON fields of the FDA Label database.
4. Severity Thresholds Formulation
MedKit categorizes interaction warnings into three levels based on the exact words the FDA uses:
- SEVERE: Matches "contraindicated", "fatal", "life-threatening", "black box".
- MODERATE: Matches "caution", "avoid", "monitor", "dose adjustment".
- MILD: Any standard interaction tables remaining.