-
Notifications
You must be signed in to change notification settings - Fork 7
/
outlier_generate.py
68 lines (52 loc) · 1.86 KB
/
outlier_generate.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
from flask import Blueprint, request
from services import outlier_service, drug_service
from decorators.api_endpoint_decorator import api_endpoint
app_gen = Blueprint("app_gen", __name__)
@app_gen.route(
"/outliers/generate/add-history/<int:id_segment>/<int:id_drug>", methods=["POST"]
)
@api_endpoint()
def add_history(id_segment, id_drug):
return outlier_service.add_prescription_history(
id_drug=id_drug,
id_segment=id_segment,
clean=True,
rollback_when_empty=True,
)
@app_gen.route(
"/outliers/generate/config/<int:id_segment>/<int:id_drug>", methods=["POST"]
)
@api_endpoint()
def config(id_segment, id_drug):
data = request.get_json()
drug_service.drug_config_to_generate_score(
id_drug=id_drug,
id_segment=id_segment,
id_measure_unit=data.get("idMeasureUnit", None),
division=data.get("division", None),
use_weight=data.get("useWeight", False),
measure_unit_list=data.get("measureUnitList"),
)
return True
@app_gen.route(
"/outliers/generate/prepare/<int:id_segment>/<int:id_drug>", methods=["POST"]
)
@api_endpoint()
def prepare(id_segment, id_drug):
result = outlier_service.prepare(id_drug=id_drug, id_segment=id_segment)
return result.rowcount
@app_gen.route(
"/outliers/generate/single/<int:id_segment>/<int:id_drug>", methods=["POST"]
)
@app_gen.route("/outliers/generate/fold/<int:id_segment>/<int:fold>", methods=["POST"])
@api_endpoint()
def generate(id_segment, id_drug=None, fold=None):
outlier_service.generate(id_drug=id_drug, id_segment=id_segment, fold=fold)
return True
@app_gen.route(
"/outliers/generate/remove-outlier/<int:id_segment>/<int:id_drug>", methods=["POST"]
)
@api_endpoint()
def remove_outlier(id_segment, id_drug):
outlier_service.remove_outlier(id_drug=id_drug, id_segment=id_segment)
return True