From 0cc5ae33674144d0fedd85987d6783928458a31a Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Fri, 17 Nov 2023 18:57:58 +0800 Subject: [PATCH 01/31] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/directions/views.py | 1 + api/sql_func.py | 26 ++++++++++++++++++++ api/views.py | 54 ++++++++++++++++++++++++++++++++++++++++- directions/models.py | 11 ++++++--- pyproject.toml | 2 +- 5 files changed, 89 insertions(+), 5 deletions(-) diff --git a/api/directions/views.py b/api/directions/views.py index 97ba05523b..e4f95fb0ac 100644 --- a/api/directions/views.py +++ b/api/directions/views.py @@ -170,6 +170,7 @@ def directions_generate(request): price_category=p.get("priceCategory", -1), case_id=p.get("caseId", -2), case_by_direction=p.get("caseByDirection", False), + plan_start_date=p.get("planStartDate", None) ) if type_generate == "calculate-cost": fin_source_obj = IstochnikiFinansirovaniya.objects.filter(pk=fin_source_pk).first() diff --git a/api/sql_func.py b/api/sql_func.py index 94e029da6b..8aeb03be71 100644 --- a/api/sql_func.py +++ b/api/sql_func.py @@ -404,3 +404,29 @@ def search_text_stationar(date_create_start, date_create_end, final_text): rows = namedtuplefetchall(cursor) return rows + + +def search_case_by_card_date(card_id, plan_date_start_case, research_case_id): + with connection.cursor() as cursor: + cursor.execute( + """ + SELECT + directions_napravleniya.id as case_direction_number, + directions_issledovaniya.id as case_issledovaniye_number + FROM directions_issledovaniya + LEFT JOIN directions_napravleniya ON directions_napravleniya.id = directions_issledovaniya.napravleniye_id + WHERE + directions_issledovaniya.research_id = %(research_case_id)s + and directions_issledovaniya.plan_start_date AT TIME ZONE %(tz)s = %(plan_date_start_case)s + and directions_napravleniya.client_id = %(card_id)s + """, + params={ + 'card_id': card_id, + 'plan_date_start_case': plan_date_start_case, + 'research_case_id': research_case_id, + 'tz': TIME_ZONE, + }, + ) + + rows = namedtuplefetchall(cursor) + return rows diff --git a/api/views.py b/api/views.py index 50657d840c..73f21071c6 100644 --- a/api/views.py +++ b/api/views.py @@ -79,7 +79,7 @@ from utils.xh import get_all_hospitals from .dicom import search_dicom_study from .directions.sql_func import get_lab_podr -from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar +from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar, search_case_by_card_date from laboratory.settings import URL_RMIS_AUTH, URL_ELN_MADE, URL_SCHEDULE import urllib.parse @@ -3305,6 +3305,58 @@ def get_examination_list(request): @login_required @group_required("Конструктор: Настройка организации") def print_medical_examination_data(request): + request_data = json.loads(request.body) + cards = request_data.get("cards") + research_case = Researches.objects.filter(is_case=True, hide=False).first() + print(research_case.pk) + doc = users.DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() + print(doc) + print(cards) + for card in cards: + print(card) + card_id = card.get("card_id") + researches = card.get("research") + plan_date_start_case = "2023-11-01 00:00:00" + result_search_case = search_case_by_card_date(card_id, plan_date_start_case, research_case.pk) + print(result_search_case) + financing_source = directions.IstochnikiFinansirovaniya.objects.filter(title__in=["Профосмотр", "Юрлицо"]).first() + + if result_search_case: + if result_search_case: + print("нашли случай") + pass + else: + print("не нашли случай") + result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( + card_id, + "", + financing_source.pk, + "", + None, + doc, + {-1: researches}, + {}, + False, + {}, + vich_code="", + count=1, + discount=0, + rmis_slot=None, + price_name=13, + case_id=-1, + case_by_direction=True, + plan_start_date=plan_date_start_case + ) + print(result) + + # найти случаи по карте и дате + # если нет создать случай + # к случаю привязать услуги + # отдать номера направлений + # найти направления (не отмененные) - где родитель случай + # по направлениям получить перечень услуги + # услуги по АПИ сверить с усулгами по направлениям, если не отходит создать НАПРАВЛЕНИЯ + # отдать по картам пациентов номера направлений return status_response(True) diff --git a/directions/models.py b/directions/models.py index eff4f3154d..6f10b57dae 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1293,7 +1293,9 @@ def gen_napravleniya_by_issledovaniya( price_name=None, case_id=-2, case_by_direction=False, + plan_start_date=None, ): + print(researches) result = {"r": False, "list_id": [], "list_stationar_id": [], "messageLimit": ""} if case_id > -1 and case_by_direction: iss = Napravleniya.objects.get(pk=case_id).issledovaniya_set.all().first() @@ -1322,7 +1324,6 @@ def gen_napravleniya_by_issledovaniya( else: finsource = f_obj.pk finsource = IstochnikiFinansirovaniya.objects.filter(pk=finsource).first() - if not doc_current.not_control_anketa: if control_anketa_dispanserization and finsource and "омс" in finsource.title.lower() and doc_current.pk not in EXCLUDE_DOCTOR_PROFILE_PKS_ANKETA_NEED: d1, d2 = start_end_year() @@ -1396,6 +1397,7 @@ def gen_napravleniya_by_issledovaniya( conflict_list = [] conflict_keys = [] limit_research_to_assign = {} + print(researches) for v in researches: # нормализация исследований researches_grouped_by_lab.append({v: researches[v]}) for vv in researches[v]: @@ -1562,7 +1564,8 @@ def gen_napravleniya_by_issledovaniya( issledovaniye_case = Issledovaniya( napravleniye=napravleniye_case, research=research_case, - deferred=False + deferred=False, + plan_start_date=plan_start_date ) issledovaniye_case.save() issledovaniye_case_id = issledovaniye_case.pk @@ -1668,6 +1671,7 @@ def gen_napravleniya_by_issledovaniya( how_many=research_howmany, deferred=False, external_add_order=ext_additional_num, + plan_start_date=plan_start_date ) if not directions_for_researches[dir_group].need_order_redirection and research.plan_external_performing_organization: @@ -1798,6 +1802,7 @@ def gen_napravleniya_by_issledovaniya( localizations=localizations, service_locations=service_locations, visited=visited, + plan_start_date=plan_start_date ) if not res_children["r"]: return res_children @@ -2277,7 +2282,7 @@ class Issledovaniya(models.Model): DoctorProfile, null=True, blank=True, related_name="doc_add_additional", db_index=True, help_text='Профиль-добавил исполнитель дополнительные услуги', on_delete=models.SET_NULL ) external_add_order = models.ForeignKey(ExternalAdditionalOrder, db_index=True, blank=True, null=True, default=None, help_text="Внешний заказ", on_delete=models.SET_NULL) - + plan_start_date = models.DateTimeField(help_text='Планируемая дата-время начала оказания', db_index=True, blank=True, default=None, null=True) @property def time_save_local(self): diff --git a/pyproject.toml b/pyproject.toml index 1747b68f06..e17a493c13 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ beren = "0.7.1" transliterate = "1.10.2" imgkit = "1.2.3" astm = {git = "https://github.com/moodpulse/python-astm.git", rev = "v0.6"} -psycopg2-binary = "^2.9.4" +#psycopg2-binary = "^2.9.4" boto3 = "^1.28.64" prompt-toolkit = "^3.0.36" pdf2docx = "^0.5.6" From 978073c8f6a8467622607cbecc79639eb0ef28e1 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Fri, 17 Nov 2023 20:52:12 +0800 Subject: [PATCH 02/31] =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B8=20=D1=81?= =?UTF-8?q?=D0=BB=D1=83=D1=87=D0=B0=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/sql_func.py | 6 ++-- api/views.py | 82 ++++++++++++++++++++++++++++++------------ directions/models.py | 1 - directions/sql_func.py | 15 ++++++++ 4 files changed, 79 insertions(+), 25 deletions(-) diff --git a/api/sql_func.py b/api/sql_func.py index 8aeb03be71..3867b50fe3 100644 --- a/api/sql_func.py +++ b/api/sql_func.py @@ -406,7 +406,7 @@ def search_text_stationar(date_create_start, date_create_end, final_text): return rows -def search_case_by_card_date(card_id, plan_date_start_case, research_case_id): +def search_case_by_card_date(card_id, plan_date_start_case, research_case_id, limit): with connection.cursor() as cursor: cursor.execute( """ @@ -418,13 +418,15 @@ def search_case_by_card_date(card_id, plan_date_start_case, research_case_id): WHERE directions_issledovaniya.research_id = %(research_case_id)s and directions_issledovaniya.plan_start_date AT TIME ZONE %(tz)s = %(plan_date_start_case)s - and directions_napravleniya.client_id = %(card_id)s + and directions_napravleniya.client_id = %(card_id)s + LIMIT %(limit)s """, params={ 'card_id': card_id, 'plan_date_start_case': plan_date_start_case, 'research_case_id': research_case_id, 'tz': TIME_ZONE, + 'limit': limit }, ) diff --git a/api/views.py b/api/views.py index 73f21071c6..77403688c9 100644 --- a/api/views.py +++ b/api/views.py @@ -8,6 +8,7 @@ import pytz_deprecation_shim as pytz from api.models import ManageDoctorProfileAnalyzer, Analyzer +from directions.sql_func import get_researches_by_number_directions from directory.models import Researches, SetResearch, SetOrderResearch, PatientControlParam from doctor_schedule.models import ScheduleResource from ecp_integration.integration import get_reserves_ecp, get_slot_ecp @@ -3308,25 +3309,69 @@ def print_medical_examination_data(request): request_data = json.loads(request.body) cards = request_data.get("cards") research_case = Researches.objects.filter(is_case=True, hide=False).first() - print(research_case.pk) doc = users.DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() - print(doc) - print(cards) + card_directions = {} for card in cards: - print(card) card_id = card.get("card_id") researches = card.get("research") plan_date_start_case = "2023-11-01 00:00:00" - result_search_case = search_case_by_card_date(card_id, plan_date_start_case, research_case.pk) - print(result_search_case) + result_search_case = search_case_by_card_date(card_id, plan_date_start_case, research_case.pk, 1) + case_issledovaniye_number, case_direction_number = None, None + for i in result_search_case: + case_issledovaniye_number = i.case_issledovaniye_number + case_direction_number = i.case_direction_number + break financing_source = directions.IstochnikiFinansirovaniya.objects.filter(title__in=["Профосмотр", "Юрлицо"]).first() + print(result_search_case) - if result_search_case: - if result_search_case: - print("нашли случай") - pass + if case_issledovaniye_number: + number_directons = directions.Napravleniya.objects.values_list("id", flat=True).filter(parent_case_id=case_issledovaniye_number) + print(number_directons) + researches_sql = get_researches_by_number_directions(tuple(number_directons)) + current_researches_case = set([i.research_id for i in researches_sql]) + api_researches = set(researches) + api_researches -= current_researches_case + researches = list(api_researches) + result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( + card_id, + "", + financing_source.pk, + "", + None, + doc, + {-1: researches}, + {}, + False, + {}, + vich_code="", + count=1, + discount=0, + rmis_slot=None, + price_name=13, + case_id=case_direction_number, + case_by_direction=True, + plan_start_date=plan_date_start_case + ) else: - print("не нашли случай") + napravleniye_case = directions.Napravleniya.gen_napravleniye( + card_id, + doc, + financing_source, + "", + "", + doc, + -1, + doc, + price_name_id=13 + ) + + issledovaniye_case = directions.Issledovaniya( + napravleniye=napravleniye_case, + research=research_case, + deferred=False, + plan_start_date=plan_date_start_case + ) + issledovaniye_case.save() result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( card_id, "", @@ -3343,20 +3388,13 @@ def print_medical_examination_data(request): discount=0, rmis_slot=None, price_name=13, - case_id=-1, + case_id=napravleniye_case.pk, case_by_direction=True, plan_start_date=plan_date_start_case ) - print(result) - - # найти случаи по карте и дате - # если нет создать случай - # к случаю привязать услуги - # отдать номера направлений - # найти направления (не отмененные) - где родитель случай - # по направлениям получить перечень услуги - # услуги по АПИ сверить с усулгами по направлениям, если не отходит создать НАПРАВЛЕНИЯ - # отдать по картам пациентов номера направлений + print(result.get("list_id")) + card_directions[card_id] = result.get("list_id") + return status_response(True) diff --git a/directions/models.py b/directions/models.py index 6f10b57dae..027d627c55 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1295,7 +1295,6 @@ def gen_napravleniya_by_issledovaniya( case_by_direction=False, plan_start_date=None, ): - print(researches) result = {"r": False, "list_id": [], "list_stationar_id": [], "messageLimit": ""} if case_id > -1 and case_by_direction: iss = Napravleniya.objects.get(pk=case_id).issledovaniya_set.all().first() diff --git a/directions/sql_func.py b/directions/sql_func.py index 0d8050a557..fcb079d3fa 100644 --- a/directions/sql_func.py +++ b/directions/sql_func.py @@ -84,3 +84,18 @@ def check_create_direction_patient_by_research(client_id, researches, months_ago ) rows = namedtuplefetchall(cursor) return rows + + +def get_researches_by_number_directions(direction_numbers): + with connection.cursor() as cursor: + cursor.execute( + """ + SELECT + directions_issledovaniya.research_id + FROM directions_issledovaniya + WHERE directions_issledovaniya.napravleniye_id in %(direction_numbers)s + """, + params={'direction_numbers': direction_numbers}, + ) + rows = namedtuplefetchall(cursor) + return rows \ No newline at end of file From 1bdadeaee76b21d06405235c3f76c70d7ce6854c Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Sun, 19 Nov 2023 21:28:19 +0800 Subject: [PATCH 03/31] . --- laboratory/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/laboratory/settings.py b/laboratory/settings.py index 6b592083c1..64f61c5144 100644 --- a/laboratory/settings.py +++ b/laboratory/settings.py @@ -394,6 +394,7 @@ def __getitem__(self, item): QR_CODE_ANKETA = "" RESULT_LABORATORY_FORM = "" SELF_WATERMARKS = "" +TYPE_COMPANY_SET_DIRECTION_PDF = [] try: from laboratory.local_settings import * # noqa: F403,F401 From 03539c50f615af70fef5cf37eb1ee2e85c677ec6 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 14:33:27 +0800 Subject: [PATCH 04/31] print set document for many people --- api/views.py | 49 ++++++++++++++++--- directions/models.py | 1 - forms/forms112.py | 18 ++++++- .../src/construct/ConstructCompany.vue | 7 ++- laboratory/settings.py | 2 +- utils/xh.py | 41 ++++++++++++++++ 6 files changed, 107 insertions(+), 11 deletions(-) diff --git a/api/views.py b/api/views.py index 77403688c9..d6c06e9bfc 100644 --- a/api/views.py +++ b/api/views.py @@ -24,7 +24,7 @@ UNLIMIT_PERIOD_STATISTIC_GROUP, TITLE_REPORT_FILTER_HAS_ALL_FIN_SOURCE, STATISTIC_TYPE_DEPARTMENT, - USE_TFOMS_DISTRICT, + USE_TFOMS_DISTRICT, TYPE_COMPANY_SET_DIRECTION_PDF, ) from utils.response import status_response @@ -77,12 +77,14 @@ from utils.common import non_selected_visible_type from utils.dates import try_parse_range, try_strptime from utils.nsi_directories import NSI -from utils.xh import get_all_hospitals +from utils.xh import get_all_hospitals, save_tmp_file, simple_join_two_pdf_files, simple_save_pdf_file from .dicom import search_dicom_study from .directions.sql_func import get_lab_podr from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar, search_case_by_card_date from laboratory.settings import URL_RMIS_AUTH, URL_ELN_MADE, URL_SCHEDULE import urllib.parse +from django.http import HttpResponse +from django.utils.module_loading import import_string logger = logging.getLogger("API") @@ -3311,6 +3313,7 @@ def print_medical_examination_data(request): research_case = Researches.objects.filter(is_case=True, hide=False).first() doc = users.DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() card_directions = {} + number_directons = None for card in cards: card_id = card.get("card_id") researches = card.get("research") @@ -3322,11 +3325,9 @@ def print_medical_examination_data(request): case_direction_number = i.case_direction_number break financing_source = directions.IstochnikiFinansirovaniya.objects.filter(title__in=["Профосмотр", "Юрлицо"]).first() - print(result_search_case) if case_issledovaniye_number: number_directons = directions.Napravleniya.objects.values_list("id", flat=True).filter(parent_case_id=case_issledovaniye_number) - print(number_directons) researches_sql = get_researches_by_number_directions(tuple(number_directons)) current_researches_case = set([i.research_id for i in researches_sql]) api_researches = set(researches) @@ -3392,10 +3393,44 @@ def print_medical_examination_data(request): case_by_direction=True, plan_start_date=plan_date_start_case ) - print(result.get("list_id")) - card_directions[card_id] = result.get("list_id") + if number_directons: + number_directons = [i for i in number_directons] + else: + number_directons = [] + number_directons.extend(result.get("list_id")) + card_directions[card_id] = list(set(number_directons)) + response = HttpResponse(content_type='application/pdf') + + response['Content-Disposition'] = 'inline; filename="directions.pdf"' + files_data = [] + if TYPE_COMPANY_SET_DIRECTION_PDF: + additional_page = import_string('forms.forms112.' + TYPE_COMPANY_SET_DIRECTION_PDF.split(".")[0]) + step = 0 + for card, directions_data in card_directions.items(): + step += 1 + if len(directions_data) > 1: + directions_data = [str(i) for i in directions_data] + napr_id = ", ".join(directions_data) + else: + napr_id = directions_data[0] + napr_id = f"[{napr_id}]" + fc = additional_page( + request_data={ + **dict(request.GET.items()), + "user": request.user, + "card_pk": card, + "hospital": request.user.doctorprofile.get_hospital() if hasattr(request.user, "doctorprofile") else Hospitals.get_default_hospital(), + "type_additional_pdf": TYPE_COMPANY_SET_DIRECTION_PDF.split(".")[1], + "fin_title": "профосмотр", + "napr_id": napr_id, + } + ) + saved_file_pdf = simple_save_pdf_file(fc) + files_data.append(saved_file_pdf) - return status_response(True) + buffer = simple_join_two_pdf_files(files_data) + saved_file_pdf = simple_save_pdf_file(buffer) + return JsonResponse({"fileName": saved_file_pdf}) @login_required diff --git a/directions/models.py b/directions/models.py index 027d627c55..4b15bf7e74 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1396,7 +1396,6 @@ def gen_napravleniya_by_issledovaniya( conflict_list = [] conflict_keys = [] limit_research_to_assign = {} - print(researches) for v in researches: # нормализация исследований researches_grouped_by_lab.append({v: researches[v]}) for vv in researches[v]: diff --git a/forms/forms112.py b/forms/forms112.py index 3fde782582..3bd479e5c9 100644 --- a/forms/forms112.py +++ b/forms/forms112.py @@ -26,6 +26,7 @@ from directions.views import gen_pdf_dir as f_print_direction from django.http import HttpRequest from django.utils.module_loading import import_string +from pdfrw import PdfReader, PdfWriter def form_01(request_data): @@ -342,7 +343,6 @@ def form_02(request_data): def join_two_pdf_data(func_name, http_params, user_data, buffer, ind_card, type="post"): - if type == "get": fc = func_name(request_data=http_params) is_get = False @@ -512,3 +512,19 @@ def add_appendix_direction_list(appendix_direction_list, dir_temp): elif section.get('isHospital'): direction_data.extend(list(types_direction["isHospital"])) return direction_data + + +def form_03(request_data): + file_name = request_data.get("file").replace('"', "") + dir_param = SettingManager.get("dir_param", default='/tmp', default_type='s') + file_dir = os.path.join(dir_param, file_name) + pdf_all = BytesIO() + inputs = [file_dir] + writer = PdfWriter() + for inpfn in inputs: + writer.addpages(PdfReader(inpfn).pages) + writer.write(pdf_all) + pdf_out = pdf_all.getvalue() + os.remove(file_dir) + + return pdf_out diff --git a/l2-frontend/src/construct/ConstructCompany.vue b/l2-frontend/src/construct/ConstructCompany.vue index ccc49558ad..ffbc2e8738 100644 --- a/l2-frontend/src/construct/ConstructCompany.vue +++ b/l2-frontend/src/construct/ConstructCompany.vue @@ -608,10 +608,15 @@ export default { const selectCard = this.selectedCards; return selectCard.includes(card); }).map((exam) => ({ card_id: exam.card_id, date: exam.date, research: exam.research_id })); - await this.$api('print-medical-examination-data', { + await this.$store.dispatch(actions.INC_LOADING); + const result = await this.$api('print-medical-examination-data', { cards: printData, exclude: this.excludedResearches, }); + await this.$store.dispatch(actions.DEC_LOADING); + if (result.fileName) { + window.open(`/forms/pdf?type=112.03&file=${encodeURIComponent(JSON.stringify(result.fileName))}`, '_blank'); + } }, }, }; diff --git a/laboratory/settings.py b/laboratory/settings.py index 64f61c5144..f7bae17a8a 100644 --- a/laboratory/settings.py +++ b/laboratory/settings.py @@ -394,7 +394,7 @@ def __getitem__(self, item): QR_CODE_ANKETA = "" RESULT_LABORATORY_FORM = "" SELF_WATERMARKS = "" -TYPE_COMPANY_SET_DIRECTION_PDF = [] +TYPE_COMPANY_SET_DIRECTION_PDF = "" try: from laboratory.local_settings import * # noqa: F403,F401 diff --git a/utils/xh.py b/utils/xh.py index dab9daee8b..f7fed72e20 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -1,7 +1,12 @@ +import datetime + from api.directions.sql_func import get_lab_podr from appconf.manager import SettingManager from laboratory.settings import QRCODE_OFFSET_SIZE, LEFT_QRCODE_OFFSET_SIZE from utils.flowable import QrCodeSite +import datetime +import os.path +from io import BytesIO def fix(s: str): @@ -104,3 +109,39 @@ def show_qr_lk_address(fwb, leftnone=False): def replace_values(key): replace_data = {"code": "Код МКБ10", "title": "", "id": ""} return replace_data.get(key, "") + + +def simple_join_two_pdf_files(files_data): + + from pdfrw import PdfReader, PdfWriter + + today = datetime.datetime.now() + date_now1 = datetime.datetime.strftime(today, "%y%m%d%H%M%S%f")[:-3] + date_now_str = str(date_now1) + + pdf_all = BytesIO() + inputs = files_data + writer = PdfWriter() + for inpfn in inputs: + writer.addpages(PdfReader(inpfn).pages) + writer.write(pdf_all) + pdf_out = pdf_all.getvalue() + pdf_all.close() + + for i in files_data: + os.remove(i) + return pdf_out + + +def simple_save_pdf_file(fc): + fc_buf = BytesIO() + fc_buf.write(fc) + fc_buf.seek(0) + today = datetime.datetime.now() + date_now1 = datetime.datetime.strftime(today, "%y%m%d%H%M%S%f")[:-3] + date_now_str = str(date_now1) + dir_param = SettingManager.get("dir_param", default='/tmp', default_type='s') + file_buffer1 = os.path.join(dir_param, date_now_str + '_buffer1.pdf') + save_tmp_file(fc_buf, filename=file_buffer1) + return file_buffer1 + From 84ca3055e44f542dee50c97397b35c6b13e2fc9d Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 14:36:58 +0800 Subject: [PATCH 05/31] print set document for many people --- api/directions/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/directions/views.py b/api/directions/views.py index 118a02ebbf..a96b676d6b 100644 --- a/api/directions/views.py +++ b/api/directions/views.py @@ -170,7 +170,7 @@ def directions_generate(request): price_category=p.get("priceCategory", -1), case_id=p.get("caseId", -2), case_by_direction=p.get("caseByDirection", False), - plan_start_date=p.get("planStartDate", None) + plan_start_date=p.get("planStartDate", None), slot_fact_id=p.get("slotFactId", None), ) if type_generate == "calculate-cost": From 2445ab83d56b3f0e7eb5e9d9dff95770c1635740 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:44:38 +0800 Subject: [PATCH 06/31] Update utils/xh.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- utils/xh.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/xh.py b/utils/xh.py index f7fed72e20..8423467325 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -144,4 +144,3 @@ def simple_save_pdf_file(fc): file_buffer1 = os.path.join(dir_param, date_now_str + '_buffer1.pdf') save_tmp_file(fc_buf, filename=file_buffer1) return file_buffer1 - From 31f5da73ec140a5d5c7bdbc8cda0d22fbf0ac278 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:44:44 +0800 Subject: [PATCH 07/31] Update utils/xh.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- utils/xh.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/xh.py b/utils/xh.py index 8423467325..c4fbf13fc4 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -112,7 +112,6 @@ def replace_values(key): def simple_join_two_pdf_files(files_data): - from pdfrw import PdfReader, PdfWriter today = datetime.datetime.now() From dc1977048e846b315750959d74e3e3b6a9f4ddd5 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:44:49 +0800 Subject: [PATCH 08/31] Update directions/models.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- directions/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/directions/models.py b/directions/models.py index a420008a1b..9c22fd0ac2 100644 --- a/directions/models.py +++ b/directions/models.py @@ -2276,7 +2276,6 @@ class Issledovaniya(models.Model): ) external_add_order = models.ForeignKey(ExternalAdditionalOrder, db_index=True, blank=True, null=True, default=None, help_text="Внешний заказ", on_delete=models.SET_NULL) - @property def time_save_local(self): return localtime(self.time_save) From d5dfd1940f4203a1827701a293fa39bb6cfe2d46 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:44:56 +0800 Subject: [PATCH 09/31] Update directions/models.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- directions/models.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/directions/models.py b/directions/models.py index 9c22fd0ac2..d762479822 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1557,11 +1557,7 @@ def gen_napravleniya_by_issledovaniya( price_name_id=price_name, ) research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() - issledovaniye_case = Issledovaniya( - napravleniye=napravleniye_case, - research=research_case, - deferred=False - ) + issledovaniye_case = Issledovaniya(napravleniye=napravleniye_case, research=research_case, deferred=False) issledovaniye_case.save() issledovaniye_case_id = issledovaniye_case.pk elif case_id > 0: From 7d5e25ef2bae785c1b334b9a15a2e4378bb5713a Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:45:01 +0800 Subject: [PATCH 10/31] Update api/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index d6c06e9bfc..0c3c913dc1 100644 --- a/api/views.py +++ b/api/views.py @@ -3391,7 +3391,7 @@ def print_medical_examination_data(request): price_name=13, case_id=napravleniye_case.pk, case_by_direction=True, - plan_start_date=plan_date_start_case + plan_start_date=plan_date_start_case, ) if number_directons: number_directons = [i for i in number_directons] From 2261f93af166dd3304ea4fb0f1d4440b6f3d134e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:45:11 +0800 Subject: [PATCH 11/31] Update api/sql_func.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- api/sql_func.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/api/sql_func.py b/api/sql_func.py index 3867b50fe3..dbb083d251 100644 --- a/api/sql_func.py +++ b/api/sql_func.py @@ -421,13 +421,7 @@ def search_case_by_card_date(card_id, plan_date_start_case, research_case_id, li and directions_napravleniya.client_id = %(card_id)s LIMIT %(limit)s """, - params={ - 'card_id': card_id, - 'plan_date_start_case': plan_date_start_case, - 'research_case_id': research_case_id, - 'tz': TIME_ZONE, - 'limit': limit - }, + params={'card_id': card_id, 'plan_date_start_case': plan_date_start_case, 'research_case_id': research_case_id, 'tz': TIME_ZONE, 'limit': limit}, ) rows = namedtuplefetchall(cursor) From 3adb63a74ff9b741462e7760bdc4dc78f13b8b9e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 14:48:23 +0800 Subject: [PATCH 12/31] print set document for many people --- directions/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/directions/models.py b/directions/models.py index a420008a1b..50ee815f41 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1291,6 +1291,8 @@ def gen_napravleniya_by_issledovaniya( price_name=None, case_id=-2, case_by_direction=False, + plan_start_date=None, + slot_fact_id=None ): result = {"r": False, "list_id": [], "list_stationar_id": [], "messageLimit": ""} if case_id > -1 and case_by_direction: From a376901d2932129c7141e012d9cbe986382d72f7 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 14:51:55 +0800 Subject: [PATCH 13/31] fix --- api/views.py | 2 +- utils/xh.py | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/api/views.py b/api/views.py index 0c3c913dc1..696871fd3e 100644 --- a/api/views.py +++ b/api/views.py @@ -77,7 +77,7 @@ from utils.common import non_selected_visible_type from utils.dates import try_parse_range, try_strptime from utils.nsi_directories import NSI -from utils.xh import get_all_hospitals, save_tmp_file, simple_join_two_pdf_files, simple_save_pdf_file +from utils.xh import get_all_hospitals, simple_join_two_pdf_files, simple_save_pdf_file from .dicom import search_dicom_study from .directions.sql_func import get_lab_podr from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar, search_case_by_card_date diff --git a/utils/xh.py b/utils/xh.py index c4fbf13fc4..8cc5126472 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -1,5 +1,3 @@ -import datetime - from api.directions.sql_func import get_lab_podr from appconf.manager import SettingManager from laboratory.settings import QRCODE_OFFSET_SIZE, LEFT_QRCODE_OFFSET_SIZE @@ -7,6 +5,7 @@ import datetime import os.path from io import BytesIO +from pdfrw import PdfReader, PdfWriter def fix(s: str): @@ -112,12 +111,6 @@ def replace_values(key): def simple_join_two_pdf_files(files_data): - from pdfrw import PdfReader, PdfWriter - - today = datetime.datetime.now() - date_now1 = datetime.datetime.strftime(today, "%y%m%d%H%M%S%f")[:-3] - date_now_str = str(date_now1) - pdf_all = BytesIO() inputs = files_data writer = PdfWriter() From fade0f21a45755123755fdf2124ccf11b28b3d95 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:54:58 +0800 Subject: [PATCH 14/31] Update directions/models.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- directions/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/directions/models.py b/directions/models.py index 5efb3c2d42..c8e864e618 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1292,7 +1292,7 @@ def gen_napravleniya_by_issledovaniya( case_id=-2, case_by_direction=False, plan_start_date=None, - slot_fact_id=None + slot_fact_id=None, ): result = {"r": False, "list_id": [], "list_stationar_id": [], "messageLimit": ""} if case_id > -1 and case_by_direction: From ba3be4accd4a6b4a5bb009b97656c2c4aeaa669d Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:55:12 +0800 Subject: [PATCH 15/31] Update api/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- api/views.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/api/views.py b/api/views.py index 696871fd3e..2cc4b1818c 100644 --- a/api/views.py +++ b/api/views.py @@ -3354,24 +3354,9 @@ def print_medical_examination_data(request): plan_start_date=plan_date_start_case ) else: - napravleniye_case = directions.Napravleniya.gen_napravleniye( - card_id, - doc, - financing_source, - "", - "", - doc, - -1, - doc, - price_name_id=13 - ) + napravleniye_case = directions.Napravleniya.gen_napravleniye(card_id, doc, financing_source, "", "", doc, -1, doc, price_name_id=13) - issledovaniye_case = directions.Issledovaniya( - napravleniye=napravleniye_case, - research=research_case, - deferred=False, - plan_start_date=plan_date_start_case - ) + issledovaniye_case = directions.Issledovaniya(napravleniye=napravleniye_case, research=research_case, deferred=False, plan_start_date=plan_date_start_case) issledovaniye_case.save() result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( card_id, From ced95a8ca83661d076b55bf53ccfe7f15f78472e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:55:18 +0800 Subject: [PATCH 16/31] Update api/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index 2cc4b1818c..9040480816 100644 --- a/api/views.py +++ b/api/views.py @@ -3351,7 +3351,7 @@ def print_medical_examination_data(request): price_name=13, case_id=case_direction_number, case_by_direction=True, - plan_start_date=plan_date_start_case + plan_start_date=plan_date_start_case, ) else: napravleniye_case = directions.Napravleniya.gen_napravleniye(card_id, doc, financing_source, "", "", doc, -1, doc, price_name_id=13) From 19af03b9b8827ea5645096244dd46d8bcd060db7 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Mon, 20 Nov 2023 14:55:24 +0800 Subject: [PATCH 17/31] Update api/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- api/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index 9040480816..9f09dda249 100644 --- a/api/views.py +++ b/api/views.py @@ -24,7 +24,8 @@ UNLIMIT_PERIOD_STATISTIC_GROUP, TITLE_REPORT_FILTER_HAS_ALL_FIN_SOURCE, STATISTIC_TYPE_DEPARTMENT, - USE_TFOMS_DISTRICT, TYPE_COMPANY_SET_DIRECTION_PDF, + USE_TFOMS_DISTRICT, + TYPE_COMPANY_SET_DIRECTION_PDF, ) from utils.response import status_response From 1eba55fbaff2c9f1476bfe43776b76a3e425accf Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 15:16:57 +0800 Subject: [PATCH 18/31] =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D0=BD=D0=B8=D1=80?= =?UTF-8?q?=D1=83=D0=B5=D0=BC=D0=B0=D1=8F=20=D0=B4=D0=B0=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=B0=20=D0=BE=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=83=D1=81=D0=BB=D1=83=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/views.py | 8 ++++---- directions/models.py | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/views.py b/api/views.py index 696871fd3e..cd85f89952 100644 --- a/api/views.py +++ b/api/views.py @@ -75,7 +75,7 @@ from statistics_tickets.models import VisitPurpose, ResultOfTreatment, StatisticsTicket, Outcomes, ExcludePurposes from tfoms.integration import match_enp from utils.common import non_selected_visible_type -from utils.dates import try_parse_range, try_strptime +from utils.dates import try_parse_range, try_strptime, normalize_dots_date from utils.nsi_directories import NSI from utils.xh import get_all_hospitals, simple_join_two_pdf_files, simple_save_pdf_file from .dicom import search_dicom_study @@ -3317,7 +3317,9 @@ def print_medical_examination_data(request): for card in cards: card_id = card.get("card_id") researches = card.get("research") - plan_date_start_case = "2023-11-01 00:00:00" + plan_date_start_case = card.get("date") + plan_date_start_case = normalize_dots_date(plan_date_start_case) + plan_date_start_case = f"{plan_date_start_case} 00:00:00" result_search_case = search_case_by_card_date(card_id, plan_date_start_case, research_case.pk, 1) case_issledovaniye_number, case_direction_number = None, None for i in result_search_case: @@ -3348,7 +3350,6 @@ def print_medical_examination_data(request): count=1, discount=0, rmis_slot=None, - price_name=13, case_id=case_direction_number, case_by_direction=True, plan_start_date=plan_date_start_case @@ -3363,7 +3364,6 @@ def print_medical_examination_data(request): doc, -1, doc, - price_name_id=13 ) issledovaniye_case = directions.Issledovaniya( diff --git a/directions/models.py b/directions/models.py index 5efb3c2d42..2f023632b9 100644 --- a/directions/models.py +++ b/directions/models.py @@ -2273,6 +2273,7 @@ class Issledovaniya(models.Model): DoctorProfile, null=True, blank=True, related_name="doc_add_additional", db_index=True, help_text='Профиль-добавил исполнитель дополнительные услуги', on_delete=models.SET_NULL ) external_add_order = models.ForeignKey(ExternalAdditionalOrder, db_index=True, blank=True, null=True, default=None, help_text="Внешний заказ", on_delete=models.SET_NULL) + plan_start_date = models.DateTimeField(null=True, blank=True, db_index=True, help_text='Планируемое время начала услуги') @property def time_save_local(self): From 3817047370a576ca2d338ca884d345c110c00a30 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 15:25:56 +0800 Subject: [PATCH 19/31] =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D0=BD=D0=B8=D1=80?= =?UTF-8?q?=D1=83=D0=B5=D0=BC=D0=B0=D1=8F=20=D0=B4=D0=B0=D1=82=D0=B0=20-fi?= =?UTF-8?q?x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/views.py b/api/views.py index 5825d7069f..ef6a09f130 100644 --- a/api/views.py +++ b/api/views.py @@ -76,7 +76,7 @@ from statistics_tickets.models import VisitPurpose, ResultOfTreatment, StatisticsTicket, Outcomes, ExcludePurposes from tfoms.integration import match_enp from utils.common import non_selected_visible_type -from utils.dates import try_parse_range, try_strptime +from utils.dates import try_parse_range, try_strptime, normalize_dots_date from utils.nsi_directories import NSI from utils.xh import get_all_hospitals, simple_join_two_pdf_files, simple_save_pdf_file from .dicom import search_dicom_study @@ -3318,8 +3318,9 @@ def print_medical_examination_data(request): for card in cards: card_id = card.get("card_id") researches = card.get("research") - plan_date_start_case = "2023-11-01 00:00:00" - result_search_case = search_case_by_card_date(card_id, plan_date_start_case, research_case.pk, 1) + plan_start_date_case = normalize_dots_date(card.get("date")) + plan_start_date_case = f"{plan_start_date_case} 00:00:00" + result_search_case = search_case_by_card_date(card_id, plan_start_date_case, research_case.pk, 1) case_issledovaniye_number, case_direction_number = None, None for i in result_search_case: case_issledovaniye_number = i.case_issledovaniye_number @@ -3352,7 +3353,7 @@ def print_medical_examination_data(request): price_name=13, case_id=case_direction_number, case_by_direction=True, - plan_start_date=plan_date_start_case + plan_start_date=plan_start_date_case ) else: napravleniye_case = directions.Napravleniya.gen_napravleniye( @@ -3364,14 +3365,13 @@ def print_medical_examination_data(request): doc, -1, doc, - price_name_id=13 ) issledovaniye_case = directions.Issledovaniya( napravleniye=napravleniye_case, research=research_case, deferred=False, - plan_start_date=plan_date_start_case + plan_start_date=plan_start_date_case ) issledovaniye_case.save() result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( @@ -3392,7 +3392,7 @@ def print_medical_examination_data(request): price_name=13, case_id=napravleniye_case.pk, case_by_direction=True, - plan_start_date=plan_date_start_case, + plan_start_date=plan_start_date_case, ) if number_directons: number_directons = [i for i in number_directons] From d062dd39f43030faf0731a88afee45f59b84b46c Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Mon, 20 Nov 2023 15:34:42 +0800 Subject: [PATCH 20/31] fix: price_name =None --- api/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/views.py b/api/views.py index ef6a09f130..3edbe3811f 100644 --- a/api/views.py +++ b/api/views.py @@ -3350,7 +3350,7 @@ def print_medical_examination_data(request): count=1, discount=0, rmis_slot=None, - price_name=13, + price_name=None, case_id=case_direction_number, case_by_direction=True, plan_start_date=plan_start_date_case @@ -3389,7 +3389,7 @@ def print_medical_examination_data(request): count=1, discount=0, rmis_slot=None, - price_name=13, + price_name=None, case_id=napravleniye_case.pk, case_by_direction=True, plan_start_date=plan_start_date_case, From 3061b8435afa176860261e9e240e573531809e8e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 08:36:11 +0800 Subject: [PATCH 21/31] hash to file name - store in cashe --- api/views.py | 108 ++---------------- directions/views.py | 100 +++++++++++++++- forms/forms112.py | 29 ++--- .../src/construct/ConstructCompany.vue | 4 +- pyproject.toml | 2 +- utils/xh.py | 34 ++++-- 6 files changed, 147 insertions(+), 130 deletions(-) diff --git a/api/views.py b/api/views.py index 3edbe3811f..82a4419bb6 100644 --- a/api/views.py +++ b/api/views.py @@ -8,7 +8,7 @@ import pytz_deprecation_shim as pytz from api.models import ManageDoctorProfileAnalyzer, Analyzer -from directions.sql_func import get_researches_by_number_directions +from directions.views import create_case_by_cards from directory.models import Researches, SetResearch, SetOrderResearch, PatientControlParam from doctor_schedule.models import ScheduleResource from ecp_integration.integration import get_reserves_ecp, get_slot_ecp @@ -76,15 +76,14 @@ from statistics_tickets.models import VisitPurpose, ResultOfTreatment, StatisticsTicket, Outcomes, ExcludePurposes from tfoms.integration import match_enp from utils.common import non_selected_visible_type -from utils.dates import try_parse_range, try_strptime, normalize_dots_date +from utils.dates import try_parse_range, try_strptime from utils.nsi_directories import NSI -from utils.xh import get_all_hospitals, simple_join_two_pdf_files, simple_save_pdf_file +from utils.xh import get_all_hospitals, simple_join_two_pdf_files, simple_save_pdf_file, correspondence_set_file_hash from .dicom import search_dicom_study from .directions.sql_func import get_lab_podr from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar, search_case_by_card_date from laboratory.settings import URL_RMIS_AUTH, URL_ELN_MADE, URL_SCHEDULE import urllib.parse -from django.http import HttpResponse from django.utils.module_loading import import_string logger = logging.getLogger("API") @@ -3311,104 +3310,11 @@ def get_examination_list(request): def print_medical_examination_data(request): request_data = json.loads(request.body) cards = request_data.get("cards") - research_case = Researches.objects.filter(is_case=True, hide=False).first() - doc = users.DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() - card_directions = {} - number_directons = None - for card in cards: - card_id = card.get("card_id") - researches = card.get("research") - plan_start_date_case = normalize_dots_date(card.get("date")) - plan_start_date_case = f"{plan_start_date_case} 00:00:00" - result_search_case = search_case_by_card_date(card_id, plan_start_date_case, research_case.pk, 1) - case_issledovaniye_number, case_direction_number = None, None - for i in result_search_case: - case_issledovaniye_number = i.case_issledovaniye_number - case_direction_number = i.case_direction_number - break - financing_source = directions.IstochnikiFinansirovaniya.objects.filter(title__in=["Профосмотр", "Юрлицо"]).first() - - if case_issledovaniye_number: - number_directons = directions.Napravleniya.objects.values_list("id", flat=True).filter(parent_case_id=case_issledovaniye_number) - researches_sql = get_researches_by_number_directions(tuple(number_directons)) - current_researches_case = set([i.research_id for i in researches_sql]) - api_researches = set(researches) - api_researches -= current_researches_case - researches = list(api_researches) - result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( - card_id, - "", - financing_source.pk, - "", - None, - doc, - {-1: researches}, - {}, - False, - {}, - vich_code="", - count=1, - discount=0, - rmis_slot=None, - price_name=None, - case_id=case_direction_number, - case_by_direction=True, - plan_start_date=plan_start_date_case - ) - else: - napravleniye_case = directions.Napravleniya.gen_napravleniye( - card_id, - doc, - financing_source, - "", - "", - doc, - -1, - doc, - ) - - issledovaniye_case = directions.Issledovaniya( - napravleniye=napravleniye_case, - research=research_case, - deferred=False, - plan_start_date=plan_start_date_case - ) - issledovaniye_case.save() - result = directions.Napravleniya.gen_napravleniya_by_issledovaniya( - card_id, - "", - financing_source.pk, - "", - None, - doc, - {-1: researches}, - {}, - False, - {}, - vich_code="", - count=1, - discount=0, - rmis_slot=None, - price_name=None, - case_id=napravleniye_case.pk, - case_by_direction=True, - plan_start_date=plan_start_date_case, - ) - if number_directons: - number_directons = [i for i in number_directons] - else: - number_directons = [] - number_directons.extend(result.get("list_id")) - card_directions[card_id] = list(set(number_directons)) - response = HttpResponse(content_type='application/pdf') - - response['Content-Disposition'] = 'inline; filename="directions.pdf"' + card_directions = create_case_by_cards(cards) files_data = [] if TYPE_COMPANY_SET_DIRECTION_PDF: additional_page = import_string('forms.forms112.' + TYPE_COMPANY_SET_DIRECTION_PDF.split(".")[0]) - step = 0 for card, directions_data in card_directions.items(): - step += 1 if len(directions_data) > 1: directions_data = [str(i) for i in directions_data] napr_id = ", ".join(directions_data) @@ -3430,8 +3336,10 @@ def print_medical_examination_data(request): files_data.append(saved_file_pdf) buffer = simple_join_two_pdf_files(files_data) - saved_file_pdf = simple_save_pdf_file(buffer) - return JsonResponse({"fileName": saved_file_pdf}) + + id_file = simple_save_pdf_file(buffer) + hash_file = correspondence_set_file_hash(id_file) + return JsonResponse({"id": hash_file}) @login_required diff --git a/directions/views.py b/directions/views.py index b646fcf1af..140930a39d 100644 --- a/directions/views.py +++ b/directions/views.py @@ -26,17 +26,21 @@ from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, PageBreak from transliterate import translit +import directions import directory.models as directory +from directions.sql_func import get_researches_by_number_directions +from users.models import DoctorProfile +from api.sql_func import search_case_by_card_date from hospitals.models import Hospitals import slog.models as slog from appconf.manager import SettingManager -from directions.models import Napravleniya, Issledovaniya, TubesRegistration, DirectionParamsResult +from directions.models import Napravleniya, Issledovaniya, TubesRegistration, DirectionParamsResult, IstochnikiFinansirovaniya from laboratory.decorators import logged_in_or_token from laboratory.settings import FONTS_FOLDER, PRINT_ADDITIONAL_PAGE_DIRECTION_FIN_SOURCE, PRINT_APPENDIX_PAGE_DIRECTION from laboratory.utils import strtime, strdate from podrazdeleniya.models import Podrazdeleniya from utils import xh -from utils.dates import try_parse_range +from utils.dates import try_parse_range, normalize_dots_date from django.utils.module_loading import import_string from utils.matrix import transpose @@ -1040,3 +1044,95 @@ def px(x=0.0): def pxr(x=0.0): x *= mm return w - x + +def create_case_by_cards(cards): + research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() + doc = DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() + card_directions = {} + number_directons = None + for card in cards: + card_id = card.get("card_id") + researches = card.get("research") + plan_start_date_case = normalize_dots_date(card.get("date")) + plan_start_date_case = f"{plan_start_date_case} 00:00:00" + result_search_case = search_case_by_card_date(card_id, plan_start_date_case, research_case.pk, 1) + case_issledovaniye_number, case_direction_number = None, None + for i in result_search_case: + case_issledovaniye_number = i.case_issledovaniye_number + case_direction_number = i.case_direction_number + break + financing_source = IstochnikiFinansirovaniya.objects.filter(title__in=["Профосмотр", "Юрлицо"]).first() + + if case_issledovaniye_number: + number_directons = Napravleniya.objects.values_list("id", flat=True).filter(parent_case_id=case_issledovaniye_number) + researches_sql = get_researches_by_number_directions(tuple(number_directons)) + current_researches_case = set([i.research_id for i in researches_sql]) + api_researches = set(researches) + api_researches -= current_researches_case + researches = list(api_researches) + result = Napravleniya.gen_napravleniya_by_issledovaniya( + card_id, + "", + financing_source.pk, + "", + None, + doc, + {-1: researches}, + {}, + False, + {}, + vich_code="", + count=1, + discount=0, + rmis_slot=None, + price_name=None, + case_id=case_direction_number, + case_by_direction=True, + plan_start_date=plan_start_date_case + ) + else: + napravleniye_case = Napravleniya.gen_napravleniye( + card_id, + doc, + financing_source, + "", + "", + doc, + -1, + doc, + ) + + issledovaniye_case = Issledovaniya( + napravleniye=napravleniye_case, + research=research_case, + deferred=False, + plan_start_date=plan_start_date_case + ) + issledovaniye_case.save() + result = Napravleniya.gen_napravleniya_by_issledovaniya( + card_id, + "", + financing_source.pk, + "", + None, + doc, + {-1: researches}, + {}, + False, + {}, + vich_code="", + count=1, + discount=0, + rmis_slot=None, + price_name=None, + case_id=napravleniye_case.pk, + case_by_direction=True, + plan_start_date=plan_start_date_case, + ) + if number_directons: + number_directons = [i for i in number_directons] + else: + number_directons = [] + number_directons.extend(result.get("list_id")) + card_directions[card_id] = list(set(number_directons)) + return card_directions diff --git a/forms/forms112.py b/forms/forms112.py index 3bd479e5c9..01c03c0bc4 100644 --- a/forms/forms112.py +++ b/forms/forms112.py @@ -22,7 +22,7 @@ from directions.models import Napravleniya, Issledovaniya from hospitals.models import Hospitals from laboratory.settings import FONTS_FOLDER, BASE_DIR -from utils.xh import save_tmp_file +from utils.xh import save_tmp_file, correspondence_get_file_hash from directions.views import gen_pdf_dir as f_print_direction from django.http import HttpRequest from django.utils.module_loading import import_string @@ -515,16 +515,17 @@ def add_appendix_direction_list(appendix_direction_list, dir_temp): def form_03(request_data): - file_name = request_data.get("file").replace('"', "") - dir_param = SettingManager.get("dir_param", default='/tmp', default_type='s') - file_dir = os.path.join(dir_param, file_name) - pdf_all = BytesIO() - inputs = [file_dir] - writer = PdfWriter() - for inpfn in inputs: - writer.addpages(PdfReader(inpfn).pages) - writer.write(pdf_all) - pdf_out = pdf_all.getvalue() - os.remove(file_dir) - - return pdf_out + id_file = request_data.get("id").replace('"', "") + file_data = correspondence_get_file_hash(id_file) + if file_data: + dir_param = SettingManager.get("dir_param", default='/tmp', default_type='s') + file_dir = os.path.join(dir_param, file_data) + pdf_all = BytesIO() + inputs = [file_dir] + writer = PdfWriter() + for inpfn in inputs: + writer.addpages(PdfReader(inpfn).pages) + writer.write(pdf_all) + pdf_out = pdf_all.getvalue() + os.remove(file_dir) + return pdf_out diff --git a/l2-frontend/src/construct/ConstructCompany.vue b/l2-frontend/src/construct/ConstructCompany.vue index ffbc2e8738..4961b120f9 100644 --- a/l2-frontend/src/construct/ConstructCompany.vue +++ b/l2-frontend/src/construct/ConstructCompany.vue @@ -614,8 +614,8 @@ export default { exclude: this.excludedResearches, }); await this.$store.dispatch(actions.DEC_LOADING); - if (result.fileName) { - window.open(`/forms/pdf?type=112.03&file=${encodeURIComponent(JSON.stringify(result.fileName))}`, '_blank'); + if (result.id) { + window.open(`/forms/pdf?type=112.03&id=${encodeURIComponent(JSON.stringify(result.id))}`, '_blank'); } }, }, diff --git a/pyproject.toml b/pyproject.toml index ca6274d158..124eb13ee1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ beren = "0.7.1" transliterate = "1.10.2" imgkit = "1.2.3" astm = {git = "https://github.com/mikhailprivalov/python-astm.git", rev = "v0.6"} -psycopg2-binary = "^2.9.4" +#psycopg2-binary = "^2.9.4" boto3 = "^1.29.3" prompt-toolkit = "^3.0.36" pdf2docx = "^0.5.6" diff --git a/utils/xh.py b/utils/xh.py index 8cc5126472..1e96e457f9 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -2,10 +2,13 @@ from appconf.manager import SettingManager from laboratory.settings import QRCODE_OFFSET_SIZE, LEFT_QRCODE_OFFSET_SIZE from utils.flowable import QrCodeSite -import datetime +import uuid import os.path from io import BytesIO from pdfrw import PdfReader, PdfWriter +from django.core.cache import cache +import hashlib +import base64 def fix(s: str): @@ -110,18 +113,18 @@ def replace_values(key): return replace_data.get(key, "") -def simple_join_two_pdf_files(files_data): +def simple_join_two_pdf_files(inputs): pdf_all = BytesIO() - inputs = files_data writer = PdfWriter() + dir_param = SettingManager.get("dir_param", default='/tmp', default_type='s') for inpfn in inputs: - writer.addpages(PdfReader(inpfn).pages) + writer.addpages(PdfReader(os.path.join(dir_param, inpfn)).pages) writer.write(pdf_all) pdf_out = pdf_all.getvalue() pdf_all.close() - for i in files_data: - os.remove(i) + for i in inputs: + os.remove(os.path.join(dir_param,i)) return pdf_out @@ -129,10 +132,19 @@ def simple_save_pdf_file(fc): fc_buf = BytesIO() fc_buf.write(fc) fc_buf.seek(0) - today = datetime.datetime.now() - date_now1 = datetime.datetime.strftime(today, "%y%m%d%H%M%S%f")[:-3] - date_now_str = str(date_now1) dir_param = SettingManager.get("dir_param", default='/tmp', default_type='s') - file_buffer1 = os.path.join(dir_param, date_now_str + '_buffer1.pdf') + name = str(uuid.uuid4()) + '_buffer.pdf' + file_buffer1 = os.path.join(dir_param, name) save_tmp_file(fc_buf, filename=file_buffer1) - return file_buffer1 + return name + + +def correspondence_set_file_hash(title_name): + k = base64.b64encode(hashlib.sha1(title_name.encode('utf-8')).digest()) + key_cashe = k.decode() + cache.set(key_cashe, title_name, 60 * 10) + return key_cashe + + +def correspondence_get_file_hash(k): + return cache.get(k) From c9c7cc8d59b379fffe4e705ebcae2cbd42d231a7 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 08:36:21 +0800 Subject: [PATCH 22/31] hash to file name - store in cashe --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 124eb13ee1..ca6274d158 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ beren = "0.7.1" transliterate = "1.10.2" imgkit = "1.2.3" astm = {git = "https://github.com/mikhailprivalov/python-astm.git", rev = "v0.6"} -#psycopg2-binary = "^2.9.4" +psycopg2-binary = "^2.9.4" boto3 = "^1.29.3" prompt-toolkit = "^3.0.36" pdf2docx = "^0.5.6" From 9058714472a665d631c1c510ac4a7145af7159cd Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 08:39:50 +0800 Subject: [PATCH 23/31] fix import pep --- api/views.py | 2 +- directions/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/views.py b/api/views.py index 82a4419bb6..07b511024d 100644 --- a/api/views.py +++ b/api/views.py @@ -81,7 +81,7 @@ from utils.xh import get_all_hospitals, simple_join_two_pdf_files, simple_save_pdf_file, correspondence_set_file_hash from .dicom import search_dicom_study from .directions.sql_func import get_lab_podr -from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar, search_case_by_card_date +from .sql_func import users_by_group, users_all, get_diagnoses, get_resource_researches, search_data_by_param, search_text_stationar from laboratory.settings import URL_RMIS_AUTH, URL_ELN_MADE, URL_SCHEDULE import urllib.parse from django.utils.module_loading import import_string diff --git a/directions/views.py b/directions/views.py index 140930a39d..ca70cdca2c 100644 --- a/directions/views.py +++ b/directions/views.py @@ -26,7 +26,6 @@ from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, PageBreak from transliterate import translit -import directions import directory.models as directory from directions.sql_func import get_researches_by_number_directions from users.models import DoctorProfile @@ -1045,6 +1044,7 @@ def pxr(x=0.0): x *= mm return w - x + def create_case_by_cards(cards): research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() doc = DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() From eb0d8bc22767fc9b06b2602908c796fd8bb915f4 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Tue, 21 Nov 2023 08:54:26 +0800 Subject: [PATCH 24/31] Update utils/xh.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- utils/xh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/xh.py b/utils/xh.py index 1e96e457f9..14bbf90d29 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -124,7 +124,7 @@ def simple_join_two_pdf_files(inputs): pdf_all.close() for i in inputs: - os.remove(os.path.join(dir_param,i)) + os.remove(os.path.join(dir_param, i)) return pdf_out From f1c5cbaf7801d8a729a2f18b59de0dc084f21f75 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Tue, 21 Nov 2023 08:54:35 +0800 Subject: [PATCH 25/31] Update directions/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- directions/views.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/directions/views.py b/directions/views.py index ca70cdca2c..a41812426c 100644 --- a/directions/views.py +++ b/directions/views.py @@ -1102,12 +1102,7 @@ def create_case_by_cards(cards): doc, ) - issledovaniye_case = Issledovaniya( - napravleniye=napravleniye_case, - research=research_case, - deferred=False, - plan_start_date=plan_start_date_case - ) + issledovaniye_case = Issledovaniya(napravleniye=napravleniye_case, research=research_case, deferred=False, plan_start_date=plan_start_date_case) issledovaniye_case.save() result = Napravleniya.gen_napravleniya_by_issledovaniya( card_id, From 14adc33d40c9b1159d53661c2d72af1ef32d0e4e Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Tue, 21 Nov 2023 08:54:44 +0800 Subject: [PATCH 26/31] Update directions/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- directions/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/directions/views.py b/directions/views.py index a41812426c..11b2eca8e2 100644 --- a/directions/views.py +++ b/directions/views.py @@ -1088,7 +1088,7 @@ def create_case_by_cards(cards): price_name=None, case_id=case_direction_number, case_by_direction=True, - plan_start_date=plan_start_date_case + plan_start_date=plan_start_date_case, ) else: napravleniye_case = Napravleniya.gen_napravleniye( From 02902adee014e8f13085b5d6111e55865c3a6779 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Tue, 21 Nov 2023 08:54:53 +0800 Subject: [PATCH 27/31] Update directions/views.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- directions/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/directions/views.py b/directions/views.py index 11b2eca8e2..6cfc9edab9 100644 --- a/directions/views.py +++ b/directions/views.py @@ -1045,6 +1045,7 @@ def pxr(x=0.0): return w - x + def create_case_by_cards(cards): research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() doc = DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() From ad10dd58a9d669ec9f81218805c519c7a3f3d88a Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 09:00:18 +0800 Subject: [PATCH 28/31] fix --- utils/xh.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utils/xh.py b/utils/xh.py index 14bbf90d29..bd2b3719d6 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -8,7 +8,6 @@ from pdfrw import PdfReader, PdfWriter from django.core.cache import cache import hashlib -import base64 def fix(s: str): @@ -140,10 +139,9 @@ def simple_save_pdf_file(fc): def correspondence_set_file_hash(title_name): - k = base64.b64encode(hashlib.sha1(title_name.encode('utf-8')).digest()) - key_cashe = k.decode() - cache.set(key_cashe, title_name, 60 * 10) - return key_cashe + k = hashlib.sha1(title_name.encode('utf-8')).hexdigest() + cache.set(k, title_name, 60 * 10) + return k def correspondence_get_file_hash(k): From 199632d5535d921311dee1b7a149c2652aaa1b19 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 09:09:06 +0800 Subject: [PATCH 29/31] =?UTF-8?q?=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B8=20=D1=85=D1=8D=D1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/xh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/xh.py b/utils/xh.py index bd2b3719d6..cf3956da45 100644 --- a/utils/xh.py +++ b/utils/xh.py @@ -140,7 +140,7 @@ def simple_save_pdf_file(fc): def correspondence_set_file_hash(title_name): k = hashlib.sha1(title_name.encode('utf-8')).hexdigest() - cache.set(k, title_name, 60 * 10) + cache.set(k, title_name, 60 * 1) return k From 97c5b4a4299558a87e4048ddac0a3347eaed6cfd Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 09:22:25 +0800 Subject: [PATCH 30/31] pep --- directions/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/directions/views.py b/directions/views.py index 6cfc9edab9..11b2eca8e2 100644 --- a/directions/views.py +++ b/directions/views.py @@ -1045,7 +1045,6 @@ def pxr(x=0.0): return w - x - def create_case_by_cards(cards): research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() doc = DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() From 3fca8589159995d2832cc6f8097d0c8e623cf87c Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko Date: Tue, 21 Nov 2023 10:12:33 +0800 Subject: [PATCH 31/31] add slot_fact_id --- directions/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/directions/models.py b/directions/models.py index 45e953584b..ef210791ef 100644 --- a/directions/models.py +++ b/directions/models.py @@ -1059,6 +1059,7 @@ def gen_napravleniye( hospital=-1, external_order=None, price_name_id=None, + slot_fact_id=None, ) -> 'Napravleniya': """ Генерация направления @@ -1130,6 +1131,12 @@ def gen_napravleniye( if save: dir.save() dir.set_polis() + if slot_fact_id: + from doctor_schedule.models import SlotFact + + f = SlotFact.objects.get(pk=slot_fact_id) + f.direction = dir + f.save(update_fields=['direction']) return dir @staticmethod @@ -1557,6 +1564,7 @@ def gen_napravleniya_by_issledovaniya( hospital=hospital_override, external_order=external_order, price_name_id=price_name, + slot_fact_id=slot_fact_id, ) research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() issledovaniye_case = Issledovaniya(napravleniye=napravleniye_case, research=research_case, deferred=False) @@ -1588,6 +1596,7 @@ def gen_napravleniya_by_issledovaniya( hospital=hospital_override, external_order=external_order, price_name_id=price_name, + slot_fact_id=slot_fact_id, ) npk = directions_for_researches[dir_group].pk result["list_id"].append(npk) @@ -1619,6 +1628,7 @@ def gen_napravleniya_by_issledovaniya( hospital=hospital_override, external_order=external_order, price_name_id=price_name, + slot_fact_id=slot_fact_id, ) npk = directions_for_researches[dir_group].pk result["list_id"].append(npk) @@ -1839,6 +1849,7 @@ def gen_napravleniya_by_issledovaniya( external_organization=external_organization, price_category=price_category, hospital=hospital_override, + slot_fact_id=slot_fact_id, ) result["list_id"].append(new_direction.pk) Issledovaniya(napravleniye=new_direction, research_id=research_dir, deferred=False).save()