Raymii.org
Quis custodiet ipsos custodes?Home | About | All pages | Cluster Status | RSS Feed
NurseCalc o2 - Bash script and online app for Oxygen Calculations
Published: 12-02-2012 | Author: Remy van Elst | Text only version of this article
❗ This post is over twelve years old. It may no longer be up to date. Opinions may have changed.
Table of Contents
This script will help you with nursing-related oxygen calculations.
Also available as an online tool, scroll down for the link.
Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:
I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!
Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.
You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!
Usage: ./o2.sh $si $pr $to $do
Three variables are needed, the other will be calculated. Unknown variable should be entered as 0
$si = Size of the o2 tank in liters (eg 2, 5, 10)
$pr = Pressure in o2 tank in atm (eg 120, 65, 90)
$to = Total time o2 needs to run in minutes (eg 720, 300, 1500)
$do = Dosage of o2 in ltr per minute (eg 2, 4, 10)
example: ./o2.sh 2 85 2 0 will output 85 minutes.
example: ./o2.sh 40 90 720 0 will output 5 liters per minute
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Online version
Thanks to the Illumination Software Creator application builder I've made
an online version. Same license, has bugs, not ready for production, regular
blabla.. Use on your own risk.
NurseCalc o2 Online
Bash Script
o2.sh
#!/bin/bash
# o2.sh by raymii.org
# script displays errors with float numbers, but calc is correct.
#Copyright (c) 2012 Remy van Elst
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
SI=$1
PR=$2
SP=$3
DO=$4
function expl {
echo 'NurseCalc o2 by Raymii.org. READ LICENSE';
echo 'Usage: ./o2.sh $si $pr $to $do ';
echo 'Three variables are needed, the other will be calculated. Unknown variable should be entered as 0'
echo '$si = Size of the o2 tank in liters (eg 2, 5, 10)';
echo '$pr = Pressure in o2 tank in atm (eg 120, 65, 90)';
echo '$to = Total time o2 needs to run in minutes (eg 720, 300, 1500)';
echo '$do = Dosage of o2 in ltr per minute (eg 2, 4, 10)';
echo 'Decimal hours to minutes: 4.87 hours = 0.87 hours * 0.60 = 4 hours and 52 minutes';
echo 'example: ./o2.sh 2 85 2 0 will output 85 minutes.';
echo 'example: ./o2.sh 40 90 720 0 will output 5 liters per minute';
echo 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.';
}
if [ -e $1 ] || [ -e $2 ] || [ -e $3 ] || [ -e $4 ]; then
echo 'ERROR: One or more of the required input variables was/were empty.';
expl;
exit 1
elif ! [[ "$SI" =~ ^[0-9]+([.][0-9]+)?$ ]] || ! [[ "$PR" =~ ^[0-9]+([.][0-9]+)?$ ]] || ! [[ "$SP" =~ ^[0-9]+([.][0-9]+)?$ ]] || ! [[ "$DO" =~ ^[0-9]+([.][0-9]+)?$ ]]; then
exec >&&2;
echo 'ERROR: One or more of the variables are not numerical (integer or float)';
expl;
exit 1
elif [ $SI -eq 0 ]; then
# size wanted
exec >&&2;
echo 'NurseCalc o2 by Raymii.org. READ LICENSE';
echo -e "Pressure $2 atm, nTotal time $3 min nDosage $4 ltr/min ";
echo "########## ANSWER ##########"
echo "Size of the tank in liters:";
echo "scale=2; $SP / $PR * $DO" | bc
exit 0
elif [ $PR -eq 0 ]; then
# pressure wanted
exec >&&2;
echo 'NurseCalc o2 by Raymii.org. READ LICENSE';
echo -e "Size of the tank $1 ltr, nTotal time $3 min nDosage $4 ltr/min ";
echo "########## ANSWER ##########"
echo "Pressure of the tank in atm:";
echo "scale=2; $SP * $DO / $SI" | bc
exit 0
elif [ $SP -eq 0 ]; then
# total time wanted
exec >&&2;
echo 'NurseCalc o2 by Raymii.org. READ LICENSE';
echo -e "Size of the tank $1 ltr, nPressure $2 atm nDosage $4 ltr/min ";
echo "########## ANSWER ##########"
echo "Total time of dosage in minutes:";
echo "scale=2; $SI * $PR / $DO" | bc
echo 'Total time in hours:';
echo "scale=0; ( $SI * $PR / $DO ) / 60" | bc
exit 0
elif [ $DO -eq 0 ]; then
# dosage wanted
exec >&&2;
echo 'NurseCalc o2 by Raymii.org. READ LICENSE';
echo -e "Size of the tank $1 ltr, nPressure of the tank $2 atm nTotal time $3 min";
echo "########## ANSWER ##########"
echo "Dosage in ltr/min";
echo "scale=2; ( $SI * $PR ) / $SP" | bc
exit 0
fi
Example output
remy@solaris2 ~/projects/scripts/bash/vpcalc $ bash ./o2.sh 0 90 720 5
NurseCalc o2 by Raymii.org. READ LICENSE
Pressure 90 atm,
Total time 720 min
Dosage 5 ltr/min
########## ANSWER ##########
Size of the tank in liters:
40.00
Tags: bash
, lunduke
, nursecalc
, nursing
, oxygen
, software