Skip to content

Commit

Permalink
Договор + БД - модели
Browse files Browse the repository at this point in the history
* Поле - is_contract в Research
* Поле - is_mmis в DatabaseConnectionSettings
  • Loading branch information
Wellheor1 committed Sep 11, 2023
1 parent 26b5f62 commit c6b230b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions dashboards/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions directory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="Если это параклиническое исследование - здесь указывается подготовка и кабинет")
Expand Down
8 changes: 4 additions & 4 deletions education/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}; "
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions education/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions education/views.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions laboratory/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c6b230b

Please sign in to comment.