Antibiotic Prophylaxis Calculator
Relevant source files
The following files were used as context for generating this wiki page:
The Antibiotic Prophylaxis Calculator is a clinical decision support tool designed for healthcare professionals. It implements a decision algorithm to determine the necessity of antibiotic prophylaxis for various types of wounds, based on modern medical guidelines. The calculator assesses wound characteristics, patient-specific risk factors, and allergy history to provide a recommendation, including the choice of antibiotic, dosage, and duration.
This calculator is one of the core features of the MDcalc application, alongside the Electrolyte Correction Calculator, Pediatric Dose Calculator, and others. It is integrated into the main application page and can be selected by the user to perform a calculation.
Sources: README.md, PROJECT_SUMMARY.md, src/app/page.tsx:169-184
Component Architecture
The feature is implemented as a single React component, AntibioticProphylaxisCalculator. It manages its own state for user inputs and calculation results using React's useState hook. The component is built using several reusable presentational components like Card, Select, NumberInput, and Checkbox for its user interface.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:3-10
The diagram below shows the dependencies of the AntibioticProphylaxisCalculator component.
User Interface and State Management
The user interface is structured into three logical steps for data entry: "Wound Assessment," "Patient Factors," and "Allergies and Additional Parameters." All user inputs are stored in a single state object named inputs, which is initialized with default values.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:450-571
Initial State
The calculator is initialized with the following default values for a typical low-risk scenario.
| Parameter | Initial Value |
|---|---|
woundType | 'clean' |
woundLocation | 'other' |
contaminationType | 'none' |
patientAge | 45 |
patientWeight | 70 |
hasDiabetes | false |
hasImmunodeficiency | false |
hasVascularDisease | false |
hasMalnutrition | false |
timeFromInjury | 2 |
hasAllergies | false |
allergies | [] |
renalFunction | 'normal' |
surgeryDuration | 60 |
isDelayedClosure | false |
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:16-36
Calculation Logic
The core logic resides within the calculateProphylaxis function. It is triggered when the user clicks the "Calculate" button. The function evaluates multiple patient and wound factors to determine the risk level and whether antibiotic prophylaxis is required.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:47-346
This flowchart illustrates the high-level decision-making process within the calculateProphylaxis function.
Step 1: Immediate Indications
The algorithm first checks for conditions that automatically warrant antibiotic use, bypassing the risk domain assessment. These are considered high-risk scenarios.
- Wound Type:
open-fractureorgunshot. - Time from Injury: Greater than 6 hours.
- Contamination Type:
fecesorsoil.
If any of these conditions are met, isAntibioticNeeded is set to true and riskLevel is set to 'high'.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:66-91
Step 2: Risk Domain Assessment
If no immediate indications are present, the algorithm evaluates three domains of risk factors.
| Domain | Factors |
|---|---|
| A: Contamination | Any contamination type other than 'none'. |
| B: Location | hand-foot, face, perineum, groin, armpit, joint, bone. |
| C: Patient Factors | Age ≥ 65, Diabetes, Immunodeficiency, Vascular Disease, Malnutrition. |
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:96-121
Step 3: Decision Based on Risk
The decision to recommend antibiotics is based on the number of identified risk domains:
- 0 domains: Low risk. Antibiotics are generally not required.
- 1 domain: Medium risk. The decision is left to clinical discretion. The calculator defaults to not recommending antibiotics but flags the risk.
- 2 or more domains: High risk. Antibiotics are recommended.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:124-136
Step 4: Antibiotic Regimen Selection
If antibiotics are deemed necessary, a specific regimen is selected based on the woundType and the patient's allergy status (hasAllergies to beta-lactams). A switch statement handles the selection logic.
| Wound Type | Standard Regimen | Beta-Lactam Allergy Alternative |
|---|---|---|
clean | Cefazolin | Clindamycin |
open-fracture | Cefazolin | Clindamycin |
contaminated, crush | Cefazolin + Gentamicin | Piperacillin/Tazobactam |
bite | Amoxicillin-clavulanate | Clindamycin + TMP/SMX |
water-fresh | Ciprofloxacin | Ciprofloxacin |
water-salt | Doxycycline + Ceftriaxone | Doxycycline + Ceftriaxone |
gunshot | Cefazolin | Cefazolin |
abdominal | Cefazolin + Metronidazole | Cefazolin + Metronidazole |
farm | Cefazolin + Gentamicin + Penicillin G | Cefazolin + Gentamicin + Penicillin G |
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:144-287
Step 5: Dose Adjustment and Finalization
After selecting a regimen, the dose is adjusted based on several factors:
- Weight: The dose is proportionally increased if the patient's weight is over 100 kg.
- Renal Function: The dose is reduced for mild (x0.8), moderate (x0.6), or severe (x0.4) renal impairment.
- Surgery Duration: An additional dose is recommended if surgery lasts over 120 minutes.
- Delayed Closure: An additional dose is recommended if the wound closure is delayed.
Finally, a list of relevant clinical notes and mandatory warnings is compiled and added to the result object.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:290-335
Data Structures
The component relies on two primary data structures for its operation, which are implicitly defined by the useState hooks.
AntibioticProphylaxisInputs
This structure holds all the data collected from the user.
| Field | Type | Description |
|---|---|---|
woundType | string | The type of the wound (e.g., 'clean', 'bite'). |
woundLocation | string | The anatomical location of the wound. |
contaminationType | string | The type of wound contamination. |
patientAge | number | The patient's age in years. |
patientWeight | number | The patient's weight in kilograms. |
has... | boolean | A series of flags for patient comorbidities (Diabetes, Immunodeficiency, etc.). |
timeFromInjury | number | Hours elapsed since the injury occurred. |
hasAllergies | boolean | Flag for beta-lactam allergy. |
renalFunction | string | Patient's renal function status ('normal', 'mild', etc.). |
surgeryDuration | number | Expected duration of surgery in minutes. |
isDelayedClosure | boolean | Flag indicating if wound closure will be delayed. |
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:16-36
AntibioticProphylaxisResult
This structure holds the complete output of the calculation.
| Field | Type | Description |
|---|---|---|
isAntibioticNeeded | boolean | The final decision on whether antibiotics are needed. |
recommendedAntibiotic | string | The name of the recommended antibiotic or combination. |
dose | number | The calculated dose in milligrams. |
frequency | string | How often the antibiotic should be administered. |
duration | string | The total duration of the prophylaxis. |
route | string | The administration route (e.g., 'Intravenous', 'Oral'). |
additionalDoses | number | The number of extra doses required. |
riskDomains | string[] | A list of identified high-risk domains. |
riskLevel | 'low' | 'medium' | 'high' | The overall calculated infection risk level. |
notes | string[] | An array of contextual notes about the calculation. |
warnings | string[] | An array of important clinical warnings. |
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:49-63
Internationalization (i18n)
The calculator is multilingual, sourcing its text from a centralized i18n system.
- The
useLanguagehook provides thetfunction for translating static labels (e.g., "Patient weight", "Calculate"). These translations are defined insrc/i18n/translations.ts. - The options for the
Selectcomponents (e.g., wound types, locations) are dynamically loaded fromsrc/i18n/antibioticOptions.tsbased on the currently selected language. This file exports anoptionsobject keyed by language.
Sources: src/calculators/AntibioticProphylaxisCalculator.tsx:12-13, src/i18n/translations.ts:39, 218, src/i18n/antibioticOptions.ts
Application Integration
The AntibioticProphylaxisCalculator is conditionally rendered on the main application page (src/app/page.tsx). A state variable, activeCalculator, determines which calculator is currently displayed. When the user clicks the "Wound Antibiotic Prophylaxis" card or navigation button, the activeCalculator state is set to 'antibiotic', causing the component to be mounted and displayed.
Sources: src/app/page.tsx:10, 24, 91, 258-273
The following sequence diagram illustrates the user flow from selecting the calculator to seeing the results.
Conclusion
The Antibiotic Prophylaxis Calculator is a key feature of the application that translates complex clinical guidelines into an interactive and easy-to-use tool. It systematically evaluates wound, patient, and procedural factors to provide an evidence-based recommendation on the use of antibiotics. Its architecture promotes maintainability by separating UI, state, logic, and i18n data, and its integration into the main application is managed through simple state transitions.
Sources: README.md, src/calculators/AntibioticProphylaxisCalculator.tsx