From 835cb78e57cd4074463f9da185f767abd9f9e0e5 Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Tue, 9 Jul 2024 14:13:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=BB=E4=BF=9D=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_review/entity/zx_ie_settlement.py | 3 +- photo_review/photo_review.py | 3 +- photo_review/util/data_util.py | 39 +++++++++++++++++++------ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/photo_review/entity/zx_ie_settlement.py b/photo_review/entity/zx_ie_settlement.py index ce5eccc..59f3271 100644 --- a/photo_review/entity/zx_ie_settlement.py +++ b/photo_review/entity/zx_ie_settlement.py @@ -23,7 +23,8 @@ class ZxIeSettlement(Base): personal_account_payment = Column(DECIMAL(18, 2), comment='个人账户支付') personal_funded_amount_str = Column(String(255), comment='自费金额字符串') personal_funded_amount = Column(DECIMAL(18, 2), comment='自费金额') - medical_insurance_type = Column(String(255), comment='医保类型') + medical_insurance_type_str = Column(String(255), comment='医保类型字符串') + medical_insurance_type = Column(String(40), comment='医保类型') admission_id = Column(String(50), comment='住院号') settlement_id = Column(String(50), comment='医保结算单号码') create_time = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"), comment='创建时间') diff --git a/photo_review/photo_review.py b/photo_review/photo_review.py index f60eb0d..dd7222d 100644 --- a/photo_review/photo_review.py +++ b/photo_review/photo_review.py @@ -321,7 +321,7 @@ def settlement_task(pk_phhd, settlement_list): get_best_value_in_keys(settlement_list_ie_result, PERSONAL_ACCOUNT_PAYMENT)), "personal_funded_amount_str": handle_original_data( get_best_value_in_keys(settlement_list_ie_result, PERSONAL_FUNDED_AMOUNT)), - "medical_insurance_type": handle_insurance_type( + "medical_insurance_type_str": handle_original_data( get_best_value_in_keys(settlement_list_ie_result, MEDICAL_INSURANCE_TYPE)), "admission_id": handle_id(get_best_value_in_keys(settlement_list_ie_result, ADMISSION_ID)), "settlement_id": handle_id(get_best_value_in_keys(settlement_list_ie_result, SETTLEMENT_ID)), @@ -333,6 +333,7 @@ def settlement_task(pk_phhd, settlement_list): settlement_data["personal_cash_payment"] = handle_decimal(settlement_data["personal_cash_payment_str"]) settlement_data["personal_account_payment"] = handle_decimal(settlement_data["personal_account_payment_str"]) settlement_data["personal_funded_amount"] = handle_decimal(settlement_data["personal_funded_amount_str"]) + settlement_data["medical_insurance_type"] = handle_insurance_type(settlement_data["medical_insurance_type_str"]) save_or_update_ie(ZxIeSettlement, pk_phhd, settlement_data) diff --git a/photo_review/util/data_util.py b/photo_review/util/data_util.py index ed46ca2..754f5e4 100644 --- a/photo_review/util/data_util.py +++ b/photo_review/util/data_util.py @@ -85,16 +85,25 @@ def parse_department(string): result = [] if not string: return result - result.append(handle_department(string)) + string = re.sub(r'\([^()]*\)|\[[^\[\]]*\]|\{[^\{\}]*\}|([^()]*)|[^⺀-鿿]', '', string)[:255] + if string == "科": + return result + result.append(string) string_without_num = re.sub(r'\d|一|二|三|四|五|六|七|八|九|十', '', string) + if string == "科": + return result if string_without_num != string: - result.append(handle_department(string_without_num)) - string_without_brackets = re.sub(r'\([^()]*\)|\[[^\[\]]*\]|\{[^\{\}]*\}|([^()]*)', "", string_without_num) - if string_without_brackets != string_without_num: - result.append(handle_department(string_without_brackets)) - pure_string = string_without_brackets.split("科")[0] + "科" - if pure_string != string_without_brackets: - result.append(handle_department(pure_string)) + result.append(string_without_num) + pure_string = string_without_num.split("科")[0] + "科" + if string == "科": + return result + if pure_string != string_without_num: + result.append(pure_string) + pure_string_without_io = pure_string.replace("内", "").replace("外", "") + if string == "科": + return result + if pure_string_without_io != pure_string: + result.append(pure_string) return result @@ -109,7 +118,19 @@ def handle_name(string): def handle_insurance_type(string): if not string: return "" - return string.replace(":", "").replace(":", "")[:255] + worker_insurance_keys = ["社保", "城保", "职"] + villager_insurance_keys = ["农保", "居民"] + migrant_worker_insurance_keys = ["农民工"] + no_insurance_keys = ["自费", "全费"] + if any(key in string for key in worker_insurance_keys): + return "职工医保" + if any(key in string for key in villager_insurance_keys): + return "居民医保" + if any(key in string for key in migrant_worker_insurance_keys): + return "农民工医保" + if any(key in string for key in no_insurance_keys): + return "无医保" + return "" # 处理原始数据