diff --git a/forms/forms106.py b/forms/forms106.py index 014a43329d..6233c53e83 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 + 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 = "" + if new_result: + result = [new_result] + + return result 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 { 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"},