-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTebNo.py
301 lines (264 loc) · 13.9 KB
/
TebNo.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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'TebNo.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# 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, Qt
from PyQt5.QtWidgets import QTableWidgetItem, QMessageBox
from PatientModel import PatientModel
from AllVisits import AllVisitsModel
from pathlib import Path
import os
from unidecode import unidecode
import resources
from database import Patient, Visit, PatientOperations, VisitOperations
from PatientScreenApp import PatientWindow
from TimerBox import TimerMessageBox
from Charts import VisitsChart, PatientsChart, VisitPriority
from OSHandling import OSHandling
class Ui_TebNoContainer(object):
def setupUi(self, TebNoContainer):
QtGui.QFontDatabase.addApplicationFont(':/fonts/Vazirmatn-Bold.ttf')
TebNoContainer.setObjectName("TebNoContainer")
TebNoContainer.resize(700, 680)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(TebNoContainer.sizePolicy().hasHeightForWidth())
TebNoContainer.setSizePolicy(sizePolicy)
TebNoContainer.setMinimumSize(QtCore.QSize(700, 680))
TebNoContainer.setMaximumSize(QtCore.QSize(700, 680))
TebNoContainer.setGeometry(QtCore.QRect(200, 30, 0, 0))
#Style Path
with open(OSHandling.styleHandling(), 'r') as f:
TebNoContainer.setStyleSheet(f.read())
self.maintab = QtWidgets.QTabWidget(TebNoContainer)
self.maintab.setGeometry(QtCore.QRect(40, 0, 650, 650))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.maintab.sizePolicy().hasHeightForWidth())
self.maintab.setSizePolicy(sizePolicy)
self.maintab.setMinimumSize(QtCore.QSize(650, 650))
self.maintab.setMaximumSize(QtCore.QSize(650, 650))
self.maintab.setLayoutDirection(QtCore.Qt.RightToLeft)
self.maintab.setIconSize(QtCore.QSize(32, 32))
self.maintab.setObjectName("maintab")
self.newPatient = QtWidgets.QWidget()
self.newPatient.setObjectName("newPatient")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.newPatient)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.name = QtWidgets.QLabel(self.newPatient)
self.name.setObjectName("name")
self.verticalLayout_2.addWidget(self.name)
self.fname = QtWidgets.QLineEdit(self.newPatient)
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
self.fname.setFont(font)
self.fname.setLocale(QtCore.QLocale(QtCore.QLocale.Persian, QtCore.QLocale.Iran))
self.fname.setEchoMode(QtWidgets.QLineEdit.Normal)
self.fname.setObjectName("fname")
self.verticalLayout_2.addWidget(self.fname)
self.lastname = QtWidgets.QLabel(self.newPatient)
self.lastname.setObjectName("lastname")
self.verticalLayout_2.addWidget(self.lastname)
self.lname = QtWidgets.QLineEdit(self.newPatient)
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
self.lname.setFont(font)
self.lname.setLocale(QtCore.QLocale(QtCore.QLocale.Persian, QtCore.QLocale.Iran))
self.lname.setObjectName("lname")
self.verticalLayout_2.addWidget(self.lname)
self.birth = QtWidgets.QLabel(self.newPatient)
self.birth.setObjectName("birth")
self.verticalLayout_2.addWidget(self.birth)
self.birthDate = QtWidgets.QLineEdit(self.newPatient)
self.birthDate.setEchoMode(QtWidgets.QLineEdit.Normal)
self.birthDate.setCursorPosition(10)
self.birthDate.setObjectName("birthDate")
self.verticalLayout_2.addWidget(self.birthDate)
self.nCode = QtWidgets.QLabel(self.newPatient)
self.nCode.setObjectName("nCode")
self.verticalLayout_2.addWidget(self.nCode)
self.nationalCode = QtWidgets.QLineEdit(self.newPatient)
self.nationalCode.setText("")
self.nationalCode.setEchoMode(QtWidgets.QLineEdit.Normal)
# self.nationalCode.setCursorPosition(0)
# self.nationalCode.installEventFilter(self)
self.nationalCode.setObjectName("nationalCode")
self.verticalLayout_2.addWidget(self.nationalCode)
self.phone = QtWidgets.QLabel(self.newPatient)
self.phone.setObjectName("phone")
self.verticalLayout_2.addWidget(self.phone)
self.phoneNumber = QtWidgets.QLineEdit(self.newPatient)
self.phoneNumber.setEchoMode(QtWidgets.QLineEdit.Normal)
# self.phoneNumber.setCursorPosition(0)
# self.phoneNumber.installEventFilter(self)
self.phoneNumber.setObjectName("phoneNumber")
self.verticalLayout_2.addWidget(self.phoneNumber)
self.submitBtn = QtWidgets.QPushButton(self.newPatient)
self.submitBtn.setObjectName("submitBtn")
self.verticalLayout_2.addWidget(self.submitBtn)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/images/person.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.maintab.addTab(self.newPatient, icon, "")
self.viewPatients = QtWidgets.QWidget()
self.verticalLayoutWidget = QtWidgets.QWidget(self.viewPatients)
self.verticalLayoutWidget.setGeometry(QtCore.QRect(60, 20, 511, 441))
self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
self.patientListsLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
self.patientListsLayout.setContentsMargins(0, 0, 0, 0)
self.patientListsLayout.setObjectName("patientListsLayout")
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
self.patientsList = QtWidgets.QTableView()
self.patientsList.setFont(font)
self.patient_model = PatientModel(self, ['نام','نام خانوادگی', 'کد ملی', 'شماره همراه'])
self.patientsList.setModel(self.patient_model)
self.patientsList.doubleClicked.connect(self.patientsShow)
self.patientListsLayout.addWidget(self.patientsList)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/images/patients.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.maintab.addTab(self.viewPatients, icon1, "")
# visits list here
self.viewVisits = QtWidgets.QWidget()
self.verticalLayoutWidget_3 = QtWidgets.QWidget(self.viewVisits)
self.verticalLayoutWidget_3.setGeometry(QtCore.QRect(60, 20, 511, 441))
self.verticalLayoutWidget_3.setObjectName("verticalLayoutWidget_3")
self.visitListsLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_3)
self.visitListsLayout.setContentsMargins(0, 0, 0, 0)
self.visitListsLayout.setObjectName("visitListsLayout")
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
self.visitsList = QtWidgets.QTableView()
self.visitsList.setFont(font)
self.visit_model = AllVisitsModel(self, ['نام خانوادگی', 'کد ملی','تاریخ', 'ساعت', 'وضعیت'])
self.visitsList.setModel(self.visit_model)
self.visitListsLayout.addWidget(self.visitsList)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/images/visits.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.maintab.addTab(self.viewVisits, icon1, "")
#statistics plots
self.viewPlots = QtWidgets.QWidget()
self.plotsLayout = QtWidgets.QVBoxLayout(self.viewPlots)
self.visitPlot = QtWidgets.QPushButton(self.viewPlots)
self.visitPlot.setObjectName("visitPlot")
self.plotsLayout.addWidget(self.visitPlot)
self.patientPlot = QtWidgets.QPushButton(self.viewPlots)
self.patientPlot.setObjectName("patientPlot")
self.plotsLayout.addWidget(self.patientPlot)
self.visitChartPlot = QtWidgets.QPushButton(self.viewPlots)
self.visitChartPlot.setObjectName("visitChartPlot")
self.plotsLayout.addWidget(self.visitChartPlot)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/images/statistics.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.maintab.addTab(self.viewPlots, icon1, "")
self.visitPlot.clicked.connect(self.visit_statistics)
self.patientPlot.clicked.connect(self.patient_statistics)
self.visitChartPlot.clicked.connect(self.visits_charts)
self.submitBtn.clicked.connect(self.save_patient)
self.retranslateUi(TebNoContainer)
self.maintab.setCurrentIndex(0)
#Patients Information Screen
# self.patientScreen = PatientWindow(self.visitsList)
# self.patientScreen.closed.connect(self.show)
QtCore.QMetaObject.connectSlotsByName(TebNoContainer)
def retranslateUi(self, TebNoContainer):
_translate = QtCore.QCoreApplication.translate
TebNoContainer.setWindowTitle(_translate("TebNoContainer", "Form"))
self.name.setText(_translate("TebNoContainer", "نام:"))
self.lastname.setText(_translate("TebNoContainer", "نام خانودگی:"))
self.birth.setText(_translate("TebNoContainer", "سال تولد:"))
self.birthDate.setInputMask(_translate("TebNoContainer", "1999/99/99"))
self.birthDate.setText(_translate("TebNoContainer", "1//"))
self.nCode.setText(_translate("TebNoContainer", "کد ملی:"))
self.nationalCode.setInputMask(_translate("TebNoContainer", "9999999999"))
self.phone.setText(_translate("TebNoContainer", "شماره همراه:"))
self.phoneNumber.setInputMask(_translate("TebNoContainer", "99999999999"))
self.submitBtn.setText(_translate("TebNoContainer", "ذخیره اطلاعات"))
self.visitPlot.setText(_translate("TebNoContainer", "آمار نوبتها"))
self.patientPlot.setText(_translate("TebNoContainer", "آمار بیماران"))
self.visitChartPlot.setText(_translate("TebNoContainer", "نمودار نوبتها"))
self.maintab.setTabText(self.maintab.indexOf(self.newPatient), _translate("TebNoContainer", "بیمار جدید"))
self.maintab.setTabText(self.maintab.indexOf(self.viewPatients), _translate("TebNoContainer", "مشاهده بیماران"))
self.maintab.setTabText(self.maintab.indexOf(self.viewVisits), _translate("TebNoContainer", "نوبتها"))
self.maintab.setTabText(self.maintab.indexOf(self.viewPlots), _translate("TebNoContainer", "آمارها"))
def save_patient(self):
args = {
'name': self.fname.text(),
'lastname': self.lname.text(),
'birth_date': unidecode(self.birthDate.text()),
'phoneNumber': unidecode(self.phoneNumber.text()),
'nationalCode': unidecode(self.nationalCode.text())
}
message = PatientOperations.addPatient(**args)
if message == "بیمار با مشخصات مورد نظر ثبت شد.":
self.clear_save_patient_inputs()
patient_model = PatientModel(self, ['نام','نام خانوادگی', 'کد ملی', 'شماره همراه'])
self.patientsList.setModel(patient_model)
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
messagebox = TimerMessageBox(4, message, font)
messagebox.exec_()
def clear_save_patient_inputs(self):
self.fname.setText('')
self.lname.setText('')
self.birthDate.setText('')
self.phoneNumber.setText('')
self.nationalCode.setText('')
def patientsShow(self):
nationalCode = ""
indexes = self.patientsList.selectionModel().selectedIndexes()
for index in indexes:
nationalCode = index.child(index.row(), 2).data()
self.patientScreen = PatientWindow(self.visitsList, nationalCode, self.patientsList)
self.patientScreen.setScreen()
self.patientScreen.closed.connect(self.show)
self.hide()
self.patientScreen.show()
def visit_statistics(self):
visits = VisitOperations.show_visits_monthly_2()
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
if (visits is not None):
self.visitsChart = VisitsChart(visits)
self.visitsChart.closed.connect(self.show)
self.hide()
self.visitsChart.show()
else:
messagebox = TimerMessageBox(4, "نوبتی وجود ندارد.", font)
messagebox.exec_()
def patient_statistics(self):
ages = PatientOperations().show_patients_ages()
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
if (ages is not None):
self.patientsChart = PatientsChart(ages)
self.patientsChart.closed.connect(self.show)
self.hide()
self.patientsChart.show()
else:
messagebox = TimerMessageBox(4, "بیماری وجود ندارد.", font)
messagebox.exec_()
def visits_charts(self):
results = VisitOperations.show_visits_chart()
font = QtGui.QFont()
font.setFamily("Vazirmatn")
font.setPointSize(10)
if(results is not None):
self.visitPriority = VisitPriority(results)
self.visitPriority.closed.connect(self.show)
self.hide()
self.visitPriority.show()
else:
messagebox = TimerMessageBox(4, "نوبتی در بازه زمانی مورد نظر وجود ندارد.", font)
messagebox.exec_()