Medical Formulas and References
Relevant source files
The following files were used as context for generating this wiki page:The Medical Calculators application is built upon a foundation of established medical algorithms and formulas to provide accurate clinical decision support. The integrity and precision of these calculations are paramount, as they directly influence the recommendations provided to healthcare professionals. Each calculator implements specific, evidence-based formulas derived from scientific articles and clinical guidelines.
This document outlines the key medical formulas implemented across the various calculators, their corresponding data structures, and the logic used for calculations and interpretations. The project emphasizes medical accuracy, requiring that all new contributions document their sources and adhere to verified clinical guidelines.
Sources: PROJECT_SUMMARY.md, CONTRIBUTING.md:37-45
Electrolyte Correction Formulas
The ElectrolyteCorrectionCalculator provides functionality for managing disorders of potassium, sodium, magnesium, and calcium. It uses distinct formulas for hypo- and hyper- states.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx, src/i18n/translations.ts:403-410
Sodium Correction
Sodium correction is a critical feature, implementing two primary formulas based on the patient's condition (hyponatremia or hypernatremia). The logic differentiates based on user selection and applies the appropriate algorithm.
Sources: SODIUM_CORRECTION_CALCULATOR.md:3-16, src/calculators/ElectrolyteCorrectionCalculator.tsx:131-213
The following diagram shows the data flow for the sodium correction calculation.
Adrogue-Madias Formula (Hyponatremia)
For hyponatremia, the application uses the Adrogue-Madias formula to calculate the expected change in serum sodium per liter of IV fluid. The project documentation explicitly defines this formula.
Δ[Na] = ([Na]IVF - [Na]serum) / (TBW + 1)
Sources: SODIUM_CORRECTION_CALCULATOR.md:18-24, PROJECT_SUMMARY.md:36-37
Free Water Deficit Formula (Hypernatremia)
For hypernatremia, the free water deficit is calculated to determine the amount of fluid needed to correct the sodium level.
Free Water Deficit = TBW × ([Na]current / [Na]target - 1)
Sources: SODIUM_CORRECTION_CALCULATOR.md:26-32, PROJECT_SUMMARY.md:38-39
Total Body Water (TBW) Calculation
Both sodium correction formulas depend on an accurate estimation of Total Body Water (TBW). The calculation is patient-specific, accounting for gender, age, and weight. The implementation in ElectrolyteCorrectionCalculator.tsx uses a coefficient-based approach.
| Patient Group | TBW Coefficient |
|---|---|
| Child (0-17 years) | 60% |
| Adult Male (18-59 years) | 60% |
| Adult Female (18-59 years) | 50% |
| Elderly Male (≥60 years) | 50% |
| Elderly Female (≥60 years) | 45% |
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:140-147, SODIUM_CORRECTION_CALCULATOR.md:34-39
The implementation logic is as follows:
// src/calculators/ElectrolyteCorrectionCalculator.tsx:140-147
let coefficientK = 0.6; // по умолчанию
if (patientAge >= 0 && patientAge <= 17) {
coefficientK = 0.6; // для обоих полов
} else if (patientAge >= 18 && patientAge <= 59) {
coefficientK = patientGender === 'male' ? 0.6 : 0.5;
} else if (patientAge >= 60) {
coefficientK = patientGender === 'male' ? 0.5 : 0.45;
}
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:140-147
IV Fluid Sodium Concentrations
The calculator uses a predefined set of sodium concentrations for various intravenous fluids.
| Fluid Type | Sodium Concentration (mEq/L) |
|---|---|
| 3% Hypertonic Saline | 513 |
| 0.9% Normal Saline | 154 (implemented as 153.9) |
| 0.45% Half Normal Saline | 77 (implemented as 76.95) |
| 5% Dextrose in Water | 0 |
| Lactated Ringer's | 130 (implemented as 129.3) |
Sources: SODIUM_CORRECTION_CALCULATOR.md:43-49, src/calculators/ElectrolyteCorrectionCalculator.tsx:153-157
Potassium, Magnesium, and Calcium Correction
For hypokalemia, hypomagnesemia, and hypocalcemia, the calculator determines the electrolyte deficit using a generalized formula:
Deficit = (Target Level - Corrected Current Level) * Volume of Distribution * Patient Weight
The volume of distribution is a constant factor (e.g., 0.2 for potassium, 0.3 for magnesium and calcium) multiplied by the patient's weight.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:82-83, 217-218, 230-231
Blood Gas Analysis Formulas
The BloodGasAnalysisCalculator.tsx component is a complex module that implements numerous formulas for the interpretation of acid-base disorders.
Sources: src/calculators/BloodGasAnalysisCalculator.tsx
Primary Calculations
These formulas calculate key initial values from the user's input.
| Formula | Description | Implementation |
|---|---|---|
| Anion Gap | Na - (Cl + HCO3) | calculateAnionGap() |
| Corrected Anion Gap | Anion Gap + 2.5 * (4.0 - Albumin) | calculateCorrectedAnionGap() |
| Base Excess | Zander-van Slyke formula | calculateBaseExcess() |
| Osmolar Gap | (2*Na + Glucose/18 + BUN/2.8 + Ethanol/4.6) - 285 | calculateOsmolarGap() |
| Urine Anion Gap | Urine Na + Urine K - Urine Cl | calculateUrineAnionGap() |
Sources: src/calculators/BloodGasAnalysisCalculator.tsx:138-146, 172-178, 203-226, 292-304, 307-315
Interpretation Logic
The core of the blood gas calculator is the interpretAcidBaseStatus function, which follows a multi-step process to identify primary and mixed disorders.
This diagram illustrates the high-level interpretation flow.
Compensatory Response Formulas
-
Winter's Formula (Metabolic Acidosis): Calculates the expected PaCO2 to assess respiratory compensation.
Expected PaCO2 = 1.5 * HCO3 + 8
Sources: src/calculators/BloodGasAnalysisCalculator.tsx:149-152, 421-423 -
Expected PaCO2 (Metabolic Alkalosis):
Expected PaCO2 = 0.7 * HCO3 + 20
Sources: src/calculators/BloodGasAnalysisCalculator.tsx:155-158, 442-444 -
Expected HCO3 (Respiratory Acidosis/Alkalosis): The system calculates expected bicarbonate levels for both acute and chronic respiratory conditions to determine chronicity and check for mixed disorders.
Sources: src/calculators/BloodGasAnalysisCalculator.tsx:462-479, 492-509
Infusion Therapy Formulas
The InfusionTherapyCalculator is used to estimate a patient's fluid requirements.
Sources: src/calculators/InfusionTherapyCalculator.tsx
Fluid Requirement Calculation
The total infusion volume is determined by summing maintenance fluid, fluid deficit, and ongoing losses.
Sources: src/calculators/InfusionTherapyCalculator.tsx:156-157
-
Total Body Water (Watson Formula): Unlike the electrolyte calculator, this component uses the more complex Watson formula for TBW.
- Male:
2.447 - (0.09156 * age) + (0.1074 * height) + (0.3362 * weight) - Female:
-2.097 + (0.1069 * height) + (0.2466 * weight)
Sources: src/calculators/InfusionTherapyCalculator.tsx:75-82
- Male:
-
Maintenance Fluid: Calculated based on weight and age brackets. For adults, a standard
30 ml/kg/dayis used.
Sources: src/calculators/InfusionTherapyCalculator.tsx:125-130 -
Fluid Deficit: Estimated as 5% of body weight in cases of dehydration.
Sources: src/calculators/InfusionTherapyCalculator.tsx:85-94 -
Ongoing Losses: Accounts for insensible losses plus additional losses from fever, vomiting, diarrhea, and burns (using the Parkland formula).
Sources: src/calculators/InfusionTherapyCalculator.tsx:97-122
Pediatric Dosing Formulas
The PediatricDoseCalculator implements several methodologies to determine the correct dosage for children, based on the selected medication.
Sources: src/calculators/PediatricDoseCalculator.tsx
Dosing Methodologies
The calculateDose function selects a dosing method based on the medication's properties in the pediatricMedicationsDatabase.
-
Weight-Based Dosing: The most common method, where dose is calculated as
dose_per_kg * patient_weight. The implementation includes logic to select the correct dose based on the route of administration (e.g., IV vs. oral).
Sources: src/calculators/PediatricDoseCalculator.tsx:102-171 -
Body Surface Area (BSA) Dosing: For certain medications, the dose is based on BSA, which is calculated using the DuBois formula:
BSA = sqrt((weight_kg * height_cm) / 3600)
Sources: src/calculators/PediatricDoseCalculator.tsx:187-193, 226-228 -
Age-Based & Fixed Dosing: Simpler methods used for specific medications.
Sources: src/calculators/PediatricDoseCalculator.tsx:173-185
Medical Accuracy and References
The project places a strong emphasis on medical accuracy. The CONTRIBUTING.md file mandates that any new calculator must use verified sources like clinical recommendations and scientific articles. Furthermore, these sources must be documented within the code and in the main MEDICAL_REFERENCES.md file. This process ensures that all formulas and algorithms are evidence-based and reliable for clinical use.
Sources: CONTRIBUTING.md:37-45, SODIUM_CORRECTION_CALCULATOR.md:100-105
Summary
The medical-calculators project integrates a variety of standard, evidence-based medical formulas to power its features. From complex acid-base interpretation in the BloodGasAnalysisCalculator to patient-specific electrolyte corrections in the ElectrolyteCorrectionCalculator, each formula is implemented in TypeScript to provide real-time calculations. The use of detailed documentation and strict contribution guidelines regarding medical accuracy ensures the application serves as a reliable tool for healthcare professionals.