Skip to content

Commit

Permalink
Merge branch 'develop' into consturctor-laboratory-search
Browse files Browse the repository at this point in the history
  • Loading branch information
urchinpro authored Dec 16, 2024
2 parents e050972 + f1c5368 commit 465e427
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 20 deletions.
5 changes: 4 additions & 1 deletion api/directions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,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:
Expand Down
39 changes: 39 additions & 0 deletions command_utils/management/commands/import_mkb.py
Original file line number Diff line number Diff line change
@@ -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
68 changes: 64 additions & 4 deletions forms/forms106.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand All @@ -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)
Expand All @@ -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)]
Expand All @@ -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"<u>{title}</u>, код по МКБ <u>{code}</u>"
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:
Expand All @@ -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}<u>{title}</u>, код по МКБ <u>{code}</u><br/>"
Expand All @@ -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 = "&nbsp;"
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"<u>{result}</u>", style), Paragraph(f"код по МКБ {space_symbol * 3}<u>{result_mkb_code}</u>", 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
10 changes: 6 additions & 4 deletions forms/pdf_templates/template_federal_order_530_titul_page.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
{"text": "Основное заболевание: {}", "cdaTitles": [ "п.п.-Основное Ds мкб"], "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Осложнения основного заболевания: <u>{}</u>", "cdaTitles": ["п.п.-Пусто"], "style": "style"},
{"text": "{}", "cdaTitles": ["п.п.-Осложнения Ds мкб"], "style": "style"},
{"tbl": "Таблица", "cdaTitles": ["п.п.-Осложнения табл"], "type": "Осложнения", "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Внешняя причина при травмах, отравлениях: <u>{}</u> код по МКБ: <u>{}</u>", "cdaTitles": ["п.п.-Внешняя причина Ds текст", "п.п.-Внешняя причина Ds мкб" ], "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Сопутствующие заболевания: <u>{}</u>", "cdaTitles": ["п.п.-Пусто"], "style": "style"},
{"text": "{}", "cdaTitles": ["п.п.-Сопутствующие Ds мкб"], "style": "style"},
{"tbl": "Таблица", "cdaTitles": ["п.п.-Сопутствующие табл"], "type": "Сопутствующие", "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Дополнительные сведения о заболевании: <u>{}</u>", "cdaTitles": ["п.п.-Дополнительные сведения заболевания"], "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
Expand All @@ -60,11 +60,13 @@
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Основное заболевание: <u>{}</u> код по МКБ: <u>{}</u>", "cdaTitles": ["в.э.-Основное Ds текст", "в.э.-Основное Ds мкб"], "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Осложнения основного заболевания: <u>{}</u> код по МКБ: <u>{}</u>", "cdaTitles": ["в.э.-Осложнения Ds текст", "в.э.-Осложнения Ds мкб"], "style": "style"},
{"text": "Осложнения основного заболевания: <u>{}</u>", "cdaTitles": ["в.э.-Пусто"], "style": "style"},
{"tbl": "Таблица", "cdaTitles": ["в.э.-Осложнения табл"], "type": "Осложнения", "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Внешняя причина при травмах, отравлениях: <u>{}</u> код по МКБ: <u>{}</u>", "cdaTitles": ["в.э.-Внешняя причина Ds текст", "в.э.-Внешняя причина Ds мкб"], "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Сопутствующие заболевания: <u>{}</u> код по МКБ: <u>{}</u>", "cdaTitles": ["в.э.-Сопутствующие Ds текс", "в.э.-Сопутствующие Ds мкб"], "style": "style"},
{"text": "Сопутствующие заболевания: {}", "cdaTitles": ["в.э.-Пусто"], "style": "style"},
{"tbl": "Таблица", "cdaTitles": ["в.э.-Сопутствующие табл"], "type": "Сопутствующие", "style": "style"},
{"text": "", "spacer_data": 0.5, "Spacer": "true", "style": "styleCenter"},
{"text": "Дополнительные сведения о заболевании: <u>{}</u>", "cdaTitles": ["в.э.-Дополнительные сведения заболевания"], "style": "style"},
{"text": "", "spacer_data": 0.6, "Spacer": "true", "style": "styleCenter"},
Expand Down
17 changes: 11 additions & 6 deletions l2-frontend/src/construct/ParaclinicResearchEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@
<Treeselect
v-model="row.newGroupId"
placeholder="Группа..."
:options="possibleGroupsForField"
:options="findPossibleGroupForField"
/>
</div>
</div>
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -1425,7 +1432,6 @@ export default {
await this.loadDepartmentsForPermissions();
await this.load_deparments();
await this.loadDynamicDirectories();
this.findPossibleGroupForField();
},
mounted() {
window.$(window).on('beforeunload', () => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
},
Expand Down Expand Up @@ -2059,4 +2061,7 @@ export default {
padding: 7px 12px;
width: 116px !important;
};
.change-field-group {
margin: 6px 0;
}
</style>
6 changes: 3 additions & 3 deletions l2-frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion laboratory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "2024.12.120019+74217f"
__version__ = "2024.12.151313+fe4486"
VERSION = __version__
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 465e427

Please sign in to comment.