-
Notifications
You must be signed in to change notification settings - Fork 0
/
Viewpatient.py
411 lines (379 loc) · 18.4 KB
/
Viewpatient.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Viewpatient.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# 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
import sqlite3
class ViewPatientssInfo(object):
# to delete patient info
def DeletePat(self):
# Get Name from the user to delete the info
Name = self.SfullNameLE.text()
db = sqlite3.connect("Hospital.db")
db.execute("delete from PatientInfo where name=" + "'" + Name + "'") # Query to delete info based on Name
db.commit()
message1 = QMessageBox()
message1.setWindowTitle("Successfull")
message1.setInformativeText("You have successfully deleted information of : " + Name)
message1.exec_()
result = db.execute("select * from PatientInfo")
self.tableWidget.setRowCount(0)
# Using two for loops to insert the data after deleting
for RowNum, RowDATA in enumerate(result):
self.tableWidget.insertRow(RowNum)
for ColumnNum, ColumnData in enumerate(RowDATA):
self.tableWidget.setItem(RowNum, ColumnNum, QtWidgets.QTableWidgetItem(str(ColumnData)))
db.close()
# Clearing all the fields
self.ClearFields()
#def to update patient info
def UpdatePatient(self):
SName=self.SfullNameLE.text()
Name = self.FullNameLE.text()
Address = self.AddresLE.text()
Email = self.EmailLE.text()
Phone_no = self.PhoneLE.text()
Date_of_Birth = self.BirthDateLE.text()
Marital_Status = self.MaritalCMB.currentText()
Gender = self.GenderCMB.currentText()
Illness = self.IllnessLE.text()
db= sqlite3.connect("Hospital.db")
db.execute("update PatientInfo set Name=?,Date_of_Birth=?,Address=?,Phone_no=?,Marital_Status=?,Gender=?,Illness=?,Email=? where Name ="+"'"+SName+"'",
(Name,Date_of_Birth,Address,Phone_no,Marital_Status,Gender,Illness,Email))
db.commit()
message = QMessageBox()
message.setWindowTitle("Successfull")
message.setInformativeText("You have successfully Updated: " + Name + ''''s profile''')
message.exec_()
# Select data from the PatientInformation table to appear in tableWidgets after updating the data
result = db.execute("select * from PatientInfo where name=" + "'" + SName + "'")
self.tableWidget.setRowCount(0)
# Using two for loops to insert the data from result query into tableWidget
for RowNum, RowDATA in enumerate(result):
self.tableWidget.insertRow(RowNum)
for ColumnNum, ColumnData in enumerate(RowDATA):
self.tableWidget.setItem(RowNum, ColumnNum, QtWidgets.QTableWidgetItem(str(ColumnData)))
db.close()
# def to clear fields
def ClearFields(self):
self.FullNameLE.clear()
self.BirthDateLE.clear()
self.AddresLE.clear()
self.PhoneLE.clear()
self.MaritalCMB.setCurrentText("")
self.GenderCMB.setCurrentText("")
self.IllnessLE.clear()
self.EmailLE.clear()
# def to view patient info
def ViewPatient(self):
db = sqlite3.connect("Hospital.db")
result= db.execute("Select * from PatientInfo")
self.tableWidget.setRowCount(0)
for RowNum, RowDATA in enumerate(result):
self.tableWidget.insertRow(RowNum)
for ColumnNum, ColumnData in enumerate(RowDATA):
self.tableWidget.setItem(RowNum, ColumnNum, QtWidgets.QTableWidgetItem(str(ColumnData)))
db.close()
print("You want to view")
# Clearing all the fields if there is any information left there after clicking search button
self.ClearFields()
def SearchClicked(self):
# Get the data from the user
SName = self.SfullNameLE.text()
db = sqlite3.connect("Hospital.db")
result = db.execute("select * from PatientInfo where Name=" + "'" + SName + "'")
self.tableWidget.setRowCount(0)
# Using two for loops to insert the data into tableWidgets
for RowNum, RowDATA in enumerate(result):
self.tableWidget.insertRow(RowNum)
for ColumnNum, ColumnData in enumerate(RowDATA):
self.tableWidget.setItem(RowNum, ColumnNum, QtWidgets.QTableWidgetItem(str(ColumnData)))
list = [] # List to append data from ViewName query to use the data for setting lineEdits
########################
ViewName = db.execute("select * from PatientInfo where Name=" + "'" + SName + "'")
for RowNum, RowDATA in enumerate(ViewName):
for ColumnNum, ColumnData in enumerate(RowDATA):
list.append(ColumnData)
self.FullNameLE.setText(list[0])
self.BirthDateLE.setText(list[1])
self.AddresLE.setText(list[2])
self.PhoneLE.setText(str(list[3]))
self.MaritalCMB.setCurrentText(list[4])
self.GenderCMB.setCurrentText(list[5])
self.IllnessLE.setText(list[6])
self.EmailLE.setText(list[7])
db.close()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(734, 616)
MainWindow.setStyleSheet("background-color: rgb(192, 192, 192);")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
self.tableWidget.setGeometry(QtCore.QRect(10, 60, 721, 311))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
self.tableWidget.setFont(font)
self.tableWidget.setStyleSheet("background-color: rgb(238, 240, 244);")
self.tableWidget.setRowCount(0)
self.tableWidget.setColumnCount(8)
self.tableWidget.setObjectName("tableWidget")
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(1, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(2, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(3, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(4, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(5, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(6, item)
item = QtWidgets.QTableWidgetItem()
font = QtGui.QFont()
font.setFamily("Courier")
item.setFont(font)
self.tableWidget.setHorizontalHeaderItem(7, item)
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(10, 10, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label.setFont(font)
self.label.setObjectName("label")
self.SfullNameLE = QtWidgets.QLineEdit(self.centralwidget)
self.SfullNameLE.setGeometry(QtCore.QRect(90, 10, 121, 31))
self.SfullNameLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.SfullNameLE.setObjectName("SfullNameLE")
self.SearchBtn = QtWidgets.QPushButton(self.centralwidget)
self.SearchBtn.setGeometry(QtCore.QRect(240, 10, 91, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.SearchBtn.setFont(font)
self.SearchBtn.setStyleSheet("background-color: rgb(89, 128, 255);")
self.SearchBtn.setObjectName("SearchBtn")
# to activate search button
self.SearchBtn.clicked.connect(self.SearchClicked)
self.DeleteBtn = QtWidgets.QPushButton(self.centralwidget)
self.DeleteBtn.setGeometry(QtCore.QRect(390, 10, 91, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.DeleteBtn.setFont(font)
self.DeleteBtn.setStyleSheet("background-color: rgb(89, 128, 255);")
self.DeleteBtn.setObjectName("DeleteBtn")
# to activate deletebtn
self.DeleteBtn.clicked.connect(self.DeletePat)
self.ViewPatBtn = QtWidgets.QPushButton(self.centralwidget)
self.ViewPatBtn.setGeometry(QtCore.QRect(530, 10, 161, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.ViewPatBtn.setFont(font)
self.ViewPatBtn.setStyleSheet("background-color: rgb(89, 128, 255);")
self.ViewPatBtn.setObjectName("ViewPatBtn")
# to activate view pat btn
self.ViewPatBtn.clicked.connect(self.ViewPatient)
self.UpdateBtn = QtWidgets.QPushButton(self.centralwidget)
self.UpdateBtn.setGeometry(QtCore.QRect(590, 470, 91, 31))
font = QtGui.QFont()
font.setFamily("Courier")
self.UpdateBtn.setFont(font)
self.UpdateBtn.setStyleSheet("background-color: rgb(89, 128, 255);")
### activate update btn
self.UpdateBtn.clicked.connect(self.UpdatePatient)
self.UpdateBtn.setObjectName("UpdateBtn")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(20, 410, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.FullNameLE = QtWidgets.QLineEdit(self.centralwidget)
self.FullNameLE.setGeometry(QtCore.QRect(110, 410, 141, 31))
self.FullNameLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.FullNameLE.setObjectName("FullNameLE")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(20, 450, 81, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.BirthDateLE = QtWidgets.QLineEdit(self.centralwidget)
self.BirthDateLE.setGeometry(QtCore.QRect(110, 450, 141, 31))
self.BirthDateLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.BirthDateLE.setObjectName("BirthDateLE")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(20, 490, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.AddresLE = QtWidgets.QLineEdit(self.centralwidget)
self.AddresLE.setGeometry(QtCore.QRect(110, 490, 141, 31))
self.AddresLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.AddresLE.setObjectName("AddresLE")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(20, 530, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.PhoneLE = QtWidgets.QLineEdit(self.centralwidget)
self.PhoneLE.setGeometry(QtCore.QRect(110, 530, 141, 31))
self.PhoneLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.PhoneLE.setObjectName("PhoneLE")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(280, 410, 111, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.MaritalCMB = QtWidgets.QComboBox(self.centralwidget)
self.MaritalCMB.setGeometry(QtCore.QRect(400, 410, 101, 31))
self.MaritalCMB.setStyleSheet("background-color: rgb(255, 255, 255);")
self.MaritalCMB.setObjectName("MaritalCMB")
self.MaritalCMB.addItem("")
self.MaritalCMB.setItemText(0, "")
self.MaritalCMB.addItem("")
self.MaritalCMB.addItem("")
self.MaritalCMB.addItem("")
self.MaritalCMB.addItem("")
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(300, 450, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.GenderCMB = QtWidgets.QComboBox(self.centralwidget)
self.GenderCMB.setGeometry(QtCore.QRect(400, 450, 101, 31))
self.GenderCMB.setStyleSheet("background-color: rgb(255, 255, 255);")
self.GenderCMB.setObjectName("GenderCMB")
self.GenderCMB.addItem("")
self.GenderCMB.setItemText(0, "")
self.GenderCMB.addItem("")
self.GenderCMB.addItem("")
self.GenderCMB.addItem("")
self.label_8 = QtWidgets.QLabel(self.centralwidget)
self.label_8.setGeometry(QtCore.QRect(300, 490, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.IllnessLE = QtWidgets.QLineEdit(self.centralwidget)
self.IllnessLE.setGeometry(QtCore.QRect(380, 490, 141, 31))
self.IllnessLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.IllnessLE.setObjectName("IllnessLE")
self.label_9 = QtWidgets.QLabel(self.centralwidget)
self.label_9.setGeometry(QtCore.QRect(300, 530, 71, 31))
font = QtGui.QFont()
font.setFamily("Courier")
font.setPointSize(8)
font.setItalic(False)
self.label_9.setFont(font)
self.label_9.setObjectName("label_9")
self.EmailLE = QtWidgets.QLineEdit(self.centralwidget)
self.EmailLE.setGeometry(QtCore.QRect(380, 530, 141, 31))
self.EmailLE.setStyleSheet("background-color: rgb(255, 255, 255);")
self.EmailLE.setObjectName("EmailLE")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Full Name"))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Birth Date"))
item = self.tableWidget.horizontalHeaderItem(2)
item.setText(_translate("MainWindow", "Address"))
item = self.tableWidget.horizontalHeaderItem(3)
item.setText(_translate("MainWindow", "Phone "))
item = self.tableWidget.horizontalHeaderItem(4)
item.setText(_translate("MainWindow", "Marital Status"))
item = self.tableWidget.horizontalHeaderItem(5)
item.setText(_translate("MainWindow", "Gender"))
item = self.tableWidget.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "Illness"))
item = self.tableWidget.horizontalHeaderItem(7)
item.setText(_translate("MainWindow", "Email"))
self.label.setText(_translate("MainWindow", "Full Name:"))
self.SearchBtn.setText(_translate("MainWindow", "Search"))
self.DeleteBtn.setText(_translate("MainWindow", "Delete"))
self.ViewPatBtn.setText(_translate("MainWindow", "View all Patients"))
self.UpdateBtn.setText(_translate("MainWindow", "Update"))
self.label_2.setText(_translate("MainWindow", "Full Name:"))
self.label_3.setText(_translate("MainWindow", "Birth Date"))
self.label_4.setText(_translate("MainWindow", "Address"))
self.label_5.setText(_translate("MainWindow", "Phone"))
self.label_6.setText(_translate("MainWindow", "Marital Status"))
self.MaritalCMB.setItemText(1, _translate("MainWindow", "Single"))
self.MaritalCMB.setItemText(2, _translate("MainWindow", "Married"))
self.MaritalCMB.setItemText(3, _translate("MainWindow", "Divorced"))
self.MaritalCMB.setItemText(4, _translate("MainWindow", "Widowed"))
self.label_7.setText(_translate("MainWindow", "Gender"))
self.GenderCMB.setItemText(1, _translate("MainWindow", "Male"))
self.GenderCMB.setItemText(2, _translate("MainWindow", "Female"))
self.GenderCMB.setItemText(3, _translate("MainWindow", "Other"))
self.label_8.setText(_translate("MainWindow", "Illness"))
self.label_9.setText(_translate("MainWindow", "Email"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = ViewPatientssInfo()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())