-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolUI.py
More file actions
298 lines (218 loc) · 7.39 KB
/
SolUI.py
File metadata and controls
298 lines (218 loc) · 7.39 KB
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
#!/usr/bin/env python
import sys
import os
import re
import string
from PyQt4 import QtCore, QtGui, uic
##Main Window##
class SolBeatMain(QtGui.QMainWindow):
def __init__(self, parent=None):
#variables
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
#self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/main.ui', self)
#self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/optionsmenu.ui', self)
#self.center()
#myPixmap = QtGui.QPixmap('ekgui/uiDev/logo.png')
#self.pic.setPixmap(myPixmap)
#self.ui.pic.setScaledContents(True)
myapp = optionsMenu()
myapp.show()
#connect buttons
#self.ui.exitButton.clicked.connect(self.quit)
#self.ui.optionsButton.clicked.connect(self.optionsOpen)
#center the window on the screen
def center(self):
qr = self.frameGeometry()
cp = QtGui.QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
#open the options menu
def optionsOpen(self):
myapp = optionsMenu()
myapp.show()
#close the window
def quit(self):
self.close()
##Options Menu##
class optionsMenu(SolBeatMain):
def __init__(self, parent=None):
#variables
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/optionsmenu.ui', self)
self.center()
#connect buttons
self.ui.exitButton.clicked.connect(self.back)
self.ui.selectButton.clicked.connect(self.next)
def next(self):
if(self.ui.optionsList.currentRow() == 0):
self.close()
myapp = newOrExisting()
myapp.show()
def back(self):
self.close()
myapp = SolBeatMain()
myapp.setFocus()
##Patient Prompt##
class newOrExisting(SolBeatMain):
def __init__(self, parent=None):
#variables
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/neworexist.ui', self)
self.center()
#connect buttons
self.ui.exitButton.clicked.connect(self.back)
self.ui.selectButton.clicked.connect(self.next)
def next(self):
if(self.ui.listWidget.currentRow() == 0):
self.close()
myapp = newUser()
myapp.show()
if(self.ui.listWidget.currentRow() == 1):
self.close()
myapp = browseusers()
myapp.show()
def back(self):
self.close()
myapp = optionsMenu()
myapp.show()
##Create a New User##
class newUser(SolBeatMain):
def __init__(self, parent=None):
#variables
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/newuser.ui', self)
self.patientName.setPlaceholderText("First Last")
#self.patientNotes.setPlaceholderText("Enter patient notes here.")
self.center()
#connect buttons
self.ui.exitButton.clicked.connect(self.back)
self.ui.selectButton.clicked.connect(self.next)
def next(self):
#make a patient info directory if there isn't one already
newpath = os.path.dirname(os.path.abspath(__file__)) + '/patientInfo'
if not os.path.exists(newpath):
os.makedirs(newpath)
#create a new folder for the user
foldername = re.sub('[\W_]+', '', str(self.ui.patientName.text()))
newpath = os.path.dirname(os.path.abspath(__file__)) + '/patientInfo/' + foldername
if not os.path.exists(newpath):
os.makedirs(newpath)
#create a patient info file for the entered patient
filename = foldername
fd = os.open(newpath + '/' + filename + '.txt', os.O_RDWR|os.O_CREAT|os.O_EXCL)
with open('patientInfo/patientlist.txt', 'a') as file:
file.write(str(self.ui.patientName.text()) + '\n')
file.close
#write info to the file
ret = os.write(fd, "Patient Name: " + str(self.ui.patientName.text()) + '\n\n' + "---Patient Notes---" + '\n' + str(self.ui.patientNotes.toPlainText()))
#close the file
os.close(fd)
#close the window
self.close()
myapp = genericMessage(str(self.ui.patientName.text()) + " has been added successfully!")
myapp.show()
else:
myapp = genericMessage("No patient entered or patient already exists in database!")
myapp.show()
def back(self):
self.close()
myapp = newOrExisting()
myapp.show()
##Show a List of Existing Users##
class browseusers(SolBeatMain):
def __init__(self, parent=None):
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/browseusers.ui', self)
self.center()
#open patientlist file and read from it#
newpath = os.path.dirname(os.path.abspath(__file__)) + '/patientInfo'
if not os.path.exists(newpath):
os.makedirs(newpath)
try:
with open('patientInfo/patientlist.txt', 'a+') as f:
for line in f:
line = line.replace('\n', '')
name = self.lastFirst(line)
self.ui.userList.addItem(name)
self.ui.userList.sortItems()
except AttributeError:
myapp = genericMessage('There are currently no users in the system.')
myapp.show()
#myapp = genericMessage('There are currently no users in the system.')
#myapp.show()
self.ui.selectButton.clicked.connect(self.next)
self.ui.exitButton.clicked.connect(self.back)
#print(line)
#connect buttons
#self.ui.selectButton.clicked.connect(self.next)
def next(self):
self.close()
myapp = viewPatientInfo(self.ui.userList.currentItem().text())
myapp.show()
def back(self):
self.close()
myapp = newOrExisting()
myapp.show()
def lastFirst(self, name):
name = ', '.join(reversed(name.split(' ')))
#print(name)
return name
##View Selected Patient Information##
class viewPatientInfo(SolBeatMain):
def __init__(self, name, parent=None):
#variables
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/viewpatientinfo.ui', self)
#display patient name
self.ui.patientName.setText(self.firstLast(name))
#view patient information
#read info from the file
foldername = re.sub('[\W_]+', '', str(self.firstLast(name)))
newpath = os.path.dirname(os.path.abspath(__file__)) + '/patientInfo'
fd = os.open(newpath + '/' + foldername + '/' + foldername + '.txt', os.O_RDWR)
line = os.read(fd, 10000)
print line
file.close
#close the file
os.close(fd)
#window stuff
self.center()
#connect buttons
self.ui.selectButton.clicked.connect(self.next)
self.ui.exitButton.clicked.connect(self.back)
def next(self):
self.close()
def back(self):
self.close()
myapp = browseusers()
myapp.show()
def firstLast(self, name):
name = ' '.join(reversed(str(name).split(',')))
#print(name)
return name
##Message Popup Template##
class genericMessage(SolBeatMain):
def __init__(self, message, parent=None):
#variables
#initialize and load main UI
QtGui.QWidget.__init__(self, parent)
self.ui = uic.loadUi(os.path.dirname(os.path.abspath(__file__)) + '/ekgui/uiDev/genericmessage.ui', self)
#print out the message
self.ui.messageBox.setText(message)
self.center()
#connect buttons
self.ui.selectButton.clicked.connect(self.next)
def next(self):
self.close()
###############################################################
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = SolBeatMain()
myapp.show()
sys.exit(app.exec_())