Public
Edited
Feb 10, 2022
2 forks
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
/**
* Uses Henderson–Hasselbalch's equation to calculate pH based on serum HCO3 and PCO2
*/
function HH_pH(PCO2, HCO3=24, pKa=6.1, alpha=0.03){
let pH = pKa + Math.log10(HCO3/(alpha * PCO2))
return pH
}
Insert cell
/**
* Uses Henderson–Hasselbalch's equation to calculate pCO2 based on serum HCO3 and pH
*/
function HH_PCO2(pH, HCO3, pKa=6.1, alpha=0.03){
let pCO2 = HCO3 / (10**(pH-pKa) * alpha)
return pCO2
}
Insert cell
/**
* Takes a tidal volume(TV), respiratory rate(RR), and dead space volume (TVd)
* Returns alveolar ventilation(VA), and dead space ventilation(VD)
*/
function MV(TV, RR, TVd=0){
let TVa = TV - TVd
let VD = TVd * RR
let VA = TVa * RR
return [VA, VD]
}
Insert cell
/**
* Calculates new PCO2 based on old PCO2, and changes in tidal volume, and respiratory rate accounting for dead space
*/
function newPCO2(TV_old, RR_old, PCO2_old, TV_new, RR_new, TVd){
let [VA_old, VD_old] = MV(TV_old, RR_old, TVd)
let [VA_new, VD_new] = MV(TV_new, RR_new, TVd)
let PCO2_new = VA_old * PCO2_old / VA_new
return PCO2_new
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more