From 84c8b16349e30ddc2a3703810ad26f0a50b62bd0 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Fri, 6 Dec 2024 10:20:52 +0800 Subject: [PATCH 1/4] fix diag_print --- forms/forms106.py | 40 +++++++++++++++++++ ...template_federal_order_530_titul_page.json | 8 ++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index 014a43329d..d9ba3029c7 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1330,5 +1330,45 @@ def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles difference = len(cda_titles_sec) - len(data_cda) if len(data_cda) < len(cda_titles_sec): data_cda = [*data_cda, *["" for count in range(difference)]] + data_cda = check_diagnos_row_is_dict(data_cda) + objs.append(Paragraph(section.get("text").format(*data_cda), styles_obj[section.get("style")])) return objs + + +def check_diagnos_row_is_dict(data_cda): + result = data_cda + new_result = "" + field_json = {} + if len(data_cda) > 0: + try: + field_json = json.loads(data_cda[0]) + is_dict = True + except: + is_dict = False + if is_dict and not field_json.get('columns'): + code = field_json.get("code") + title = field_json.get("title") + new_result = f"{title}, код по МКБ {code}" + elif is_dict and field_json.get('columns'): + new_result = "" + rows_data = field_json.get("rows") + for r_data in rows_data: + for current_diag in r_data: + diag_data = {} + try: + diag_data = json.loads(current_diag) + is_dict = True + except: + is_dict = False + if is_dict and diag_data.get('code'): + title = diag_data.get("title") + code = diag_data.get("code") + new_result = f"{new_result}{title}, код по МКБ {code}
" + if new_result: + result = [new_result] + + return result + + + diff --git a/forms/pdf_templates/template_federal_order_530_titul_page.json b/forms/pdf_templates/template_federal_order_530_titul_page.json index e3748070f1..e8a94a5a16 100644 --- a/forms/pdf_templates/template_federal_order_530_titul_page.json +++ b/forms/pdf_templates/template_federal_order_530_titul_page.json @@ -31,13 +31,15 @@ {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Дата и время установления диагноза при поступлении: {} время: {}", "cdaTitles": ["п.п.-Дата предв. Ds", "п.п.-Время предв. Ds"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, - {"text": "Основное заболевание: {} код по МКБ: {}", "cdaTitles": ["п.п.-Основное Ds текст", "п.п.-Основное Ds мкб"], "style": "style"}, + {"text": "Основное заболевание: {}", "cdaTitles": [ "п.п.-Основное Ds мкб"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, - {"text": "Осложнения основного заболевания: {} код по МКБ: {}", "cdaTitles": ["п.п.-Осложнения Ds текст", "п.п.-Осложнения Ds мкб"], "style": "style"}, + {"text": "Осложнения основного заболевания: {}", "cdaTitles": ["п.п.-Пусто"], "style": "style"}, + {"text": "{}", "cdaTitles": ["п.п.-Осложнения Ds мкб"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Внешняя причина при травмах, отравлениях: {} код по МКБ: {}", "cdaTitles": ["п.п.-Внешняя причина Ds текст", "п.п.-Внешняя причина Ds мкб" ], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, - {"text": "Сопутствующие заболевания: {} код по МКБ: {}", "cdaTitles": ["п.п.-Сопутствующие Ds текс", "п.п.-Сопутствующие Ds мкб"], "style": "style"}, + {"text": "Сопутствующие заболевания: {}", "cdaTitles": ["п.п.-Пусто"], "style": "style"}, + {"text": "{}", "cdaTitles": ["п.п.-Сопутствующие Ds мкб"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Дополнительные сведения о заболевании: {}", "cdaTitles": ["п.п.-Дополнительные сведения заболевания"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, From 6e99841962ddb0e11a4109edaadadf847579fa0e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:24:28 +0800 Subject: [PATCH 2/4] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index d9ba3029c7..e834572785 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1369,6 +1369,3 @@ def check_diagnos_row_is_dict(data_cda): result = [new_result] return result - - - From 2100b9c85d011fd5ee9f3caf9aeaa5aa4e1f8727 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Fri, 6 Dec 2024 10:30:27 +0800 Subject: [PATCH 3/4] fix type_field diag_print --- forms/forms106.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index d9ba3029c7..1c22e58966 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1346,25 +1346,28 @@ def check_diagnos_row_is_dict(data_cda): is_dict = True except: is_dict = False - if is_dict and not field_json.get('columns'): - code = field_json.get("code") - title = field_json.get("title") - new_result = f"{title}, код по МКБ {code}" - elif is_dict and field_json.get('columns'): + try: + if is_dict and not field_json.get('columns'): + code = field_json.get("code") + title = field_json.get("title") + new_result = f"{title}, код по МКБ {code}" + elif is_dict and field_json.get('columns'): + new_result = "" + rows_data = field_json.get("rows") + for r_data in rows_data: + for current_diag in r_data: + diag_data = {} + try: + diag_data = json.loads(current_diag) + is_dict = True + except: + is_dict = False + if is_dict and diag_data.get('code'): + title = diag_data.get("title") + code = diag_data.get("code") + new_result = f"{new_result}{title}, код по МКБ {code}
" + except: new_result = "" - rows_data = field_json.get("rows") - for r_data in rows_data: - for current_diag in r_data: - diag_data = {} - try: - diag_data = json.loads(current_diag) - is_dict = True - except: - is_dict = False - if is_dict and diag_data.get('code'): - title = diag_data.get("title") - code = diag_data.get("code") - new_result = f"{new_result}{title}, код по МКБ {code}
" if new_result: result = [new_result] From 72aeddebf6f00779a20ebf86b3badf22ac39a1fe Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Fri, 6 Dec 2024 10:36:38 +0800 Subject: [PATCH 4/4] fix form 003 --- forms/forms_func.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/forms/forms_func.py b/forms/forms_func.py index 32c1ce7d5c..129c0ce052 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -458,22 +458,11 @@ def primary_reception_get_data(hosp_first_num, site_type=0): 'Время установления диагноза', 'Кому доверяю', ] - cda_dict_title = {} - result_by_cda = {} - if CDA_TITLES_FIELDS_PRIMARY_RESEARCH: - cda_ids_data = cda_data_by_title(tuple(CDA_TITLES_FIELDS_PRIMARY_RESEARCH)) - cda_ids = [i.id for i in cda_ids_data] - cda_dict_title = {i.id: i.title for i in cda_ids_data} - fields_data = get_title_fields_by_cda_relation(primary_research_id, tuple(cda_ids)) - titles_field = [i.title for i in fields_data] list_values = None if titles_field and hosp_primary_receptions: list_values = get_result_value_iss(hosp_primary_iss, primary_research_id, titles_field) - if CDA_TITLES_FIELDS_PRIMARY_RESEARCH: - result_by_cda = {cda_dict_title.get(value[4]): value[2] for value in list_values} - date_entered_value, time_entered_value, type_transport, medicament_allergy = '', '', '', '' who_directed, plan_hospital, extra_hospital, type_hospital = '', '', '', '' time_start_ill, diagnos_who_directed, diagnos_entered = '', '', '' @@ -694,7 +683,6 @@ def primary_reception_get_data(hosp_first_num, site_type=0): 'date_diagnosis': date_diagnosis, 'time_diagnosis': time_diagnosis, 'whom_transfer_health_data': whom_transfer_health_data, - 'result_by_cda': result_by_cda, } @@ -721,7 +709,7 @@ def primary_reception_get_data_by_cda(hosp_first_num, site_type=0): if titles_field and hosp_primary_receptions: list_values = get_result_value_iss(hosp_primary_iss, primary_research_id, titles_field) - if CDA_TITLES_FIELDS_PRIMARY_RESEARCH: + if CDA_TITLES_FIELDS_PRIMARY_RESEARCH and list_values: result_by_cda = {cda_dict_title.get(value[4]): value[2] for value in list_values} return {