Infusion Therapy Calculator
Relevant source files
The following files were used as context for generating this wiki page:Introduction
The Infusion Therapy Calculator is a React component designed to assist healthcare professionals in calculating a patient's fluid requirements, correcting deficits, and formulating an infusion therapy plan. It takes a comprehensive set of patient parameters—including demographics, clinical signs, laboratory results, and ongoing losses—to generate a detailed report. This report includes calculated fluid volumes, recommended infusion solutions with rates, and crucial monitoring parameters.
The calculator is integrated into the main application, appearing as a selectable option on the home page. It provides a user-friendly interface for data entry and presents the complex results in a structured, readable format, complete with warnings and contraindications to guide clinical decision-making. Note that the UI text for this specific calculator is hardcoded in Russian and does not currently use the project's internationalization (i18n) system.
Sources: src/calculators/InfusionTherapyCalculator.tsx:343-349, src/app/page.tsx:103-111, 249-267
Architecture and Core Components
The InfusionTherapyCalculator is a standard React functional component (React.FC). Its state is managed using the useState hook to hold user inputs (data) and the calculated output (result).
The component is built using several reusable UI components from the project's library:
Card: Wraps the main input form and the results display.NumberInput: For all numerical data entry (e.g., weight, age, lab values).Select: For dropdown selections like gender.Checkbox: For boolean flags (e.g.,hasDehydration,hasSepsis).Button: For triggering calculation and reset actions.
Sources: src/calculators/InfusionTherapyCalculator.tsx:8, 10-14, 352-353, CONTRIBUTING.md
The following diagram illustrates the component's internal structure and state management.
Data Model
The calculator's functionality is defined by two primary data structures: InfusionTherapyInputs for collecting patient data and InfusionTherapyResult for storing the calculated outcomes. These are defined in src/types/index.ts.
InfusionTherapyInputs
This interface captures all the data points required for the calculation, categorized into patient demographics, clinical status, lab values, and other factors.
| Field | Type | Description |
|---|---|---|
weight | number | null | Patient's ideal weight in kg. |
height | number | null | Patient's height in cm. |
age | number | null | Patient's age in years. |
gender | 'male' | 'female' | Patient's gender. |
currentWeight | number | null | Patient's current measured weight in kg. |
hasEdema | boolean | Flag for presence of edema. |
hasDehydration | boolean | Flag for clinical signs of dehydration. |
hasOverhydration | boolean | Flag for clinical signs of overhydration. |
serumSodium | number | null | Serum sodium level in mmol/L. |
serumPotassium | number | null | Serum potassium level in mmol/L. |
serumChloride | number | null | Serum chloride level in mmol/L. |
serumGlucose | number | null | Serum glucose level in mmol/L. |
serumCreatinine | number | null | Serum creatinine level in µmol/L. |
serumAlbumin | number | null | Serum albumin level in g/L. |
bloodPressure | { systolic: number | null; diastolic: number | null; } | Systolic and diastolic blood pressure. |
heartRate | number | null | Heart rate in beats per minute. |
centralVenousPressure | number | null | Central venous pressure in cm H2O. |
urineOutput | number | null | Urine output in mL/hour. |
hasVomiting | boolean | Flag for vomiting. |
hasDiarrhea | boolean | Flag for diarrhea. |
hasFever | boolean | Flag for fever. |
feverTemperature | number | null | Patient's temperature in °C if fever is present. |
isPostoperative | boolean | Flag for postoperative status. |
surgeryDuration | number | null | Duration of surgery in minutes. |
bloodLoss | number | null | Estimated blood loss in mL. |
thirdSpaceLoss | number | null | Estimated third space loss in mL. |
hasBurns | boolean | Flag for burns. |
burnSurfaceArea | number | null | Percentage of total body surface area affected by burns. |
hasSepsis | boolean | Flag for sepsis. |
hasKidneyFailure | boolean | Flag for kidney failure. |
Sources: src/types/index.ts:161-213
InfusionTherapyResult
This interface structures the output of the calculation, providing a comprehensive plan for therapy.
| Field | Type | Description |
|---|---|---|
totalBodyWater | number | Total body water in liters. |
extracellularFluid | number | Extracellular fluid volume in liters. |
intracellularFluid | number | Intracellular fluid volume in liters. |
maintenanceFluid | number | Daily maintenance fluid requirement in mL. |
maintenanceRate | number | Infusion rate for maintenance fluid in mL/hour. |
fluidDeficit | number | Calculated fluid deficit in mL. |
deficitCorrectionRate | number | Recommended rate for correcting the deficit in mL/hour. |
deficitCorrectionTime | number | Time to correct the deficit in hours. |
ongoingLosses | number | Estimated daily ongoing fluid losses in mL. |
ongoingLossesRate | number | Infusion rate to replace ongoing losses in mL/hour. |
totalInfusionVolume | number | Total daily infusion volume in mL. |
totalInfusionRate | number | Average total infusion rate in mL/hour. |
recommendedSolutions | RecommendedSolution[] | Array of recommended IV solutions. |
monitoringParameters | MonitoringParameter[] | Array of parameters to monitor. |
warnings | string[] | Array of clinical warnings. |
contraindications | string[] | Array of contraindications to therapy. |
additionalRecommendations | string[] | Array of general recommendations. |
Sources: src/types/index.ts:215-248
The diagram below shows the relationship between the main result interface and its nested types.
Sources: src/types/index.ts:215-259
Calculation Logic
The core logic resides within the handleCalculate function, which orchestrates a series of calculations to determine the final infusion plan.
Main Calculation Flow
The process begins with user input validation and proceeds through several stages of fluid calculation, culminating in the generation of recommendations and a final result object.
This flowchart shows the high-level data flow within the handleCalculate function.
Total Body Water (TBW) Calculation
Total Body Water is calculated using the Watson formula, which accounts for the patient's weight, height, age, and gender.
- Male:
TBW = 2.447 - (0.09156 * age) + (0.1074 * height) + (0.3362 * weight) - Female:
TBW = -2.097 + (0.1069 * height) + (0.2466 * weight)
Once TBW is determined, fluid compartments are estimated as:
- Extracellular Fluid:
TBW * 0.4 - Intracellular Fluid:
TBW * 0.6
Sources: src/calculators/InfusionTherapyCalculator.tsx:59-67, 153-155
Fluid Requirement Calculations
The total fluid requirement is a sum of maintenance needs, existing deficits, and ongoing losses.
Maintenance Fluid
The calculateMaintenanceFluid function determines the baseline daily fluid requirement based on age and weight tiers.
| Age | Formula |
|---|---|
| < 1 year | weight * 100 mL/day |
| < 10 years | weight * 80 mL/day |
| < 20 years | weight * 60 mL/day |
| ≥ 20 years | weight * 30 mL/day |
Sources: src/calculators/InfusionTherapyCalculator.tsx:132-137
Fluid Deficit
The calculateFluidDeficit function estimates the volume to be replaced due to dehydration. If the hasDehydration flag is true, the deficit is calculated as 5% of the patient's body weight (weight * 0.05 * 1000 mL). No deficit is calculated if edema or overhydration is present.
Sources: src/calculators/InfusionTherapyCalculator.tsx:70-79
Ongoing Losses
The calculateOngoingLosses function estimates additional fluid losses from various sources. The total is a sum of the following:
| Source | Calculation |
|---|---|
| Basal (insensible) | weight * 15 mL/day |
| Fever | (temperature - 37.0) * 100 mL for each degree Celsius above 37.0. |
| Vomiting | +500 mL/day |
| Diarrhea | +1000 mL/day |
| Postoperative | +200 to +600 mL/day based on surgery duration. |
| Burns (Parkland formula) | burnSurfaceArea * 4 * weight mL/day. |
Sources: src/calculators/InfusionTherapyCalculator.tsx:82-129
Result Generation
After all volumes are calculated, the handleCalculate function assembles a comprehensive set of recommendations.
Recommended Solutions
An array of RecommendedSolution objects is created based on the patient's condition:
- Deficit Correction: If a fluid deficit exists,
0.9% NaClorRinger'ssolution is recommended to replace it. - Hyponatremia: If serum sodium is < 135 mmol/L,
0.9% NaClis recommended for slow correction. - Hypokalemia: If serum potassium is < 3.5 mmol/L,
KCl in 0.9% NaClis recommended. - Maintenance: A solution of
5% glucose + 0.18% NaClis always added to cover basal needs.
Sources: src/calculators/InfusionTherapyCalculator.tsx:181-224
Monitoring and Warnings
- Monitoring: A static list of
MonitoringParameterobjects is generated, specifying the parameter (e.g., Urine Output, Blood Pressure), frequency, target value, and critical thresholds. - Warnings: Conditional warnings are added to an array for conditions like kidney failure, sepsis, or extensive burns.
- Contraindications: Contraindications are generated if the patient has signs of overhydration or edema.
Sources: src/calculators/InfusionTherapyCalculator.tsx:227-276
User Interface and Interaction
The component's UI is divided into a two-column layout: an input form on the left and a results panel on the right, which is conditionally rendered after a successful calculation.
The user interaction flow is managed by two primary event handlers:
handleCalculate(): Triggered by the "Calculate" button. It performs input validation, runs all calculations, and updates theresultstate to display the output.handleReset(): Resets thedataandresultstates to their initial values, clearing the form and the results panel.
The following sequence diagram illustrates the user's journey from entering data to viewing the results.
Conclusion
The InfusionTherapyCalculator is a sophisticated clinical tool that encapsulates complex physiological formulas into a simple and interactive component. By systematically calculating maintenance, deficit, and ongoing fluid needs, it provides a structured and detailed infusion plan. The inclusion of specific solution recommendations, monitoring parameters, and contextual warnings makes it a powerful decision-support tool for managing patient fluid balance.