|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
@Date:2022/07/26 11:19:30
|
|
|
|
|
'''
|
|
|
|
|
import datetime
|
|
|
|
|
from flask import jsonify, request
|
|
|
|
|
from flask import jsonify, request, g
|
|
|
|
|
from flask import Blueprint
|
|
|
|
|
from db_logic.client import BllClient
|
|
|
|
|
|
|
|
|
@ -15,6 +15,8 @@ from db_logic.user import BllUser
|
|
|
|
|
from models.user_models import EntityUser
|
|
|
|
|
from models.client_models import EntityClient
|
|
|
|
|
from Common.Utils import DrugStatus, PageParam, Utils
|
|
|
|
|
from Common.auth import token_auth
|
|
|
|
|
|
|
|
|
|
drug_router = Blueprint("drug", __name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,12 +24,13 @@ drug_router = Blueprint("drug", __name__)
|
|
|
|
|
|
|
|
|
|
# 试剂扫码领用
|
|
|
|
|
@drug_router.route("/use", methods=["GET", "POST"])
|
|
|
|
|
@token_auth.login_required
|
|
|
|
|
def drug_collect():
|
|
|
|
|
# 获取参数
|
|
|
|
|
bar_code = request.values.get("bar_code")
|
|
|
|
|
# user_id=request.values.get("user_id")
|
|
|
|
|
# 默认用户id,后续从token 中获取
|
|
|
|
|
user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1'
|
|
|
|
|
# user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1'
|
|
|
|
|
# 强制使用,默认0不强制,1强制
|
|
|
|
|
force_use = request.values.get("force_use")
|
|
|
|
|
force_use = force_use if force_use != '' else '0'
|
|
|
|
@ -57,7 +60,8 @@ def drug_collect():
|
|
|
|
|
data = Utils.false_return(status=2, msg=f'"{drug_entity.name}({drug_entity.bar_code})"此类药有更接近保质期的实例"{drug_obj.bar_code}", 存在于"{drug_obj.client_code}"号终端')
|
|
|
|
|
else:
|
|
|
|
|
# 领取试剂
|
|
|
|
|
user_info = BllUser().findEntity(EntityUser.user_id==user_id)
|
|
|
|
|
# user_info = BllUser().findEntity(EntityUser.user_id==user_id)
|
|
|
|
|
user_info = g.current_user
|
|
|
|
|
drug_entity.by_user_date = Utils.get_str_datetime()
|
|
|
|
|
drug_entity.by_user_id=user_info.user_id
|
|
|
|
|
drug_entity.by_user_name=user_info.real_name
|
|
|
|
@ -77,13 +81,14 @@ def drug_collect():
|
|
|
|
|
|
|
|
|
|
# 试剂归还
|
|
|
|
|
@drug_router.route("/drug_return", methods=["GET", "POST"])
|
|
|
|
|
@token_auth.login_required
|
|
|
|
|
def drug_return():
|
|
|
|
|
# 获取参数
|
|
|
|
|
bar_code = request.values.get("bar_code")
|
|
|
|
|
place = request.values.get("place")
|
|
|
|
|
# user_id = request.values.get("user_id")
|
|
|
|
|
# 默认用户id,后续从token 中获取
|
|
|
|
|
user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1'
|
|
|
|
|
# user_id = '4cea74ee-0d8b-11ed-943e-f47b094925e1'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 根据条码查询试剂信息
|
|
|
|
@ -97,7 +102,8 @@ def drug_return():
|
|
|
|
|
drug_info.status = DrugStatus.Normal
|
|
|
|
|
if place:
|
|
|
|
|
drug_info.place = place
|
|
|
|
|
user_info = BllUser().findEntity(EntityUser.user_id == user_id)
|
|
|
|
|
# user_info = BllUser().findEntity(EntityUser.user_id == user_id)
|
|
|
|
|
user_info = g.current_user
|
|
|
|
|
BllMedicament().drugReturn(drug_info, BllClient().findEntity(drug_info.client_id), user_info)
|
|
|
|
|
data = Utils.true_return(msg="药剂归还成功", data=Utils.to_dict(drug_info))
|
|
|
|
|
return jsonify(data)
|
|
|
|
@ -105,6 +111,7 @@ def drug_return():
|
|
|
|
|
|
|
|
|
|
# 试剂领用/归还,列表展示
|
|
|
|
|
@drug_router.route("/use_or_return_list", methods=["GET", "POST"])
|
|
|
|
|
@token_auth.login_required
|
|
|
|
|
def drug_use_retur_list():
|
|
|
|
|
status = request.values.get("status")
|
|
|
|
|
page = int(request.values.get("page", 1))
|
|
|
|
@ -116,6 +123,7 @@ def drug_use_retur_list():
|
|
|
|
|
|
|
|
|
|
# 试剂称重展示试剂详细信息
|
|
|
|
|
@drug_router.route("/get_drug_info", methods=["GET", "POST"])
|
|
|
|
|
@token_auth.login_required
|
|
|
|
|
def get_drug_info():
|
|
|
|
|
bar_code = request.values.get("bar_code")
|
|
|
|
|
data_list = BllMedicament().get_bar_code_drug_info(bar_code=bar_code)
|
|
|
|
@ -126,6 +134,7 @@ def get_drug_info():
|
|
|
|
|
|
|
|
|
|
# 试剂管理
|
|
|
|
|
@drug_router.route("/drug_manage", methods=["GET", "POST"])
|
|
|
|
|
@token_auth.login_required
|
|
|
|
|
def get_drug_manage():
|
|
|
|
|
seach_word = request.values.get("seach_word")
|
|
|
|
|
client_id = request.values.get("client_id")
|
|
|
|
|