From 906904edf46220b8a938b2cd8005577221b27396 Mon Sep 17 00:00:00 2001 From: sergei kasianenko Date: Tue, 2 Jul 2024 09:53:37 +0800 Subject: [PATCH 1/2] hosp_research_template for user --- api/stationar/views.py | 10 +++++++--- users/models.py | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/stationar/views.py b/api/stationar/views.py index 04b6aed350..e2bbe7502c 100644 --- a/api/stationar/views.py +++ b/api/stationar/views.py @@ -139,13 +139,17 @@ def hosp_services_by_type(request): r_type = data["r_type"] result = [] type_by_key = HospitalService.TYPES_BY_KEYS.get(r_type, -1) + hosp_research = None + if request.user.doctorprofile.hosp_research_template: + hosp_research = request.user.doctorprofile.hosp_research_template + elif request.user.doctorprofile.podrazdeleniye.hosp_research_default: + hosp_research = request.user.doctorprofile.podrazdeleniye.hosp_research_default for i in Issledovaniya.objects.filter(napravleniye__pk=base_direction_pk, research__is_hospital=True): - hosp_research = i.research + if not hosp_research: + hosp_research = i.research if int(data['hospResearch']) > -1: hosp_research = int(data['hospResearch']) - if request.user.doctorprofile.podrazdeleniye.hosp_research_default_id: - hosp_research = request.user.doctorprofile.podrazdeleniye.hosp_research_default_id for hs in HospitalService.objects.filter(site_type=type_by_key, main_research=hosp_research, hide=False): result.append( { diff --git a/users/models.py b/users/models.py index 8e964d2b09..7971ec94cb 100644 --- a/users/models.py +++ b/users/models.py @@ -38,6 +38,7 @@ class Meta: class Position(models.Model): + title = models.CharField(max_length=255, help_text='Название') title = models.CharField(max_length=255, help_text='Название') hide = models.BooleanField(help_text='Скрытие', default=False) rmis_id = models.PositiveSmallIntegerField(default=None, db_index=True, blank=True, null=True) @@ -110,6 +111,9 @@ class DoctorProfile(models.Model): date_stop_certificate = models.DateField(help_text='Дата окончания сертификата', db_index=True, default=None, blank=True, null=True) replace_doctor_cda = models.ForeignKey('self', related_name='used_doctor_cda', help_text="Замена доктора для cda", blank=True, null=True, default=None, on_delete=models.SET_NULL) additional_info = models.TextField(default='', blank=True, help_text='Дополнительная информация описывать словарем {}') + hosp_research_template = models.ForeignKey( + 'directory.Researches', related_name='hosp_research_template', blank=True, default=None, null=True, verbose_name="Услуга стационара по котрой по умолчанию подгружаются шаблоны", + on_delete=models.CASCADE) @staticmethod def get_system_profile(): From ed6b7429ce1761b0efaac8f50da30559556aa3c7 Mon Sep 17 00:00:00 2001 From: Sergei Kasianenko <41939763+urchinpro@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:10:40 +0800 Subject: [PATCH 2/2] Update users/models.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- users/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/users/models.py b/users/models.py index 7971ec94cb..cac06d8c6e 100644 --- a/users/models.py +++ b/users/models.py @@ -112,8 +112,14 @@ class DoctorProfile(models.Model): replace_doctor_cda = models.ForeignKey('self', related_name='used_doctor_cda', help_text="Замена доктора для cda", blank=True, null=True, default=None, on_delete=models.SET_NULL) additional_info = models.TextField(default='', blank=True, help_text='Дополнительная информация описывать словарем {}') hosp_research_template = models.ForeignKey( - 'directory.Researches', related_name='hosp_research_template', blank=True, default=None, null=True, verbose_name="Услуга стационара по котрой по умолчанию подгружаются шаблоны", - on_delete=models.CASCADE) + 'directory.Researches', + related_name='hosp_research_template', + blank=True, + default=None, + null=True, + verbose_name="Услуга стационара по котрой по умолчанию подгружаются шаблоны", + on_delete=models.CASCADE, + ) @staticmethod def get_system_profile():