@@ -1,4 +1,3 @@
|
|||||||
import concurrent.futures
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
@@ -291,10 +290,25 @@ def save_or_update_ie(table, pk_phhd, data):
|
|||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
|
|
||||||
def settlement_task(pk_phhd, settlement_list):
|
def photo_review(pk_phhd, task_flows):
|
||||||
settlement_list_ie_result = information_extraction(
|
settlement_list = []
|
||||||
Taskflow("information_extraction", schema=SETTLEMENT_LIST_SCHEMA, model="uie-x-base",
|
discharge_record = []
|
||||||
task_path="config/model/settlement_list_model", layout_analysis=LAYOUT_ANALYSIS), settlement_list)
|
cost_list = []
|
||||||
|
|
||||||
|
session = MysqlSession()
|
||||||
|
phrecs = session.query(ZxPhrec.pk_phrec, ZxPhrec.pk_phhd, ZxPhrec.cRectype, ZxPhrec.cfjaddress) \
|
||||||
|
.filter(ZxPhrec.pk_phhd == pk_phhd) \
|
||||||
|
.all()
|
||||||
|
session.close()
|
||||||
|
for phrec in phrecs:
|
||||||
|
if phrec.cRectype == "1":
|
||||||
|
settlement_list.append(phrec)
|
||||||
|
elif phrec.cRectype == "3":
|
||||||
|
discharge_record.append(phrec)
|
||||||
|
elif phrec.cRectype == "4":
|
||||||
|
cost_list.append(phrec)
|
||||||
|
|
||||||
|
settlement_list_ie_result = information_extraction(task_flows[0], settlement_list)
|
||||||
settlement_data = {
|
settlement_data = {
|
||||||
"pk_phhd": pk_phhd,
|
"pk_phhd": pk_phhd,
|
||||||
"name": handle_name(get_best_value_in_keys(settlement_list_ie_result, PATIENT_NAME)),
|
"name": handle_name(get_best_value_in_keys(settlement_list_ie_result, PATIENT_NAME)),
|
||||||
@@ -320,11 +334,7 @@ def settlement_task(pk_phhd, settlement_list):
|
|||||||
settlement_data["personal_funded_amount"] = handle_decimal(settlement_data["personal_funded_amount_str"])
|
settlement_data["personal_funded_amount"] = handle_decimal(settlement_data["personal_funded_amount_str"])
|
||||||
save_or_update_ie(ZxIeSettlement, pk_phhd, settlement_data)
|
save_or_update_ie(ZxIeSettlement, pk_phhd, settlement_data)
|
||||||
|
|
||||||
|
discharge_record_ie_result = information_extraction(task_flows[1], discharge_record)
|
||||||
def discharge_task(pk_phhd, discharge_record):
|
|
||||||
discharge_record_ie_result = information_extraction(
|
|
||||||
Taskflow("information_extraction", schema=DISCHARGE_RECORD_SCHEMA, model="uie-x-base",
|
|
||||||
task_path="config/model/discharge_record_model", layout_analysis=LAYOUT_ANALYSIS), discharge_record)
|
|
||||||
discharge_data = {
|
discharge_data = {
|
||||||
"pk_phhd": pk_phhd,
|
"pk_phhd": pk_phhd,
|
||||||
"hospital": handle_hospital(get_best_value_in_keys(discharge_record_ie_result, HOSPITAL)),
|
"hospital": handle_hospital(get_best_value_in_keys(discharge_record_ie_result, HOSPITAL)),
|
||||||
@@ -361,11 +371,7 @@ def discharge_task(pk_phhd, discharge_record):
|
|||||||
discharge_data["department"] = ylks.name
|
discharge_data["department"] = ylks.name
|
||||||
save_or_update_ie(ZxIeDischarge, pk_phhd, discharge_data)
|
save_or_update_ie(ZxIeDischarge, pk_phhd, discharge_data)
|
||||||
|
|
||||||
|
cost_list_ie_result = information_extraction(task_flows[2], cost_list)
|
||||||
def cost_task(pk_phhd, cost_list):
|
|
||||||
cost_list_ie_result = information_extraction(
|
|
||||||
Taskflow("information_extraction", schema=COST_LIST_SCHEMA, model="uie-x-base",
|
|
||||||
task_path="config/model/cost_list_model", layout_analysis=LAYOUT_ANALYSIS), cost_list)
|
|
||||||
cost_data = {
|
cost_data = {
|
||||||
"pk_phhd": pk_phhd,
|
"pk_phhd": pk_phhd,
|
||||||
"name": handle_name(get_best_value_in_keys(cost_list_ie_result, PATIENT_NAME)),
|
"name": handle_name(get_best_value_in_keys(cost_list_ie_result, PATIENT_NAME)),
|
||||||
@@ -379,30 +385,6 @@ def cost_task(pk_phhd, cost_list):
|
|||||||
save_or_update_ie(ZxIeCost, pk_phhd, cost_data)
|
save_or_update_ie(ZxIeCost, pk_phhd, cost_data)
|
||||||
|
|
||||||
|
|
||||||
def photo_review(pk_phhd):
|
|
||||||
settlement_list = []
|
|
||||||
discharge_record = []
|
|
||||||
cost_list = []
|
|
||||||
|
|
||||||
session = MysqlSession()
|
|
||||||
phrecs = session.query(ZxPhrec.pk_phrec, ZxPhrec.pk_phhd, ZxPhrec.cRectype, ZxPhrec.cfjaddress) \
|
|
||||||
.filter(ZxPhrec.pk_phhd == pk_phhd) \
|
|
||||||
.all()
|
|
||||||
session.close()
|
|
||||||
for phrec in phrecs:
|
|
||||||
if phrec.cRectype == "1":
|
|
||||||
settlement_list.append(phrec)
|
|
||||||
elif phrec.cRectype == "3":
|
|
||||||
discharge_record.append(phrec)
|
|
||||||
elif phrec.cRectype == "4":
|
|
||||||
cost_list.append(phrec)
|
|
||||||
|
|
||||||
with concurrent.futures.ProcessPoolExecutor() as executor:
|
|
||||||
executor.submit(settlement_task, pk_phhd, settlement_list)
|
|
||||||
executor.submit(discharge_task, pk_phhd, discharge_record)
|
|
||||||
executor.submit(cost_task, pk_phhd, cost_list)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# 持续检测新案子
|
# 持续检测新案子
|
||||||
while 1:
|
while 1:
|
||||||
@@ -411,10 +393,18 @@ def main():
|
|||||||
phhds = session.query(ZxPhhd.pk_phhd).filter(ZxPhhd.exsuccess_flag == '1').limit(PHHD_BATCH_SIZE).all()
|
phhds = session.query(ZxPhhd.pk_phhd).filter(ZxPhhd.exsuccess_flag == '1').limit(PHHD_BATCH_SIZE).all()
|
||||||
session.close()
|
session.close()
|
||||||
if phhds:
|
if phhds:
|
||||||
|
ie_task_flows = [
|
||||||
|
Taskflow("information_extraction", schema=SETTLEMENT_LIST_SCHEMA, model="uie-x-base",
|
||||||
|
task_path="config/model/settlement_list_model", layout_analysis=LAYOUT_ANALYSIS),
|
||||||
|
Taskflow("information_extraction", schema=DISCHARGE_RECORD_SCHEMA, model="uie-x-base",
|
||||||
|
task_path="config/model/discharge_record_model", layout_analysis=LAYOUT_ANALYSIS),
|
||||||
|
Taskflow("information_extraction", schema=COST_LIST_SCHEMA, model="uie-x-base",
|
||||||
|
task_path="config/model/cost_list_model", layout_analysis=LAYOUT_ANALYSIS),
|
||||||
|
]
|
||||||
for phhd in phhds:
|
for phhd in phhds:
|
||||||
pk_phhd = phhd.pk_phhd
|
pk_phhd = phhd.pk_phhd
|
||||||
logging.info(f"开始识别:{pk_phhd}")
|
logging.info(f"开始识别:{pk_phhd}")
|
||||||
photo_review(pk_phhd)
|
photo_review(pk_phhd, ie_task_flows)
|
||||||
|
|
||||||
# 识别完成更新标识
|
# 识别完成更新标识
|
||||||
session = MysqlSession()
|
session = MysqlSession()
|
||||||
|
|||||||
Reference in New Issue
Block a user