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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more