-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.py
142 lines (98 loc) · 3.59 KB
/
routes.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
import os
from flask import Flask, request, jsonify, render_template
app = Flask(__name__)
skin_imported = False
db_imported = False
try:
print("importing patient_util...")
import patient_util
db_imported = True
except ImportError as e:
print(e)
print("unable to import patient_util.py")
try:
print("importing image_util...")
import image_util
skin_imported = True
except ImportError as e:
print(e)
print("face_recognition/keras/tensorflow not installed. disabling image_util.py")
# TODO: Add HTTP codes
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')
"""
Basic database operations
"""
# Insert new patient into database
@app.route('/api/patient/insert', methods=['POST'])
def insert_patient():
return jsonify(patient_util.insert_patient(request))
# Delete patient from database
@app.route('/api/patient/delete', methods=['POST'])
def delete_patient():
return jsonify(patient_util.delete_patient(request))
# Change patient info - not implemented yet
@app.route('/api/patient/modify', methods=['POST'])
def modify_patient():
return jsonify({})
# Query patient info - includes what room they are in, if any
@app.route('/api/patient/query', methods=['GET'])
def query_patient():
return jsonify(patient_util.query_patient(request))
# Given a face and a name, finds the patient id that best matches them.
@app.route('/api/patient/match', methods=['GET'])
def match_patient():
return jsonify(patient_util.match_patient(request))
# Given a patient id and a face, gives a True/False value for if they match.
@app.route('/api/patient/verify', methods=['GET'])
def verify_patient():
return jsonify(patient_util.verify_patient(request))
"""
Patient Queue - Related
"""
# requests.post("http://localhost:5000/api/patient/enqueue?patient_id=1&room_number=0")
# requests.post("http://localhost:5000/api/patient/enqueue?patient_id=1&room_number=1")
# requests.post("http://localhost:5000/api/patient/dequeue")
# Adds a patient to the queue.
@app.route('/api/patient/enqueue', methods=['POST'])
def enqueue_patient():
return jsonify(patient_util.enqueue_patient(request))
# Gets and removes the first patient from the queue.
@app.route('/api/patient/dequeue', methods=['POST'])
def dequeue_patient():
return jsonify(patient_util.dequeue_patient(request))
# Assigns a room number to a patient. When commanding "check on (person's name)", AIMAR will know where the person is.
@app.route('/api/patient/assign', methods=['POST'])
def assign_patient_room():
return jsonify(patient_util.assign_patient_room(request))
@app.route('/api/patient/leave', methods=['POST'])
def leave_patient_room():
return jsonify(patient_util.leave_patient_room(request))
@app.route('/api/room/coordinates', methods=['GET'])
def get_room_coordinates():
return jsonify(patient_util.get_room_coordinates(request))
"""
To display patient queue information in browser
"""
@app.route('/api/queue', methods=['GET'])
def get_queue():
return jsonify(patient_util.get_queue())
@app.route('/api/room/list', methods=['GET'])
def get_patient_room_pairings():
return jsonify(patient_util.get_patient_room_pairings())
"""
Skin lesion classification
"""
# Diagnoses a skin image.
@app.route('/api/skin', methods=['POST'])
def classify_skin():
return jsonify(image_util.classify_skin(request))
if __name__ == "__main__":
if not os.path.exists("./images"):
os.mkdir("./images")
if not os.path.exists("./images/patients"):
os.mkdir("./images/patients")
ip = input("Desktop IP: ")
app.run(host=ip, port=5000, debug=False)