修正细节错误

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 json
import logging import logging
import os import os
@@ -115,6 +116,14 @@ def information_extraction(phrec, pk_phhd):
:return:记录类型,信息抽取结果 :return:记录类型,信息抽取结果
""" """
img_path = common_util.get_processed_img_path(phrec.cfjaddress) 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): if image_util.is_photo(img_path):
book_img_path = model_util.det_book(img_path) # 识别文档区域并裁剪 book_img_path = model_util.det_book(img_path) # 识别文档区域并裁剪
dewarped_img_path = model_util.dewarp(book_img_path) # 去扭曲 dewarped_img_path = model_util.dewarp(book_img_path) # 去扭曲
@@ -433,9 +442,9 @@ def parse_pdf_text(settlement_text):
'医保类型', '住院号', '医保结算单号码'] '医保类型', '住院号', '医保结算单号码']
discharge_key = ['科室', '患者姓名', '入院日期', '出院日期', '住院号'] discharge_key = ['科室', '患者姓名', '入院日期', '出院日期', '住院号']
cost_key = ['患者姓名', '入院日期', '出院日期', '费用总额'] cost_key = ['患者姓名', '入院日期', '出院日期', '费用总额']
settlement_result = {key: results[key] for key in settlement_key if key in results} settlement_result = {key: copy.copy(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} discharge_result = {key: copy.copy(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} cost_result = {key: copy.copy(results[key]) for key in cost_key if key in results}
return settlement_result, discharge_result, cost_result return settlement_result, discharge_result, cost_result
@@ -452,7 +461,7 @@ def photo_review(pk_phhd, name):
session = MysqlSession() session = MysqlSession()
phrecs = session.query(ZxPhrec.pk_phrec, ZxPhrec.cRectype, ZxPhrec.cfjaddress).filter( phrecs = session.query(ZxPhrec.pk_phrec, ZxPhrec.cRectype, ZxPhrec.cfjaddress).filter(
ZxPhrec.pk_phhd == pk_phhd ZxPhrec.pk_phhd == pk_phhd
).order_by(ZxPhrec.cRectype).all() ).order_by(ZxPhrec.cRectype, ZxPhrec.rowno).all()
session.close() session.close()
# 同一批图的标识 # 同一批图的标识
@@ -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['personal_account_payment']) + float(settlement_data['personal_cash_payment'])
< float(settlement_data['medical_expenses']) < float(settlement_data['medical_expenses'])
) )
if has_pdf:
review_result['has_discharge'] &= discharge_text
# 三项资料缺页判断 # 三项资料缺页判断
page_description = [] page_description = []
if review_result['has_discharge']: 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') task_path='model/cost_list_model', layout_analysis=False, precision='fp16')
@app.route('/', methods=['POST']) @app.route('/', methods=['POST'], endpoint='cost')
@process_request @process_request
def main(): def main():
img_path = request.form.get('img_path') 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') task_path='model/discharge_record_model', layout_analysis=False, precision='fp16')
@app.route('/', methods=['POST']) @app.route('/', methods=['POST'], endpoint='discharge')
@process_request @process_request
def main(): def main():
img_path = request.form.get('img_path') 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') task_path='model/settlement_list_model', layout_analysis=False, precision='fp16')
@app.route('/', methods=['POST']) @app.route('/', methods=['POST'], endpoint='settlement')
@process_request @process_request
def main(): def main():
img_path = request.form.get('img_path') img_path = request.form.get('img_path')