-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdgui.py
More file actions
134 lines (124 loc) · 4.18 KB
/
Copy pathcmdgui.py
File metadata and controls
134 lines (124 loc) · 4.18 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
from models.nlp import Model
from messaging.ClinicalTrialMessaging import send_message
from oracle import runner, show_messages
from sys import exit
def addTrial():
print("Enter the new trial title to add: ")
title = input()
print("Enter the trial description: ")
desc = input()
print("Enter your address as a contact point: ")
address = input()
my_model.add_trial(title, description=desc, address=address)
print("Trial stored")
researchOutput()
def send():
print("Enter private key: ")
researcherKey = input()
print("Enter patient address: ")
receiverAddress = input()
print("Enter message: ")
data = input()
send_message(message=data, sender_pub=researcherAddress, sender_priv=researcherKey, receiver=receiverAddress)
researchOutput()
def researchOutput():
print("Would you like to [a]dd a trial, [s]end message, [c]heck your messages, or [e]xit?")
line = input()
if line == 'a' or line == 'A':
addTrial()
elif line == 's' or line == "S":
send()
elif line == 'c' or line == "C":
checkMessages(researcherAddress, 'r')
elif line == 'e' or line == 'E':
exit()
def search():
print("Please enter any search terms: ")
line = input()
# load model and pass input into model
# model returns list of relevant trials
trials = my_model.search(line)
print("Here are a list of current trials in that area:")
index = 1
for i in trials:
print(index, i)
index += 1
print("Which trial would you like to access? (number)")
line = int(input())
print("Accessing", trials[line - 1])
print("Would you like to [c]ontact the researcher or [s]end data?")
line = input()
if (line == 'c' or line == 'C'):
# run the oracle to send messages
print("Enter private key: ")
patientKey = input()
print("Enter receiver address: ")
receiverAddress = input()
print("Enter message: ")
message = input()
send_message(message=message, sender_pub=patientAddress, sender_priv=patientKey, receiver=receiverAddress)
elif(line == 's' or line == 'S'):
# execute atomic contract
print("Enter private key: ")
patientKey = input()
print("Enter receiver address: ")
receiverAddress = input()
print("Enter data: ")
data = input()
message = f"DATA:{data}"
send_message(message=message, sender_pub=patientAddress, sender_priv=patientKey, receiver=receiverAddress)
runner(receiverAddress)
patientOutput()
def checkMessages(address, _id):
lst = show_messages(address)
if len(lst) == 0:
print("You have no messages")
else:
print("Here are your most recent messages:")
for s in lst:
print(s[0], 'sent by', s[1])
break
if _id == 'p':
patientOutput()
else:
researchOutput()
def reply():
print("Enter private key: ")
patientKey = input()
print("Enter receiver address: ")
receiverAddress = input()
print("Enter data: ")
data = input()
send_message(message=data, sender_pub=patientAddress, sender_priv=patientKey, receiver=receiverAddress)
patientOutput()
def patientOutput():
print("Would you like to [s]earch for trials, [r]eply to message, [c]heck you messages, or [e]xit?")
line = input()
if(line == 's' or line == 'S'):
search()
elif line == 'r' or line == "R":
reply()
elif(line == 'c' or line =='C'):
checkMessages(patientAddress, 'p')
elif (line == 'e' or line == 'E'):
exit()
my_model = Model()
# my_model.search('Chemotherapy trials for woman older than 30')
my_model.train_model()
passwords = ["CMU", "JHU", "RPI"]
print("Researcher (WIP) [R] or Patient [P]?")
line = input()
if line == "r" or line == "R":
print("Input your identifier: ")
line = input()
if passwords.count(line) == 0:
print("Invalid identifier, ending session")
exit()
print("Welcome", line)
print("Enter your address: ")
researcherAddress = input()
researchOutput()
elif line == "p" or line == "P":
print("Enter your address: ")
patientAddress = input()
patientOutput()