Skip to content

Commit 49346f7

Browse files
author
Agnibho Mondal
committed
First commit
1 parent 1071367 commit 49346f7

24 files changed

+1897
-2
lines changed

LICENSE.txt

+674
Large diffs are not rendered by default.

README.md

-2
This file was deleted.

README.txt

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
DDStorm
2+
=======
3+
4+
What is DDStorm?
5+
-------------------
6+
7+
DDStorm is a python application for brainstorming medical differential
8+
diagnosis.
9+
10+
DDStorm is still in development phase and not ready for deployment.
11+
12+
Licensing
13+
---------
14+
15+
Copyright (c) 2015 Agnibho Mondal
16+
All rights reserved
17+
18+
This file is part of DDStorm.
19+
20+
DDStorm is free software: you can redistribute it and/or modify
21+
it under the terms of the GNU General Public License as published by
22+
the Free Software Foundation, either version 3 of the License, or
23+
(at your option) any later version.
24+
25+
DDStorm is distributed in the hope that it will be useful,
26+
but WITHOUT ANY WARRANTY; without even the implied warranty of
27+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+
GNU General Public License for more details.
29+
30+
You should have received a copy of the GNU General Public License
31+
along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
32+
33+
Contacts
34+
--------
35+
36+
Agnibho Mondal
37+
38+
www.agnibho.com

__main__.py

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#! /usr/bin/python3
2+
3+
# DDStorm
4+
# -------
5+
# Copyright (c) 2015 Agnibho Mondal
6+
# All rights reserved
7+
8+
# This file is part of DDStorm.
9+
10+
# DDStorm is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License as published by
12+
# the Free Software Foundation, either version 3 of the License, or
13+
# (at your option) any later version.
14+
15+
# DDStorm is distributed in the hope that it will be useful,
16+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
# GNU General Public License for more details.
19+
20+
# You should have received a copy of the GNU General Public License
21+
# along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
22+
23+
import sys, time, subprocess
24+
from PyQt4 import QtGui, QtCore
25+
from _symptoms import Symptoms
26+
from _differentials import Differentials
27+
from ddstorm import DDStorm
28+
from conf import Conf
29+
from _extras import *
30+
from const import *
31+
32+
conf=False
33+
34+
class Content(QtGui.QWidget):
35+
change=QtCore.pyqtSignal()
36+
def __init__(self):
37+
super(Content, self).__init__()
38+
self.dd=DDStorm(True,conf)
39+
if(not self.dd.compiler.clean):
40+
ret=QtGui.QMessageBox.warning(self, "Compilation Error", "Error was encountered while compiling the Knowledgebase.", "Ignore", "View Log")
41+
if(ret==1):
42+
x_logfile()
43+
self.initUI()
44+
def initUI(self):
45+
global conf
46+
47+
grid=QtGui.QGridLayout()
48+
self.setLayout(grid)
49+
50+
self.symp=Symptoms(self.dd.symptoms())
51+
self.symp.setFrameShape(QtGui.QFrame.StyledPanel)
52+
self.symp.changed.connect(self.update)
53+
54+
self.diff=Differentials()
55+
self.diff.setFrameShape(QtGui.QFrame.StyledPanel)
56+
57+
grid.addWidget(self.symp, 0, 0)
58+
grid.addWidget(self.diff, 0, 1)
59+
grid.setColumnStretch(0, 1)
60+
grid.setColumnStretch(1, 1)
61+
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Cleanlooks"))
62+
def update(self, data):
63+
self.diff.update(self.dd.dd(data))
64+
self.change.emit()
65+
66+
class Window(QtGui.QMainWindow):
67+
def __init__(self):
68+
super(Window, self).__init__()
69+
self.initUI()
70+
def initUI(self):
71+
global conf
72+
self.con=Content()
73+
self.sett=SettingsDialog(conf)
74+
if(conf.get("status_message")=="on"):
75+
self.con.change.connect(self.showStatus)
76+
77+
menu=self.menuBar()
78+
menuFile=menu.addMenu("&File")
79+
menuFile.addAction("&Save").triggered.connect(self.savefile)
80+
menuFile.addAction("E&xit").triggered.connect(self.close)
81+
menuEdit=menu.addMenu("&Edit")
82+
menuEdit.addAction("&Add").triggered.connect(self.con.symp.addItem)
83+
menuEdit.addAction("&Browse Symptoms").triggered.connect(self.con.symp.browseSymptoms)
84+
rmAction=QtGui.QAction("&Remove", self)
85+
rmAction.setShortcut("Delete")
86+
rmAction.triggered.connect(self.con.symp.remove)
87+
menuEdit.addAction(rmAction)
88+
menuEdit.addAction("&Clear All").triggered.connect(self.con.symp.removeAll)
89+
menuTool=menu.addMenu("&Tools")
90+
menuTool.addAction("&Library").triggered.connect(x_lib)
91+
menuTool.addAction("&Settings").triggered.connect(self.settings)
92+
menuTool.addAction("&View Log").triggered.connect(x_logfile)
93+
menuHelp=menu.addMenu("&Help")
94+
menuHelp.addAction("&Help").triggered.connect(x_help)
95+
menuHelp.addAction("&About").triggered.connect(self.about)
96+
97+
self.setCentralWidget(self.con)
98+
self.status=self.statusBar()
99+
self.setGeometry(200, 200, 600, 400)
100+
self.setWindowTitle("D/D Storm")
101+
self.setWindowIcon(QtGui.QIcon("icons/icon.png"))
102+
self.showMaximized()
103+
self.con.symp.new.setFocus()
104+
def showStatus(self):
105+
if(self.con.symp.getList() and self.con.diff.getList()):
106+
self.status.showMessage(str(len(self.con.diff.getList()))+" differential diagnosis for "+str(len(self.con.symp.getList()))+" symptom(s).")
107+
else:
108+
self.status.showMessage("")
109+
def savefile(self):
110+
x_save(self, self.con.symp.getList(), self.con.diff.getList())
111+
def settings(self):
112+
self.sett.exec_()
113+
def about(self):
114+
QtGui.QMessageBox.about(self, "About", "<h1>DDStorm</h1>\nBrainstorm Medicine")
115+
116+
def main():
117+
app=QtGui.QApplication(sys.argv)
118+
119+
global conf
120+
conf=Conf()
121+
if(conf.get("clean_log")=="yes"):
122+
open(LOG_FILE, "w").close()
123+
if(conf.get("splash_screen")=="yes"):
124+
ss=True
125+
else:
126+
ss=False
127+
if(ss):
128+
splash=QtGui.QSplashScreen(QtGui.QPixmap("icons/splash.png"))
129+
splash.show()
130+
time.sleep(0.1)
131+
app.processEvents()
132+
splash.showMessage("Loading...")
133+
134+
w=Window()
135+
if(ss):
136+
splash.finish(w)
137+
138+
sys.exit(app.exec_())
139+
140+
if(__name__=="__main__"):
141+
main()

_differentials.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# DDStorm
2+
# -------
3+
# Copyright (c) 2015 Agnibho Mondal
4+
# All rights reserved
5+
6+
# This file is part of DDStorm.
7+
8+
# DDStorm is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 3 of the License, or
11+
# (at your option) any later version.
12+
13+
# DDStorm is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
18+
# You should have received a copy of the GNU General Public License
19+
# along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
20+
21+
from PyQt4 import QtGui
22+
23+
class Differentials(QtGui.QFrame):
24+
data=[]
25+
def __init__(self):
26+
super(Differentials, self).__init__()
27+
self.initUI()
28+
def initUI(self):
29+
self.label=QtGui.QLabel("Differential Diagnosis")
30+
self.label.setStyleSheet("font-size:18px")
31+
self.listWidget=QtGui.QListWidget(self)
32+
self.listWidget.setStyleSheet("font-size:14px")
33+
self.listWidget.setSelectionMode(0)
34+
box=QtGui.QVBoxLayout()
35+
box.addWidget(self.label)
36+
box.addWidget(self.listWidget)
37+
self.setLayout(box)
38+
39+
def update(self, data):
40+
self.data=data
41+
self.listWidget.clear()
42+
if(self.data):
43+
for d in self.data:
44+
QtGui.QListWidgetItem(d, self.listWidget)
45+
46+
def getList(self):
47+
return self.data

_extras.py

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# DDStorm
2+
# -------
3+
# Copyright (c) 2015 Agnibho Mondal
4+
# All rights reserved
5+
6+
# This file is part of DDStorm.
7+
8+
# DDStorm is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 3 of the License, or
11+
# (at your option) any later version.
12+
13+
# DDStorm is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
18+
# You should have received a copy of the GNU General Public License
19+
# along with DDStorm. If not, see <http://www.gnu.org/licenses/>.
20+
21+
import subprocess, os
22+
from PyQt4 import QtGui, QtCore
23+
from const import *
24+
25+
def x_settings():
26+
subprocess.Popen(["xdg-open", CONF_FILE])
27+
28+
def x_lib():
29+
if(os.path.isfile(CONF_FILE)):
30+
with open(CONF_FILE) as conf:
31+
for line in conf:
32+
if(line.startswith("library_path=")):
33+
library_path=line[13:-1]
34+
if(os.path.isdir(library_path)):
35+
subprocess.Popen(["xdg-open", library_path])
36+
37+
def x_save(w, symp, diff):
38+
fname=QtGui.QFileDialog.getSaveFileName(w, "Save File", "~", "HTML files('*.html')")
39+
if(not fname.endswith(".html")):
40+
fname=fname+".html"
41+
with open(fname, "w") as f:
42+
print("<!DOCTYPE html><html><head><title>Differential Diagnosis</title></head>", file=f)
43+
print("<body><h1>Differential Diagnosis</h1>", file=f)
44+
print("<table style='width:100%'>", file=f)
45+
print("<tr><th>Symptoms</th><th>Diffrential Diagnosis</th></tr>", file=f)
46+
print("<tr><td style='vertical-align:text-top'><ol>", file=f)
47+
for s in symp:
48+
print("<li>"+s+"</li>", file=f)
49+
print("</ol></td><td style='vertical-align:text-top'><ol>", file=f)
50+
for d in diff:
51+
print("<li>"+d+"</li>", file=f)
52+
print("</ol></td></tr></table></body></html>", file=f)
53+
54+
def x_help():
55+
if(os.path.isfile(HELP_FILE)):
56+
subprocess.Popen(["xdg-open", HELP_FILE])
57+
else:
58+
subprocess.Popen(["xdg-open", "http://www.agnibho.com"])
59+
60+
def x_logfile():
61+
subprocess.Popen(["xdg-open", LOG_FILE])
62+
63+
class SettingsDialog(QtGui.QDialog):
64+
def __init__(self, conf):
65+
super(SettingsDialog, self).__init__()
66+
self.setWindowTitle("Settings")
67+
self.conf=conf
68+
self.initUI()
69+
def initUI(self):
70+
self.lpLabel=QtGui.QLabel("Libary Path:")
71+
self.lpEdit=QtGui.QLineEdit(self.conf.get("library_path"))
72+
self.lpBrowse=QtGui.QPushButton("Browse")
73+
self.lpBrowse.clicked.connect(self.lpUpdate)
74+
self.mpLabel=QtGui.QLabel("Module Path:")
75+
self.mpEdit=QtGui.QLineEdit(self.conf.get("module_path"))
76+
self.mpBrowse=QtGui.QPushButton("Browse")
77+
self.mpBrowse.clicked.connect(self.mpUpdate)
78+
self.splash=QtGui.QCheckBox("Show Splash Screen")
79+
if(self.conf.get("splash_screen")=="yes"):
80+
self.splash.setChecked(True)
81+
self.clean=QtGui.QCheckBox("Clean Log on Exit")
82+
if(self.conf.get("clean_log")=="yes"):
83+
self.clean.setChecked(True)
84+
self.status=QtGui.QCheckBox("Show Status Message")
85+
if(self.conf.get("status_message")=="on"):
86+
self.status.setChecked(True)
87+
self.ok=QtGui.QPushButton("Ok")
88+
self.ok.clicked.connect(self.save)
89+
self.cancel=QtGui.QPushButton("Cancel")
90+
self.cancel.clicked.connect(self.close)
91+
self.default=QtGui.QPushButton("Default")
92+
self.default.clicked.connect(self.reset)
93+
94+
ctrl=QtGui.QHBoxLayout()
95+
ctrl.addWidget(self.ok)
96+
ctrl.addWidget(self.cancel)
97+
ctrl.addWidget(self.default)
98+
layout=QtGui.QGridLayout(self)
99+
layout.addWidget(self.lpLabel, 0, 0)
100+
layout.addWidget(self.lpEdit, 0, 1)
101+
layout.addWidget(self.lpBrowse, 0, 2)
102+
layout.addWidget(self.mpLabel, 1, 0)
103+
layout.addWidget(self.mpEdit, 1, 1)
104+
layout.addWidget(self.mpBrowse, 1, 2)
105+
layout.addWidget(self.splash, 2, 0)
106+
layout.addWidget(self.clean, 3, 0)
107+
layout.addWidget(self.status, 4, 0)
108+
layout.addLayout(ctrl, 5, 1)
109+
110+
self.cancel.setFocus()
111+
112+
def lpUpdate(self):
113+
self.lpEdit.setText(self.getFolder())
114+
def cpUpdate(self):
115+
self.cpEdit.setText(self.getFolder())
116+
def mpUpdate(self):
117+
self.mpEdit.setText(self.getFolder())
118+
119+
def getFolder(self):
120+
dn=QtGui.QFileDialog.getExistingDirectory()
121+
if(dn.startswith(QtCore.QDir.currentPath())):
122+
dn="."+dn[len(QtCore.QDir.currentPath()):]+"/"
123+
else:
124+
dn=dn+"/"
125+
return dn
126+
127+
def save(self):
128+
self.conf.set("library_path", self.lpEdit.text())
129+
self.conf.set("class_path", self.cpEdit.text())
130+
self.conf.set("module_path", self.mpEdit.text())
131+
if(self.splash.isChecked()):
132+
self.conf.set("splash_screen", "yes")
133+
else:
134+
self.conf.set("splash_screen", "no")
135+
if(self.clean.isChecked()):
136+
self.conf.set("clean_log", "yes")
137+
else:
138+
self.conf.set("clean_log", "no")
139+
if(self.status.isChecked()):
140+
self.conf.set("status_message", "on")
141+
else:
142+
self.conf.set("status_message", "off")
143+
QtGui.QMessageBox.information(self, "Restart required", "Some settings takes effect only after restarting DDStorm")
144+
self.close()
145+
self.conf.write()
146+
147+
def reset(self):
148+
self.conf.default()
149+
self.lpEdit.setText(self.conf.get("library_path"))
150+
self.cpEdit.setText(self.conf.get("class_path"))
151+
self.mpEdit.setText(self.conf.get("module_path"))
152+
if(self.conf.get("splash_screen")=="yes"):
153+
self.splash.setChecked(True)
154+
else:
155+
self.splash.setChecked(False)
156+
if(self.conf.get("clean_log")=="yes"):
157+
self.clean.setChecked(True)
158+
else:
159+
self.clean.setChecked(False)
160+
if(self.conf.get("status_message")=="on"):
161+
self.status.setChecked(True)
162+
else:
163+
self.status.setChecked(False)

0 commit comments

Comments
 (0)