Tighten lab item routing and dedupe rows

This commit is contained in:
2026-05-19 17:41:24 +08:00
parent b55112b457
commit 4909705a2d
5 changed files with 127 additions and 24 deletions

View File

@@ -79,6 +79,22 @@ def build_fixture(root):
"req_reason": "未知组合检测",
"sampled_dt": "2026-01-01 08:10:00",
},
{
"rptunitid": "161",
"rechkdt": "2026-01-01 10:15:00",
"reportid": "20260101-161-4",
"reporttype": "10",
"req_reason": "甲功七项(化学发光法)[复]",
"sampled_dt": "2026-01-01 08:15:00",
},
{
"rptunitid": "161",
"rechkdt": "2026-01-01 10:15:00",
"reportid": "20260101-161-4",
"reporttype": "10",
"req_reason": "甲功七项(化学发光法)[复]",
"sampled_dt": "2026-01-01 08:15:00",
},
]
for row in reports:
for header in REPORT_HEADERS:
@@ -90,6 +106,12 @@ def build_fixture(root):
[{"reportid": reports[0]["reportid"], "rpt_itemname": "谷草转氨酶", "result_str": "21"}],
[{"reportid": reports[1]["reportid"], "rpt_itemname": "B型前脑尿钠肽", "result_str": "57.20"}],
[{"reportid": reports[2]["reportid"], "rpt_itemname": "神秘检测项目", "result_str": "42"}],
[
{"reportid": reports[3]["reportid"], "rpt_itemname": "甲状腺球蛋白", "result_str": "6.02"},
],
[
{"reportid": reports[4]["reportid"], "rpt_itemname": "甲状腺球蛋白", "result_str": "6.02"},
],
]
detail_dir = root / "Tests_Detail_List" / patient_id
for report, rows in zip(reports, details):
@@ -114,10 +136,13 @@ def assert_dynamic_routing(workbook_path):
try:
liver_rows = rows_for(workbook["肝功"])
heart_rows = rows_for(workbook["心衰系列"])
immune_rows = rows_for(workbook["免疫系列"])
summary_text = "\n".join("\t".join(row) for row in rows_for(workbook["未检测到内容汇总"]))
liver_data = [row for row in liver_rows[1:] if row and row[0]]
heart_data = [row for row in heart_rows[1:] if row and row[0]]
tumor_data = [row for row in rows_for(workbook["各类肿瘤标志物"])[1:] if row and row[0]]
immune_data = [row for row in immune_rows[1:] if row and row[0]]
assert len(liver_data) == 1, liver_data
assert liver_data[0][3] == "肝功十项[复]_电解质五项[复]_肾功三项[复]"
@@ -132,6 +157,9 @@ def assert_dynamic_routing(workbook_path):
assert "神秘检测项目" in summary_text
assert "谷草转氨酶" not in summary_text
assert "B型前脑尿钠肽" not in summary_text
assert len(tumor_data) == 0, tumor_data
assert len(immune_data) == 1, immune_data
assert immune_data[0][3] == "甲功七项(化学发光法)[复]"
finally:
workbook.close()