Sodium Correction Calculator
Relevant source files
The following files were used as context for generating this wiki page:The Sodium Correction Calculator is a feature within the ElectrolyteCorrectionCalculator module designed for healthcare professionals. It provides a tool for calculating the correction of sodium imbalances, specifically hyponatremia (low sodium) and hypernatremia (high sodium). The calculator implements established medical algorithms, including a custom sodium deficit formula for hyponatremia and standard formulas for hypernatremia, to ensure safe and effective patient care.
This tool is integrated into a larger system of medical calculators, leveraging a shared component architecture and type system. It provides patient-specific calculations by accounting for age, gender, and weight to estimate total body water and recommends appropriate IV fluid types and infusion rates based on the calculated deficit or excess.
Sources: SODIUM_CORRECTION_CALCULATOR.md, PROJECT_SUMMARY.md, src/calculators/ElectrolyteCorrectionCalculator.tsx
Architecture and Component Overview
The Sodium Correction Calculator is not a standalone component but is part of the ElectrolyteCorrectionCalculator. The UI dynamically adapts based on the user's selection of "Sodium" as the electrolyte type.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:509-520
Component Interaction
The user interacts with a single, dynamic form. The selection of "Sodium" triggers conditional rendering of fields and logic specific to sodium correction.
This diagram illustrates the user's journey through the calculator interface.
Key UI Components
The calculator is built using a set of reusable components:
| Component | File Path | Purpose |
|---|---|---|
Card | src/components/Card.tsx | Main container for the calculator UI. |
Select | src/components/Select.tsx | Used for selecting electrolyte type, correction type, and gender. |
NumberInput | src/components/NumberInput.tsx | Used for all numerical inputs like weight, age, and sodium levels. |
Button | src/components/Button.tsx | Triggers calculation and reset actions. |
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:4-9, README.md:29-35
Data Model and State Management
The calculator's state is managed within the ElectrolyteCorrectionCalculator component using the useState hook. The primary data structures are defined in src/types/index.ts.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:18, src/types/index.ts:13-43
Input State (ElectrolyteCorrectionInputs)
This interface holds all user-provided data. For sodium correction, the relevant fields are:
| Field | Type | Description | Source |
|---|---|---|---|
electrolyteType | 'sodium' | The selected electrolyte. | src/types/index.ts:14 |
correctionType | 'hypo' | 'hyper' | The type of sodium imbalance. | src/types/index.ts:15 |
currentLevel | number | null | The patient's current serum sodium level (mmol/L). | src/types/index.ts:16 |
weight | number | null | The patient's weight in kg. | src/types/index.ts:17 |
age | number | null | The patient's age in years. | src/types/index.ts:21 |
gender | 'male' | 'female' | The patient's gender. | src/types/index.ts:22 |
Sources: src/types/index.ts:13-23, src/calculators/ElectrolyteCorrectionCalculator.tsx:20-30
Result State (ElectrolyteCorrectionResult)
This interface stores the output of the calculation.
The relationship between input, result, and recommended dose structures is shown below.
Sources: src/types/index.ts:25-43
Calculation Logic
The core logic resides in the calculateCorrection function, which branches based on the selected correctionType ('hypo' or 'hyper').
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:47-451
Hyponatremia (Hypo) Correction
For hyponatremia, the calculator determines the total sodium deficit and the required volume of various IV fluids to correct it.
1. Total Body Water (TBW) Coefficient
A coefficient K is determined based on the patient's age and gender to estimate the total body water as a percentage of body weight.
| Age | Gender | Coefficient (K) |
|---|---|---|
| 0-17 | Male / Female | 0.6 |
| 18-59 | Male | 0.6 |
| 18-59 | Female | 0.5 |
| ≥ 60 | Male | 0.5 |
| ≥ 60 | Female | 0.45 |
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:164-171, SODIUM_CORRECTION_CALCULATOR.md:31-36
The logic for determining this coefficient is implemented as follows:
// src/calculators/ElectrolyteCorrectionCalculator.tsx:164-171
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;
}
2. Sodium Deficit Calculation
The total sodium deficit is calculated using the formula:
Sodium Deficit (mmol) = K * Weight (kg) * (Target Sodium - Current Sodium)
The target sodium is hardcoded to 140 mmol/L.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:175-177
3. IV Fluid Volume Calculation
The volume of each IV fluid required to correct the deficit is calculated by dividing the total sodium deficit by the sodium concentration of the fluid.
Volume (mL) = (Sodium Deficit / Fluid Na+ Concentration) * 1000
The calculator uses the following predefined sodium concentrations for IV fluids:
| Fluid Type | Sodium Concentration (mEq/L or mmol/L) |
|---|---|
| 3% Hypertonic Saline | 513 |
| 0.9% Normal Saline | 154 (coded as 153.9) |
| 0.45% Half Normal Saline | 77 (coded as 76.95) |
| Lactated Ringer's | 130 (coded as 129.3) |
| 5% Dextrose in Water | 0 |
Sources: SODIUM_CORRECTION_CALCULATOR.md:38-46, src/calculators/ElectrolyteCorrectionCalculator.tsx:180-188
4. Infusion Rate and Duration
A safe correction rate of 0.5 mmol/L/hr is enforced. The total time for correction is calculated to not exceed this rate, with a minimum duration of 24 hours.
Time (hours) = max(24, (Target Sodium - Current Sodium) / 0.5)
The infusion rate for each fluid is then Volume / Time.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:191-193
Hypernatremia (Hyper) Correction
For hypernatremia, the calculator recommends using 5% Dextrose (D5W) to correct the free water deficit. The correction is designed to be slow to prevent osmotic demyelination.
The logic is as follows:
- A fixed dose of 1000 ml of D5W is recommended for IV infusion.
- A warning is issued to ensure the correction is slow, not exceeding 8-12 mmol/L per day.
- Recommendations include monitoring sodium levels every 4-6 hours.
This is a simplified approach compared to the free water deficit formula mentioned in the documentation, which is not directly implemented in the calculateCorrection function for hypernatremia.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:351-363, SODIUM_CORRECTION_CALCULATOR.md:23-28
Calculation Flow
The diagram below shows the sequence of operations when the "Calculate" button is clicked.
Safety Features and Recommendations
The calculator incorporates several safety measures to guide clinical practice.
- Maximum Correction Rate: For hyponatremia, a safe correction rate of 0.5 mmol/L/hr is used to calculate infusion duration, with a goal of preventing osmotic demyelination.
- Significant Deviation Warning: If the patient's current sodium level deviates from the normal value (140 mmol/L) by more than 15 mmol/L, a specific warning is generated to advise careful correction.
- Monitoring Guidelines: The output includes recommendations for monitoring serum sodium levels every 2-4 hours during hyponatremia correction and every 4-6 hours for hypernatremia.
Sources: src/calculators/ElectrolyteCorrectionCalculator.tsx:191-192, 239-245, 360-363, 441-443, SODIUM_CORRECTION_CALCULATOR.md:48-63, src/i18n/translations.ts:404, 406
Conclusion
The Sodium Correction Calculator is an integral part of the medical-calculators application, providing essential decision support for managing sodium disorders. It combines patient-specific data with established medical formulas to recommend IV fluid therapy for both hyponatremia and hypernatremia. By embedding safety protocols, such as controlled correction rates and explicit warnings, the tool aims to reduce the risk of treatment-related complications like osmotic demyelination. Its implementation within the flexible ElectrolyteCorrectionCalculator component allows for a consistent user experience across different electrolyte imbalance scenarios.
Sources: PROJECT_SUMMARY.md, SODIUM_CORRECTION_CALCULATOR.md, src/calculators/ElectrolyteCorrectionCalculator.tsx