-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
73 lines (54 loc) · 2.31 KB
/
server.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
from modules import checker_client
from cfg import config
import uvicorn
import os
from fastapi import FastAPI, Request
# Init section
app = FastAPI()
username = config.username
password = config.password
authUrl = config.priaid_authservice_url
healthUrl = config.priaid_healthservice_url
language = config.language
api_medic_client = checker_client.DiagnosisClient(username=username, password=password, auth_service_url=authUrl,
health_service_url=healthUrl, language=language)
@app.get("/symptoms")
async def get_symptoms():
return {"symptoms": api_medic_client.load_symptoms()}
@app.get("/issues")
async def get_issues():
return {"issues": api_medic_client.load_issues()}
@app.post("/issue_info")
async def get_issue_info(info: Request):
req_info = await info.json()
issue_id = req_info["issue_id"]
return {"information": api_medic_client.load_issue_info(issue_id)}
@app.post("/identify_disease")
async def identify_disease(info: Request):
req_info = await info.json()
potential_diseases = req_info["symptoms"]
gender = req_info["gender"]
year_of_birth = req_info["year_of_birth"]
return {"result": api_medic_client.loadDiagnosis(potential_diseases, gender, year_of_birth)}
@app.get("/red_flag")
async def get_red_flag(info: Request):
req_info = await info.json()
symptom_id = req_info['symptom_id']
return {"result": api_medic_client.load_red_flag(symptom_id)}
@app.get("/body_sublocations")
async def get_body_sublocations(info: Request):
req_info = await info.json()
body_location_id = req_info["body_sublocation"]
return {"result": api_medic_client.load_body_sublocation(body_location_id)}
@app.post("/get_specialisations")
async def get_specialisations(info: Request):
req_info = await info.json()
selected_symptoms = req_info["symptoms"]
gender = req_info["gender"]
year_of_birth = req_info["year_of_birth"]
return {"result": api_medic_client.load_specialisations(selectedSymptoms=selected_symptoms, gender=gender,
yearOfBirth=year_of_birth)}
def main():
uvicorn.run(f"{os.path.basename(__file__)[:-3]}:app", log_level="info")
if __name__ == '__main__':
main()