初步添加自动审核功能
This commit is contained in:
@@ -412,17 +412,19 @@ class ZxIeReview(Base):
|
||||
pk_ie_review = Column(INTEGER(11), primary_key=True, comment='自动审核主键')
|
||||
pk_phhd = Column(INTEGER(11), nullable=False, comment='报销案子主键')
|
||||
success = Column(BIT(1))
|
||||
integrity = Column(BIT(1))
|
||||
has_settlement = Column(BIT(1))
|
||||
has_discharge = Column(BIT(1))
|
||||
has_cost = Column(BIT(1))
|
||||
full_page = Column(BIT(1))
|
||||
page_description = Column(String(255), comment='具体缺页描述')
|
||||
consistency = Column(BIT(1), comment='三项资料一致性。0:不一致;1:一致')
|
||||
name_match = Column(CHAR(1), server_default=text("'0'"),
|
||||
comment='三项资料姓名是否一致。0:不一致;1:一致;2:结算单不一致;3:出院记录不一致;4:费用清单不一致;5:与报销申请对象不一致')
|
||||
comment='三项资料姓名是否一致。0:都不一致;1:一致;2:结算单不一致;3:出院记录不一致;4:费用清单不一致;5:与报销申请对象不一致')
|
||||
admission_date_match = Column(CHAR(1), server_default=text("'0'"),
|
||||
comment='三项资料入院日期是否一致。0:不一致;1:一致;2:结算单不一致;3:出院记录不一致;4:费用清单不一致')
|
||||
comment='三项资料入院日期是否一致。0:都不一致;1:一致;2:结算单不一致;3:出院记录不一致;4:费用清单不一致')
|
||||
discharge_date_match = Column(CHAR(1), server_default=text("'0'"),
|
||||
comment='三项资料出院日期是否一致。0:不一致;1:一致;2:结算单不一致;3:出院记录不一致;4:费用清单不一致')
|
||||
comment='三项资料出院日期是否一致。0:都不一致;1:一致;2:结算单不一致;3:出院记录不一致;4:费用清单不一致')
|
||||
create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间')
|
||||
creator = Column(String(255), comment='创建人')
|
||||
update_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
|
||||
|
||||
@@ -16,7 +16,7 @@ from rapidfuzz import process, fuzz
|
||||
from sqlalchemy import update
|
||||
|
||||
from db import MysqlSession
|
||||
from db.mysql import BdYljg, BdYlks, ZxIeResult, ZxIeCost, ZxIeDischarge, ZxIeSettlement, ZxPhhd, ZxPhrec
|
||||
from db.mysql import BdYljg, BdYlks, ZxIeResult, ZxIeCost, ZxIeDischarge, ZxIeSettlement, ZxPhhd, ZxPhrec, ZxIeReview
|
||||
from log import HOSTNAME
|
||||
from photo_review import PHHD_BATCH_SIZE, SLEEP_MINUTES, HOSPITAL_ALIAS, HOSPITAL_FILTER, DEPARTMENT_ALIAS, \
|
||||
DEPARTMENT_FILTER
|
||||
@@ -390,6 +390,7 @@ def settlement_task(pk_phhd, settlement_list, identity):
|
||||
settlement_data["medical_expenses_str"] = handle_original_data(parse_money_result[0])
|
||||
settlement_data["medical_expenses"] = parse_money_result[1]
|
||||
save_or_update_ie(ZxIeSettlement, pk_phhd, settlement_data)
|
||||
return settlement_data
|
||||
|
||||
|
||||
def discharge_task(pk_phhd, discharge_record, identity):
|
||||
@@ -462,6 +463,7 @@ def discharge_task(pk_phhd, discharge_record, identity):
|
||||
if best_match:
|
||||
discharge_data["pk_ylks"] = best_match[2]
|
||||
save_or_update_ie(ZxIeDischarge, pk_phhd, discharge_data)
|
||||
return discharge_data
|
||||
|
||||
|
||||
def cost_task(pk_phhd, cost_list, identity):
|
||||
@@ -477,9 +479,10 @@ def cost_task(pk_phhd, cost_list, identity):
|
||||
cost_data["discharge_date"] = handle_date(cost_data["discharge_date_str"])
|
||||
cost_data["medical_expenses"] = handle_decimal(cost_data["medical_expenses_str"])
|
||||
save_or_update_ie(ZxIeCost, pk_phhd, cost_data)
|
||||
return cost_data
|
||||
|
||||
|
||||
def photo_review(pk_phhd):
|
||||
def photo_review(pk_phhd, name):
|
||||
settlement_list = []
|
||||
discharge_record = []
|
||||
cost_list = []
|
||||
@@ -499,15 +502,80 @@ def photo_review(pk_phhd):
|
||||
|
||||
# 同一批图的标识
|
||||
identity = int(time.time())
|
||||
settlement_task(pk_phhd, settlement_list, identity)
|
||||
discharge_task(pk_phhd, discharge_record, identity)
|
||||
cost_task(pk_phhd, cost_list, identity)
|
||||
settlement_data = settlement_task(pk_phhd, settlement_list, identity)
|
||||
discharge_data = discharge_task(pk_phhd, discharge_record, identity)
|
||||
cost_data = cost_task(pk_phhd, cost_list, identity)
|
||||
|
||||
review_result = {
|
||||
'pk_phhd': pk_phhd,
|
||||
}
|
||||
# 三项资料完整性判断
|
||||
# 三项资料缺项判断
|
||||
if (settlement_data['personal_account_payment'] + settlement_data['personal_cash_payment']
|
||||
< settlement_data['medical_expenses']):
|
||||
review_result['has_settlement'] = True
|
||||
# TODO:出院记录和费用清单暂时没想好怎么判断
|
||||
review_result['has_discharge'] = True
|
||||
review_result['has_cost'] = True
|
||||
# 三项资料缺页判断
|
||||
# TODO:缺页需要对页码进行抽取,暂未训练相关模型
|
||||
review_result['full_page'] = True
|
||||
|
||||
if (review_result['has_settlement'] and review_result['has_discharge'] and review_result['has_cost']
|
||||
and review_result['full_page']):
|
||||
review_result['integrity'] = True
|
||||
|
||||
# 三项资料一致性判断
|
||||
# 姓名一致性
|
||||
unique_name = {settlement_data['name'], discharge_data['name'], cost_data['name']}
|
||||
if len(unique_name) == 1:
|
||||
review_result['name_match'] = '1' if name == settlement_data['name'] else '5'
|
||||
elif len(unique_name) == 2:
|
||||
if settlement_data['name'] != discharge_data['name'] and settlement_data['name'] != cost_data['name']:
|
||||
review_result['name_match'] = '2'
|
||||
elif discharge_data['name'] != settlement_data['name'] and discharge_data['name'] != cost_data['name']:
|
||||
review_result['name_match'] = '3'
|
||||
else:
|
||||
review_result['name_match'] = '4'
|
||||
else:
|
||||
review_result['name_match'] = '0'
|
||||
|
||||
# 住院日期一致性
|
||||
if (settlement_data['admission_date'] == discharge_data['admission_date']
|
||||
and settlement_data['discharge_date'] == discharge_data['discharge_date']):
|
||||
review_result['admission_date_match'] = '1'
|
||||
else:
|
||||
review_result['admission_date_match'] = '0'
|
||||
|
||||
# 出院日期一致性
|
||||
unique_discharge_date = {settlement_data['discharge_date'], discharge_data['discharge_date'],
|
||||
cost_data['discharge_date']}
|
||||
if len(unique_discharge_date) == 1:
|
||||
review_result['discharge_date_match'] = '1'
|
||||
elif len(unique_discharge_date) == 2:
|
||||
if (settlement_data['discharge_date'] != discharge_data['discharge_date']
|
||||
and settlement_data['discharge_date'] != cost_data['discharge_date']):
|
||||
review_result['discharge_date_match'] = '2'
|
||||
elif (discharge_data['discharge_date'] != settlement_data['discharge_date']
|
||||
and discharge_data['discharge_date'] != cost_data['discharge_date']):
|
||||
review_result['discharge_date_match'] = '3'
|
||||
else:
|
||||
review_result['discharge_date_match'] = '4'
|
||||
else:
|
||||
review_result['discharge_date_match'] = '0'
|
||||
|
||||
if (review_result['name_match'] == '1' and review_result['admission_date_match'] == '1'
|
||||
and review_result['discharge_date_match'] == '1'):
|
||||
review_result['consistency'] = True
|
||||
|
||||
review_result['success'] = review_result['integrity'] and review_result['consistency']
|
||||
save_or_update_ie(ZxIeReview, pk_phhd, review_result)
|
||||
|
||||
|
||||
def main():
|
||||
while 1:
|
||||
session = MysqlSession()
|
||||
phhds = (session.query(ZxPhhd.pk_phhd)
|
||||
phhds = (session.query(ZxPhhd.pk_phhd, ZxPhhd.cXm)
|
||||
.join(ZxPhrec, ZxPhhd.pk_phhd == ZxPhrec.pk_phhd, isouter=True)
|
||||
.filter(ZxPhhd.exsuccess_flag == "1")
|
||||
.filter(ZxPhrec.pk_phrec.isnot(None))
|
||||
@@ -524,7 +592,7 @@ def main():
|
||||
pk_phhd = phhd.pk_phhd
|
||||
logging.info(f"开始识别:{pk_phhd}")
|
||||
start_time = time.time()
|
||||
photo_review(pk_phhd)
|
||||
photo_review(pk_phhd, phhd.cXm)
|
||||
|
||||
# 识别完成更新标识
|
||||
session = MysqlSession()
|
||||
|
||||
Reference in New Issue
Block a user