|
|
|
@ -4,11 +4,13 @@
|
|
|
|
|
@Date:2022/07/18 16:54:45
|
|
|
|
|
'''
|
|
|
|
|
import sys
|
|
|
|
|
import datetime
|
|
|
|
|
from dateutil.relativedelta import relativedelta
|
|
|
|
|
sys.path.append('.')
|
|
|
|
|
from sqlalchemy import distinct, or_, and_, desc, asc
|
|
|
|
|
from sqlalchemy.sql import func
|
|
|
|
|
from db_logic.db_base import Repository
|
|
|
|
|
from models.medicament_models import EntityMedicament, EntityMedicamentRecord, EntityMedicamentTemplate, EntityVariety
|
|
|
|
|
from models.medicament_models import EntityMedicament, EntityMedicamentRecord, EntityMedicamentTemplate, EntityVariety, EntityMedicamentVariety
|
|
|
|
|
from models.client_models import EntityClient
|
|
|
|
|
from models.user_models import EntityUser
|
|
|
|
|
from db_logic.meidcament_variety import BllMedicamentVariety
|
|
|
|
@ -26,7 +28,7 @@ class BllMedicament(Repository):
|
|
|
|
|
def update(self, entity):
|
|
|
|
|
entity.remark30 = '0'
|
|
|
|
|
return super().update(entity)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_register_list(self, user, page_param):
|
|
|
|
|
|
|
|
|
|
# sql_all = f"""
|
|
|
|
@ -35,7 +37,7 @@ class BllMedicament(Repository):
|
|
|
|
|
# user_id='{user.user_id}' and
|
|
|
|
|
# is_solve=1 and
|
|
|
|
|
# solve_date > DATE_SUB('{Utils.get_str_datetime()}', INTERVAL 10 hour)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# """
|
|
|
|
|
# data = self.execute(sql_all).fetchall()
|
|
|
|
|
# data_list = []
|
|
|
|
@ -50,7 +52,7 @@ class BllMedicament(Repository):
|
|
|
|
|
# if drugobj:
|
|
|
|
|
# data_list.append(j)
|
|
|
|
|
# #所有试剂
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +71,7 @@ class BllMedicament(Repository):
|
|
|
|
|
# 获取可入库层数据
|
|
|
|
|
def get_drug_save_db_info(self, drug_name, func_type):
|
|
|
|
|
# sql_all = f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# select name, IFNULL(num,0) number, c.client_name, c.client_id, cell_code, cell_speci from (
|
|
|
|
|
# select cell_code, a.client_id, cell_speci, client_name from (
|
|
|
|
|
# select * from rms_client_cell
|
|
|
|
@ -81,7 +83,7 @@ class BllMedicament(Repository):
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# HAVING number < 40
|
|
|
|
|
# """
|
|
|
|
|
sql_all = f"""
|
|
|
|
@ -90,9 +92,9 @@ class BllMedicament(Repository):
|
|
|
|
|
select a.cell_code,a.client_id, a.cell_speci, IFNULL(a.storage_quantity,0) storage_quantity, count(b.name) num, IFNULL(GROUP_CONCAT(b.name),'') name_json
|
|
|
|
|
from (select * from rms_client_cell) a
|
|
|
|
|
LEFT JOIN (select * from rms_medicament) b on a.client_id=b.client_id and a.cell_speci=b.place
|
|
|
|
|
GROUP BY a.id
|
|
|
|
|
GROUP BY a.id order by a.cell_speci asc
|
|
|
|
|
) c LEFT JOIN (select * from rms_client where func_type={func_type}) d on c.client_id=d.client_id
|
|
|
|
|
where d.client_name is not null
|
|
|
|
|
where d.client_name is not null order by d.client_name asc
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
data = self.execute(sql_all).fetchall()
|
|
|
|
@ -113,6 +115,7 @@ class BllMedicament(Repository):
|
|
|
|
|
"client_cell": [i.cell_speci]
|
|
|
|
|
}
|
|
|
|
|
data_dict[i.client_id] = client_dict
|
|
|
|
|
data_dict[i.client_id]["client_cell"].sort()
|
|
|
|
|
# data_dict = {}
|
|
|
|
|
# for i in data:
|
|
|
|
|
# if i.client_id in data_dict.keys():
|
|
|
|
@ -253,10 +256,11 @@ class BllMedicament(Repository):
|
|
|
|
|
new_code = seach_word[i*2:(i+1)*2] + new_code
|
|
|
|
|
else:
|
|
|
|
|
new_code = seach_word
|
|
|
|
|
new_code = f"%{new_code}%"
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" (bar_code like '{new_code}' or bar_code like '{seach_word}' )"
|
|
|
|
|
# TODO 确认下面这段和上面修改b_code代码作用
|
|
|
|
|
# new_code = f"%{new_code}%"
|
|
|
|
|
# if filter_base:
|
|
|
|
|
# filter_base += " or "
|
|
|
|
|
# filter_base += f" (bar_code like '{new_code}' or bar_code like '{seach_word}' )"
|
|
|
|
|
if func_type:
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
@ -274,7 +278,7 @@ class BllMedicament(Repository):
|
|
|
|
|
page_param.totalRecords=count_number
|
|
|
|
|
page_sql = Utils.sql_paging_assemble(sql_all, page_param)
|
|
|
|
|
return self.execute(page_sql).fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 选择药剂入库--试剂详情
|
|
|
|
|
def get_drug_info_distinct_list(self, seach_word, func_type, page_param, client_id=None):
|
|
|
|
|
# 动态添加查询条件
|
|
|
|
@ -299,7 +303,7 @@ class BllMedicament(Repository):
|
|
|
|
|
try:
|
|
|
|
|
count_number = len(self.execute(sql_all).fetchall())
|
|
|
|
|
except Exception:
|
|
|
|
|
count_number = 0
|
|
|
|
|
count_number = 0
|
|
|
|
|
page_param.totalRecords = count_number
|
|
|
|
|
# 分页sql
|
|
|
|
|
page_sql = Utils.sql_paging_assemble(sql_all, page_param)
|
|
|
|
@ -317,7 +321,7 @@ class BllMedicament(Repository):
|
|
|
|
|
medicament_id=entityDrug.medicament_id,
|
|
|
|
|
price=entityDrug.price,
|
|
|
|
|
record_type=DrugRecordType.PutIn,
|
|
|
|
|
record_remain=float(entityDrug.remain),
|
|
|
|
|
record_remain=float(entityDrug.remain) if entityDrug.remain else 0,
|
|
|
|
|
|
|
|
|
|
is_empty=0,
|
|
|
|
|
create_date=Utils.get_str_datetime(),
|
|
|
|
@ -337,7 +341,7 @@ class BllMedicament(Repository):
|
|
|
|
|
return True
|
|
|
|
|
return boolean_
|
|
|
|
|
# 药剂领用
|
|
|
|
|
def drugUse(self, entityDrug=EntityMedicament(), entityClient=EntityClient(), entityUser=EntityUser()):
|
|
|
|
|
def drugUse(self, entityDrug=EntityMedicament(), entityClient=EntityClient(), entityUser=EntityUser(),notes=''):
|
|
|
|
|
#创建事务
|
|
|
|
|
self.beginTrans()
|
|
|
|
|
entityDrug.remark30 = '0'
|
|
|
|
@ -356,6 +360,7 @@ class BllMedicament(Repository):
|
|
|
|
|
create_date=Utils.get_str_datetime(),
|
|
|
|
|
create_user_id=entityUser.user_id,
|
|
|
|
|
create_user_name=entityUser.real_name,
|
|
|
|
|
notes = notes
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
self.session.add(entityDrugRecord)
|
|
|
|
@ -374,8 +379,7 @@ class BllMedicament(Repository):
|
|
|
|
|
|
|
|
|
|
drug = BllMedicament().findEntity(entityDrug.medicament_id)
|
|
|
|
|
lastRemain = float(drug.remain)
|
|
|
|
|
if not entityDrug.remain:
|
|
|
|
|
entityDrug.remain=0
|
|
|
|
|
remain_result = {"is_liquid": False, "use_volume": 0, "use_quality": 0}
|
|
|
|
|
|
|
|
|
|
if entityClient.client_id not in client_list:
|
|
|
|
|
entityDrugRecord = EntityMedicamentRecord(
|
|
|
|
@ -394,6 +398,15 @@ 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):
|
|
|
|
@ -404,6 +417,8 @@ class BllMedicament(Repository):
|
|
|
|
|
self.session.merge(entityVariety)
|
|
|
|
|
|
|
|
|
|
self.commitTrans()
|
|
|
|
|
remain_result["use_quality"] = float(lastRemain) - float(entityDrug.remain if entityDrug.remain else 0)
|
|
|
|
|
return remain_result
|
|
|
|
|
|
|
|
|
|
# 药剂登记
|
|
|
|
|
def drugRegister(self, entityDrug, entityClient=EntityClient(), entityUser=EntityUser()):
|
|
|
|
@ -434,8 +449,11 @@ class BllMedicament(Repository):
|
|
|
|
|
self.session.add(entityDrugRecord)
|
|
|
|
|
self.commitTrans()
|
|
|
|
|
|
|
|
|
|
# 获取领用和归还页面列表
|
|
|
|
|
def drug_use_return(self, status, func_type, user, page_param):
|
|
|
|
|
# 获取领用和归还页面列表 管理员要能看到所有领用/归还列表数据
|
|
|
|
|
def drug_use_return(self, status, func_type, user, page_param, is_admin):
|
|
|
|
|
filter_base = f" status={status} and func_type='{func_type}' "
|
|
|
|
|
if not is_admin:
|
|
|
|
|
filter_base += f"and by_user_id='{user.user_id}' "
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select * from rms_medicament where status={status} and func_type='{func_type}' and by_user_id='{user.user_id}' order by by_user_date desc
|
|
|
|
|
"""
|
|
|
|
@ -469,7 +487,7 @@ class BllMedicament(Repository):
|
|
|
|
|
filter_base1 = ""
|
|
|
|
|
if client_place:
|
|
|
|
|
filter_base1 += f"where place='{client_place}'"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# sql_all =f"""
|
|
|
|
|
# select DISTINCT
|
|
|
|
|
# `name`, speci, cas_number,net_weight_unit, purity,
|
|
|
|
@ -574,17 +592,19 @@ class BllMedicament(Repository):
|
|
|
|
|
count_number= len(self.execute(sql_all).fetchall())
|
|
|
|
|
except Exception:
|
|
|
|
|
count_number = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 进行分页sql拼接
|
|
|
|
|
if page_param:
|
|
|
|
|
page_param.totalRecords = count_number
|
|
|
|
|
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self.execute(sql_all).fetchall()
|
|
|
|
|
|
|
|
|
|
# 入库、领用、归还记录
|
|
|
|
|
def drug_show_type_info(self, record_type, start_time, end_time, put_in_user_name, name, func_type, client_id, statue_type, page_param, client_place):
|
|
|
|
|
filter_base1 = f" WHERE record_type={record_type} "
|
|
|
|
|
filter_base1 = ''
|
|
|
|
|
if record_type:
|
|
|
|
|
filter_base1 = f" WHERE record_type={record_type} "
|
|
|
|
|
if put_in_user_name:
|
|
|
|
|
filter_base1 += f" and create_user_name like '%{put_in_user_name}%'"
|
|
|
|
|
if start_time and end_time:
|
|
|
|
@ -596,11 +616,11 @@ class BllMedicament(Repository):
|
|
|
|
|
name = f"%{name}%"
|
|
|
|
|
filter_base2 += f" (`name` like '{name}' or english_name like '{name}') "
|
|
|
|
|
|
|
|
|
|
if statue_type:
|
|
|
|
|
if statue_type and statue_type != '100':
|
|
|
|
|
if filter_base2:
|
|
|
|
|
filter_base2 += " and "
|
|
|
|
|
filter_base2 = f" `status`={statue_type}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if func_type:
|
|
|
|
|
if filter_base2:
|
|
|
|
|
filter_base2 += " and "
|
|
|
|
@ -613,8 +633,8 @@ class BllMedicament(Repository):
|
|
|
|
|
filter_base += f"where place='{client_place}'"
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select
|
|
|
|
|
`name`, english_name, bar_code, purity,
|
|
|
|
|
cas_number, speci, use_quantity, `status`,
|
|
|
|
|
record_type, `name`, english_name, bar_code, purity,
|
|
|
|
|
cas_number, speci, use_quantity, use_volume, `status`,
|
|
|
|
|
create_date, create_user_name, a.client_id, client_code, client_name, unit_code
|
|
|
|
|
from (select * from rms_medicament_record {filter_base1}
|
|
|
|
|
) as a LEFT JOIN(
|
|
|
|
@ -637,6 +657,58 @@ class BllMedicament(Repository):
|
|
|
|
|
sql_all = Utils.sql_paging_assemble(sql_all, page_param)
|
|
|
|
|
return self.execute(sql_all).fetchall()
|
|
|
|
|
|
|
|
|
|
def drug_show_un_warehoused_type_info(self, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
未入库记录(未归还)
|
|
|
|
|
:param kwargs: record_type, start_time, end_time, put_in_user_name, name, func_type, client_id, statue_type,
|
|
|
|
|
page_param, client_place
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
filter_base1 = " where record_type=2 "
|
|
|
|
|
if kwargs.get("put_in_user_name"):
|
|
|
|
|
filter_base1 += f" and create_user_name like '%{kwargs.get('put_in_user_name')}%'"
|
|
|
|
|
if kwargs.get("start_time") and kwargs.get("end_time"):
|
|
|
|
|
filter_base1 += f" and create_date >= '{kwargs.get('start_time')}' and create_date <= '{kwargs.get('end_time')}'"
|
|
|
|
|
if kwargs.get("client_id"):
|
|
|
|
|
filter_base1 += f" and client_id='{kwargs.get('client_id')}'"
|
|
|
|
|
filter_base2 = " `status` = 2 "
|
|
|
|
|
if kwargs.get("func_type"):
|
|
|
|
|
if filter_base2:
|
|
|
|
|
filter_base2 += " and "
|
|
|
|
|
filter_base2 += f" func_type='{kwargs.get('func_type')}' "
|
|
|
|
|
|
|
|
|
|
if filter_base2:
|
|
|
|
|
filter_base2 = f" where {filter_base2}"
|
|
|
|
|
|
|
|
|
|
filter_base = ""
|
|
|
|
|
if kwargs.get("client_place"):
|
|
|
|
|
filter_base += f"where place='{kwargs.get('client_place')}'"
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select
|
|
|
|
|
`name`, english_name, bar_code, purity,
|
|
|
|
|
cas_number, speci, use_quantity, use_volume, `status`,
|
|
|
|
|
create_date, create_user_name, a.client_id, client_code, client_name, unit_code
|
|
|
|
|
from (select * from rms_medicament_record {filter_base1}
|
|
|
|
|
) as a LEFT JOIN(
|
|
|
|
|
select
|
|
|
|
|
medicament_id, `name`, english_name,
|
|
|
|
|
bar_code, purity, speci, cas_number,
|
|
|
|
|
net_weight, remain, `status`,
|
|
|
|
|
by_user_date, by_user_name, unit_code
|
|
|
|
|
FROM rms_medicament {filter_base2}
|
|
|
|
|
) as b on a.medicament_id=b.medicament_id
|
|
|
|
|
LEFT JOIN(select client_id,client_name from rms_client {filter_base}) c on a.client_id=c.client_id
|
|
|
|
|
where name is not null and client_name is not null GROUP BY b.medicament_id ORDER BY create_date desc
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
count_number = len(self.execute(sql_all).fetchall())
|
|
|
|
|
except Exception:
|
|
|
|
|
count_number = 0
|
|
|
|
|
if kwargs["page_param"]:
|
|
|
|
|
kwargs["page_param"].totalRecords = count_number
|
|
|
|
|
sql_all = Utils.sql_paging_assemble(sql_all, kwargs["page_param"])
|
|
|
|
|
return self.execute(sql_all).fetchall(), count_number
|
|
|
|
|
|
|
|
|
|
def client_room_number(self):
|
|
|
|
|
sql_all = """
|
|
|
|
|
select
|
|
|
|
@ -663,7 +735,7 @@ class BllMedicament(Repository):
|
|
|
|
|
group by `name`, speci, purity
|
|
|
|
|
"""
|
|
|
|
|
return self.execute(sql_all).fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 库存盘点获取分组后的试剂信息数据
|
|
|
|
|
def get_drug_stock_info(self, client_id):
|
|
|
|
|
sql_all = f"""
|
|
|
|
@ -685,11 +757,11 @@ class BllMedicament(Repository):
|
|
|
|
|
filter_base = f" and {filter_base}"
|
|
|
|
|
# sql_all = f"""
|
|
|
|
|
# select a.*,b.client_name from (
|
|
|
|
|
# select
|
|
|
|
|
# select
|
|
|
|
|
# `name`, speci, purity, count(*) drug_num, manufacturer, distributor,client_id,medicament_id
|
|
|
|
|
# from
|
|
|
|
|
# from
|
|
|
|
|
# rms_medicament WHERE `status`=1 {filter_base}
|
|
|
|
|
# GROUP BY
|
|
|
|
|
# GROUP BY
|
|
|
|
|
# `name`, speci, purity, client_id
|
|
|
|
|
# ) a LEFT JOIN (
|
|
|
|
|
# select * from rms_client
|
|
|
|
@ -697,9 +769,9 @@ class BllMedicament(Repository):
|
|
|
|
|
# """
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select a.*,b.client_name from (
|
|
|
|
|
select * from rms_medicament WHERE `status`=1 {filter_base}
|
|
|
|
|
select * from rms_medicament WHERE rms_medicament.func_type=1 and `status`=1 {filter_base}
|
|
|
|
|
) a LEFT JOIN (
|
|
|
|
|
select * from rms_client
|
|
|
|
|
select * from rms_client WHERE rms_client.place =10
|
|
|
|
|
) b on a.client_id = b.client_id
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
@ -734,7 +806,7 @@ class BllMedicament(Repository):
|
|
|
|
|
if client_id =='72e70542-b70d-11e8-aea5-448a5bc6c417':
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f" client_id in ('72e70542-b70d-11e8-aea5-448a5bc6c417') "
|
|
|
|
|
filter_base += f" client_id in ('72e70542-b70d-11e8-aea5-448a5bc6c417') "
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base = f" where {filter_base}"
|
|
|
|
|
sql_all = f"""
|
|
|
|
@ -759,7 +831,7 @@ class BllMedicament(Repository):
|
|
|
|
|
if data:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getDrugSetPotionStorageIn(self,name,clientId=""):
|
|
|
|
@ -811,6 +883,108 @@ class BllMedicament(Repository):
|
|
|
|
|
obj_list.append(obj)
|
|
|
|
|
self.insert_many(obj_list)
|
|
|
|
|
|
|
|
|
|
def get_last_drug(self, client_id, drug_name, put_in_date, func_type):
|
|
|
|
|
"""
|
|
|
|
|
判断获取最早入库试剂信息
|
|
|
|
|
"""
|
|
|
|
|
filter_base = ""
|
|
|
|
|
if func_type:
|
|
|
|
|
filter_base += f"func_type='{func_type}'"
|
|
|
|
|
if client_id:
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
filter_base += f"client_id='{client_id}'"
|
|
|
|
|
if drug_name:
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base += " and "
|
|
|
|
|
|
|
|
|
|
filter_base += f" `name`='{drug_name}' "
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base = f" and {filter_base}"
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select a.*,b.client_name from (
|
|
|
|
|
select * from rms_medicament WHERE `status`=1 {filter_base}
|
|
|
|
|
) a LEFT JOIN (
|
|
|
|
|
select * from rms_client
|
|
|
|
|
) b on a.client_id = b.client_id order by a.put_in_date asc
|
|
|
|
|
"""
|
|
|
|
|
medicament_obj = self.execute(sql_all).fetchone()
|
|
|
|
|
return medicament_obj
|
|
|
|
|
|
|
|
|
|
def get_drug_total_num(self, filter_base):
|
|
|
|
|
"""
|
|
|
|
|
获取药剂总数
|
|
|
|
|
:param filter_base:
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
if filter_base:
|
|
|
|
|
filter_base = f" and {filter_base}"
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select count(medicament_id) count_number from rms_medicament where `status` != 3 {filter_base}
|
|
|
|
|
"""
|
|
|
|
|
# 查看分组数据
|
|
|
|
|
data = self.execute(sql_all).fetchone()
|
|
|
|
|
return data.count_number if data.count_number else 0
|
|
|
|
|
|
|
|
|
|
def get_chemicals_total_num(self):
|
|
|
|
|
"""
|
|
|
|
|
获取化学品总数量
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
num = self.get_drug_total_num('')
|
|
|
|
|
return num
|
|
|
|
|
|
|
|
|
|
def get_chemicals_total_weight(self):
|
|
|
|
|
"""
|
|
|
|
|
获取化学品总重量
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
sql_all = f"""
|
|
|
|
|
select sum(remain) total_weight from rms_medicament where `status` != 3
|
|
|
|
|
"""
|
|
|
|
|
# 查看分组数据
|
|
|
|
|
data = self.execute(sql_all).fetchone()
|
|
|
|
|
return data.total_weight if data.total_weight else 0
|
|
|
|
|
|
|
|
|
|
def get_chemicals_other_total_num(self):
|
|
|
|
|
"""
|
|
|
|
|
获取其他化学品总数量
|
|
|
|
|
:return: standard_num 普通危化总数 2
|
|
|
|
|
reagent_num 易制毒易制爆总数 1
|
|
|
|
|
consumables_num 对照品数量 3
|
|
|
|
|
"""
|
|
|
|
|
standard_num = self.get_drug_total_num("func_type=2")
|
|
|
|
|
reagent_num = self.get_drug_total_num("func_type=1")
|
|
|
|
|
consumables_num = self.get_drug_total_num("func_type=3")
|
|
|
|
|
return standard_num, reagent_num, consumables_num
|
|
|
|
|
|
|
|
|
|
def update_expiration_date(self, drug_entry):
|
|
|
|
|
"""
|
|
|
|
|
更改试剂有效期
|
|
|
|
|
液体1年 ,普通固体5年, 易潮解固体2年
|
|
|
|
|
:param drug_entry:
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
expiration_dict = {
|
|
|
|
|
"ml": 1,
|
|
|
|
|
"g": 5,
|
|
|
|
|
"mg": 5,
|
|
|
|
|
}
|
|
|
|
|
unit = drug_entry.net_weight_unit
|
|
|
|
|
add_year = expiration_dict.get(unit) if expiration_dict.get(unit) else 2
|
|
|
|
|
date_now = datetime.datetime.now()
|
|
|
|
|
add_expiration_date = (date_now + relativedelta(years=add_year)).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
if add_expiration_date > drug_entry.expiration_date:
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
drug_entry.expiration_date = add_expiration_date
|
|
|
|
|
self.beginTrans()
|
|
|
|
|
self.session.merge(drug_entry)
|
|
|
|
|
self.commitTrans()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
data = BllMedicament().getDrugSetPotionStorageIn("2-氨基苯酚", '1c39cb24-07f8-11ed-abd4-f47b094925e1')
|
|
|
|
|
print(data)
|
|
|
|
@ -833,4 +1007,4 @@ if __name__ == '__main__':
|
|
|
|
|
# )
|
|
|
|
|
# print(typ_dic)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|