diff --git a/results/prepare_data.py b/results/prepare_data.py index 3869473e14..c06b27b3d4 100644 --- a/results/prepare_data.py +++ b/results/prepare_data.py @@ -1010,15 +1010,28 @@ 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): + temp_data = [] + 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 +1041,10 @@ 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 and result: + temp_data.append([Paragraph(f"{result}", style), Paragraph(f"код по МКБ {space_symbol * 3}{result_mkb_code}", style)]) + else: + temp_data.append(Paragraph(f"{result}", style)) opinion.append(temp_data) table_width = []