in clns-CORONET_tool/CORONET_functions.py [0:0]
def calculate_NEWS2(x):
'''
Function to calculate NEWS2 score
https://www.mdcalc.com/national-early-warning-score-news-2
INPUT:
dictionary
x = {'Respiratory Rate (bpm)': int,
'Hypercapnic respiratory failure': str, -string 'Yes' or 'No'
'SpO2 (%)': int,
'Supplemental O2': str, -string 'Yes' or 'No'
'Systolic BP (mmHg)': int,
'Heart Rate (bpm)':int
'Consciousness': 'str, -string 'Yes' or 'No'
'Temperature (degrees of C)': float, - decimal
}
OUTPUT:
NEWS2_score - int
'''
rr_score = 0
sat_score = 0
supp_o2_score = 0
Systolic_BP_score = 0
Heart_rate_score = 0
Consciousness_score = 0
Temperature_score = 0
# Respiratory Rate (bpm)
if (11 >= x['Respiratory Rate (bpm)']) & (x['Respiratory Rate (bpm)'] >= 9):
rr_score = 1
elif x['Respiratory Rate (bpm)'] <= 8:
rr_score = 3
elif (24 >= x['Respiratory Rate (bpm)']) & (x['Respiratory Rate (bpm)'] >= 21):
rr_score = 2
elif x['Respiratory Rate (bpm)'] >= 25:
rr_score = 3
# SpO2
if x['Hypercapnic respiratory failure'] == 'No':
# SpO2 (%)
if x['SpO2 (%)'] <= 91:
sat_score = 3
elif (92 <= x['SpO2 (%)']) & (x['SpO2 (%)'] <= 93):
sat_score = 2
elif (94 <= x['SpO2 (%)']) & (x['SpO2 (%)'] <= 95):
sat_score = 1
elif x['Hypercapnic respiratory failure'] == 'Yes':
# SpO2 (%)
if x['SpO2 (%)'] <= 83:
sat_score = 3
elif (84 <= x['SpO2 (%)']) & (x['SpO2 (%)'] <= 85):
sat_score = 2
elif (86 <= x['SpO2 (%)']) & (x['SpO2 (%)'] <= 87):
sat_score = 1
elif (93 <= x['SpO2 (%)']) & (x['SpO2 (%)'] <= 94):
sat_score = 1
elif (95<= x['SpO2 (%)']) & (x['SpO2 (%)'] <= 96):
sat_score = 2
elif x['SpO2 (%)'] >= 97:
sat_score = 3
# Supplemental O2
if x['Supplemental O2'] == 'Yes':
supp_o2_score = 2
# Systolic BP (mmHg)
if x['Systolic BP (mmHg)'] <= 90:
Systolic_BP_score = 3
elif (91 <= x['Systolic BP (mmHg)']) & (x['Systolic BP (mmHg)'] <= 100):
Systolic_BP_score = 2
elif (101 <= x['Systolic BP (mmHg)']) & (x['Systolic BP (mmHg)'] <= 110):
Systolic_BP_score = 1
elif x['Systolic BP (mmHg)'] >= 220:
Systolic_BP_score = 3
# Consciousness
if x['Consciousness'] == 'No':
Consciousness_score = 3
# Temperature
if x['Temperature (degrees of C)'] <= 35:
Temperature_score = 3
elif (35.1 <= x['Temperature (degrees of C)']) & (x['Temperature (degrees of C)'] <= 36):
Temperature_score = 1
elif (38.1 <= x['Temperature (degrees of C)']) & (x['Temperature (degrees of C)'] <= 39):
Temperature_score = 1
elif x['Temperature (degrees of C)'] >= 39.1:
Temperature_score = 2
# Temperature
if x['Heart Rate (bpm)'] <= 40:
Heart_rate_score = 3
elif (41 <= x['Heart Rate (bpm)']) & (x['Heart Rate (bpm)'] <= 50):
Heart_rate_score = 1
elif (91 <= x['Heart Rate (bpm)']) & (x['Heart Rate (bpm)'] <= 110):
Heart_rate_score = 1
elif (111 <= x['Heart Rate (bpm)']) & (x['Heart Rate (bpm)'] <= 130):
Heart_rate_score = 2
elif x['Heart Rate (bpm)'] >= 131:
Heart_rate_score = 3
NEWS2_score = rr_score + sat_score + supp_o2_score + Systolic_BP_score + Consciousness_score + Temperature_score + Heart_rate_score
#print(rr_score, sat_score, Systolic_BP_score, Consciousness_score, Temperature_score, Heart_rate_score)
return NEWS2_score