|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
# 药剂登记
|
|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|