From cafefde842199b28d4ed3592d5b8f405ffc4aa43 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Wed, 18 Dec 2024 13:03:58 +0800 Subject: [PATCH 1/2] table for any simple protocol --- results/prepare_data.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/results/prepare_data.py b/results/prepare_data.py index 3869473e14..38e23c7525 100644 --- a/results/prepare_data.py +++ b/results/prepare_data.py @@ -1010,15 +1010,27 @@ def table_part_result(value, width_max_table=None): opinion = [[Paragraph(f"{t}", style) for t in table_titles]] table_rows = value['rows'] + space_symbol = " " for t in table_rows: temp_data = [] for value_raw in t: result = "" + result_mkb_code = "" + result_mkb_title = "" + clinic_diag_text = "" + is_diag_table = False try: row_data = json.loads(value_raw) if isinstance(row_data, list): result = '
'.join(row_data) + elif isinstance(row_data, dict): + if row_data.get("code", None): + result_mkb_code = f"{row_data.get('code')}" + if row_data.get("title", None): + result_mkb_title = f"{row_data.get('title')}" + result = f"{result_mkb_title}; {clinic_diag_text}" + is_diag_table = True else: if row_data.get('fio', None): result = f"{row_data.get('family')} {row_data.get('name')} {row_data.get('patronymic')}" @@ -1028,7 +1040,11 @@ def table_part_result(value, width_max_table=None): result = f"{result} ({position})" except: result = value_raw - temp_data.append(Paragraph(f"{result}", style)) + if is_diag_table: + temp_data.append([Paragraph(f"{result}", style), Paragraph(f"код по МКБ {space_symbol * 3}{result_mkb_code}", style)]) + temp_data.append([Paragraph("", style), Paragraph("", style)]) + else: + temp_data.append(Paragraph(f"{result}", style)) opinion.append(temp_data) table_width = [] From f5b6a44b63306326d5171fd4f69729b075cb328f Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Wed, 18 Dec 2024 13:27:51 +0800 Subject: [PATCH 2/2] table for any simple protocol --- results/prepare_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/results/prepare_data.py b/results/prepare_data.py index 38e23c7525..c06b27b3d4 100644 --- a/results/prepare_data.py +++ b/results/prepare_data.py @@ -1025,6 +1025,7 @@ def table_part_result(value, width_max_table=None): if isinstance(row_data, list): result = '
'.join(row_data) elif isinstance(row_data, dict): + temp_data = [] if row_data.get("code", None): result_mkb_code = f"{row_data.get('code')}" if row_data.get("title", None): @@ -1040,9 +1041,8 @@ def table_part_result(value, width_max_table=None): result = f"{result} ({position})" except: result = value_raw - if is_diag_table: + if is_diag_table and result: temp_data.append([Paragraph(f"{result}", style), Paragraph(f"код по МКБ {space_symbol * 3}{result_mkb_code}", style)]) - temp_data.append([Paragraph("", style), Paragraph("", style)]) else: temp_data.append(Paragraph(f"{result}", style)) opinion.append(temp_data)