Skip to main content

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)

DrugClassOnsetRoute
NorepinephrineVasopressor1 minIV
VasopressinVasopressor5 minIV
EpinephrineVasopressor1 minIV
VancomycinAntibiotic60 minIV
FurosemideDiuretic30 minIV
PropofolSedative0.5 minIV
ThiamineVitamin30 minIV
HeparinAnticoagulant5 minIV
MorphineAnalgesic5 minIV
FentanylAnalgesic1 minIV
MidazolamSedative2 minIV
DexmedetomidineSedative15 minIV
KetamineAnesthetic1 minIV
AmoxicillinAntibiotic30 minPO
MetforminAntidiabetic60 minPO
Insulin_RegularAntidiabetic15 minIV

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):

eGFRAdjustment
60+No adjustment
30-5975% of standard dose
15-2950% of standard dose
under 1525% 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):

ClassAdjustment
ANo adjustment
B50% of standard dose
C25% 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

FieldTypeDescription
namestrDrug name (used as key)
categorystre.g., "antibiotic", "vasopressor"
bioavailabilityfloat0.0�1.0 fraction absorbed
onset_minfloatMinutes to initial effect
peak_minfloatMinutes to peak effect
half_life_minfloatElimination half-life (min)
duration_minfloatDuration of action (min)
standard_dosefloatStandard dose amount
dose_unitstre.g., "mg", "mcg/kg/min"
max_dosefloatMaximum safe dose
min_dosefloatMinimum effective dose
contraindicationslistList of contraindication strings
interactionsdict{drug: severity} mapping
renal_adjustboolRequires renal dose adjustment
hepatic_adjustboolRequires hepatic dose adjustment
routestr"IV", "PO", "IM", "SC"
metabolismstrPrimary metabolism pathway
excretionstrPrimary excretion pathway
tip

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