Skip to content

Web app to visualize and help clinicians safely correct hyponatremia.

License

Notifications You must be signed in to change notification settings

nickmmark/na-pathway

Repository files navigation

NaPathway: A tool for safely correcting hyponatremia

🧠 Medical Context for Hyponatremia

Severe hyponatremia (sodium < 120 mEq/L) is a potentially serious electrolyte disturbance among hospitalized patients. Correcting hyponatremia too rapidly can lead to serious neurologicla complications such as Central pontine myelinolysis (CPM) and Osmotic Demyelination Syndrome (ODS). Avoiding these complications requires careful monitoring and titration of therapies. One challenge is defining precise sodium correction goals and determining if the correction is occuring as intended, particularly in the context of multiple therapies being administered. This is fundamentally a data visualization problem, that can be solved with an interactive web-app.

📈 Solution

The patient's sodium values are displayed in an xy plot versus time. The safe rate of correction is shown as a glideslope. The user can add more sodium values and see if they fall within the safe rate of correction. Values outside the safe correction range are highlighted.
The user can use the default rate of sodium correction (6-8 mEq/L/day), a more cautious rate (4-6 mEq/L/day), a more aggressive rate (8-10 mEq/L/day), or even a custom rate. The user can also indicate when treatments such as D5W, Normal Saline, 3% saline, or ddAVP are administered. These therapies are also shown on the graph. The app can also help the user estimate how giving crystalloid or free water with change the patients sodium. Finally, the user can save the graph to disk, paste it into the medical record, or print it out, so everyone on the medical team has shared mental model about the plan for safe sodium correction.

demonstration of the features of NaPathway

Try it out here.

⚙️ Features

  • Patient Information: Enter gender, age, and weight to auto-calculate total body water (TBW).
  • Correction Rate: Select or customize target sodium correction rate (mEq/L/day).
  • Sodium Measurements: Add time-stamped serum sodium values; see red flags when out of safe range.
  • Treatments Administered: Log boluses and infusions (0.9% NS, 3% NS, LR, D5W, ddAVP).
    • Bolus ΔNa computed per distribution formula.
    • Infusion ΔNa per hour calculated using the same distribution formula.
  • Dynamic Chart:
    • Shaded blue zone representing allowable glideslope.
    • Lines for minimum and maximum correction rates.
    • Horizontal bars for treatments, color-coded.
  • Tooltips & Labels:
    • Detailed tooltips showing expected ∆Na (mEq/L or mEq/L/hour).
    • Concise on-graph labels to avoid clutter.
  • Export & Share: Copy graph to clipboard, save as PNG, or print for documentation.

Example of a warning when the rate of sodium correction exceeds the specified safe correction rate



🧮 Calculating the expected change in sodium with IV fluids

In order to calculate how an infusion or bolus will alter the patients serum sodium, we need to estimate their Total Body Water (TBW). We can estimate TBW using:

$$TBW = Mass(kg) x C$$

The coefficient (C) used to estimate TBW depends on age, gender, and weight:

  • Children and adult males: 0.6 * body weight (in kg)
  • Adult females and elderly males: 0.5 * body weight (in kg)
  • Elderly females: 0.45 * body weight (in kg)

Note that there are more accurate anthropometric equations - like the Watson Formula - that use height, weight, age, and gender. I have chosen to use the simpler approximation because height data is not always available. Ideally, if this was connected to the EHR, the app would use the better formula if more information was available.

In order to calculate the expected change in sodium, we also need to consider the sodium content of different intravenous fluid solutions:

  • 0.9% saline = 154 mEq/L
  • 3% saline = 513 mEq/L
  • 5% saline = 856 mEq/L
  • Lactated Ringers = 130 mEq/L
  • Dextrose 5% water (D5W) = 0 mEq/L

Specifically to calculate the expected change in sodium, we use the patients TBW, most recent sodium value, and the sodium content of the infusate, using the following equation:

$$\Delta[\mathrm{Na}] = \frac{[\mathrm{Na}]_{\text{infusate}} -[\mathrm{Na}]_{\text{serum}} }{\mathrm{TBW}+\mathrm{volume_infused}}$$

It's slighty more complicated if we want to calculate the hourly change in sodium with continuous infusions.

Given:

  • $TBW$ = total body water (L)
  • ${Na}_{start}$ = initial serum sodium (mEq/L)
  • ${Na}_{inf}$ = sodium concentration of the infusate (mEq/L)
  • $\dot V$ = infusion rate (mL/hr)
  • ${V}_{hr}$ = $\dot{V} / 1000$ (L infused in one hour)

Then after one hour:

$$\mathrm{NewNa}_{\mathrm{hr}} = \frac{[\mathrm{Na}]_{\mathrm{start}}\times \mathrm{TBW} + [\mathrm{Na}]_{\mathrm{inf}}\times V_{\mathrm{hr}}} {\mathrm{TBW} + V_{\mathrm{hr}}}$$

and the expected change per hour is

$$\Delta[\mathrm{Na}]_{\mathrm{per\,hr}} = \mathrm{NewNa}_{\mathrm{hr}} \;-\; [\mathrm{Na}]_{\mathrm{start}}.$$

Practically, we can surface the expected change in sodium as a property of each infusion (as a tooltip on each therapy). Therefore if a patient is receiving multiple treatments we can see how each would be expected to change their serum sodium.

NaPathway calculates the expected change in sodium with each therapy administered



⚙️ Implementation

  • HTML/CSS/JavaScript for the UI and calculations
  • Uses luxon.js for handling date/times and chart.js for displaying the results. It uses the Luxon Chart.js adapter for easy interoperability between the two.
  • Uses the Asynchronous Clipboard API for pasting and the window.print function for printing or export to PDF.
  • Event Listeners: Inputs and buttons trigger updateGraph() or calculateTBW() to dynamically update the UI.



⚠️ Limitations

Sodium does not fully explain ODS risk

Although the original report of osmotic demyelination syndrome suggested that the cause was rapid correction of sodium (>12 mEq/L/day) more recent studies suggest that ODS can occur with slower rates of correction. In a cohort described by Seethapathy et al, CPM occured in 5 of 7 patients despite correcting sodiuma at a slower rate (<8 mEq/L/day). Even patients with relatively slow correction of hyponatremia can develop CPM/ODS. A larger multi-center observational study by MacMillan et al found that 7/12 patients who developed CPM did not have rapid correction. Thus, extremely cautious rates of sodium correction (e.g. <6 mEq/L/day) may be warranted in high risk patients. The NaPathway app allows users to choose a more cautious rate of correction for high risk patients. This is not a substitute for clinical judgement.

Changes in endogenous ADH can lead to over-correction

Frequently, patient present with hyponatremia in the setting of high endogenous ADH levels (for example with hypovolemia). Following volume resuscitation, the endogenous ADH levels drop and the sodium can rise rapidly, potentially causing dangerously rapid overocorrection. For this reason exogenous ADH can be administered in the form of ddAVP to blunt the rapid rise in sodium when endogenous ADH falls. This apporach is termed the ddAVP clamp. A good discussion of this approach can be found here. The NaPathway app allows you to add ddAVP on the plot to see when it is working.

Need for rapid initial correction

In some circumstances (for example seizures), a rapid initial sodium correction is necessary. Typically the goal will be to rapidly increase sodium by 3-5 mEq/L, however the 24 hour correction goal remains unchanged. The current NaPathway app does not adjust the correction glideslope to account for this.

An app can't replace clincal judgement

Perhaps most importantly, a data vizualization app isn't a substitute for clinical judgement. Context is important (what is the etiology of hyponatremia?) and there are many factors (ongoing free water intake, urinary losses, fluids in other medication infusion) that the app does not capture. The NaPathway app is intended to help experienced and trained clinicians combine the data together to make better informed decisions. It is not intended to tell clinicians what to do. Expert clinical judgement is still essential. Double check any calculation. Don't be stupid.



🔢 Versions

  • 1.0 first working version - features sodium graph with variable rates of correction
  • 1.1 added ability to print, save, & copy the graph
  • 2.0 added basic therapies
  • 3.0 implemented calculations of TBW and expected change in serum sodium
  • 3.1 many bug fixes



🚧 Features to Add

[x] Add therapies (d5W, 3% NS, ddAVP, etc)

[x] Add more info about therapies on the graph, for example:

  • ideally I could add a weight based calculator to estimate how much a given free water bolus would be expected to decrease the sodium
  • when was ddAVP given --> show the expected half life of the drug

[ ] Make it possible to easily share the graph with someone else

  • one approach would be to persist the data (e.g. on a server) and have a login or direct link
  • alternatively could have a "share" button that included the data in the hyperlink itself?

[ ] Add a watermark to the graph

  • always good to be be transparent about the source! also helps others find the app.

[ ] Ideally this would be integrated into the EHR so the user wouldn't have to do any data entry.

  • this could pull lots of additional data --> therapeutics given, urine output, other labs, etc
  • this is really where this app needs to go ultimately & why I've made it open source under an MIT license



🪪 License

NaPathway is released under an MIT License - free to reuse (including commercially) but please acknowledge where you got it! It's my sincere hope that people will steal this code and use it to deploy within thier own EHR.



📚 References

About

Web app to visualize and help clinicians safely correct hyponatremia.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages