From d897bf089fb8af87de066204c7ca6a5c6a2d31e6 Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Wed, 14 Aug 2024 10:35:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=BB=E9=99=A2=E5=90=8D?= =?UTF-8?q?=E7=9A=84=E5=88=86=E6=9E=90=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_review/photo_review.py | 15 +++++++++------ util/data_util.py | 13 +++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/photo_review/photo_review.py b/photo_review/photo_review.py index bbb31a3..3aa4ba1 100644 --- a/photo_review/photo_review.py +++ b/photo_review/photo_review.py @@ -19,7 +19,8 @@ from photo_review import PATIENT_NAME, ADMISSION_DATE, DISCHARGE_DATE, MEDICAL_E from ucloud import ufile from util import image_util, util from util.data_util import handle_date, handle_decimal, parse_department, handle_name, \ - handle_insurance_type, handle_original_data, handle_hospital, handle_department, handle_id, handle_age, parse_money + handle_insurance_type, handle_original_data, handle_hospital, handle_department, handle_id, handle_age, parse_money, \ + parse_hospital # 合并信息抽取结果 @@ -242,11 +243,13 @@ def discharge_task(pk_phhd, discharge_record, identity): if hospitals: hospital_like_conditions = [] for hospital in hospitals: - if hospital in HOSPITAL_ALIAS: - for hospital_alias in HOSPITAL_ALIAS[hospital]: - hospital_like_conditions.append(BdYljg.name.like(f'%{hospital_alias}%')) - else: - hospital_like_conditions.append(BdYljg.name.like(f'%{hospital}%')) + parsed_hospitals = parse_hospital(hospital) + for parsed_hospital in parsed_hospitals: + if parsed_hospital in HOSPITAL_ALIAS: + for hospital_alias in HOSPITAL_ALIAS[parsed_hospital]: + hospital_like_conditions.append(BdYljg.name.like(f'%{hospital_alias}%')) + else: + hospital_like_conditions.append(BdYljg.name.like(f'%{parsed_hospital}%')) session = MysqlSession() yljg = session.query(BdYljg.pk_yljg, BdYljg.name).filter(or_(*hospital_like_conditions)).limit(1).one_or_none() session.close() diff --git a/util/data_util.py b/util/data_util.py index 94b2b36..bb9ad6c 100644 --- a/util/data_util.py +++ b/util/data_util.py @@ -173,3 +173,16 @@ def handle_age(string): string = string.split("岁")[0] num = re.sub(r'\D', '', string) return num[-3:] + + +# 分析医院 +def parse_hospital(string): + result = [] + if not string: + return result + + string_without_brackets = string.replace(")", "").replace(")", "").replace("(", " ").replace("(", " ") + string_without_company = string_without_brackets.replace("有限公司", "") + simple_chinese_string = string_without_company.replace("醫", "医") + result += simple_chinese_string.split(" ") + return result