-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFinal_Code.py
310 lines (224 loc) · 10.4 KB
/
Final_Code.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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
print('Welcome to the Patient Prescreening Treatment Tool, We hope we can help you feel better today!\n')
print('Please answer the questions that pop up below with either "y" for yes or "n" for no, multiple invalid answers will terminate the questionaire\n Thank you!')
Python_Project_Data_Diagnosis = open("Python_Project_Data_Diagnosis.csv","r")
class Illness:
# Removed flu_score and allergy_score
def __init__(self):
self._cold_score = 0
self._covid_score = 0
# Added symptoms to match those in symptoms dataset
def ask_questions(self):
self.fever()
self.headache()
self.body_aches()
self.fatigue()
self.congestion()
self.sneezing()
self.sore_throat()
self.cough()
self.shortness_breath()
self.runny_nose()
self.diarrhea()
self.scratchy_throat()
self.watery_eyes()
self.nausea()
self.vomiting()
self.lost_smell_or_taste()
self.chills()
self.sinus_pressure()
self.score()
return True
# Removed flu and allergy scores from each function
# Defined each symptom on our dataset, an input variable for each symptom, and a score variable that is calculated from on user input
def fever(self):
""" Asks if they have a fever """
#Altered fever output message
fever_input = input("Do you have a fever with a temperature of 100F or greater? (y/n): ")
# checking for valid answer
if fever_input.lower() != 'y' and fever_input.lower() != 'n':
print('Invalid answer')
self.fever()
# increase score if the symptom is present
elif fever_input.lower() == 'y':
self._covid_score += 10
self._cold_score += 0
def headache(self):
"""Asks if they have a headache"""
headache_input = input("Do you have a headache? (y/n): ")
if headache_input.lower() != 'y' and headache_input.lower() != 'n':
print('Invalid answer')
self.headache()
elif headache_input.lower() == 'y':
self._covid_score += 5
self._cold_score += 1
def body_aches(self):
""" Ask if they have body or muscle aches"""
pain_input = input('Do you have any body or muscle aches? (y/n): ')
if pain_input.lower() != 'y' and pain_input.lower() != 'n':
print('Invalid answer')
self.pain()
elif pain_input.lower() == 'y':
self._covid_score += 5
self._cold_score += 1
def fatigue(self):
""" Ask if they have fatigue """
fatigue_input = input('Do you have any fatigue? (y/n): ')
if fatigue_input.lower() != 'y' and fatigue_input.lower() != 'n':
print('Invalid answer')
self.fatigue()
elif fatigue_input.lower() == 'y':
self._covid_score += 5
self._cold_score += 1
def congestion(self):
""" Ask if they have congestion"""
stuffy_nose_input = input('Do you have a stuffy nose or congestion? (y/n): ')
if stuffy_nose_input.lower() != 'y' and stuffy_nose_input.lower() != 'n':
print('Invalid answer')
self.stuffy_nose()
elif stuffy_nose_input.lower() == 'y':
self._cold_score += 1
self._cold_score += 10
def sneezing(self):
""" Ask if they are sneezing """
sneezing_input = input('Do you have a lot of sneezing? (y/n): ')
if sneezing_input.lower() != 'y' and sneezing_input.lower() != 'n':
print('Invalid answer, try again')
self.sneezing()
elif sneezing_input.lower() == 'y':
self._covid_score += 1
self._cold_score += 10
def sore_throat(self):
""" Ask if they have a sore throat """
sore_throat_input = input('Do you have a sore throat? (y/n): ')
if sore_throat_input.lower() != 'y' and sore_throat_input.lower() != 'n':
print('Invalid answer, try again')
self.sore_throat()
elif sore_throat_input.lower() == 'y':
self._covid_score += 1
self._cold_score += 10
def cough(self):
""" Ask if they have a cough"""
cough_input = input('Do you have the coughs? (y/n): ')
if cough_input.lower() != 'y' and cough_input.lower() != 'n':
print('Invalid answer, try again')
self.cough()
elif cough_input.lower() == 'y':
self._covid_score += 10
self._cold_score += 5
def shortness_breath(self):
""" Ask if they have shortness of breath """
breath_input = input('Do you have shortness of breath? (y/n): ')
if breath_input.lower() != 'y' and breath_input.lower() != 'n':
print('Invalid answer, try again')
self.shortness_breath()
elif breath_input.lower() == 'y':
self._covid_score += 10
self._cold_score += 1
def runny_nose(self):
""" Ask if they have runny nose """
runny_nose_input = input('Do you have a runny nose (y/n): ')
if runny_nose_input.lower() != 'y' and runny_nose_input.lower() != 'n':
print('Invalid answer, try again')
self.runny_nose()
elif runny_nose_input.lower() == 'y':
self._covid_score += 1
self._cold_score += 10
def diarrhea(self):
""" Ask if they have diarrhea """
diarrhea_input = input('Do you have diarrhea? (y/n): ')
if diarrhea_input.lower() != 'y' and diarrhea_input != 'n':
print('Invalid answer, try again')
self.diarrhea()
elif diarrhea_input.lower() == 'y':
self._covid_score += 10
self._cold_score += 1
else:
pass
# Defined symptom and user input variables for each
def scratchy_throat(self):
""" Ask if they have a scratchy throat """
scratchy_throat_input = input('Do you have a scratchy throat? (y/n): ')
if scratchy_throat_input.lower() != 'y' and scratchy_throat_input.lower() != 'n':
print('Invalid answer')
self.scratchy_throat()
elif scratchy_throat_input.lower() == 'y':
self._covid_score += 2
self._cold_score += 5
def watery_eyes(self):
""" Ask if they have watery eyes """
watery_eyes_input = input('Do you have watery eyes? (y/n): ')
if watery_eyes_input.lower() != 'y' and watery_eyes_input.lower() != 'n':
print('Invalid answer')
self.watery_eyes()
elif watery_eyes_input.lower() == 'y':
self._covid_score += 0
self._cold_score += 2
def nausea(self):
""" Ask if they have nausea """
nausea_input = input('Do you have nausea? (y/n): ')
if nausea_input.lower() != 'y' and nausea_input.lower() != 'n':
print('Invalid answer')
self.nausea()
elif nausea_input.lower() == 'y':
self._covid_score += 3
self._cold_score += 1
def vomiting(self):
""" Ask if they have been vomiting """
vomiting_input = input('Have you thrown up? (y/n): ')
if vomiting_input.lower() != 'y' and vomiting_input.lower() != 'n':
print('Invalid answer')
self.vomiting()
elif vomiting_input.lower() == 'y':
self._covid_score += 3
self._cold_score += 1
def lost_smell_or_taste(self):
""" Ask if they have lost their smell or taste """
lost_input = input('Have you lost your smell or taste? (y/n): ')
if lost_input.lower() != 'y' and lost_input.lower() != 'n':
print('Invalid answer')
self.lost_smell_or_taste()
elif lost_input.lower() == 'y':
self._covid_score += 5
self._cold_score += 0
def chills(self):
""" Ask if they have experienced chills """
chills_input = input('Have you experienced chills? (y/n): ')
if chills_input.lower() != 'y' and chills_input.lower() != 'n':
print('Invalid answer')
self.chills()
elif chills_input.lower() == 'y':
self._covid_score += 5
self._cold_score += 2
def sinus_pressure(self):
""" Ask if they have sinus pressure """
sp_input = input('Do you have sinus pressure? (y/n): ')
if sp_input.lower() != 'y' and sp_input.lower() != 'n':
print('Invalid answer')
self.sinus_pressure()
elif sp_input.lower() == 'y':
self._covid_score += 1
self._cold_score += 3
def score(self):
scores = []
scores.append(int(self._covid_score))
scores.append(int(self._cold_score))
scores.sort()
# Changed output messages
print('\nBased on our findings with your symptoms, we think your symtoms are most likely related to the following: ')
if scores[-1] == self._cold_score:
print('Common Cold')
user_input_cold = input("Would you like a list of recommended OTC medicines to treat your cold symtoms?")
if user_input_cold == "y":
print('Option 1: Diphenhydramine 25g (Allergy Relief)','\nOption 2: Loratadine D (Congestion Allergy Relief)','\nOption 3: Dexamethorphan 3 oz (Cough Relief)','\nOption 4:Generiz Robitussin 8 oz (Cough and Chest Congestion)','\nOption 5: Mucinex (Chest Congestion Expectorant')
elif user_input_cold == "n":
print("Please contact your doctor for any recommendations on treatment. We hope you feel better soon!")
elif scores[-1] == self._covid_score:
print ('Covid-19: Please quarantine until tested and you have recieved a negative result. In addition, contact your doctor as soon as possible.')
user_input_covid = input("Would you like a list of recommended OTC medicines to treat your Covid-19 symptoms?")
if user_input_covid == "y":
print('Option 1: Generic DayQuil OR NyQuil Cap (Multisymptom Cold and Flu)','\nOption 2: Acetaminophen 325mg (Pain/Fever Reliever)','\nOption 3: Chewable Bismuth (Stomach Relief)')
elif user_input_covid == "n":
print("Please contact your doctor for any recommendations on treatment. We hope you feel better soon!")
if __name__ == '__main__':
il = Illness()
il.ask_questions()