Skip to content

Commit

Permalink
Merge branch 'develop' into assignments-highlighting-non-results
Browse files Browse the repository at this point in the history
  • Loading branch information
urchinpro authored Mar 18, 2024
2 parents eb1fa79 + c483a84 commit 9e4e119
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 38 deletions.
6 changes: 4 additions & 2 deletions api/directions/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def get_history_dir(d_s, d_e, card_id, who_create_dir, services, is_serv, iss_pk
directory_researches.is_expertise,
person_contract.id as person_contract_id,
person_contract.dir_list as contract_dirs,
directions_napravleniya.hospital_id as dir_hosp
directions_napravleniya.hospital_id as dir_hosp,
directions_napravleniya.rmis_number as rmis_number
FROM directions_issledovaniya
LEFT JOIN directory_researches
ON directions_issledovaniya.research_id = directory_researches.Id
Expand Down Expand Up @@ -108,7 +109,8 @@ def get_history_dir(d_s, d_e, card_id, who_create_dir, services, is_serv, iss_pk
directions_napravleniya.visit_date,
directions_napravleniya.time_microbiology_receive,
directions_napravleniya.time_gistology_receive,
is_case
is_case,
directions_napravleniya.rmis_number
FROM t_iss_tubes
LEFT JOIN t_recive
ON t_iss_tubes.tubesregistration_id = t_recive.id_t_recive
Expand Down
8 changes: 7 additions & 1 deletion api/directions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def directions_history(request):
status_set = {-2}
lab = set()
lab_title = None
person_contract_dirs, planed_doctor, register_number = "", "", ""
person_contract_dirs, planed_doctor, register_number, rmis_number = "", "", "", ""
created_document_only_user_hosp = SettingManager.get("created_document_only_user_hosp", default='false', default_type='b')
user_groups = [str(x) for x in request.user.groups.all()]
type_service = request_data.get("type_service", None)
Expand Down Expand Up @@ -525,13 +525,16 @@ def directions_history(request):
'person_contract_dirs': person_contract_dirs,
'planed_doctor': planed_doctor,
'register_number': register_number,
'rmis_number': rmis_number,
}
)
child_researches_titles = ""
person_contract_pk = -1
person_contract_dirs = ""
planed_doctor = ""
register_number = ""
rmis_number = ""

dir = i[0]
expertise_data = get_expertise(dir)
is_expertise = False
Expand Down Expand Up @@ -616,6 +619,8 @@ def directions_history(request):
register_number = i[29]
if i[30]:
planed_doctor = f"{i[30]} {i[31]} {i[32]}"
if i[37]:
rmis_number = i[37]

status = min(status_set)
if len(lab) > 0:
Expand Down Expand Up @@ -653,6 +658,7 @@ def directions_history(request):
'person_contract_dirs': person_contract_dirs,
'planed_doctor': planed_doctor,
'register_number': register_number,
'rmis_number': rmis_number,
}
)
res['directions'] = final_result
Expand Down
81 changes: 51 additions & 30 deletions integration_framework/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,24 +1578,46 @@ def external_direction_create(request):
return Response({"ok": False, "message": "Некорректный auth токен"})

body = json.loads(request.body)
result = create_direction_by_param(body, request)
return Response(result)


@api_view(["POST"])
def external_list_direction_create(request):
if not hasattr(request.user, "hospitals"):
return Response({"ok": False, "message": "Некорректный auth токен"})
body_directions = json.loads(request.body)
for body in body_directions:
result = create_direction_by_param(body, request)
if not result.get("ok"):
try:
Log.log(
str(body.get("internalId")),
122002,
body={"data": body},
)
except Exception as e:
logger.exception(e)


def create_direction_by_param(body, request):
org = body.get("org", {})
code_tfoms = org.get("codeTFOMS")
oid_org = org.get("oid")

if not code_tfoms and not oid_org:
return Response({"ok": False, "message": "Должно быть указано хотя бы одно значение из org.codeTFOMS или org.oid"})
return {"ok": False, "message": "Должно быть указано хотя бы одно значение из org.codeTFOMS или org.oid"}

if code_tfoms:
hospital = Hospitals.objects.filter(code_tfoms=code_tfoms).first()
else:
hospital = Hospitals.objects.filter(oid=oid_org).first()

if not hospital:
return Response({"ok": False, "message": "Организация не найдена"})
return {"ok": False, "message": "Организация не найдена"}

if not request.user.hospitals.filter(pk=hospital.pk).exists():
return Response({"ok": False, "message": "Нет доступа в переданную организацию"})
return {"ok": False, "message": "Нет доступа в переданную организацию"}

is_exclude_contorl_documnets = False
if hospital.pk in HOSPITAL_PKS_NOT_CONTROL_DOCUMENT_EXTERNAL_CREATE_DIRECTION:
Expand All @@ -1606,15 +1628,15 @@ def external_direction_create(request):
enp = (patient.get("enp") or "").replace(" ", "")

if enp and (len(enp) != 16 or not enp.isdigit()):
return Response({"ok": False, "message": "Неверные данные полиса, должно быть 16 чисел"})
return {"ok": False, "message": "Неверные данные полиса, должно быть 16 чисел"}

snils = (patient.get("snils") or "").replace(" ", "").replace("-", "")

if not enp and not snils and not is_exclude_contorl_documnets:
return Response({"ok": False, "message": "При пустом patient.enp должно быть передано patient.snils или patient.passportSerial+patient.passportNumber"})
return {"ok": False, "message": "При пустом patient.enp должно быть передано patient.snils или patient.passportSerial+patient.passportNumber"}

if snils and not petrovna.validate_snils(snils):
return Response({"ok": False, "message": "patient.snils: не прошёл валидацию"})
return {"ok": False, "message": "patient.snils: не прошёл валидацию"}

lastname = str(patient.get("lastName") or "")
firstname = str(patient.get("firstName") or "")
Expand All @@ -1627,22 +1649,22 @@ def external_direction_create(request):
sex = "ж"

if not enp and not (lastname and firstname and birthdate and birthdate):
return Response({"ok": False, "message": "При пустом patient.enp должно быть передано поле patient.individual"})
return {"ok": False, "message": "При пустом patient.enp должно быть передано поле patient.individual"}

if lastname and not firstname:
return Response({"ok": False, "message": "При передаче lastname должен быть передан и firstname"})
return {"ok": False, "message": "При передаче lastname должен быть передан и firstname"}

if firstname and not lastname:
return Response({"ok": False, "message": "При передаче firstname должен быть передан и lastname"})
return {"ok": False, "message": "При передаче firstname должен быть передан и lastname"}

if firstname and lastname and not birthdate:
return Response({"ok": False, "message": "При передаче firstname и lastname должно быть передано поле birthdate"})
return {"ok": False, "message": "При передаче firstname и lastname должно быть передано поле birthdate"}

if birthdate and (not re.fullmatch(r"\d{4}-\d\d-\d\d", birthdate) or birthdate[0] not in ["1", "2"]):
return Response({"ok": False, "message": "birthdate должно соответствовать формату YYYY-MM-DD"})
return {"ok": False, "message": "birthdate должно соответствовать формату YYYY-MM-DD"}

if birthdate and sex not in ["м", "ж"]:
return Response({"ok": False, "message": 'individual.sex должно быть "м" или "ж"'})
return {"ok": False, "message": 'individual.sex должно быть "м" или "ж"'}

individual = None
if enp:
Expand Down Expand Up @@ -1681,25 +1703,25 @@ def external_direction_create(request):
)

if not individual:
return Response({"ok": False, "message": "Физлицо не найдено"})
return {"ok": False, "message": "Физлицо не найдено"}

card = Card.objects.filter(individual=individual, base__internal_type=True).first()
if not card:
card = Card.add_l2_card(individual)

if not card:
return Response({"ok": False, "message": "Карта не найдена"})
return {"ok": False, "message": "Карта не найдена"}

financing_source_title = body.get("financingSource", "")
if financing_source_title.lower() not in ["омс", "бюджет", "платно"]:
return Response({"ok": False, "message": "Некорректный источник финансирования"})
return {"ok": False, "message": "Некорректный источник финансирования"}

financing_source = directions.IstochnikiFinansirovaniya.objects.filter(title__iexact=financing_source_title, base__internal_type=True).first()
financing_category_code = body.get("financingCategory", "")
price_category = PriceCategory.objects.filter(title__startswith=financing_category_code).first()

if not financing_source:
return Response({"ok": False, "message": "Некорректный источник финансирования"})
return {"ok": False, "message": "Некорректный источник финансирования"}

message = None

Expand All @@ -1713,11 +1735,11 @@ def external_direction_create(request):

diag_text = body.get("diagText", "") # обязательно
if not diag_text:
return Response({"ok": False, "message": "Диагноз описание не заполнено"})
return {"ok": False, "message": "Диагноз описание не заполнено"}

diag_mkb10 = body.get("diagMKB10", "") # обязательно
if not diag_mkb10:
return Response({"ok": False, "message": "Диагноз по МКБ10 не заполнен (не верно)"})
return {"ok": False, "message": "Диагноз по МКБ10 не заполнен (не верно)"}
open_skob = "{"
close_skob = "}"

Expand All @@ -1734,32 +1756,30 @@ def external_direction_create(request):
}
method_obtain_material = body.get("methodObtainMaterial", "") # обязательно code из НСИ 1.2.643.5.1.13.13.99.2.33"
if not method_obtain_material or method_obtain_material not in [1, 2, 3, 4, 5, 6, 7]:
return Response({"ok": False, "message": "Способо забора не верно заполнено"})
return {"ok": False, "message": "Способо забора не верно заполнено"}

resident_code = patient.get("residentCode", "") # обязательно code из НСИ 1.2.643.5.1.13.13.11.1042"
if not resident_code or resident_code not in [1, 2]:
return Response({"ok": False, "message": "Не указан вид жительства"})
return {"ok": False, "message": "Не указан вид жительства"}
if resident_code == 1:
resident_data = f'{open_skob}"code": "1", "title": "Город"{close_skob}'
else:
resident_data = f'{open_skob}"code": "2", "title": "Село"{close_skob}'

solution10 = body.get("solution10", "") # обязательно
if not solution10 or solution10 not in ["true", "false"]:
return Response({"ok": False, "message": "Не указано помещен в 10% раствор"})
return {"ok": False, "message": "Не указано помещен в 10% раствор"}

doctor_fio = body.get("doctorFio", "") # обязательно
if not doctor_fio:
return Response({"ok": False, "message": "Не указан врач производивший забор материала"})
return {"ok": False, "message": "Не указан врач производивший забор материала"}
material_mark = body.get("materialMark", "")
numbers_vial = []
for k in material_mark:
result_check = check_valid_material_mark(k, numbers_vial)
if not result_check:
return Response({"ok": False, "message": "Не верная маркировка материала"})
return {"ok": False, "message": "Не верная маркировка материала"}
numbers_vial = result_check
if len(numbers_vial) != sorted(numbers_vial)[-1]:
return Response({"ok": False, "message": "Не верная маркировка флаконов (порядок 1,2,3,4...)"})

try:
with transaction.atomic():
Expand All @@ -1772,6 +1792,7 @@ def external_direction_create(request):
hospital=hospital,
id_in_hospital=id_in_hospital,
price_category=price_category,
rmis_number=id_in_hospital if body.get("isRMIS") else None,
)

time_get = str(body.get("dateTimeGet", "") or "") or None
Expand All @@ -1795,7 +1816,7 @@ def external_direction_create(request):
pathological_process = {1: "1-Внешне неизмененная ткань", 2: "2-Узел", 3: "3-Пятно", 4: "4-Полип", 5: "5-Эрозия", 6: "6-Язва", 7: "7-Прочие"}
for m_m in material_mark:
result_table_field.append(
[str(m_m["numberVial"]), m_m.get("localization", ""), pathological_process[m_m["pathologicalProcess"]], str(m_m["objectValue"]), m_m.get("description", "")]
[str(m_m["numberVial"]), m_m.get("localization", ""), pathological_process[m_m.get("pathologicalProcess", 7)], str(m_m["objectValue"]), m_m.get("description", "")]
)
data_marked["rows"] = result_table_field
match_keys = {
Expand Down Expand Up @@ -1826,7 +1847,7 @@ def external_direction_create(request):
)
except Exception as e:
logger.exception(e)
return Response({"ok": True, "id": str(direction.pk)})
return {"ok": True, "id": str(direction.pk)}

except InvalidData as e:
logger.exception(e)
Expand All @@ -1835,7 +1856,7 @@ def external_direction_create(request):
logger.exception(e)
message = "Серверная ошибка"

return Response({"ok": False, "message": message})
return {"ok": False, "message": message}


@api_view(["POST"])
Expand Down Expand Up @@ -1923,11 +1944,11 @@ def external_get_pdf_result(request):
return JsonResponse({"result": pdf_data})


def check_valid_material_mark(current_material_data, current_numbers_vial):
def check_valid_material_mark(current_material_data, current_numbers_vial, isCheckpathologicalProcess=False):
for k, v in current_material_data.items():
if k == "numberVial" and not isinstance(v, int): # обязательно число
return False
if k == "pathologicalProcess" and v not in [1, 2, 3, 4, 5, 6, 7]: # "code из НСИ 1.2.643.5.1.13.13.99.2.34" обязательно
if isCheckpathologicalProcess and k == "pathologicalProcess" and v not in [1, 2, 3, 4, 5, 6, 7]: # "code из НСИ 1.2.643.5.1.13.13.99.2.34" обязательно
return False
if k == "objectValue" and not isinstance(v, int): # обязательно число
return False
Expand Down
1 change: 1 addition & 0 deletions l2-frontend/src/ui-cards/DirectionsHistory/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
:class="['status-' + row.status]"
>
<strong>
<span v-if="row.rmis_number">e</span>
{{ row.status }}
<span v-if="row.maybe_onco">*О</span>
<span v-if="row.is_application">**З</span>
Expand Down
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.30001597"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001597.tgz"
integrity sha512-7LjJvmQU6Sj7bL0j5b5WY/3n7utXUJvAe1lxhsHDbLmwX9mdL86Yjtr+5SRCyf8qME4M7pU2hswj0FpyBVCv9w==
version "1.0.30001598"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001598.tgz"
integrity sha512-j8mQRDziG94uoBfeFuqsJUNECW37DXpnvhcMJMdlH2u3MRkq1sAI0LJcXP1i/Py0KbSIC4UDj8YHPrTn5YsL+Q==

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.3.120305+95738d"
__version__ = "2024.3.171159+d5b7dc"
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.3.120305+95738d"
version = "2024.3.171159+d5b7dc"
description = ""
authors = ["Mikhail Privalov <[email protected]>"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions slog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Log(models.Model):
(121107, 'Сотрудники: обновление должности сотрудника'),
(122000, 'Гистология: регистрация материала гистологии'),
(122001, 'Гистология: api-приём направлений'),
(122002, 'Ошибка Гистология: api-приём направлений списком'),
(130000, 'Настройка прайсов: изменение цены'),
(130001, 'Настройка прайсов: удаление цены'),
(130002, 'Настройка компаний: изменение компании'),
Expand Down

0 comments on commit 9e4e119

Please sign in to comment.