-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.py
278 lines (225 loc) · 8.98 KB
/
dashboard.py
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
import streamlit as st
import pandas as pd
import numpy as np
st.title("Patient DashBoard")
st.sidebar.title("DashBoard")
st.sidebar.markdown("All the required details at one place.")
#--------------------------------------------DATA IMPORTING START------------------------------------------------------------------#
#@st.cache(persist=True)
@st.cache(allow_output_mutation=True)
def load_details():
details=pd.read_csv("patients.csv")
return (details)
patient_details=load_details()
@st.cache(allow_output_mutation=True)
def load_observations():
details=pd.read_csv("observations.csv")
return (details)
patient_observations=load_observations()
@st.cache(allow_output_mutation=True)
def load_condition():
details=pd.read_csv("conditions.csv")
return (details)
patient_conditions=load_condition()
@st.cache(allow_output_mutation=True)
def load_allergies():
details=pd.read_csv("allergies.csv")
return (details)
patient_allergies=load_allergies()
@st.cache(allow_output_mutation=True)
def load_careplans():
details=pd.read_csv("careplans.csv")
return (details)
patient_careplans=load_careplans()
@st.cache(allow_output_mutation=True)
def load_devices():
details=pd.read_csv("devices.csv")
return (details)
patient_devices=load_devices()
@st.cache(allow_output_mutation=True)
def load_suppliers():
details=pd.read_csv("providers.csv")
return(details)
suppliers=load_suppliers()
@st.cache(allow_output_mutation=True)
def load_medication():
details=pd.read_csv("medications.csv")
return (details)
patient_medications=load_medication()
#-------------------------------------------------DATA IMPORTING END----------------------------------------------------------------#
#----------------------------------------------------DATA CLEARING START------------------------------------------------------------#
patient_details['PREFIX'] = patient_details['PREFIX'].str.replace('\f+',' ')
patient_details['MAIDEN'] = patient_details['MAIDEN'].str.replace('\f+','')
index=0
for i in patient_details["PREFIX"]:
if not(isinstance(i, str)):
patient_details["PREFIX"][index]=''
index=index+1
index=0
for i in patient_details["FIRST"]:
patient_details["FIRST"][index]=''.join([i for i in i if not i.isdigit()])
index=index+1;
index=0
for i in patient_details["LAST"]:
patient_details["LAST"][index]=''.join([i for i in i if not i.isdigit()])
index=index+1;
index=0
for i in patient_details["MAIDEN"]:
if (isinstance(i, str)):
patient_details["MAIDEN"][index]=''.join([i for i in i if not i.isdigit()])
else:
patient_details["MAIDEN"][index]=''
index=index+1;
index=0
for i in patient_details["MARITAL"]:
if(i=="M"):
patient_details["MARITAL"][index]="Marrried"
elif(i=="S"):
patient_details["MARITAL"][index]="Single"
elif(i==''):
patient_details["MARITAL"][index]="N/A"
index=index+1;
index=0
for i in patient_details["GENDER"]:
if(i=="M"):
patient_details["GENDER"][index]="Male"
if(i=="F"):
patient_details["GENDER"][index]="Female"
index=index+1;
#----------------------------------------------------DATA CLEARING END--------------------------------------------------------------#
#------------------------------------------Display Function---------------------------------------------#
def main_display():
st.sidebar.subheader("Patient Details to Display:")
choice = st.sidebar.radio('', ('Personal Details', 'Patient Obsevations', 'Patient Allergies' , 'Patient Conditions' , 'Monitoring Devices', 'Medication Records'))
if(choice=='Personal Details'):
st.write("\n")
st.subheader("Personal Details of the Patient-")
index=-1
for i in patient_details["Id"]:
index=index+1
if patient_id==i:
st.write("Address of the patient: "+patient_details["ADDRESS"][index]+", "+patient_details["CITY"][index]+", "+patient_details["STATE"][index]+", "+patient_details["COUNTY"][index])
st.write("Zip Code-"+str(patient_details["ZIP"][index]))
st.write("Gender of the patient: "+patient_details["GENDER"][index])
st.write("Race of the patient: "+patient_details["RACE"][index])
st.write("Ethnicity of the patient: "+patient_details["ETHNICITY"][index])
#st.write("Marital Status of patient: "+patient_details["MARITAL"][index])
if(choice=='Patient Obsevations'):
st.write("\n")
st.subheader("Medical Details of the Patient-")
index=0
reading=0
st.markdown("#### Observation:"+str(reading+1))
reading=reading+1
for i in patient_observations["PATIENT"]:
if patient_id==i:
if(patient_observations["DESCRIPTION"][index]!='QOLS')and(patient_observations["DESCRIPTION"][index]!='DALY')and(patient_observations["DESCRIPTION"][index]!="QALY"):
if("/uL" in str(patient_observations["UNITS"][index])):
st.write(patient_observations["DESCRIPTION"][index]+": "+str(patient_observations["VALUE"][index])+" x "+str(patient_observations["UNITS"][index]))
else:
st.write(patient_observations["DESCRIPTION"][index]+": "+str(patient_observations["VALUE"][index])+""+str(patient_observations["UNITS"][index]))
if(patient_observations["DESCRIPTION"][index]=="Tobacco smoking status NHIS"):
st.markdown("#### Observation:"+str(reading+1))
reading+=1
index=index+1
if(choice=='Patient Allergies'):
st.write("\n")
st.subheader("Allergies suffered by the Patient-")
index=0
found=0
for i in patient_allergies["PATIENT"]:
if patient_id==i:
st.write(str(patient_allergies["DESCRIPTION"][index]))
found=1
index=index+1
if found==0:
st.write("No Allergies to Report.")
else:
st.markdown("### Take care of these while interacting with Patient")
if(choice=='Patient Conditions'):
st.write("\n")
st.subheader("Patient is suffering from:")
index=0
for i in patient_conditions['PATIENT']:
if patient_id==i:
st.write(patient_conditions['DESCRIPTION'][index])
index=index+1
index=0
st.subheader("Patient's careplan to Keep in Mind-:")
for i in patient_careplans['PATIENT']:
if i==patient_id:
st.write(patient_careplans['DESCRIPTION'][index])
index=index+1
if(choice=='Monitoring Devices'):
st.write("\n")
st.subheader("Monitoring devices/Implants for the Patient")
index=0
found=0
for i in patient_devices['PATIENT']:
if i==patient_id:
st.write("Device: "+patient_devices['DESCRIPTION'][index])
st.write("Device id:"+patient_devices['UDI'][index])
found=1
index=index+1
if found==0:
st.write("No Implants/Devices for the Patient.")
if(choice=='Medication Records'):
patient_medications['STOP']= patient_medications['STOP'].apply(str)
st.write("\n")
st.subheader("Medication Records of the Patient")
index=0
found=0
reading=0
for i in patient_medications["PATIENT"]:
if patient_id==i:
found=1
st.markdown("#### Record:"+str(reading+1))
reading+=1
st.write("Medicine Name: "+ patient_medications["DESCRIPTION"][index])
if(patient_medications["REASONCODE"][index]>0):
st.write("Reason prescribed: "+ str(patient_medications["REASONDESCRIPTION"][index]))
st.write("Start Date: "+ patient_medications["START"][index][:10])
if(patient_medications["STOP"][index]!="nan"):
st.write("Stop Date: "+ str(patient_medications["STOP"][index][:10]))
else:
st.write("Stop Date: Ongoing")
index=index+1
if found==0:
st.write("No Medication Records found for the Patient.")
#------------------------------------------------------------------------------------------------------------#
#---------------------------------------------------Final working-------------------------------------------------------------------#
patient_id = st.text_input("ENTER THE PATIENT ID:")
if(patient_id!=""):
st.markdown("#### Patient ID: "+ patient_id)
index=-1;
for i in patient_details["Id"]:
index=index+1
if patient_id==i:
st.markdown("#### Patient Name: "+patient_details["PREFIX"][index]+" "+patient_details["FIRST"][index]+" "+patient_details["LAST"][index]+" "+patient_details["MAIDEN"][index])
main_display()
else:
st.markdown("#### Patient ID: ")
st.markdown("#### Patient Name: ")
choice = st.sidebar.radio('', ('Personal Details', 'Patient Obsevations', 'Patient Allergies' , 'Patient Conditions' , 'Monitoring Devices', 'Medication Records'))
if(choice=='Personal Details'):
st.write("\n")
st.subheader("Personal Details of the Patient-")
if(choice=='Patient Obsevations'):
st.write("\n")
st.subheader("Medical Details of the Patient-")
if(choice=='Patient Allergies'):
st.write("\n")
st.subheader("Allergies suffered by the Patient-")
if(choice=='Patient Conditions'):
st.write("\n")
st.subheader("Patient is suffering from-")
if(choice=='Monitoring Devices'):
st.write("\n")
st.subheader("Monitoring devices/Implants for the Patient-")
if(choice=='Medication Records'):
st.write("\n")
st.subheader("Medication Records of the Patient-")
st.sidebar.subheader("Medical Suppliers Loacations")
if st.sidebar.checkbox("Show", True, key='0'):
st.subheader("Locations of Medical Suppliers in Massachusetts")
st.map(suppliers)