-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.py
77 lines (62 loc) · 2.86 KB
/
Controller.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
import sys
from PyQt5.QtWidgets import (QWidget, QGridLayout,QPushButton, QApplication)
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import DiseaseFinder
import DiseaseSelector
import DevCtrl
import pymysql
class Controller:
def __init__(self, symptomlist):
self.symptomlist = symptomlist
DiseaseList, self.tempDiseaseFinder = self.findDisease(symptomlist)
app = QApplication(sys.argv)
self.windowExample = DevCtrl.Viewer(symptomlist, DiseaseList, self)
self.windowExample.show()
sys.exit(app.exec_())
def findDisease(self, symptomlist):
DiseaseList = []
val = DiseaseFinder.DiseaseFinder(symptomlist).checkDisease()
self.back = False # back이 1이면 backbutton이 활성화되었다고 생각하고 그 전 단계로 돌아간다.
if val != None:
# create diseaseList
DiseaseList = [] # 병명, site 주소가 저장되어 있다.
# destory symptom's list
del(symptomlist)
for key in val: # 이름만 따로 저장해서 activate("viewer, DiseaseList")
DiseaseList.append(key)
tempDiseaseFinder = val
print(DiseaseList)
return DiseaseList, tempDiseaseFinder
else:
# activate backbutton + prompt
print("decrease symptoms")
# enter symptoms()
def selectDisease(self, selectedDisease):
#selectedDisease = '라이 증후군(Reye syndrome)'
url = ""
for diseaseName in self.tempDiseaseFinder:
if(selectedDisease == diseaseName):
url = self.tempDiseaseFinder[diseaseName]
tempDiseaseInfo = DiseaseSelector.DiseaseSelector(url).makeSelectedDiseaseInfo() # 선택된 증상, 관련질환, 진료과 등등이 저장
###activate("viewer", selectedDiseaseInfo)
self.windowExample2 = DevCtrl.Viewer2(selectedDisease, tempDiseaseInfo, self)
self.windowExample2.show()
selectedDiseaseInfo = {} # 병명, 진료과 저장
selectedDiseaseInfo['병명'] = selectedDisease
for diseaseinfo in tempDiseaseInfo:
if diseaseinfo == "진료과": # 병명과 진료과만 따로 저장(이후에 UC-5, 6에서 이용하기 위해)
selectedDiseaseInfo[diseaseinfo] = tempDiseaseInfo[diseaseinfo]
f = open("selectedDiseaseInfo.txt", "w")
keys = list(selectedDiseaseInfo.keys())
for k in keys:
f.write(str(k)+": "+selectedDiseaseInfo[k]+"\n")
f.close()
#print(diseaseinfo)
print(tempDiseaseInfo)
#print(tempDiseaseInfo.keys())
return selectedDiseaseInfo
DiseaseList = []
symptomlist = ['머리', '건망증']
controller = Controller(symptomlist)