From c6b230b3b5dc2ca61b9f961ab161d43f514889e1 Mon Sep 17 00:00:00 2001 From: Well Date: Mon, 11 Sep 2023 15:43:45 +0800 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B3=D0=BE=D0=B2=D0=BE=D1=80=20+?= =?UTF-8?q?=20=D0=91=D0=94=20-=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Поле - is_contract в Research * Поле - is_mmis в DatabaseConnectionSettings --- dashboards/models.py | 1 + directory/models.py | 1 + education/main.py | 8 ++++---- education/sql_func.py | 5 ++--- education/views.py | 8 +++++--- laboratory/settings.py | 2 -- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dashboards/models.py b/dashboards/models.py index 31c534ab1c..c9ee85e518 100644 --- a/dashboards/models.py +++ b/dashboards/models.py @@ -25,6 +25,7 @@ class DatabaseConnectSettings(models.Model): port = models.CharField(max_length=5, default="", help_text='Порт', db_index=False) driver = models.CharField(max_length=128, default="", help_text='Драйвер', db_index=False) encrypt = models.CharField(max_length=5, default="", help_text='Шифрование', db_index=False) + is_mmis = models.BooleanField(default=False, help_text='это ММИС', db_index=True) def __str__(self): return f"{self.title} - {self.database}" diff --git a/directory/models.py b/directory/models.py index 4a74e91b69..5123baeed7 100644 --- a/directory/models.py +++ b/directory/models.py @@ -243,6 +243,7 @@ class Researches(models.Model): is_monitoring = models.BooleanField(default=False, blank=True, help_text="Это мониторинг", db_index=True) is_expertise = models.BooleanField(default=False, blank=True, help_text="Это экспертиза", db_index=True) is_aux = models.BooleanField(default=False, blank=True, help_text="Это вспомогательный", db_index=True) + is_contract = models.BooleanField(default=False, blank=True, help_text="Это договор", db_index=True) site_type = models.ForeignKey(ResearchSite, default=None, null=True, blank=True, help_text='Место услуги', on_delete=models.SET_NULL, db_index=True) need_vich_code = models.BooleanField(default=False, blank=True, help_text="Необходимость указания кода вич в направлении") paraclinic_info = models.TextField(blank=True, default="", help_text="Если это параклиническое исследование - здесь указывается подготовка и кабинет") diff --git a/education/main.py b/education/main.py index 3a408cfd71..e71c7d8f9e 100644 --- a/education/main.py +++ b/education/main.py @@ -4,14 +4,14 @@ from education.sql_func import get_connection_params, get_enrollees_by_id, get_changes, get_grade_entrance_exams, get_application_by_id, get_achievements_by_id from education.views import update_education_individual, change_encoding_cp1251 from hospitals.models import Hospitals -from laboratory.settings import EDUCATION_BASE_TITLE, TIME_ZONE, MMIS_CONNECT_WITH_PYODBC +from laboratory.settings import TIME_ZONE, MMIS_CONNECT_WITH_PYODBC from pymssql import OperationalError from pyodbc import InterfaceError import pytz_deprecation_shim as pytz -def create_connection_string(settings_name: str): - connection_params = get_connection_params(settings_name)[0] +def create_connection_string(): + connection_params = get_connection_params()[0] if MMIS_CONNECT_WITH_PYODBC: connection_string = ( f"DRIVER={connection_params.driver}; SERVER={connection_params.ip_address},{connection_params.port}; DATABASE={connection_params.database}; Encrypt={connection_params.encrypt}; " @@ -73,7 +73,7 @@ def get_ids_changes_enrollees(connection_string: str): def process_update_enrollees(): time_start = time.time() - connection_string = create_connection_string(EDUCATION_BASE_TITLE) + connection_string = create_connection_string() user_obj_hospital = Hospitals.objects.get(is_default=True) while time.time() - time_start < MAX_LOOP_TIME: ids_changed_enrollees, current_last_log = get_ids_changes_enrollees(connection_string) diff --git a/education/sql_func.py b/education/sql_func.py index f8cd925c13..a002304b71 100644 --- a/education/sql_func.py +++ b/education/sql_func.py @@ -8,7 +8,7 @@ from utils.db import namedtuplefetchall -def get_connection_params(settings_name): +def get_connection_params(): with connection.cursor() as cursor: cursor.execute( """ @@ -21,9 +21,8 @@ def get_connection_params(settings_name): dashboards_databaseconnectsettings.driver, dashboards_databaseconnectsettings.encrypt FROM public.dashboards_databaseconnectsettings - WHERE dashboards_databaseconnectsettings.title = %(name_settings)s + WHERE dashboards_databaseconnectsettings.is_mmis = true """, - params={"name_settings": settings_name}, ) rows = namedtuplefetchall(cursor) return rows diff --git a/education/views.py b/education/views.py index 28d861dd00..c7426097b7 100644 --- a/education/views.py +++ b/education/views.py @@ -1,9 +1,10 @@ from clients.models import Individual +from directory.models import Researches from education.models import ApplicationEducation, EducationSpeciality, EntranceExam, Subjects, ExamType, Faculties, Achievement, AchievementType from education.sql_func import get_dashboard_data import simplejson as json -from laboratory.settings import EDUCATION_REASEARCH_CONTRACT_IDS, MMIS_CONNECT_WITH_PYODBC +from laboratory.settings import MMIS_CONNECT_WITH_PYODBC from laboratory.utils import current_year @@ -158,7 +159,8 @@ def get_all_enrollees(request): year_study = current_year() else: year_study = year_study.get('label') - data = get_dashboard_data(year_study, tuple(EDUCATION_REASEARCH_CONTRACT_IDS)) + research_contract_ids = Researches.objects.filter(is_contract=True).values_list('id', flat=True) + data = get_dashboard_data(year_study, tuple(research_contract_ids)) last_app_id = -1 template_result = { "card": "", @@ -197,7 +199,7 @@ def get_all_enrollees(request): temp_result["applicationPersonNumber"] = i.personal_number temp_result["is_original"] = i.original temp_result["is_enrolled"] = i.is_enrolled - if i.is_enrolled and EDUCATION_REASEARCH_CONTRACT_IDS: + if i.is_enrolled and research_contract_ids: temp_result["researchContractId"] = i.direction_id temp_result["is_expelled"] = i.is_expelled temp_result["create_date"] = date diff --git a/laboratory/settings.py b/laboratory/settings.py index b2f820aece..2cedc2535a 100644 --- a/laboratory/settings.py +++ b/laboratory/settings.py @@ -389,8 +389,6 @@ def __getitem__(self, item): ECP_SEARCH_PATIENT = {} DAYS_AGO_SEARCH_RESULT = {} # {"isLab: 90", "isInstrument: 365"} NEED_ORDER_DIRECTION_FOR_DEFAULT_HOSPITAL = False -EDUCATION_BASE_TITLE = '' -EDUCATION_REASEARCH_CONTRACT_IDS = [] MMIS_CONNECT_WITH_PYODBC = False try: