medcalc
v0.2.0
Published
Collection of medical calculators
Readme
MedCalc
MedCalc is a JavaScript library providing medical calculators for nephrology and kidney function assessment. It implements evidence-based formulas commonly used in clinical practice for evaluating kidney disease and acute kidney injury.
Features
✓ CKD-EPI 2021 Equation - Calculate estimated Glomerular Filtration Rate (eGFR)
✓ GFR Staging - Determine chronic kidney disease stages based on eGFR
✓ KDIGO Classification - Assess acute kidney injury severity
✓ Zero Dependencies - Lightweight and fast
✓ Type Safe - Built with modern JavaScript and proper validation
✓ Well Tested - Comprehensive test suite with clinical reference values
Installation
npm install medcalcUsage
CKD-EPI Equation (2021)
Calculate estimated Glomerular Filtration Rate using the latest CKD-EPI creatinine equation:
import { ckdEpi } from 'medcalc'
// Calculate eGFR for a 60-year-old male with creatinine 1.4 mg/dL
const eGFR = ckdEpi({
creat: 1.4, // Serum creatinine in mg/dL
age: 60, // Age in years
gender: 'M', // 'M' for male, 'F' for female
})
console.log(eGFR) // 57.5 mL/min/1.73 m²GFR Staging
Determine chronic kidney disease stage based on eGFR:
import { gfrStage } from 'medcalc'
const stage = gfrStage({ tfg: 45 }) // tfg = eGFR value
console.log(stage) // '3b'
// Stage reference:
// '1': ≥90 mL/min/1.73 m²
// '2': 60-89 mL/min/1.73 m²
// '3a': 45-59 mL/min/1.73 m²
// '3b': 30-44 mL/min/1.73 m²
// '4': 15-29 mL/min/1.73 m²
// '5': <15 mL/min/1.73 m²KDIGO Acute Kidney Injury Classification
Assess acute kidney injury severity using KDIGO criteria:
import { kdigo } from 'medcalc'
// Based on creatinine change
const akiStage = kdigo({
baseCreat: 1.0, // Baseline creatinine (mg/dL)
currentCreat: 2.1, // Current creatinine (mg/dL)
})
console.log(akiStage) // 2 (Stage 2 AKI)
// Based on urine output
const akiStageUrine = kdigo({
diuresis: 200, // Urine output (mL)
interval: 8, // Time interval (hours)
weight: 70, // Patient weight (kg)
})
// For patients on dialysis
const akiStageDialysis = kdigo({
inDialysis: true,
})
console.log(akiStageDialysis) // 3 (Stage 3 AKI)API Reference
ckdEpi(params)
Calculates estimated GFR using the CKD-EPI 2021 equation.
Parameters:
creat(number): Serum creatinine in mg/dLage(number): Age in yearsgender(string): 'M' for male, 'F' for female
Returns: number | undefined - eGFR in mL/min/1.73 m², or undefined for invalid input
gfrStage(params)
Determines CKD stage based on eGFR value.
Parameters:
tfg(number): eGFR value in mL/min/1.73 m²
Returns: string | undefined - Stage ('1', '2', '3a', '3b', '4', '5'), or undefined for invalid input
kdigo(params)
Classifies acute kidney injury using KDIGO criteria.
Parameters:
baseCreat(number, optional): Baseline creatinine in mg/dLcurrentCreat(number, optional): Current creatinine in mg/dLdiuresis(number, optional): Urine output in mLinterval(number, optional): Time interval in hoursweight(number, optional): Patient weight in kginDialysis(boolean, optional): Whether patient is on dialysis
Returns: number | undefined - AKI stage (1, 2, or 3), or undefined if no AKI
Clinical References
- CKD-EPI 2021: Kidney Disease: Improving Global Outcomes (KDIGO)
- KDIGO AKI Guidelines: Clinical Practice Guideline for Acute Kidney Injury
- Test reference values from: Brazilian Society of Nephrology Calculator
Development
# Install dependencies
npm install
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Lint code
npm run lintLicense
Copyright © 2018 Luiz Américo Pereira Câmara. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.
Made with ♥ by Luiz Américo Pereira Câmara and contributors
