med.pk - Pharmacokinetic Engine
100+ drug profiles with weight-based dosing, interaction checking, plasma concentration modeling, and a custom drug registry for adding any drug.
Built-in Drugs (16)
| Drug | Class | Onset | Route |
|---|---|---|---|
| Norepinephrine | Vasopressor | 1 min | IV |
| Vasopressin | Vasopressor | 5 min | IV |
| Epinephrine | Vasopressor | 1 min | IV |
| Vancomycin | Antibiotic | 60 min | IV |
| Furosemide | Diuretic | 30 min | IV |
| Propofol | Sedative | 0.5 min | IV |
| Thiamine | Vitamin | 30 min | IV |
| Heparin | Anticoagulant | 5 min | IV |
| Morphine | Analgesic | 5 min | IV |
| Fentanyl | Analgesic | 1 min | IV |
| Midazolam | Sedative | 2 min | IV |
| Dexmedetomidine | Sedative | 15 min | IV |
| Ketamine | Anesthetic | 1 min | IV |
| Amoxicillin | Antibiotic | 30 min | PO |
| Metformin | Antidiabetic | 60 min | PO |
| Insulin_Regular | Antidiabetic | 15 min | IV |
Methods
calculate_dose(drug, weight_kg) ? dict
Weight-based dosing calculation with safety bounds checking.
check_interactions(drug, current_drugs) ? dict
Check for known drug-drug interactions. Severity levels: MONITOR, MODERATE, MAJOR, SEVERE.
plasma_concentration(drug, dose, time_min, weight_kg) ? float
One-compartment IV bolus model for plasma concentration at time t.
get_profile(drug) ? DrugProfile
Get full pharmacokinetic profile (bioavailability, onset, peak, half-life, etc.).
administer(drug, dose, weight_kg) ? dict
Register drug administration and check interactions with active drugs.
time_to_effect(drug) ? dict
Get onset, peak, duration, and half-life timing for a drug.
check_contraindications(drug, patient_conditions) ? dict
Check patient-specific contraindications.
list_drugs(category) ? list
List all available drugs, optionally filtered by category.
list_categories() ? list
List all unique drug categories.
Dose Adjustments & TDM
renal_adjust(drug, egfr) ? dict
Adjust dosing based on renal function (eGFR, mL/min/1.73m2):
| eGFR | Adjustment |
|---|---|
| 60+ | No adjustment |
| 30-59 | 75% of standard dose |
| 15-29 | 50% of standard dose |
| under 15 | 25% of standard dose |
lib.pk.renal_adjust("Vancomycin", 25)
# {'adjustment_factor': 0.5, 'recommendation': 'Reduce dose by 50%'}
hepatic_adjust(drug, child_pugh_class) ? dict
Adjust dosing based on hepatic function (Child-Pugh class A, B, or C):
| Class | Adjustment |
|---|---|
| A | No adjustment |
| B | 50% of standard dose |
| C | 25% of standard dose |
therapeutic_range(drug) ? dict
Get therapeutic drug monitoring (TDM) ranges:
lib.pk.therapeutic_range("Vancomycin")
# {'trough': (15, 20), 'peak': (20, 40), 'unit': 'mcg/mL',
# 'monitoring_frequency': 'Before 4th dose, then weekly'}
trough_estimate(drug, dose_mg, interval_hr, weight_kg) ? dict
Estimate trough concentration using a one-compartment model.
lib.pk.trough_estimate("Vancomycin", 1000, 12, 70)
# {'estimated_trough': 14.2, 'within_range': False,
# 'recommendation': 'Consider dose increase'}
Custom Drug Registration
Add any drug to the engine via the Python SDK:
from moisscode.modules.med_pk import PharmacokineticEngine, DrugProfile
pk = PharmacokineticEngine()
# Register a custom drug
pk.register_drug(DrugProfile(
name="Ceftriaxone",
category="antibiotic",
bioavailability=1.0,
onset_min=30.0,
peak_min=120.0,
half_life_min=480.0, # 8 hours
duration_min=1440.0, # 24 hours
standard_dose=1000.0,
dose_unit="mg",
max_dose=4000.0,
min_dose=500.0,
contraindications=["cephalosporin_allergy"],
interactions={"Warfarin": "MODERATE"},
route="IV",
metabolism="hepatic",
excretion="renal/biliary",
))
# Now use it in protocols
pk.calculate_dose("Ceftriaxone", 70)
DrugProfile Fields
| Field | Type | Description |
|---|---|---|
name | str | Drug name (used as key) |
category | str | e.g., "antibiotic", "vasopressor" |
bioavailability | float | 0.0�1.0 fraction absorbed |
onset_min | float | Minutes to initial effect |
peak_min | float | Minutes to peak effect |
half_life_min | float | Elimination half-life (min) |
duration_min | float | Duration of action (min) |
standard_dose | float | Standard dose amount |
dose_unit | str | e.g., "mg", "mcg/kg/min" |
max_dose | float | Maximum safe dose |
min_dose | float | Minimum effective dose |
contraindications | list | List of contraindication strings |
interactions | dict | {drug: severity} mapping |
renal_adjust | bool | Requires renal dose adjustment |
hepatic_adjust | bool | Requires hepatic dose adjustment |
route | str | "IV", "PO", "IM", "SC" |
metabolism | str | Primary metabolism pathway |
excretion | str | Primary excretion pathway |
To remove a drug: pk.unregister_drug("DrugName"). To list all categories: pk.list_categories().
See Also
- med.lab — lab-based monitoring for therapeutic drug levels
- med.scores — severity scoring to guide dosing decisions
- med.genomics — pharmacogenomic-guided dose adjustments
- med.micro — empiric therapy selection before PK dosing
- Drug Discovery Pipeline — walkthrough using PK with chemistry modules