From a728d7de3db3949f370e504d35d2fab8da1b9b85 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sat, 30 Nov 2024 00:30:12 +0800 Subject: [PATCH 01/19] 530_Titul_from_tmalate --- api/stationar/sql_func.py | 20 +- external_system/models.py | 7 + external_system/sql_func.py | 17 + forms/forms106.py | 306 +++++++++++++++++- forms/forms_func.py | 23 +- ...template_federal_order_530_titul_page.json | 77 +++++ laboratory/settings.py | 1 + 7 files changed, 443 insertions(+), 8 deletions(-) create mode 100644 forms/pdf_templates/template_federal_order_530_titul_page.json diff --git a/api/stationar/sql_func.py b/api/stationar/sql_func.py index 1f7d2446f1..172d892947 100644 --- a/api/stationar/sql_func.py +++ b/api/stationar/sql_func.py @@ -171,15 +171,13 @@ def get_result_value_iss(iss_pk, research_pk, titles_field): cursor.execute( """ WITH - t_field AS (SELECT "id", title FROM directory_paraclinicinputfield + t_field AS (SELECT "id", title, cda_option_id FROM directory_paraclinicinputfield WHERE group_id in (SELECT "id" FROM directory_paraclinicinputgroups WHERE research_id=%(id_research)s) AND title = ANY(ARRAY[%(titles_field)s])) - SELECT field_id, issledovaniye_id, "value", title FROM public.directions_paraclinicresult + SELECT field_id, issledovaniye_id, "value", title, cda_option_id FROM public.directions_paraclinicresult LEFT JOIN t_field ON directions_paraclinicresult.field_id = t_field.id where field_id in (SELECT "id" FROM t_field) and issledovaniye_id = %(id_iss)s - - """, params={'id_iss': iss_pk, 'id_research': research_pk, 'titles_field': titles_field}, ) @@ -247,3 +245,17 @@ def get_assignments_by_history(history_id: int): ) rows = namedtuplefetchall(cursor) return rows + + +def get_title_fields_by_cda_relation(id_research, cda_id_field): + with connection.cursor() as cursor: + cursor.execute( + """ + SELECT "id", title, cda_option_id FROM directory_paraclinicinputfield + WHERE group_id in (SELECT "id" FROM directory_paraclinicinputgroups WHERE research_id=%(id_research)s) + AND directory_paraclinicinputfield.cda_option_id IN %(cda_option)s + """, + params={"id_research": id_research, 'cda_option': cda_id_field}, + ) + rows = namedtuplefetchall(cursor) + return rows \ No newline at end of file diff --git a/external_system/models.py b/external_system/models.py index 94a1adf759..80367bb502 100644 --- a/external_system/models.py +++ b/external_system/models.py @@ -109,7 +109,14 @@ def get_cda_params(is_doc_refferal, is_treatment, is_form, is_extract): result = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": f"{x.title} - {x.code}"} for x in CdaFields.objects.filter(is_form=True).order_by("title")]] elif is_extract: result = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": f"{x.title} - {x.code}"} for x in CdaFields.objects.filter(is_extract=True).order_by("title")]] + else: + result = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": f"{x.title} - {x.code}"} for x in CdaFields.objects.filter(is_doc_refferal=True).order_by("title")]] + + return result + @staticmethod + def get_cda_id_by_titles(cda_titles): + result = CdaFields.objects.filter(title__in=cda_titles) return result diff --git a/external_system/sql_func.py b/external_system/sql_func.py index 0caec0b7b9..acf14e68a6 100644 --- a/external_system/sql_func.py +++ b/external_system/sql_func.py @@ -29,3 +29,20 @@ def get_nsi_code_fsidi(method): ) rows = namedtuplefetchall(cursor) return rows + + +def cda_data_by_title(cda_title): + with connection.cursor() as cursor: + cursor.execute( + """ + SELECT + id, + title + from external_system_cdafields + where title in %(cda_title)s + """, + params={'cda_title': cda_title}, + ) + rows = namedtuplefetchall(cursor) + return rows + diff --git a/forms/forms106.py b/forms/forms106.py index d0fcf018b3..e015f34485 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -23,6 +23,8 @@ from api.sql_func import get_fraction_result from utils.dates import normalize_date from .forms_func import primary_reception_get_data, hosp_extract_get_data, hosp_get_clinical_diagnos, hosp_get_transfers_data, hosp_get_operation_data, closed_bl +from laboratory.settings import FONTS_FOLDER, BASE_DIR +import simplejson as json def form_01(request_data): @@ -560,7 +562,7 @@ def later_pages(canvas, document): return pdf -def form_02(request_data): +def form_03_1(request_data): """ Форма 003/у - cтационарная карта 530Н """ @@ -775,7 +777,7 @@ def form_02(request_data): Spacer(1, 0.5 * mm), Paragraph("Направлен в стационар (дневной стационар):", style), Spacer(1, 0.5 * mm), - Paragraph(f"Наименование медицинской организации, направившей пациента: {primary_reception_data['who_directed']}", style), + Paragraph(f"Наименование медицинской организации, направившей пациента: {primary_reception_data['who_directed']}", style), Spacer(1, 0.5 * mm), Paragraph(f"Номер и дата направления: {primary_reception_data['ext_direction_number']} от {number_direction} г.", style), Spacer(1, 0.5 * mm), @@ -983,3 +985,303 @@ def form_02(request_data): buffer.close() return pdf + + +def form_02(request_data): + """ + Форма 003/у - cтационарная карта 530Н + """ + + num_dir = request_data["dir_pk"] + direction_obj = Napravleniya.objects.get(pk=num_dir) + hosp_nums_obj = hosp_get_hosp_direction(num_dir) + hosp_nums = f"- {hosp_nums_obj[0].get('direction')}" + + ind_card = direction_obj.client + patient_data = ind_card.get_data_individual() + + hospital: Hospitals = request_data["hospital"] + + hospital_name = hospital.safe_short_title + hospital_address = hospital.safe_address + hospital_kod_ogrn = hospital.safe_ogrn + + if sys.platform == "win32": + locale.setlocale(locale.LC_ALL, "rus_rus") + else: + locale.setlocale(locale.LC_ALL, "ru_RU.UTF-8") + + pdfmetrics.registerFont(TTFont("PTAstraSerifBold", os.path.join(FONTS_FOLDER, "PTAstraSerif-Bold.ttf"))) + pdfmetrics.registerFont(TTFont("PTAstraSerifReg", os.path.join(FONTS_FOLDER, "PTAstraSerif-Regular.ttf"))) + pdfmetrics.registerFont(TTFont("Symbola", os.path.join(FONTS_FOLDER, "Symbola.ttf"))) + + buffer = BytesIO() + doc = SimpleDocTemplate(buffer, pagesize=A4, leftMargin=20 * mm, rightMargin=12 * mm, topMargin=5 * mm, bottomMargin=10 * mm, allowSplitting=1, title="Форма {}".format("003/у")) + width, height = portrait(A4) + styleSheet = getSampleStyleSheet() + style = styleSheet["Normal"] + style.fontName = "PTAstraSerifReg" + style.fontSize = 11 + style.leading = 12 + style.spaceAfter = 0.5 * mm + + styleLead = deepcopy(style) + styleLead.leading = 12 + styleLead.alignment = TA_JUSTIFY + + styleBold = deepcopy(style) + styleBold.fontName = "PTAstraSerifBold" + styleCenter = deepcopy(style) + styleCenter.alignment = TA_CENTER + styleCenter.fontSize = 12 + styleCenter.leading = 9 + styleCenter.spaceAfter = 1 * mm + styleCenterBold = deepcopy(styleBold) + styleCenterBold.alignment = TA_CENTER + styleCenterBold.fontSize = 7 + styleCenterBold.leading = 15 + styleCenterBold.face = "PTAstraSerifBold" + styleCenterBold.borderColor = black + styleJustified = deepcopy(style) + styleJustified.alignment = TA_JUSTIFY + styleJustified.spaceAfter = 4.5 * mm + styleJustified.fontSize = 12 + styleJustified.leading = 4.5 * mm + + styleRight = deepcopy(styleJustified) + styleRight.alignment = TA_RIGHT + + objs = [] + + styleT = deepcopy(style) + styleT.alignment = TA_LEFT + styleT.fontSize = 10 + styleT.leading = 4.5 * mm + styleT.face = "PTAstraSerifReg" + + print_district = "" + if SettingManager.get("district", default="True", default_type="b"): + if ind_card.district is not None: + print_district = "Уч: {}".format(ind_card.district.title) + + opinion = [ + [ + Paragraph("{}
Адрес: {}
ОГРН: {}
{}
".format(hospital_name, hospital_address, hospital_kod_ogrn, print_district), styleT), + Paragraph( + "Код формы по ОКУД:
" + "Медицинская документация
форма № 003/у

Утверждена приказом Министерства здравоохранения Российской Федерации от «5» августа 2022г. N 530н
", + styleT, + ), + ], + ] + + tbl = Table(opinion, 2 * [90 * mm]) + tbl.setStyle( + TableStyle( + [ + ("GRID", (0, 0), (-1, -1), 0.75, colors.white), + ("LEFTPADDING", (1, 0), (-1, -1), 80), + ("VALIGN", (0, 0), (-1, -1), "TOP"), + ] + ) + ) + + objs.append(tbl) + if patient_data["age"] < SettingManager.get("child_age_before", default="15", default_type="i"): + patient_data["serial"] = patient_data["bc_serial"] + patient_data["num"] = patient_data["bc_num"] + else: + patient_data["serial"] = patient_data["passport_serial"] + patient_data["num"] = patient_data["passport_num"] + + p_phone = "" + if patient_data["phone"]: + p_phone = "тел.: " + ", ".join(patient_data["phone"]) + + card_num_obj = patient_data["card_num"].split(" ") + p_card_num = card_num_obj[0] + + # взять самое последнее направленеие из hosp_dirs + hosp_last_num = hosp_nums_obj[-1].get("direction") + ############################################################################################################ + # Получение данных из выписки + # Взять услугу типа выписка. Из полей "Дата выписки" - взять дату. Из поля "Время выписки" взять время + hosp_extract_data = hosp_extract_get_data(hosp_last_num) + + extrac_date, extract_time, outcome = "", "", "" + days_count = "__________________________" + result_hospital = "" + if hosp_extract_data: + extrac_date = hosp_extract_data["date_value"] + extract_time = hosp_extract_data["time_value"] + days_count = hosp_extract_data["days_count"] + if hosp_extract_data["outcome"]: + outcome = hosp_extract_data["outcome"] + if hosp_extract_data["result_hospital"]: + result_hospital = hosp_extract_data["result_hospital"] + + # Получить отделение - из названия услуги или самого главного направления + first_bed_profile = hosp_nums_obj[0].get("research_title") + iss_first_depart = Issledovaniya.objects.get(pk=hosp_nums_obj[0].get("issledovaniye")) + first_hosp_depart = iss_first_depart.hospital_department_override.title if iss_first_depart.hospital_department_override else "" + + ############################################################################################################ + # Получить данные из первичного приема (самого первого hosp-направления) + hosp_first_num = hosp_nums_obj[0].get("direction") + primary_reception_data = primary_reception_get_data(hosp_first_num) + print(primary_reception_data.get('result_by_cda')) + + ########################################################################################################### + # Получение данных группы крови + fcaction_avo_id = Fractions.objects.filter(title="Групповая принадлежность крови по системе АВО").first() + fcaction_rezus_id = Fractions.objects.filter(title="Резус").first() + group_blood_avo = get_fraction_result(ind_card.pk, fcaction_avo_id.pk, count=1) + if group_blood_avo: + group_blood_avo_value = group_blood_avo[0][5] + else: + group_blood_avo_value = primary_reception_data["blood_group"] + + open_symbola = '' + close_symbola = "" + variants = { + "Oαβ (I)": f"O{open_symbola}\u03B1\u03B2{close_symbola}", + "Bα (III)": f"B{open_symbola}\u03B1{close_symbola} (III)", + "Aβ (II)": f"A{open_symbola}\u03B2{close_symbola}(II)", + "A₂β (II)": f"A₂{open_symbola}\u03B2{close_symbola}", + "AB₀ (IV)": f"AB{open_symbola}\u2070{close_symbola} (IV)", + "A₂B₀ (IV)": f"A₂B{open_symbola}\u2070{close_symbola}", + } + if variants.get(group_blood_avo_value): + group_blood_avo_value = variants.get(group_blood_avo_value) + + group_blood_rezus = get_fraction_result(ind_card.pk, fcaction_rezus_id.pk, count=1) + if group_blood_rezus: + group_rezus_value = group_blood_rezus[0][5].replace("
", " ") + else: + group_rezus_value = primary_reception_data["resus_factor"] + + ##################################################################################################### + # получить даные из переводного эпикриза: Дата перевода, Время перевода, в какое отделение переведен + # у каждого hosp-направления найти подчиненное эпикриз Перевод* + transfers_data = hosp_get_transfers_data(hosp_nums_obj) + transfers = "" + for i in transfers_data: + transfers = ( + f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']}
Дата и время перевода {i['date_transfer_value']} " + f"время:{i['time_transfer_value']};
" + ) + + plan_form = primary_reception_data["plan_hospital"] + extra_hospital = primary_reception_data["extra_hospital"] + result_form = "" + if plan_form.lower() == "да": + result_form = "плановая — 1" + if extra_hospital.lower() == "да": + result_form = "экстренная — 2" + number_direction = normalize_date(primary_reception_data["ext_direction_date"]) + bold_open = '' + bold_close = "" + title_page = [ + Indenter(left=0 * mm), + Spacer(1, 2 * mm), + Paragraph( + 'МЕДИЦИНСКАЯ КАРТА ПАЦИЕНТА,
ПОЛУЧАЮЩЕГО МЕДИЦННСКУЮ ПОМОЩЬ
В СТАЦИОНАРНЫХ УСЛОВНЯХ
№ {} {}
'.format( + p_card_num, hosp_nums + ), + styleCenterBold, + ), + Spacer(1, 2 * mm), + Paragraph(f"Фамилия, имя, отчество:  {patient_data['fio']}", style), + Spacer(1, 0.2 * mm), + Paragraph(f"Дата рождения: {patient_data['born']} Пол: {patient_data['sex']}", style), + Spacer(1, 0.5 * mm), + + Paragraph("Поступил в: стационар - 1", style), + Spacer(1, 0.5 * mm), + # Paragraph(f"Дата и время поступления: {primary_reception_data['date_entered_value']}, {primary_reception_data['time_entered_value']}", style), + # Spacer(1, 0.5 * mm), + # Paragraph(f"Поступил через {primary_reception_data['time_start_ill']} часов после начала заболевания, получения травмы, отравления.", style), + # Spacer(1, 0.5 * mm), + ] + current_template = SettingManager.get("template_federal_order_530_titul_page", default='', default_type='s') + objs.extend(title_page) + if not os.path.join( + BASE_DIR, + 'forms', + 'pdf_templates', + ): + current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") + else: + current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") + + if current_template_file: + with open(current_template_file) as json_file: + data = json.load(json_file) + body_paragraphs = data['body_paragraphs'] + + styleLead = deepcopy(style) + styleLead.leading = 12 + styleLead.alignment = TA_JUSTIFY + + styleBold = deepcopy(style) + styleBold.fontName = "PTAstraSerifBold" + styleCenter = deepcopy(style) + styleCenter.alignment = TA_CENTER + styleCenter.fontSize = 12 + styleCenter.leading = 9 + styleCenter.spaceAfter = 1 * mm + styleCenterBold = deepcopy(styleBold) + styleCenterBold.alignment = TA_CENTER + styleCenterBold.fontSize = 7 + styleCenterBold.leading = 15 + styleCenterBold.face = "PTAstraSerifBold" + styleCenterBold.borderColor = black + styleJustified = deepcopy(style) + styleJustified.alignment = TA_JUSTIFY + styleJustified.spaceAfter = 4.5 * mm + styleJustified.fontSize = 12 + styleJustified.leading = 4.5 * mm + + styleRight = deepcopy(styleJustified) + styleRight.alignment = TA_RIGHT + + styles_obj = { + "style": style, "styleCenter": styleCenter, "styleLead": styleLead, "styleBold": styleBold, "styleCenterBold": styleCenterBold, + "styleJustified": styleJustified, + "styleRight": styleRight + } + cdaTitles = {} + if current_template_file: + for section in body_paragraphs: + objs = check_section_param(objs, styles_obj, section, tbl, primary_reception_data.get('result_by_cda')) + + if primary_reception_data.get("weight"): + title_page.append(Paragraph(f"Вес: {primary_reception_data['weight']}", styleRight)) + + doc.build(objs) + pdf = buffer.getvalue() + buffer.close() + + return pdf + + +def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles): + space_symbol = ' ' + if section.get('Spacer'): + height_spacer = section.get('spacer_data') + objs.append(Spacer(1, height_spacer * mm)) + elif section.get('page_break'): + objs.append(PageBreak()) + elif section.get('specification'): + objs.append(tbl_specification) + elif section.get('text'): + cda_titles_sec = section.get('cdaTitles') + data_cda = [cda_titles.get(i) for i in cda_titles_sec if cda_titles.get(i)] + print(data_cda) + print(len(cda_titles_sec)) + if len(data_cda) < 1: + data_cda = ["" for count in range(len(cda_titles_sec))] + print(section.get('text')) + print(data_cda) + objs.append(Paragraph(section.get('text').format(*data_cda), styles_obj[section.get('style')])) + return objs diff --git a/forms/forms_func.py b/forms/forms_func.py index 81b3dc08a1..3c77ecfe72 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -9,11 +9,13 @@ from clients.models import Document, DispensaryReg, Card from directions.models import Napravleniya, Issledovaniya, ParaclinicResult, IstochnikiFinansirovaniya, PersonContract from directory.models import Researches +from external_system.models import CdaFields +from external_system.sql_func import cda_data_by_title from laboratory import utils -from laboratory.settings import MEDEXAM_FIN_SOURCE_TITLE +from laboratory.settings import MEDEXAM_FIN_SOURCE_TITLE, CDA_TITLES_FIELDS_PRIMARY_RESEARCH from laboratory.utils import strdate from api.stationar.stationar_func import hosp_get_data_direction, check_transfer_epicrisis -from api.stationar.sql_func import get_result_value_iss +from api.stationar.sql_func import get_result_value_iss, get_title_fields_by_cda_relation from utils.dates import normalize_date import json @@ -457,10 +459,26 @@ 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)) + print(cda_ids_data) + cda_ids = [i.id for i in cda_ids_data] + cda_dict_title = {i.id: i.title for i in cda_ids_data} + print(cda_ids) + + fields_data = get_title_fields_by_cda_relation(primary_research_id, tuple(cda_ids)) + print(fields_data) + 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 = '', '', '' @@ -681,6 +699,7 @@ 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 } diff --git a/forms/pdf_templates/template_federal_order_530_titul_page.json b/forms/pdf_templates/template_federal_order_530_titul_page.json new file mode 100644 index 0000000000..bae86c88cf --- /dev/null +++ b/forms/pdf_templates/template_federal_order_530_titul_page.json @@ -0,0 +1,77 @@ +{"header": [ + {"text": "МЕДИЦИНСКАЯ КАРТА ПАЦИЕНТА,", "style": "styleCenter"}, + {"text": "ПОЛУЧАЮЩЕГО МЕДИЦННСКУЮ ПОМОЩЬ", "style": "styleCenter"}, + {"text": "В СТАЦИОНАРНЫХ УСЛОВНЯХ, В УСЛОВИЯХ ДНЕВНОГО СТАЦИОНАРА", "style": "styleCenter"}, + {"text": "№","vars": "[p_card_num, hosp_nums]", "style": "styleCenter"} + ], +"body_paragraphs": [ + {"text": "Дата и время поступления: {} время: {}", "cdaTitles": ["п.п.-Дата поступления","п.п.-Время поступления"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Поступил через {} часов после начала заболевания, получения травмы, отравления", "cdaTitles": ["п.п.-Поступил через"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Направлен в стационар (дневной стационар): {}", "cdaTitles": ["п.п.-Тип направитель"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Наименование медицинской организации (фамилия, имя, отчество (при наличии) индивидуального предпринимателя, осуществляющего медицинскую деятельность), направившей пациента: {}", "cdaTitles": ["п.п.-Организация направитель"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Номер и дата направления: {} от {}", "cdaTitles": ["п.п.-Номер направления", "п.п.-Дата направления"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Поступил в стационар (дневной стационар) для оказания медицинской помощи в текущем году: по поводу основного заболевания, указанного в диагнозе при поступлении: {}", "cdaTitles": ["п.п.-Количество"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Форма оказания медицинской помощи: {}", "cdaTitles": ["п.п.-Форма помощи"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"tbl": "", "type": "Движение", "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Выписан: {} время: {}", "cdaTitles": ["в.э.-Дата выписки", "в.э.-Время выписки"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Количество дней нахождения в медицинской организации: {}", "cdaTitles": ["в.э.-Кол-во дней"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"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"}, + {"text": "Дата и время установления диагноза при поступлении: {} время: {}", "cdaTitles": ["п.п.-Дата предв. Ds", "п.п.-Время предв. 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": "", "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": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Дополнительные сведения о заболевании: {}", "cdaTitles": ["п.п.-Дополнительные сведения заболевания"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Проведенные оперативные вмешательства (операции):", "cdaTitles": [""], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"tbl": "", "type": "Операции", "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Исход госпитализации: {}", "cdaTitles": ["в.э.-Исход"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Наименование медицинской организации (фамилия, имя, отчество (при наличии) индивидуального предпринимателя, осуществляющего медицинскую деятельность), куда переведен пациент: {}", "cdaTitles": ["в.э.-Куда переведен"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Результат госпитализации: {}", "cdaTitles": ["в.э.-Результат"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Умер в: {} отделении {} время {}", "cdaTitles": ["в.э.-Умер отделение", "в.э.-Умер дата", "в.э.-Умер время"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Умерла беременная: {}", "cdaTitles": ["в.э.-Беременность срок"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Оформлен листок нетрудоспособности: N {} от {}", "cdaTitles": ["в.э.-ЭЛН Номер", "в.э.-ЭЛН дата" ], "style": "style"}, + {"text": "(дубликат листка нетрудоспособности N {} от {})", "cdaTitles": ["в.э.-дубликат ЭЛН Номер", "в.э.-дубликат ЭЛН дата" ], "style": "style"}, + {"text": "освобождение от работы с {} по {}", "cdaTitles": ["в.э.-ЭЛН с", "в.э.-ЭЛН по"], "style": "style"}, + {"text": "продление листка нетрудоспособности:", "cdaTitles": ["в.э.-ЭЛН с", "в.э.-ЭЛН по"], "style": "style"}, + {"text": "№{}освобождение от работы с {} по {}", "cdaTitles": ["в.э.-продление ЭЛН №", "в.э.-продление ЭЛН с", "в.э.-ЭЛН продление по"], "style": "style"}, + {"text": "приступить к работе с {}", "cdaTitles": ["в.э.-ЭЛН к работе"], "style": "style"}, + {"text": "Оформлен листок нетрудоспособности по уходу за больным членом семьи (фамилия, имя, отчество (при наличии): {}", "cdaTitles": ["в.э.-ЭЛН по уходу"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Выдано направление на медико-социальную экспертизу (МСЭ):{}", "cdaTitles": ["в.э.-МСЭ дата"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Сведения о лице, которому может быть передана информация о состоянии здоровья пациента:", "cdaTitles": [], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "фамилия, имя, отчество (при наличии), номер контактного телефона:{}", "cdaTitles": ["п.п.-Кому доверяю"], "style": "style"}, + {"text": "Дополнительные сведения о пациенте:{}", "cdaTitles": ["п.п.-Пациент доп сведения"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Фамилия, имя, отчество (при наличии) и должность лечащего врача, специальность: {}, {} подпись___________", "cdaTitles": ["в.э.-Врач ФИО", "в.э.-Врач специальность"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Фамилия, имя, отчество (при наличии) заведующего отделением: {} подпись___________", "cdaTitles": ["в.э.-Врач ФИО", "в.э.-Врач специальность"], "style": "style"} +] +} diff --git a/laboratory/settings.py b/laboratory/settings.py index 88dfc23526..5eb023bdfc 100644 --- a/laboratory/settings.py +++ b/laboratory/settings.py @@ -415,6 +415,7 @@ def __getitem__(self, item): FCM_CERT_PATH = "" PROMETHEUS_ENABLED = False USERS_PK_SHOW_FACT_ADDRESSES_025U = [] +CDA_TITLES_FIELDS_PRIMARY_RESEARCH = [] TYPE_NUMBER_SYSTEM = [] FTP_SETUP_TO_SEND_HL7_BY_RESEARCHES = { From a6fab03ed0ea00d3825b800afb6d8c99f68abbd8 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sat, 30 Nov 2024 00:31:48 +0800 Subject: [PATCH 02/19] fix --- forms/forms106.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index e015f34485..cb18f998ed 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1198,10 +1198,6 @@ def form_02(request_data): Paragraph("Поступил в: стационар - 1", style), Spacer(1, 0.5 * mm), - # Paragraph(f"Дата и время поступления: {primary_reception_data['date_entered_value']}, {primary_reception_data['time_entered_value']}", style), - # Spacer(1, 0.5 * mm), - # Paragraph(f"Поступил через {primary_reception_data['time_start_ill']} часов после начала заболевания, получения травмы, отравления.", style), - # Spacer(1, 0.5 * mm), ] current_template = SettingManager.get("template_federal_order_530_titul_page", default='', default_type='s') objs.extend(title_page) @@ -1250,7 +1246,6 @@ def form_02(request_data): "styleJustified": styleJustified, "styleRight": styleRight } - cdaTitles = {} if current_template_file: for section in body_paragraphs: objs = check_section_param(objs, styles_obj, section, tbl, primary_reception_data.get('result_by_cda')) @@ -1266,7 +1261,6 @@ def form_02(request_data): def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles): - space_symbol = ' ' if section.get('Spacer'): height_spacer = section.get('spacer_data') objs.append(Spacer(1, height_spacer * mm)) @@ -1277,11 +1271,7 @@ def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles elif section.get('text'): cda_titles_sec = section.get('cdaTitles') data_cda = [cda_titles.get(i) for i in cda_titles_sec if cda_titles.get(i)] - print(data_cda) - print(len(cda_titles_sec)) if len(data_cda) < 1: data_cda = ["" for count in range(len(cda_titles_sec))] - print(section.get('text')) - print(data_cda) objs.append(Paragraph(section.get('text').format(*data_cda), styles_obj[section.get('style')])) return objs From 8cdea0f881a6484b64b4ffd6cf6535c76f1a8ecd Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sat, 30 Nov 2024 00:34:12 +0800 Subject: [PATCH 03/19] fix --- forms/forms106.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index cb18f998ed..6c5a6b69bf 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1094,10 +1094,6 @@ def form_02(request_data): patient_data["serial"] = patient_data["passport_serial"] patient_data["num"] = patient_data["passport_num"] - p_phone = "" - if patient_data["phone"]: - p_phone = "тел.: " + ", ".join(patient_data["phone"]) - card_num_obj = patient_data["card_num"].split(" ") p_card_num = card_num_obj[0] From 0bf1ecb6f6a7cd0e04c637217ea8cad18959e72e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:52:51 +0800 Subject: [PATCH 04/19] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/forms106.py b/forms/forms106.py index 6c5a6b69bf..bd962c8514 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1240,7 +1240,7 @@ def form_02(request_data): styles_obj = { "style": style, "styleCenter": styleCenter, "styleLead": styleLead, "styleBold": styleBold, "styleCenterBold": styleCenterBold, "styleJustified": styleJustified, - "styleRight": styleRight + "styleRight": styleRight, } if current_template_file: for section in body_paragraphs: From 8acc1cb1aa7632477a9138dec608a10dafc62072 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:53:00 +0800 Subject: [PATCH 05/19] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index bd962c8514..af4b49c0c4 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1198,9 +1198,9 @@ def form_02(request_data): current_template = SettingManager.get("template_federal_order_530_titul_page", default='', default_type='s') objs.extend(title_page) if not os.path.join( - BASE_DIR, - 'forms', - 'pdf_templates', + BASE_DIR, + 'forms', + 'pdf_templates', ): current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") else: From e2bee87ccc945bef8c3c3bb9139e9e21af66816b Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:53:07 +0800 Subject: [PATCH 06/19] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/forms/forms106.py b/forms/forms106.py index af4b49c0c4..8fcc1e5954 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1238,7 +1238,11 @@ def form_02(request_data): styleRight.alignment = TA_RIGHT styles_obj = { - "style": style, "styleCenter": styleCenter, "styleLead": styleLead, "styleBold": styleBold, "styleCenterBold": styleCenterBold, + "style": style, + "styleCenter": styleCenter, + "styleLead": styleLead, + "styleBold": styleBold, + "styleCenterBold": styleCenterBold, "styleJustified": styleJustified, "styleRight": styleRight, } From d7441b9dda0b44d1738c01104913841e865114e3 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:53:15 +0800 Subject: [PATCH 07/19] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/forms106.py b/forms/forms106.py index 8fcc1e5954..0b4527a8c9 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1194,7 +1194,7 @@ def form_02(request_data): Paragraph("Поступил в: стационар - 1", style), Spacer(1, 0.5 * mm), - ] + ] current_template = SettingManager.get("template_federal_order_530_titul_page", default='', default_type='s') objs.extend(title_page) if not os.path.join( From b1cffd308df32f822d6e2ecfba9756130f50b274 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:53:21 +0800 Subject: [PATCH 08/19] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 1 - 1 file changed, 1 deletion(-) diff --git a/forms/forms106.py b/forms/forms106.py index 0b4527a8c9..6f3ea9faae 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1191,7 +1191,6 @@ def form_02(request_data): Spacer(1, 0.2 * mm), Paragraph(f"Дата рождения: {patient_data['born']} Пол: {patient_data['sex']}", style), Spacer(1, 0.5 * mm), - Paragraph("Поступил в: стационар - 1", style), Spacer(1, 0.5 * mm), ] From 3dd52fecd8bfd8a51a2cb241fce8964f5869e19e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:53:35 +0800 Subject: [PATCH 09/19] Update external_system/sql_func.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- external_system/sql_func.py | 1 - 1 file changed, 1 deletion(-) diff --git a/external_system/sql_func.py b/external_system/sql_func.py index acf14e68a6..118bd76fb0 100644 --- a/external_system/sql_func.py +++ b/external_system/sql_func.py @@ -45,4 +45,3 @@ def cda_data_by_title(cda_title): ) rows = namedtuplefetchall(cursor) return rows - From 0a28e47c257a4bd5e651dec093c1835259a1f7f4 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sat, 30 Nov 2024 00:53:41 +0800 Subject: [PATCH 10/19] Update forms/forms_func.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms_func.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/forms_func.py b/forms/forms_func.py index 3c77ecfe72..dc2e61db3f 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -699,7 +699,7 @@ 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 + 'result_by_cda': result_by_cda, } From 9120abdc8aa5d5d6e464f7bbac21a50e29ae7fb3 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sun, 1 Dec 2024 13:19:14 +0800 Subject: [PATCH 11/19] fix --- forms/forms106.py | 91 +++++++++++++------ ...template_federal_order_530_titul_page.json | 6 +- 2 files changed, 68 insertions(+), 29 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index 6f3ea9faae..5bf8bcd75c 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -741,7 +741,7 @@ def form_03_1(request_data): transfers = "" for i in transfers_data: transfers = ( - f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']}
Дата и время перевода {i['date_transfer_value']} " + f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']} палата N____
Дата и время перевода {i['date_transfer_value']} " f"время:{i['time_transfer_value']};
" ) @@ -1103,6 +1103,7 @@ def form_02(request_data): # Получение данных из выписки # Взять услугу типа выписка. Из полей "Дата выписки" - взять дату. Из поля "Время выписки" взять время hosp_extract_data = hosp_extract_get_data(hosp_last_num) + hosp_depart = hosp_nums_obj[0].get("research_title") extrac_date, extract_time, outcome = "", "", "" days_count = "__________________________" @@ -1125,7 +1126,6 @@ def form_02(request_data): # Получить данные из первичного приема (самого первого hosp-направления) hosp_first_num = hosp_nums_obj[0].get("direction") primary_reception_data = primary_reception_get_data(hosp_first_num) - print(primary_reception_data.get('result_by_cda')) ########################################################################################################### # Получение данных группы крови @@ -1159,24 +1159,15 @@ def form_02(request_data): ##################################################################################################### # получить даные из переводного эпикриза: Дата перевода, Время перевода, в какое отделение переведен # у каждого hosp-направления найти подчиненное эпикриз Перевод* + transfers_data = hosp_get_transfers_data(hosp_nums_obj) - transfers = "" + transfers = f"Отделение {hosp_depart}; профиль коек________ палата N _______" for i in transfers_data: transfers = ( - f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']}
Дата и время перевода {i['date_transfer_value']} " + f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']} палата N____
Дата и время перевода {i['date_transfer_value']} " f"время:{i['time_transfer_value']};
" ) - plan_form = primary_reception_data["plan_hospital"] - extra_hospital = primary_reception_data["extra_hospital"] - result_form = "" - if plan_form.lower() == "да": - result_form = "плановая — 1" - if extra_hospital.lower() == "да": - result_form = "экстренная — 2" - number_direction = normalize_date(primary_reception_data["ext_direction_date"]) - bold_open = '' - bold_close = "" title_page = [ Indenter(left=0 * mm), Spacer(1, 2 * mm), @@ -1194,13 +1185,8 @@ def form_02(request_data): Paragraph("Поступил в: стационар - 1", style), Spacer(1, 0.5 * mm), ] - current_template = SettingManager.get("template_federal_order_530_titul_page", default='', default_type='s') objs.extend(title_page) - if not os.path.join( - BASE_DIR, - 'forms', - 'pdf_templates', - ): + if not os.path.join(BASE_DIR, 'forms', 'pdf_templates'): current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") else: current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") @@ -1245,12 +1231,62 @@ def form_02(request_data): "styleJustified": styleJustified, "styleRight": styleRight, } + + # title_page.append(Paragraph("Проведенные оперативные вмешательства (операции):", style)) + styleTO = deepcopy(style) + styleTO.alignment = TA_LEFT + styleTO.firstLineIndent = 0 + styleTO.fontSize = 9.5 + styleTO.leading = 10 + styleTO.spaceAfter = 0.2 * mm + + # Таблица для операции + opinion_oper = [ + [ + Paragraph("Дата проведения", styleTO), + Paragraph("Наименование оперативного вмешательства (операции), код согласно номенклатуре медицинских услуг", styleTO), + Paragraph("Вид анестезиологического пособия", styleTO), + Paragraph("Кровопотеря во время оперативного вмешательства (операции), мл", styleTO), + ] + ] + + hosp_operation = hosp_get_operation_data(num_dir) + operation_result = [] + for i in hosp_operation: + operation_template = [""] * 4 + operation_template[0] = Paragraph(i["date"] + "
" + i["time_start"] + "-" + i["time_end"], styleTO) + operation_template[1] = Paragraph(f"{i['name_operation']}
({i['category_difficult']}), {i['doc_fio']}", styleTO) + operation_template[2] = Paragraph(i["anesthesia method"], styleTO) + operation_template[3] = Paragraph(i["complications"], styleTO) + operation_result.append(operation_template.copy()) + + opinion_oper.extend(operation_result) + + t_opinion_oper = opinion_oper.copy() + tbl_o = Table( + t_opinion_oper, + colWidths=( + 22 * mm, + 85 * mm, + 45 * mm, + 24 * mm, + ), + ) + tbl_o.setStyle( + TableStyle( + [ + ("GRID", (0, 0), (-1, -1), 1.0, colors.black), + ("BOTTOMPADDING", (0, 0), (-1, -1), 2.1 * mm), + ("VALIGN", (0, 0), (-1, -1), "MIDDLE"), + ] + ) + ) + + table_data = {"operation": tbl_o, "transfers": transfers} + if current_template_file: for section in body_paragraphs: - objs = check_section_param(objs, styles_obj, section, tbl, primary_reception_data.get('result_by_cda')) - - if primary_reception_data.get("weight"): - title_page.append(Paragraph(f"Вес: {primary_reception_data['weight']}", styleRight)) + objs = check_section_param(objs, styles_obj, section, table_data, primary_reception_data.get('result_by_cda')) doc.build(objs) pdf = buffer.getvalue() @@ -1265,8 +1301,11 @@ def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles objs.append(Spacer(1, height_spacer * mm)) elif section.get('page_break'): objs.append(PageBreak()) - elif section.get('specification'): - objs.append(tbl_specification) + elif section.get('tbl'): + if section.get("type") == "Операции": + objs.append(tbl_specification.get("operation")) + elif section.get("type") == "Движение": + objs.append(Paragraph(tbl_specification.get("transfers"), styles_obj[section.get('style')])) elif section.get('text'): cda_titles_sec = section.get('cdaTitles') data_cda = [cda_titles.get(i) for i in cda_titles_sec if cda_titles.get(i)] 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 bae86c88cf..6fbb39e305 100644 --- a/forms/pdf_templates/template_federal_order_530_titul_page.json +++ b/forms/pdf_templates/template_federal_order_530_titul_page.json @@ -19,7 +19,7 @@ {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Форма оказания медицинской помощи: {}", "cdaTitles": ["п.п.-Форма помощи"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, - {"tbl": "", "type": "Движение", "style": "style"}, + {"tbl": "Таблица", "type": "Движение", "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Выписан: {} время: {}", "cdaTitles": ["в.э.-Дата выписки", "в.э.-Время выписки"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, @@ -42,8 +42,8 @@ {"text": "Дополнительные сведения о заболевании: {}", "cdaTitles": ["п.п.-Дополнительные сведения заболевания"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Проведенные оперативные вмешательства (операции):", "cdaTitles": [""], "style": "style"}, - {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, - {"tbl": "", "type": "Операции", "style": "style"}, + {"text": "", "spacer_data": 0.1, "Spacer": "true", "style": "styleCenter"}, + {"tbl": "Таблица", "type": "Операции", "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 2528e55a952cdb24a1ec1872263aab9f809e34e9 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sun, 1 Dec 2024 14:50:43 +0800 Subject: [PATCH 12/19] fix --- forms/forms106.py | 45 ++++++----- forms/forms_func.py | 76 +++++++++++++++++-- ...template_federal_order_530_titul_page.json | 29 ++++++- laboratory/settings.py | 1 + 4 files changed, 125 insertions(+), 26 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index 5bf8bcd75c..2824c14a5c 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -14,7 +14,6 @@ from directions.models import Napravleniya, Issledovaniya from directory.models import Fractions from hospitals.models import Hospitals -from laboratory.settings import FONTS_FOLDER import locale import sys import os.path @@ -22,7 +21,8 @@ from api.stationar.stationar_func import hosp_get_hosp_direction from api.sql_func import get_fraction_result from utils.dates import normalize_date -from .forms_func import primary_reception_get_data, hosp_extract_get_data, hosp_get_clinical_diagnos, hosp_get_transfers_data, hosp_get_operation_data, closed_bl +from .forms_func import primary_reception_get_data, hosp_extract_get_data, hosp_get_clinical_diagnos, hosp_get_transfers_data, hosp_get_operation_data, closed_bl, \ + hosp_extract_get_data_by_cda, primary_reception_get_data_by_cda from laboratory.settings import FONTS_FOLDER, BASE_DIR import simplejson as json @@ -1102,20 +1102,9 @@ def form_02(request_data): ############################################################################################################ # Получение данных из выписки # Взять услугу типа выписка. Из полей "Дата выписки" - взять дату. Из поля "Время выписки" взять время - hosp_extract_data = hosp_extract_get_data(hosp_last_num) hosp_depart = hosp_nums_obj[0].get("research_title") - extrac_date, extract_time, outcome = "", "", "" - days_count = "__________________________" - result_hospital = "" - if hosp_extract_data: - extrac_date = hosp_extract_data["date_value"] - extract_time = hosp_extract_data["time_value"] - days_count = hosp_extract_data["days_count"] - if hosp_extract_data["outcome"]: - outcome = hosp_extract_data["outcome"] - if hosp_extract_data["result_hospital"]: - result_hospital = hosp_extract_data["result_hospital"] + hosp_extract_data = hosp_extract_get_data_by_cda(hosp_last_num) # Получить отделение - из названия услуги или самого главного направления first_bed_profile = hosp_nums_obj[0].get("research_title") @@ -1125,7 +1114,7 @@ def form_02(request_data): ############################################################################################################ # Получить данные из первичного приема (самого первого hosp-направления) hosp_first_num = hosp_nums_obj[0].get("direction") - primary_reception_data = primary_reception_get_data(hosp_first_num) + primary_reception_data = primary_reception_get_data_by_cda(hosp_first_num) ########################################################################################################### # Получение данных группы крови @@ -1135,7 +1124,7 @@ def form_02(request_data): if group_blood_avo: group_blood_avo_value = group_blood_avo[0][5] else: - group_blood_avo_value = primary_reception_data["blood_group"] + group_blood_avo_value = primary_reception_data.get("blood_group") open_symbola = '' close_symbola = "" @@ -1154,14 +1143,14 @@ def form_02(request_data): if group_blood_rezus: group_rezus_value = group_blood_rezus[0][5].replace("
", " ") else: - group_rezus_value = primary_reception_data["resus_factor"] + group_rezus_value = primary_reception_data.get("resus_factor") ##################################################################################################### # получить даные из переводного эпикриза: Дата перевода, Время перевода, в какое отделение переведен # у каждого hosp-направления найти подчиненное эпикриз Перевод* transfers_data = hosp_get_transfers_data(hosp_nums_obj) - transfers = f"Отделение {hosp_depart}; профиль коек________ палата N _______" + transfers = f"Отделение {hosp_depart}; профиль коек {first_bed_profile} палата N _______" for i in transfers_data: transfers = ( f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']} палата N____
Дата и время перевода {i['date_transfer_value']} " @@ -1283,10 +1272,28 @@ def form_02(request_data): ) table_data = {"operation": tbl_o, "transfers": transfers} + cda_data_result = {} + if hosp_extract_data.get('result_by_cda'): + cda_data_result.update(hosp_extract_data.get('result_by_cda')) + + if primary_reception_data.get('result_by_cda'): + cda_data_result.update(primary_reception_data.get('result_by_cda')) + + if not cda_data_result.get("п.п.-Группа крови"): + cda_data_result["п.п.-Группа крови"] = group_blood_avo_value + + if not cda_data_result.get("п.п.-резус"): + cda_data_result["п.п.-резус"] = group_rezus_value + + if not cda_data_result.get("п.п.-антиген К1"): + cda_data_result["п.п.-антиген К1"] = "" + + if not cda_data_result.get("п.п.-Kell"): + cda_data_result["п.п.-Kell"] = "" if current_template_file: for section in body_paragraphs: - objs = check_section_param(objs, styles_obj, section, table_data, primary_reception_data.get('result_by_cda')) + objs = check_section_param(objs, styles_obj, section, table_data, cda_data_result) doc.build(objs) pdf = buffer.getvalue() diff --git a/forms/forms_func.py b/forms/forms_func.py index dc2e61db3f..ea22bef009 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -12,7 +12,7 @@ from external_system.models import CdaFields from external_system.sql_func import cda_data_by_title from laboratory import utils -from laboratory.settings import MEDEXAM_FIN_SOURCE_TITLE, CDA_TITLES_FIELDS_PRIMARY_RESEARCH +from laboratory.settings import MEDEXAM_FIN_SOURCE_TITLE, CDA_TITLES_FIELDS_PRIMARY_RESEARCH, CDA_TITLES_FIELDS_EXTRACT_RESEARCH from laboratory.utils import strdate from api.stationar.stationar_func import hosp_get_data_direction, check_transfer_epicrisis from api.stationar.sql_func import get_result_value_iss, get_title_fields_by_cda_relation @@ -463,13 +463,9 @@ def primary_reception_get_data(hosp_first_num, site_type=0): result_by_cda = {} if CDA_TITLES_FIELDS_PRIMARY_RESEARCH: cda_ids_data = cda_data_by_title(tuple(CDA_TITLES_FIELDS_PRIMARY_RESEARCH)) - print(cda_ids_data) cda_ids = [i.id for i in cda_ids_data] cda_dict_title = {i.id: i.title for i in cda_ids_data} - print(cda_ids) - fields_data = get_title_fields_by_cda_relation(primary_research_id, tuple(cda_ids)) - print(fields_data) titles_field = [i.title for i in fields_data] list_values = None @@ -702,6 +698,35 @@ def primary_reception_get_data(hosp_first_num, site_type=0): 'result_by_cda': result_by_cda, } +def primary_reception_get_data_by_cda(hosp_first_num, site_type=0): + # Получение данных из певичного приема + hosp_primary_receptions = hosp_get_data_direction(hosp_first_num, site_type=site_type, type_service='None', level=2) + hosp_primary_iss, primary_research_id = None, None + if hosp_primary_receptions: + hosp_primary_iss = hosp_primary_receptions[0].get('iss') + primary_research_id = hosp_primary_receptions[0].get('research_id') + + cda_dict_title = {} + result_by_cda = {} + titles_field = None + 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} + + return { + 'result_by_cda': result_by_cda, + } + def hosp_extract_get_data(hosp_last_num): # Получение данных из выписки @@ -739,6 +764,7 @@ def hosp_extract_get_data(hosp_last_num): 'Отметка о выдаче листка нетрудоспособности', 'Отметка о выдаче листка нетрудоспособности через врачебную комиссию', ] + list_values = None if titles_field and hosp_extract: list_values = get_result_value_iss(hosp_extract_iss, extract_research_id, titles_field) @@ -864,6 +890,46 @@ def hosp_extract_get_data(hosp_last_num): } +def hosp_extract_get_data_by_cda(hosp_last_num): + # Получение данных из выписки + hosp_extract = hosp_get_data_direction(hosp_last_num, site_type=7, type_service='None', level=2) + if not hosp_extract: + return {} + hosp_extract_iss, extract_research_id, doc_confirm = None, None, None + if hosp_extract: + hosp_extract_iss = hosp_extract[0].get('iss') + doc_confirm = Issledovaniya.objects.get(pk=hosp_extract_iss).doc_confirmation + if not doc_confirm: + return {} + extract_research_id = hosp_extract[0].get('research_id') + + cda_dict_title = {} + result_by_cda = {} + titles_field = None + if CDA_TITLES_FIELDS_EXTRACT_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(extract_research_id, tuple(cda_ids)) + titles_field = [i.title for i in fields_data] + + list_values = None + if titles_field and hosp_extract: + list_values = get_result_value_iss(hosp_extract_iss, extract_research_id, titles_field) + + if CDA_TITLES_FIELDS_EXTRACT_RESEARCH: + result_by_cda = {cda_dict_title.get(value[4]): value[2] for value in list_values} + + if list_values: + pass + + doc_fio = doc_confirm.get_fio() + return { + 'result_by_cda': result_by_cda, + 'doc_fio': doc_fio + } + + def hosp_get_clinical_diagnos(hosp_obj): clinic_diagnos = '' tmp_clinic_diagnos = [] 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 6fbb39e305..e3748070f1 100644 --- a/forms/pdf_templates/template_federal_order_530_titul_page.json +++ b/forms/pdf_templates/template_federal_order_530_titul_page.json @@ -41,6 +41,31 @@ {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Дополнительные сведения о заболевании: {}", "cdaTitles": ["п.п.-Дополнительные сведения заболевания"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "В анамнезе: туберкулез {} ВИЧ-инфекция {} вирусные гепатиты {}сифилис {}COVID-19 {}", "cdaTitles": ["п.п.-Туберкулез", "п.п.-ВИЧ-инфекция", "п.п.-Вирусные гепатиты", "п.п.-сифилис", "п.п.-COVID-19" ], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Осмотр на педикулез, чесотку: {}, результат осмотра: {}", "cdaTitles": ["п.п.-Педикулез осмотр", "п.п.-Педикулез результат"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Аллергические реакции на лекарственные препараты, пищевая аллергия или иные виды непереносимости в анамнезе, с указанием типа и вида аллергической реакции:{}", "cdaTitles": ["п.п.-Аллергия"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Трансфузии (переливания) донорской крови и (или) ее компонентов (год, осложнения, реакции),: {}", "cdaTitles": ["п.п.-Трансфузии"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Группа крови: {}, резус-принадлежность {}, антиген К1 системы {} Kell {} ", "cdaTitles": ["п.п.-Группа крови", "п.п.-резус", "п.п.-антиген К1", "п.п.-Kell"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "иные сведения групповой принадлежности крови (при наличии) {}", "cdaTitles": ["п.п.-Иное группа крови"], "style": "style"}, + {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Диагноз клинический, установленный в стационаре, дневном стационаре: {}", "cdaTitles": ["Пустопусто"], "style": "style"}, + {"text": "Дата и время установления клинического диагноза: {} время: {}", "cdaTitles": ["в.э.-Дата клин. Ds", "в.э.-Время клин. 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": "", "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": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, + {"text": "Дополнительные сведения о заболевании: {}", "cdaTitles": ["в.э.-Дополнительные сведения заболевания"], "style": "style"}, + {"text": "", "spacer_data": 0.6, "Spacer": "true", "style": "styleCenter"}, {"text": "Проведенные оперативные вмешательства (операции):", "cdaTitles": [""], "style": "style"}, {"text": "", "spacer_data": 0.1, "Spacer": "true", "style": "styleCenter"}, {"tbl": "Таблица", "type": "Операции", "style": "style"}, @@ -55,8 +80,8 @@ {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Умерла беременная: {}", "cdaTitles": ["в.э.-Беременность срок"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, - {"text": "Оформлен листок нетрудоспособности: N {} от {}", "cdaTitles": ["в.э.-ЭЛН Номер", "в.э.-ЭЛН дата" ], "style": "style"}, - {"text": "(дубликат листка нетрудоспособности N {} от {})", "cdaTitles": ["в.э.-дубликат ЭЛН Номер", "в.э.-дубликат ЭЛН дата" ], "style": "style"}, + {"text": "Оформлен листок нетрудоспособности: N {} от {}", "cdaTitles": ["в.э.-ЭЛН Номер", "в.э.-ЭЛН дата"], "style": "style"}, + {"text": "(дубликат листка нетрудоспособности N {} от {})", "cdaTitles": ["в.э.-дубликат ЭЛН Номер", "в.э.-дубликат ЭЛН дата"], "style": "style"}, {"text": "освобождение от работы с {} по {}", "cdaTitles": ["в.э.-ЭЛН с", "в.э.-ЭЛН по"], "style": "style"}, {"text": "продление листка нетрудоспособности:", "cdaTitles": ["в.э.-ЭЛН с", "в.э.-ЭЛН по"], "style": "style"}, {"text": "№{}освобождение от работы с {} по {}", "cdaTitles": ["в.э.-продление ЭЛН №", "в.э.-продление ЭЛН с", "в.э.-ЭЛН продление по"], "style": "style"}, diff --git a/laboratory/settings.py b/laboratory/settings.py index 5eb023bdfc..ed9e97a15f 100644 --- a/laboratory/settings.py +++ b/laboratory/settings.py @@ -416,6 +416,7 @@ def __getitem__(self, item): PROMETHEUS_ENABLED = False USERS_PK_SHOW_FACT_ADDRESSES_025U = [] CDA_TITLES_FIELDS_PRIMARY_RESEARCH = [] +CDA_TITLES_FIELDS_EXTRACT_RESEARCH = [] TYPE_NUMBER_SYSTEM = [] FTP_SETUP_TO_SEND_HL7_BY_RESEARCHES = { From c9254c4aa7021cbc004cf4db155f7715efe43efd Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sun, 1 Dec 2024 14:51:41 +0800 Subject: [PATCH 13/19] Update forms/forms_func.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms_func.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/forms/forms_func.py b/forms/forms_func.py index ea22bef009..dba6c26e21 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -924,10 +924,7 @@ def hosp_extract_get_data_by_cda(hosp_last_num): pass doc_fio = doc_confirm.get_fio() - return { - 'result_by_cda': result_by_cda, - 'doc_fio': doc_fio - } + return {'result_by_cda': result_by_cda, 'doc_fio': doc_fio} def hosp_get_clinical_diagnos(hosp_obj): From efb9104e40e8190a410b26962d30573b9947db55 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sun, 1 Dec 2024 14:51:47 +0800 Subject: [PATCH 14/19] Update forms/forms_func.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms_func.py | 1 + 1 file changed, 1 insertion(+) diff --git a/forms/forms_func.py b/forms/forms_func.py index dba6c26e21..5161dafba2 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -698,6 +698,7 @@ def primary_reception_get_data(hosp_first_num, site_type=0): 'result_by_cda': result_by_cda, } + def primary_reception_get_data_by_cda(hosp_first_num, site_type=0): # Получение данных из певичного приема hosp_primary_receptions = hosp_get_data_direction(hosp_first_num, site_type=site_type, type_service='None', level=2) From 70c2dc5d4e43a382e18eb2854d548933187ecae6 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Sun, 1 Dec 2024 14:51:52 +0800 Subject: [PATCH 15/19] Update forms/forms106.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- forms/forms106.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index 2824c14a5c..242aea93a3 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -21,8 +21,16 @@ from api.stationar.stationar_func import hosp_get_hosp_direction from api.sql_func import get_fraction_result from utils.dates import normalize_date -from .forms_func import primary_reception_get_data, hosp_extract_get_data, hosp_get_clinical_diagnos, hosp_get_transfers_data, hosp_get_operation_data, closed_bl, \ - hosp_extract_get_data_by_cda, primary_reception_get_data_by_cda +from .forms_func import ( + primary_reception_get_data, + hosp_extract_get_data, + hosp_get_clinical_diagnos, + hosp_get_transfers_data, + hosp_get_operation_data, + closed_bl, + hosp_extract_get_data_by_cda, + primary_reception_get_data_by_cda, +) from laboratory.settings import FONTS_FOLDER, BASE_DIR import simplejson as json From a17b5bde83fb0a806fbeb9a31c50ddbce9e3daae Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sun, 1 Dec 2024 14:53:44 +0800 Subject: [PATCH 16/19] fix --- forms/forms106.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/forms/forms106.py b/forms/forms106.py index 242aea93a3..3c698a8ad4 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1161,7 +1161,8 @@ def form_02(request_data): transfers = f"Отделение {hosp_depart}; профиль коек {first_bed_profile} палата N _______" for i in transfers_data: transfers = ( - f"{transfers}
Переведен в отделение {i['transfer_depart']}; профиль коек {i['transfer_research_title']} палата N____
Дата и время перевода {i['date_transfer_value']} " + f"{transfers}
Переведен в отделение {i['transfer_depart']}; " + f"профиль коек {i['transfer_research_title']} палата N____
Дата и время перевода {i['date_transfer_value']} " f"время:{i['time_transfer_value']};
" ) @@ -1183,15 +1184,15 @@ def form_02(request_data): Spacer(1, 0.5 * mm), ] objs.extend(title_page) - if not os.path.join(BASE_DIR, 'forms', 'pdf_templates'): - current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") + if not os.path.join(BASE_DIR, "forms", "pdf_templates"): + current_template_file = os.path.join(BASE_DIR, "forms", "pdf_templates", "template_federal_order_530_titul_page.json") else: - current_template_file = os.path.join(BASE_DIR, 'forms', 'pdf_templates', "template_federal_order_530_titul_page.json") + current_template_file = os.path.join(BASE_DIR, "forms", "pdf_templates", "template_federal_order_530_titul_page.json") if current_template_file: with open(current_template_file) as json_file: data = json.load(json_file) - body_paragraphs = data['body_paragraphs'] + body_paragraphs = data["body_paragraphs"] styleLead = deepcopy(style) styleLead.leading = 12 @@ -1281,11 +1282,11 @@ def form_02(request_data): table_data = {"operation": tbl_o, "transfers": transfers} cda_data_result = {} - if hosp_extract_data.get('result_by_cda'): - cda_data_result.update(hosp_extract_data.get('result_by_cda')) + if hosp_extract_data.get("result_by_cda"): + cda_data_result.update(hosp_extract_data.get("result_by_cda")) - if primary_reception_data.get('result_by_cda'): - cda_data_result.update(primary_reception_data.get('result_by_cda')) + if primary_reception_data.get("result_by_cda"): + cda_data_result.update(primary_reception_data.get("result_by_cda")) if not cda_data_result.get("п.п.-Группа крови"): cda_data_result["п.п.-Группа крови"] = group_blood_avo_value @@ -1311,20 +1312,20 @@ def form_02(request_data): def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles): - if section.get('Spacer'): - height_spacer = section.get('spacer_data') + if section.get("Spacer"): + height_spacer = section.get("spacer_data") objs.append(Spacer(1, height_spacer * mm)) - elif section.get('page_break'): + elif section.get("page_break"): objs.append(PageBreak()) - elif section.get('tbl'): + elif section.get("tbl"): if section.get("type") == "Операции": objs.append(tbl_specification.get("operation")) elif section.get("type") == "Движение": - objs.append(Paragraph(tbl_specification.get("transfers"), styles_obj[section.get('style')])) - elif section.get('text'): - cda_titles_sec = section.get('cdaTitles') + objs.append(Paragraph(tbl_specification.get("transfers"), styles_obj[section.get("style")])) + elif section.get("text"): + cda_titles_sec = section.get("cdaTitles") data_cda = [cda_titles.get(i) for i in cda_titles_sec if cda_titles.get(i)] if len(data_cda) < 1: data_cda = ["" for count in range(len(cda_titles_sec))] - objs.append(Paragraph(section.get('text').format(*data_cda), styles_obj[section.get('style')])) + objs.append(Paragraph(section.get("text").format(*data_cda), styles_obj[section.get("style")])) return objs From 9291bff2551ec628b4877f5fa6d50552b899496e Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sun, 1 Dec 2024 14:54:47 +0800 Subject: [PATCH 17/19] fix --- forms/forms106.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms/forms106.py b/forms/forms106.py index 3c698a8ad4..f1789c6bab 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1158,7 +1158,7 @@ def form_02(request_data): # у каждого hosp-направления найти подчиненное эпикриз Перевод* transfers_data = hosp_get_transfers_data(hosp_nums_obj) - transfers = f"Отделение {hosp_depart}; профиль коек {first_bed_profile} палата N _______" + transfers = f"Отделение {first_hosp_depart}; профиль коек {first_bed_profile} палата N _______" for i in transfers_data: transfers = ( f"{transfers}
Переведен в отделение {i['transfer_depart']}; " From 6aa3bb6cc0fe12898067e04f1355c79a2ae6d081 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sun, 1 Dec 2024 14:57:01 +0800 Subject: [PATCH 18/19] fix --- forms/forms106.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/forms/forms106.py b/forms/forms106.py index f1789c6bab..33d4715562 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1158,6 +1158,8 @@ def form_02(request_data): # у каждого hosp-направления найти подчиненное эпикриз Перевод* transfers_data = hosp_get_transfers_data(hosp_nums_obj) + if not first_hosp_depart: + first_hosp_depart = hosp_depart transfers = f"Отделение {first_hosp_depart}; профиль коек {first_bed_profile} палата N _______" for i in transfers_data: transfers = ( From 4b14f5eb7ca7de5cb793e2d6585c4371b7bf7881 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Sun, 1 Dec 2024 14:57:40 +0800 Subject: [PATCH 19/19] fix --- forms/forms_func.py | 1 - 1 file changed, 1 deletion(-) diff --git a/forms/forms_func.py b/forms/forms_func.py index 5161dafba2..0657fcc3a3 100644 --- a/forms/forms_func.py +++ b/forms/forms_func.py @@ -9,7 +9,6 @@ from clients.models import Document, DispensaryReg, Card from directions.models import Napravleniya, Issledovaniya, ParaclinicResult, IstochnikiFinansirovaniya, PersonContract from directory.models import Researches -from external_system.models import CdaFields from external_system.sql_func import cda_data_by_title from laboratory import utils from laboratory.settings import MEDEXAM_FIN_SOURCE_TITLE, CDA_TITLES_FIELDS_PRIMARY_RESEARCH, CDA_TITLES_FIELDS_EXTRACT_RESEARCH