-
Notifications
You must be signed in to change notification settings - Fork 7
/
healthapp.py
211 lines (194 loc) · 8.32 KB
/
healthapp.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'healthui.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox
from bs4 import BeautifulSoup
import requests
from helpers.ConsultDoctor import Ui_ConsultDoctor
from helpers.drugui import Ui_Drugs
from helpers.Analyser import Ui_Dialog
from helpers.WikipediaUI import Ui_Wikipedia
from helpers.GoogleUI import Ui_Google
from helpers.dbres import Ui_Saved
class Ui_HealthApp(object):
def consultDoctor(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_ConsultDoctor()
self.ui.setupUi(self.window)
self.window.show()
def drugUI(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_Drugs()
self.ui.setupUi(self.window)
self.window.show()
def savedUi(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_Saved()
self.ui.setupUi(self.window)
self.window.show()
def covidUI(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_Dialog()
self.ui.setupUi(self.window)
self.window.show()
def WikipediaSearch(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_Wikipedia()
self.ui.setupUi(self.window)
self.window.show()
def GoogleSearch(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_Google()
self.ui.setupUi(self.window)
self.window.show()
def setupUi(self, HealthApp):
HealthApp.setObjectName("HealthApp")
HealthApp.resize(846, 600)
HealthApp.setStyleSheet("background-color: #2C3336;\n"
"font: 63 12pt \"Nunito\";")
self.centralwidget = QtWidgets.QWidget(HealthApp)
self.centralwidget.setObjectName("centralwidget")
self.query = QtWidgets.QLineEdit(self.centralwidget)
self.query.setGeometry(QtCore.QRect(280, 170, 291, 31))
font = QtGui.QFont()
font.setFamily("Nunito")
font.setPointSize(12)
font.setBold(False)
font.setItalic(False)
font.setWeight(7)
self.query.setFont(font)
self.query.setStyleSheet("border-radius:10px;\n"
"background-color: white;")
self.query.setCursorMoveStyle(QtCore.Qt.LogicalMoveStyle)
self.query.setClearButtonEnabled(False)
self.query.setObjectName("query")
self.go = QtWidgets.QPushButton(self.centralwidget)
self.go.setGeometry(QtCore.QRect(590, 170, 81, 31))
self.go.setStyleSheet("border-radius:10px;\n"
"background-color: #3CB7A1;\n"
"color: white;")
self.go.setObjectName("go")
self.result = QtWidgets.QTextBrowser(self.centralwidget)
self.result.setGeometry(QtCore.QRect(210, 230, 511, 201))
self.result.setStyleSheet("background-color: white;\n"
"border-radius: 10px;")
self.result.setObjectName("result")
self.heading = QtWidgets.QLabel(self.centralwidget)
self.heading.setGeometry(QtCore.QRect(320, 60, 241, 41))
self.heading.setStyleSheet("color: cyan;\n"
"font: 81 24pt \"Nunito ExtraBold\";\n"
"")
self.heading.setObjectName("heading")
self.wikipedia = QtWidgets.QPushButton(self.centralwidget)
self.wikipedia.setGeometry(QtCore.QRect(250, 460, 121, 31))
self.wikipedia.setStyleSheet("border-radius:10px;\n"
"background-color: #3CB7A1;\n"
"color: white;")
self.wikipedia.setObjectName("wikipedia")
self.google = QtWidgets.QPushButton(self.centralwidget)
self.google.setGeometry(QtCore.QRect(410, 460, 121, 31))
self.google.setStyleSheet("border-radius:10px;\n"
"background-color: #3CB7A1;\n"
"color: white;")
self.google.setObjectName("google")
self.left = QtWidgets.QFrame(self.centralwidget)
self.left.setGeometry(QtCore.QRect(0, 0, 141, 571))
self.left.setStyleSheet("background-color: rgb(66, 76, 81);\n"
"")
self.left.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.left.setFrameShadow(QtWidgets.QFrame.Raised)
self.left.setObjectName("left")
self.verticalLayout = QtWidgets.QVBoxLayout(self.left)
self.verticalLayout.setObjectName("verticalLayout")
self.cdoctor = QtWidgets.QPushButton(self.left)
self.cdoctor.setStyleSheet("color: cyan;\n"
"font: 81 11pt \"Nunito ExtraBold\";\n"
"")
self.cdoctor.setFlat(True)
self.cdoctor.setObjectName("cdoctor")
self.verticalLayout.addWidget(self.cdoctor)
self.covid = QtWidgets.QPushButton(self.left)
self.covid.setStyleSheet("color: cyan;\n"
"font: 81 11pt \"Nunito ExtraBold\";")
self.covid.setFlat(True)
self.covid.setObjectName("covid")
self.verticalLayout.addWidget(self.covid)
self.drugs_2 = QtWidgets.QPushButton(self.left)
self.drugs_2.setStyleSheet("color: cyan;\n"
"font: 81 11pt \"Nunito ExtraBold\";")
self.drugs_2.setFlat(True)
self.drugs_2.setObjectName("drugs_2")
self.verticalLayout.addWidget(self.drugs_2)
self.credits = QtWidgets.QPushButton(self.left)
self.credits.setStyleSheet("color: cyan;\n"
"font: 81 11pt \"Nunito ExtraBold\";")
self.credits.setFlat(True)
self.credits.setObjectName("credits")
self.verticalLayout.addWidget(self.credits)
self.databaseB = QtWidgets.QPushButton(self.centralwidget)
self.databaseB.setGeometry(QtCore.QRect(560, 460, 121, 31))
self.databaseB.setStyleSheet("border-radius:10px;\n"
"background-color: #3CB7A1;\n"
"color: white;")
self.databaseB.setObjectName("databaseB")
HealthApp.setCentralWidget(self.centralwidget)
self.retranslateUi(HealthApp)
QtCore.QMetaObject.connectSlotsByName(HealthApp)
self.go.clicked.connect(self.diseaseSearchX)
self.cdoctor.clicked.connect(self.consultDoctor)
self.covid.clicked.connect(self.covidUI)
self.drugs_2.clicked.connect(self.drugUI)
self.wikipedia.clicked.connect(self.WikipediaSearch)
self.google.clicked.connect(self.GoogleSearch)
self.databaseB.clicked.connect(self.savedUi)
def diseaseSearchX(self):
disease = self.query.text()
if len(disease)== 0:
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText("Zero Input Error")
msg.setInformativeText("Type something to search")
msg.setWindowTitle('Error')
msg.exec_()
else:
try:
url = f"https://medlineplus.gov/{disease}.html"
html_content = requests.get(url).text
soup = BeautifulSoup(html_content, "html5lib")
main_class = soup.find("div",id="topic-summary")
link = main_class.find("a")
res = main_class.text
self.result.append(str(res))
except:
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText("Error")
msg.setInformativeText("Check the spelling and try again!")
msg.setWindowTitle('Error')
msg.exec_()
def retranslateUi(self, HealthApp):
_translate = QtCore.QCoreApplication.translate
HealthApp.setWindowTitle(_translate("HealthApp", "MainWindow"))
self.query.setPlaceholderText(_translate("HealthApp", " Search here"))
self.go.setText(_translate("HealthApp", "GO"))
self.heading.setText(_translate("HealthApp", " HealthApp"))
self.wikipedia.setText(_translate("HealthApp", "Wikipedia"))
self.google.setText(_translate("HealthApp", "Google"))
self.cdoctor.setText(_translate("HealthApp", "Consult Doctor"))
self.covid.setText(_translate("HealthApp", "CovidAnalyser"))
self.drugs_2.setText(_translate("HealthApp", "Drugs"))
self.credits.setText(_translate("HealthApp", "Credits"))
self.databaseB.setText(_translate("HealthApp", "Saved"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
HealthApp = QtWidgets.QMainWindow()
ui = Ui_HealthApp()
ui.setupUi(HealthApp)
HealthApp.show()
sys.exit(app.exec_())