修正细节错误

This commit is contained in:
2024-10-17 10:38:29 +08:00
parent d374e0743a
commit 0060c4ad59
4 changed files with 22 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import copy
import json
import logging
import os
@@ -115,6 +116,14 @@ def information_extraction(phrec, pk_phhd):
:return:记录类型,信息抽取结果
"""
img_path = common_util.get_processed_img_path(phrec.cfjaddress)
if not os.path.exists(img_path):
original_img_path = common_util.get_img_path(phrec.cfjaddress)
if not original_img_path:
img_url = ufile.get_private_url(phrec.cfjaddress)
if not img_url:
return None, None, None
original_img_path = common_util.save_to_local(img_url)
shutil.copy2(original_img_path, img_path)
if image_util.is_photo(img_path):
book_img_path = model_util.det_book(img_path) # 识别文档区域并裁剪
dewarped_img_path = model_util.dewarp(book_img_path) # 去扭曲
@@ -433,9 +442,9 @@ def parse_pdf_text(settlement_text):
'医保类型', '住院号', '医保结算单号码']
discharge_key = ['科室', '患者姓名', '入院日期', '出院日期', '住院号']
cost_key = ['患者姓名', '入院日期', '出院日期', '费用总额']
settlement_result = {key: results[key] for key in settlement_key if key in results}
discharge_result = {key: results[key] for key in discharge_key if key in results}
cost_result = {key: results[key] for key in cost_key if key in results}
settlement_result = {key: copy.copy(results[key]) for key in settlement_key if key in results}
discharge_result = {key: copy.copy(results[key]) for key in discharge_key if key in results}
cost_result = {key: copy.copy(results[key]) for key in cost_key if key in results}
return settlement_result, discharge_result, cost_result
@@ -452,7 +461,7 @@ def photo_review(pk_phhd, name):
session = MysqlSession()
phrecs = session.query(ZxPhrec.pk_phrec, ZxPhrec.cRectype, ZxPhrec.cfjaddress).filter(
ZxPhrec.pk_phhd == pk_phhd
).order_by(ZxPhrec.cRectype).all()
).order_by(ZxPhrec.cRectype, ZxPhrec.rowno).all()
session.close()
# 同一批图的标识
@@ -527,9 +536,9 @@ def photo_review(pk_phhd, name):
for key, value in ie_result.items():
rec_result[key].append(value)
# 删除多余图片
if os.path.exists(processed_img_dir) and os.path.isdir(processed_img_dir):
shutil.rmtree(processed_img_dir)
# 删除多余图片
if os.path.exists(processed_img_dir) and os.path.isdir(processed_img_dir):
shutil.rmtree(processed_img_dir)
settlement_data = settlement_task(pk_phhd, settlement_result)
discharge_data = discharge_task(pk_phhd, discharge_result)
@@ -549,6 +558,9 @@ def photo_review(pk_phhd, name):
float(settlement_data['personal_account_payment']) + float(settlement_data['personal_cash_payment'])
< float(settlement_data['medical_expenses'])
)
if has_pdf:
review_result['has_discharge'] &= discharge_text
# 三项资料缺页判断
page_description = []
if review_result['has_discharge']:

View File

@@ -16,7 +16,7 @@ COST = Taskflow('information_extraction', schema=COST_LIST_SCHEMA, model='uie-x-
task_path='model/cost_list_model', layout_analysis=False, precision='fp16')
@app.route('/', methods=['POST'])
@app.route('/', methods=['POST'], endpoint='cost')
@process_request
def main():
img_path = request.form.get('img_path')

View File

@@ -16,7 +16,7 @@ DISCHARGE = Taskflow('information_extraction', schema=DISCHARGE_RECORD_SCHEMA, m
task_path='model/discharge_record_model', layout_analysis=False, precision='fp16')
@app.route('/', methods=['POST'])
@app.route('/', methods=['POST'], endpoint='discharge')
@process_request
def main():
img_path = request.form.get('img_path')

View File

@@ -18,7 +18,7 @@ SETTLEMENT_IE = Taskflow('information_extraction', schema=SETTLEMENT_LIST_SCHEMA
task_path='model/settlement_list_model', layout_analysis=False, precision='fp16')
@app.route('/', methods=['POST'])
@app.route('/', methods=['POST'], endpoint='settlement')
@process_request
def main():
img_path = request.form.get('img_path')