-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPotassium.py
More file actions
executable file
·155 lines (135 loc) · 9.28 KB
/
Copy pathPotassium.py
File metadata and controls
executable file
·155 lines (135 loc) · 9.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# -*- coding: utf-8 -*-
"""
Created on Thu May 18 02:58:42 2017
@author: CHD5N
"""
# function for screening for clinically significant hyperkalemia
def hyperkalemia_screen():
print("1. Order an ECG") # order should be automatic
print("2. Check for peaked T waves (tall [ie > R], narrow, symmetric)")
print("\nOther stuff that can happen:")
print(" (a) short QT interval")
print(" (b) long PR duration")
print("\nAnd eventually:")
print(" (c) widened QRS complex")
print(" (d) absent P waves")
# function for stabilizing cardiac membrane in case of clinically significant hyperkalemia
def stabilize_membrane():
print("\nTo stabilize the membrane, give:")
print("1. IV calcium gluconate 1 gm AND/OR") # order should be automatic
print("2. IV magnesium sulfate 1 gm")
# function for promoting intra-cellular shift of potassium
def redistribute_K():
print("\nTo shift K into cells, give:")
print("1. IV insulin 10U WITH IV D50 25 gm AND/OR") # order should be automatic
print("2. Nebulized albuterol AND/OR")
print("3. IV sodium bicarb 50 mEq")
# function for promoting elimination of potassium from body
def eliminate_K():
print("\nTo elimate K from the body, give:")
print("1. IV furosemide 20 mg OR")
print("2. IV bumetanide 1 mg (for renal elimination) AND/OR")
print("3. PO Miralax 17 gm (for enteric elimination)")
# meta-function for stabilizing cardiac membrane and redistributing and eliminating potassium
def treat_hyperkalemia():
stabilize_membrane()
redistribute_K()
eliminate_K()
# user input to give algorithm potassium level, diet status, and access; eventually should fill automatically from EMR
K = float(input("What is potassium? " )) # fill from Results in EMR
enteral = input("What is diet status? (regular, tube feeds, NPO): ") # fill from Nutrition in EMR
access = input("What is venous access? (central vs peripheral): ") # pull from LDAs in EMR
# check EMR for K orders since last BMP 'ordered_K = x mEq'
ordered_K = 0 # orders adjusted for mEq K, evatually should fill automatically from EMR
# check EMR for K given since last BMP 'given_K = y mEq'
given_K = 0 # mEq given already, eventually should fill automatically from EMR
# first part of algorithm should supplement K toward 4 in 20 mEq increments, 60 mEq per cycle
# it should adjust for K ordered/given since last BMP
# PIV supplements can be given in 10 mEq increments
# enteral route is preferred for gut health
if int(K*100) < 400: # this test is equivalent to testing for K < 4.0 but deals better with the float problem
delta = int(round((4.0 - K + given_K)*100))
delta_adj = delta - ordered_K
if delta_adj <= 60 and delta_adj % 20 == 0: # this makes sure order is in increments of 20 mEq (unless PIV)
meq = delta_adj
elif delta_adj <= 60 and delta_adj % 20 != 0:
meq = delta_adj + 10
else:
meq = 60 # max supplement order is 60 mEq at a time
if delta <= 60: # for delta <= 60
print("\nPatient needs " + str(delta) + " mEq of K. Give, then recheck BMP in 24h.")
print("Note that " + str(given_K) + " mEq given and " + str(ordered_K) + " mEq ordered, not yet given, since last BMP. Will adjust accordingly.")
# for patients who can receive enteral supplements
# default will be packet due to ease of use with tube, tablets will require manual revision
if enteral == "regular" or enteral == "reg": # this will give PO supps
if meq > 20: # this makes sure 'packet' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl orally once by giving " + str(meq/20) + " KLOR-CON packets. Recheck BMP in 24h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl orally once by giving " + str(meq/20) + " KLOR-CON packet. Recheck BMP in 24h.") # orders should be placed automatically
elif enteral == "tube feeds" or enteral == "tube" or enteral == "tf": # this will give supps via tube
if meq > 20: # this makes sure 'packet' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl via tube once by giving " + str(meq/20) + " KLOR-CON packets. Recheck BMP in 24h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl via tube once by giving " + str(meq/20) + " KLOR-CON packet. Recheck BMP in 24h.") # orders should be placed automatically
# for patients who cannot receive enteral supplements
elif access == "central" or access == "c" or access == "cvl": # this will give supps via CVL
if meq > 20: # this makes sure 'IVPB' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl via CVL once by giving " + str(meq/20) + " doses KCl 20 mEq IVPBs. Recheck BMP in 24h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl via CVL once by giving " + str(meq/20) + " dose KCl 20 mEq IVPB. Recheck BMP in 24h.") # orders should be placed automatically
else: # this will give supps via PIV
meq = delta_adj
if meq > 10: # this makes sure 'IVPB' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl via PIV once by giving " + str(meq/10) + " doses KCl 10 mEq IVPBs. Recheck BMP in 24h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl via PIV once by giving " + str(meq/10) + " dose KCl 10 mEq IVPB. Recheck BMP in 24h.") # orders should be placed automatically
else: # for delta > 60
print("\nPatient needs " + str(delta) + " mEq of K. Give 60 mEq, then recheck BMP in 6h.")
print("Note that " + str(given_K) + " mEq given and " + str(ordered_K) + " mEq ordered, not yet given, since last BMP. Will adjust accordingly.")
# for patients who can receive enteral supplements
# default will be packet due to ease of use with tube, tablets will require manual revision
if enteral == "regular" or enteral == "reg": # this will give PO supps
if meq > 20: # this makes sure 'packet' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl orally once by giving " + str(meq/20) + " KLOR-CON packets. Recheck BMP in 6h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl orally once by giving " + str(meq/20) + " KLOR-CON packet. Recheck BMP in 6h.") # orders should be placed automatically
elif enteral == "tube feeds" or enteral == "tube" or enteral == "tf": # this will give supps via tube
if meq > 20: # this makes sure 'packet' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl via tube once by giving " + str(meq/20) + " KLOR-CON packets. Recheck BMP in 6h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl via tube once by giving " + str(meq/20) + " KLOR-CON packet. Recheck BMP in 6h.") # orders should be placed automatically
# for patients who cannot receive enteral supplements
elif access == "central" or access == "c" or access == "cvl": # this will give supps via CVL
if meq > 20: # this makes sure 'IVPB' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl via CVL once by giving " + str(meq/20) + " doses KCl 20 mEq IVPBs. Recheck BMP in 6h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl via CVL once by giving " + str(meq/20) + " dose KCl 20 mEq IVPB. Recheck BMP in 6h.") # orders should be placed automatically
else: # this will give supps via PIV
if delta_adj <= 60:
meq = delta_adj
else:
meq = 60 # max supplement order is 60 mEq at a time
if meq > 10: # this makes sure 'IVPB' is plural when applicable
print("\nGive " + str(meq) + " mEq KCl via PIV once by giving " + str(meq/10) + " doses KCl 10 mEq IVPBs. Recheck BMP in 6h.") # orders should be placed automatically
else:
print("\nGive " + str(meq) + " mEq KCl via PIV once by giving " + str(meq/10) + " dose KCl 10 mEq IVPB. Recheck BMP in 6h.") # orders should be placed automatically
# this part of code should manage high K or determine K is normal
elif K > 6.0:
print("\nSince K is > 6, you should screen for ECG changes AND treat the hyperkalemia.")
print("\nTo screen for ECG changes:")
hyperkalemia_screen()
print("\nTo treat the hyperkalemia:")
treat_hyperkalemia()
print("\nLastly, recheck BMP in 6 hours.")
elif K > 5.0:
print("\nSince K is > 5, you should screen for ECG changes.")
hyperkalemia_screen()
screen = input("\nIs ECG normal? (Y/N) ")
if screen == "yes" or screen == "Y" or screen == "y":
print("\nSince ECG normal, recheck BMP in 6 hours. No intervention necessary.")
else:
print("\nWith ECG changes, treat for hyperkalemia:")
treat_hyperkalemia()
print("\nLastly, recheck BMP in 6 hours.")
else:
print("\nK is within target range.")