From 0060c4ad59f1d56cb156618599f7def830a38fba Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Thu, 17 Oct 2024 10:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=BB=86=E8=8A=82=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_review/auto_photo_review.py | 26 +++++++++++++++++------ services/paddle_services/ie_cost.py | 2 +- services/paddle_services/ie_discharge.py | 2 +- services/paddle_services/ie_settlement.py | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/photo_review/auto_photo_review.py b/photo_review/auto_photo_review.py index a0ee475..4ed9d17 100644 --- a/photo_review/auto_photo_review.py +++ b/photo_review/auto_photo_review.py @@ -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']: diff --git a/services/paddle_services/ie_cost.py b/services/paddle_services/ie_cost.py index fce2ef8..9a07bf6 100644 --- a/services/paddle_services/ie_cost.py +++ b/services/paddle_services/ie_cost.py @@ -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') diff --git a/services/paddle_services/ie_discharge.py b/services/paddle_services/ie_discharge.py index 6768d83..e0b6e46 100644 --- a/services/paddle_services/ie_discharge.py +++ b/services/paddle_services/ie_discharge.py @@ -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') diff --git a/services/paddle_services/ie_settlement.py b/services/paddle_services/ie_settlement.py index f800c08..266984a 100644 --- a/services/paddle_services/ie_settlement.py +++ b/services/paddle_services/ie_settlement.py @@ -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')