Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

NurseCalc Infuus - Bash script and Online app for infusion and drip (speed) Calculations

Published: 01-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.


This script will help you with nursing-related infusion and drip speed 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 $100 credit for 60 days.

NurseCalc infuus by Raymii.org. READ LICENSE
Usage: ./infuus.sh $HOEVEELHEID $DRUPPELSNELHEID $TIJDSDUUR $DRUPPELSML
Two variables are needed, the other will be calculated. Unknown variable should be entered as 0
LAST VARIABLE (drips per ml) IS REQUIRED!
$HOEVEELHEID = Total amount of drips
$DRUPPELSNELHEID = drip speed in drips/min
$TIJDSDUUR = Total time infusion needs to run in min
$DRUPPELSML = drips in 1 ml of fluid. Most fluids have 20dr/ml
Decimal hours to minutes: 4.87 hours = 0.87 hours * 0.60 = 4 hours and 52 minutes
Calculate total amount of drips = dr/ml * total ml = 20 dr/ml * 2400 ml = 48000 drips total
example: ./infuus.sh 2 85 2 0 will output 85 minutes.
example: ./infuus.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 Infuus Online

Bash Script

infuus.sh

#!/bin/bash
# infuus.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.

HOEVEELHEID=$1
DRUPPELSNELHEID=$2
TIJDSDUUR=$3
DRUPPELSML=$4


function expl {
    echo 'NurseCalc infuus by Raymii.org. READ LICENSE';
    echo 'Usage: ./infuus.sh $HOEVEELHEID $DRUPPELSNELHEID $TIJDSDUUR $DRUPPELSML';
    echo 'Two variables are needed, the other will be calculated. Unknown variable should be entered as 0'
    echo 'LAST VARIABLE (drips per ml) IS REQUIRED!';
    echo '$HOEVEELHEID = Total amount of drips';
    echo '$DRUPPELSNELHEID = drip speed in drips/min';
    echo '$TIJDSDUUR = Total time infusion needs to run in min';
    echo '$DRUPPELSML = drips in 1 ml of fluid. Most fluids have 20dr/ml';
    echo 'Decimal hours to minutes: 4.87 hours = 0.87 hours * 0.60 = 4 hours and 52 minutes';
    echo 'Calculate total amount of drips = dr/ml * total ml = 20 dr/ml * 2400 ml = 48000 drips total';
    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 ! [[ "$HOEVEELHEID" =~ ^[0-9]+([.][0-9]+)?$ ]] || ! [[ "$DRUPPELSNELHEID" =~ ^[0-9]+([.][0-9]+)?$ ]] || ! [[ "$TIJDSDUUR" =~ ^[0-9]+([.][0-9]+)?$ ]] || ! [[ "$DRUPPELSML" =~ ^[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 [ $HOEVEELHEID -eq 0 ] &&&& ! [ $DRUPPELSML -eq 0 ]; then 
    # hoeveelheid druppels  wanted
    exec >&&2;
    echo 'NurseCalc infuus by Raymii.org. READ LICENSE';
    echo -e "Druppelsnelheid $DRUPPELSNELHEID dr/min, nTijdsduur $TIJDSDUUR min ndr/ml = $DRUPPELSML";
    echo "########## ANSWER ##########"
    echo "Total drips";
    echo "scale=2; $DRUPPELSNELHEID * $TIJDSDUUR " | bc
    echo "Drips to ML:"; 
    echo "scale=2; ( $DRUPPELSNELHEID * $TIJDSDUUR ) / $DRUPPELSML" | bc
    exit 0

elif [ $DRUPPELSNELHEID -eq 0 ] &&&& ! [ $DRUPPELSML -eq 0 ]; then 
    # druppelsnelheid wanted
    exec >&&2;
    echo 'NurseCalc infuus by Raymii.org. READ LICENSE';
    echo -e "Tijdsduur $TIJDSDUUR min, nTotaal aantal druppels $HOEVEELHEID ndr/ml = $DRUPPELSML";
    echo "########## ANSWER ##########"
    echo "Drip speed in min";
    echo "scale=2; ( $HOEVEELHEID / $TIJDSDUUR )" | bc
    exit 0

elif [ $TIJDSDUUR -eq 0 ] &&&& ! [ $DRUPPELSML -eq 0 ]; then 
    # tijdsduur infuus wanted
    exec >&&2;
    echo 'NurseCalc infuus by Raymii.org. READ LICENSE';
    echo -e "Druppelsnelheid $DRUPPELSNELHEID dr/min, nTotaal aantal druppels $HOEVEELHEID ndr/ml = $DRUPPELSML";
    echo "########## ANSWER ##########"
    echo "Total infusion time in minutes";
    echo "scale=2; ( $HOEVEELHEID / $DRUPPELSNELHEID )" | bc
    echo "in hours";
    echo "scale=0; ( $HOEVEELHEID / $DRUPPELSNELHEID ) / 60 " | bc
    exit 0

elif [ $DRUPPELSML -eq 0 ]; then 
    echo 'DRIPS PER ML IS REQUIRED.';
    echo '';
    expl;
    echo 'exiting now.';
    exit 1;
fi

Example output

remy@solaris2 ~/projects/scripts/bash/vpcalc $ bash ./infuus.sh 34320 22 0 20
NurseCalc infuus by Raymii.org. READ LICENSE
Druppelsnelheid 22 dr/min, 
Totaal aantal druppels 34320 
dr/ml = 20
########## ANSWER ##########
Total infusion time in minutes
1560.00
in hours
26
Tags: bash , infuus , lunduke , nursecalc , nursing , software