|
|
|
@ -32,10 +32,10 @@ class BllMedicament(Repository):
|
|
|
|
|
def get_register_list(self, user, page_param):
|
|
|
|
|
|
|
|
|
|
# sql_all = f"""
|
|
|
|
|
# select * from rms_user_apply
|
|
|
|
|
# where
|
|
|
|
|
# user_id='{user.user_id}' and
|
|
|
|
|
# is_solve=1 and
|
|
|
|
|
# select * from rms_user_apply
|
|
|
|
|
# where
|
|
|
|
|
# user_id='{user.user_id}' and
|
|
|
|
|
# is_solve=1 and
|
|
|
|
|
# solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
|
|
|
|
|
|
|
|
|
|
# """
|
|
|
|
@ -79,8 +79,8 @@ class BllMedicament(Repository):
|
|
|
|
|
# select client_id, client_name from rms_client
|
|
|
|
|
# ) b on a.client_id = b.client_id
|
|
|
|
|
# ) c LEFT JOIN(
|
|
|
|
|
# select name, client_id, flow_position_code, count(*) num
|
|
|
|
|
# from rms_medicament where `name` like '%{drug_name}%' and status=1 and func_type={func_type}
|
|
|
|
|
# select name, client_id, flow_position_code, count(*) num
|
|
|
|
|
# from rms_medicament where `name` like '%{drug_name}%' and status=1 and func_type={func_type}
|
|
|
|
|
# GROUP BY client_id, flow_position_code
|
|
|
|
|
# ) d on c.client_id=d.client_id and c.cell_code=d.flow_position_code
|
|
|
|
|
|
|
|
|
@ -239,7 +239,7 @@ class BllMedicament(Repository):
|
|
|
|
|
filter_base += f" (`name` like '{seach_word}' or english_name like '{seach_word}') "
|
|
|
|
|
# 搜索bar_code
|
|
|
|
|
if b_code:
|
|
|
|
|
if len(b_code) > 10:
|
|
|
|
|
if len(b_code) > 10 and str(func_type) == "1":
|
|
|
|
|
new_code = ''
|
|
|
|
|
for i in range(int(len(b_code) / 2)):
|
|
|
|
|
new_code = b_code[i*2:(i+1)*2] + new_code
|
|
|
|
@ -248,14 +248,14 @@ class BllMedicament(Repository):
|
|
|
|
|
new_code = f"%{new_code}%"
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" bar_code like '{new_code}' "
|
|
|
|
|
if filter_base:
|
|
|
|
|
if len(seach_word) > 10:
|
|
|
|
|
new_code = ''
|
|
|
|
|
for i in range(int(len(seach_word) / 2)):
|
|
|
|
|
new_code = seach_word[i*2:(i+1)*2] + new_code
|
|
|
|
|
else:
|
|
|
|
|
new_code = seach_word
|
|
|
|
|
filter_base += f" bar_code like '{new_code}' or remark12 like '{new_code}' "
|
|
|
|
|
# if filter_base:
|
|
|
|
|
# if len(seach_word) > 10:
|
|
|
|
|
# new_code = ''
|
|
|
|
|
# for i in range(int(len(seach_word) / 2)):
|
|
|
|
|
# new_code = seach_word[i*2:(i+1)*2] + new_code
|
|
|
|
|
# else:
|
|
|
|
|
# new_code = seach_word
|
|
|
|
|
# TODO 确认下面这段和上面修改b_code代码作用
|
|
|
|
|
# new_code = f"%{new_code}%"
|
|
|
|
|
# if filter_base:
|
|
|
|
@ -269,7 +269,7 @@ class BllMedicament(Repository):
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base = f" where {filter_base}"
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select * from rms_medicament {filter_base} order by put_in_date desc
|
|
|
|
|
select * from rms_medicament {filter_base} and status != 3 order by put_in_date desc
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
count_number = len(self.execute(sql_all).fetchall())
|
|
|
|
@ -379,7 +379,6 @@ class BllMedicament(Repository):
|
|
|
|
|
|
|
|
|
|
drug = BllMedicament().findEntity(entityDrug.medicament_id)
|
|
|
|
|
lastRemain = float(drug.remain)
|
|
|
|
|
remain_result = {"is_liquid": False, "use_volume": 0, "use_quality": 0}
|
|
|
|
|
|
|
|
|
|
if entityClient.client_id not in client_list:
|
|
|
|
|
entityDrugRecord = EntityMedicamentRecord(
|
|
|
|
@ -398,15 +397,6 @@ class BllMedicament(Repository):
|
|
|
|
|
create_user_name=entityUser.real_name,
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
# 液体用量 = 用量质量 / 密度
|
|
|
|
|
medicament_variety_obj = BllMedicamentVariety().findEntity(
|
|
|
|
|
EntityMedicamentVariety.variety_id == entityDrug.variety_id)
|
|
|
|
|
if medicament_variety_obj.net_weight_unit == 'ml' and medicament_variety_obj.density:
|
|
|
|
|
use_volume = (float(lastRemain) - float(
|
|
|
|
|
entityDrug.remain if entityDrug.remain else 0)) / medicament_variety_obj.density
|
|
|
|
|
entityDrugRecord.use_volume = use_volume
|
|
|
|
|
remain_result["is_liquid"] = True
|
|
|
|
|
remain_result["use_volume"] = use_volume
|
|
|
|
|
self.session.add(entityDrugRecord)
|
|
|
|
|
entityVariety = BllMedicamentVariety().findEntity(entityDrug.variety_id)
|
|
|
|
|
if(entityDrug.remain != 0):
|
|
|
|
@ -417,7 +407,7 @@ class BllMedicament(Repository):
|
|
|
|
|
self.session.merge(entityVariety)
|
|
|
|
|
|
|
|
|
|
self.commitTrans()
|
|
|
|
|
remain_result["use_quality"] = float(lastRemain) - float(entityDrug.remain if entityDrug.remain else 0)
|
|
|
|
|
remain_result = self.calculate_use_drug(drug, weight_remain=float(entityDrug.remain))
|
|
|
|
|
return remain_result
|
|
|
|
|
|
|
|
|
|
# 药剂登记
|
|
|
|
@ -489,13 +479,13 @@ class BllMedicament(Repository):
|
|
|
|
|
filter_base1 += f"where place='{client_place}'"
|
|
|
|
|
|
|
|
|
|
# sql_all =f"""
|
|
|
|
|
# select DISTINCT
|
|
|
|
|
# `name`, speci, cas_number,net_weight_unit, purity,
|
|
|
|
|
# select DISTINCT
|
|
|
|
|
# `name`, speci, cas_number,net_weight_unit, purity,
|
|
|
|
|
# manufacturer, distributor, net_weight, net_weight_unit,
|
|
|
|
|
# client_id, put_in_user_name,category,expiration_date
|
|
|
|
|
|
|
|
|
|
# sum(CASE WHEN `status`=1 THEN 1 ELSE 0 END) count_number,
|
|
|
|
|
# sum(CASE WHEN `status`=1 THEN remain ELSE 0 END) sum_remain
|
|
|
|
|
# sum(CASE WHEN `status`=1 THEN 1 ELSE 0 END) count_number,
|
|
|
|
|
# sum(CASE WHEN `status`=1 THEN remain ELSE 0 END) sum_remain
|
|
|
|
|
# FROM rms_medicament {filter_base} GROUP BY `name`, speci, purity order by put_in_date desc
|
|
|
|
|
# """
|
|
|
|
|
sql_all = f"""
|
|
|
|
@ -982,6 +972,26 @@ class BllMedicament(Repository):
|
|
|
|
|
self.session.merge(drug_entry)
|
|
|
|
|
self.commitTrans()
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def calculate_use_drug(drug, weight_remain=0.0):
|
|
|
|
|
"""
|
|
|
|
|
计算用量
|
|
|
|
|
:return: {"is_liquid": 是否为液体, "use_volume": 液体用量, "use_quality": 固体用量, "net_weight_unit": 单位}
|
|
|
|
|
"""
|
|
|
|
|
medicament_variety_obj = BllMedicamentVariety().findEntity(
|
|
|
|
|
EntityMedicamentVariety.variety_id == drug.variety_id)
|
|
|
|
|
remain_result = {
|
|
|
|
|
"is_liquid": False,
|
|
|
|
|
"use_volume": 0,
|
|
|
|
|
"use_quality": float(drug.remain) - float(weight_remain),
|
|
|
|
|
"net_weight_unit": medicament_variety_obj.net_weight_unit
|
|
|
|
|
}
|
|
|
|
|
# 液体
|
|
|
|
|
if medicament_variety_obj.net_weight_unit == 'ml' and medicament_variety_obj.density:
|
|
|
|
|
use_volume = remain_result["use_quality"] / medicament_variety_obj.density
|
|
|
|
|
remain_result["is_liquid"] = True
|
|
|
|
|
remain_result["use_volume"] = Utils.reserve_decimal(use_volume, 2)
|
|
|
|
|
return remain_result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|