-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatus_controller.py
More file actions
39 lines (28 loc) · 1.32 KB
/
Copy pathstatus_controller.py
File metadata and controls
39 lines (28 loc) · 1.32 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
import connexion
from swagger_server.models.error_model import ErrorModel # noqa: E501
from swagger_server.models.status import Status # noqa: E501
from swagger_server import util
import config
from controllers.query_controller import *
def list_status(lang, orphacode): # noqa: E501
"""Search for a clinical entity's status by ORPHAcode
The result retrieves the clinical entity's ORPHAcode and its status (active/inactive). # noqa: E501
:param lang: Language
:type lang: str
:param orphacode: A unique and time-stable numerical identifier attributed randomly by the Orphanet database to each clinical entity upon its creation.
:type orphacode: int
:rtype: Status
"""
es = config.elastic_server
index = "rdcode_orphanomenclature"
index = "{}_{}".format(index, lang.lower())
query = "{\"query\": {\"match\": {\"ORPHAcode\": " + str(orphacode) + "}}," \
"\"_source\":[\"Date\", \"ORPHAcode\", \"Status\", \"FlagValue\"]}"
response = single_res(es, index, query)
if response["FlagValue"] == 513:
response["Status"] = "Active - Historical"
# pbl d'encodage dans la réponse depuis full UTF8
# print("response", response)
# return yaml if needed
response = if_yaml(connexion.request.accept_mimetypes.best, response)
return response