diff --git a/api/directions/views.py b/api/directions/views.py index 8775bafa66..312ffdec03 100644 --- a/api/directions/views.py +++ b/api/directions/views.py @@ -2292,7 +2292,10 @@ def directions_paraclinic_result(request): f_result = ParaclinicResult(issledovaniye=iss, field=f, value="") else: f_result = ParaclinicResult.objects.filter(issledovaniye=iss, field=f)[0] - f_result.value = field["value"] + if not field["value"]: + f_result.value = "" + else: + f_result.value = field["value"] f_result.field_type = f.field_type if f.field_type in [27, 28, 29, 32, 33, 34, 35]: try: diff --git a/command_utils/management/commands/import_mkb.py b/command_utils/management/commands/import_mkb.py new file mode 100644 index 0000000000..f10049beed --- /dev/null +++ b/command_utils/management/commands/import_mkb.py @@ -0,0 +1,39 @@ +from django.core.management import BaseCommand +from directions.models import Diagnoses +import requests +from openpyxl import load_workbook + + +def fetch(url): + page = requests.get(url) + return page.json()['list'] + + +class Command(BaseCommand): + help = "Импорт справочника МКБ" + + def add_arguments(self, parser): + parser.add_argument('path', type=str) + parser.add_argument('mode', type=str) + + def handle(self, *args, **kwargs): + fp = kwargs["path"] + self.stdout.write("Path: " + fp) + wb = load_workbook(filename=fp) + ws = wb[wb.sheetnames[0]] + starts = False + mode = kwargs.get("mode") + code, nsi_id, title = "", "", "" + for row in ws.rows: + cells = [str(x.value) for x in row] + if not starts: + if "Уникальный идентификатор" in cells: + title = cells.index("Наименование") + code = cells.index("Код МКБ-10") + nsi_id = cells.index("Уникальный идентификатор") + starts = True + else: + r = Diagnoses.objects.filter(code=cells[code], d_type=mode) + if not r.exists(): + Diagnoses(d_type=mode, code=cells[code], title=cells[title], nsi_id=cells[nsi_id], hide=False, m_type=2).save() + print('сохранено', cells[code]) # noqa: T001 diff --git a/forms/forms106.py b/forms/forms106.py index 6233c53e83..c843a98d4d 100644 --- a/forms/forms106.py +++ b/forms/forms106.py @@ -1282,8 +1282,9 @@ def form_02(request_data): ) ) - table_data = {"operation": tbl_o, "transfers": transfers} + 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")) @@ -1302,6 +1303,10 @@ def form_02(request_data): if not cda_data_result.get("п.п.-Kell"): cda_data_result["п.п.-Kell"] = " " + if cda_data_result.get("п.п.-Сопутствующие табл"): + accomponement_tbl = parse_accompanement_diagnos(cda_data_result.get("п.п.-Сопутствующие табл"), style) + table_data["Сопутствующие"] = accomponement_tbl + if current_template_file: for section in body_paragraphs: objs = check_section_param(objs, styles_obj, section, table_data, cda_data_result) @@ -1324,6 +1329,10 @@ def check_section_param(objs, styles_obj, section, tbl_specification, cda_titles 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("type") == "Сопутствующие": + objs.append(tbl_specification.get("Сопутствующие")) + elif section.get("type") == "Осложнения": + objs.append(tbl_specification.get("Осложнения")) 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)] @@ -1347,11 +1356,11 @@ def check_diagnos_row_is_dict(data_cda): except: is_dict = False try: - if is_dict and not field_json.get('columns'): + 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'): + elif is_dict and field_json.get("columns"): new_result = "" rows_data = field_json.get("rows") for r_data in rows_data: @@ -1362,7 +1371,7 @@ def check_diagnos_row_is_dict(data_cda): is_dict = True except: is_dict = False - if is_dict and diag_data.get('code'): + 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}
" @@ -1372,3 +1381,54 @@ def check_diagnos_row_is_dict(data_cda): result = [new_result] return result + + +def parse_accompanement_diagnos(accompanement_data, style): + try: + value = json.loads(accompanement_data) + except: + return None + + if not value: + return None + opinion = [] + table_rows = value["rows"] + accomponement_result = [] + space_symbol = " " + for t in table_rows: + result = "" + result_mkb_code = "" + result_mkb_title = "" + clinic_diag_text = "" + for value_raw in t: + try: + row_data = json.loads(value_raw) + if 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')}" + except: + clinic_diag_text = value_raw + result = f"{result_mkb_title}; {clinic_diag_text}" + accomponement_result.append([Paragraph(f"{result}", style), Paragraph(f"код по МКБ {space_symbol * 3}{result_mkb_code}", style)]) + accomponement_result.append([Paragraph("", style), Paragraph("", style)]) + opinion.extend(accomponement_result) + + tbl_o = Table( + opinion, + colWidths=( + 138 * mm, + 40 * mm, + ), + ) + tbl_o.setStyle( + TableStyle( + [ + ("GRID", (0, 0), (-1, -1), 1.0, colors.white), + ("TOPPADDING", (0, 0), (-1, -1), 1 * mm), + ("VALIGN", (0, 0), (-1, -1), "TOP"), + ] + ) + ) + return tbl_o 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 e8a94a5a16..5307d34d6a 100644 --- a/forms/pdf_templates/template_federal_order_530_titul_page.json +++ b/forms/pdf_templates/template_federal_order_530_titul_page.json @@ -34,12 +34,12 @@ {"text": "Основное заболевание: {}", "cdaTitles": [ "п.п.-Основное Ds мкб"], "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Осложнения основного заболевания: {}", "cdaTitles": ["п.п.-Пусто"], "style": "style"}, - {"text": "{}", "cdaTitles": ["п.п.-Осложнения Ds мкб"], "style": "style"}, + {"tbl": "Таблица", "cdaTitles": ["п.п.-Осложнения табл"], "type": "Осложнения", "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": "{}", "cdaTitles": ["п.п.-Сопутствующие Ds мкб"], "style": "style"}, + {"tbl": "Таблица", "cdaTitles": ["п.п.-Сопутствующие табл"], "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"}, @@ -60,11 +60,13 @@ {"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"}, + {"tbl": "Таблица", "cdaTitles": ["в.э.-Осложнения табл"], "type": "Осложнения", "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"}, + {"tbl": "Таблица", "cdaTitles": ["в.э.-Сопутствующие табл"], "type": "Сопутствующие", "style": "style"}, {"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"}, {"text": "Дополнительные сведения о заболевании: {}", "cdaTitles": ["в.э.-Дополнительные сведения заболевания"], "style": "style"}, {"text": "", "spacer_data": 0.6, "Spacer": "true", "style": "styleCenter"}, diff --git a/l2-frontend/src/construct/ParaclinicResearchEditor.vue b/l2-frontend/src/construct/ParaclinicResearchEditor.vue index b10df36da3..1862eccdd0 100644 --- a/l2-frontend/src/construct/ParaclinicResearchEditor.vue +++ b/l2-frontend/src/construct/ParaclinicResearchEditor.vue @@ -965,7 +965,7 @@ @@ -1396,6 +1396,13 @@ export default { expertise() { return this.$store.getters.modules.l2_expertise; }, + findPossibleGroupForField() { + const filtered = this.groups.filter((group) => { + const newFields = group.fields.filter((field) => field.pk === -1); + return newFields.length < 1; + }); + return filtered.map(group => ({ id: group.pk, label: group.pk })); + }, }, watch: { pk() { @@ -1425,7 +1432,6 @@ export default { await this.loadDepartmentsForPermissions(); await this.load_deparments(); await this.loadDynamicDirectories(); - this.findPossibleGroupForField(); }, mounted() { window.$(window).on('beforeunload', () => { @@ -1739,7 +1745,6 @@ export default { if (this.ex_deps.length > 0 && this.site_type === null) { this.site_type = this.ex_deps[0].pk; } - this.findPossibleGroupForField(); }, cancel() { // eslint-disable-next-line no-restricted-globals,no-alert @@ -1833,9 +1838,6 @@ export default { closePermissionsModal() { this.showPermissionsModal = false; }, - findPossibleGroupForField() { - this.possibleGroupsForField = this.groups.map(group => ({ id: group.pk, label: group.pk })); - }, openFileAddModal() { this.showFileAddModal = true; }, @@ -2059,4 +2061,7 @@ export default { padding: 7px 12px; width: 116px !important; }; +.change-field-group { + margin: 6px 0; +} diff --git a/l2-frontend/yarn.lock b/l2-frontend/yarn.lock index ea90a9515b..3f1b3c71ec 100644 --- a/l2-frontend/yarn.lock +++ b/l2-frontend/yarn.lock @@ -2933,9 +2933,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001449, caniuse-lite@^1.0.30001464: - version "1.0.30001687" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001687.tgz" - integrity sha512-0S/FDhf4ZiqrTUiQ39dKeUjYRjkv7lOZU1Dgif2rIqrTzX/1wV2hfKu9TOm1IHkdSijfLswxTFzl/cvir+SLSQ== + version "1.0.30001688" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001688.tgz" + integrity sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA== case-sensitive-paths-webpack-plugin@^2.3.0: version "2.4.0" diff --git a/laboratory/__init__.py b/laboratory/__init__.py index d1dc733fa1..9e7a76602b 100644 --- a/laboratory/__init__.py +++ b/laboratory/__init__.py @@ -1,2 +1,2 @@ -__version__ = "2024.12.120019+74217f" +__version__ = "2024.12.151313+fe4486" VERSION = __version__ diff --git a/pyproject.toml b/pyproject.toml index 9e699a1565..b5b384adca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ skip-string-normalization = true [tool.poetry] name = "l2" -version = "2024.12.120019+74217f" +version = "2024.12.151313+fe4486" description = "" authors = ["Mikhail Privalov "] license = "MIT"