This commit is contained in:
Ilya Mukhortov 2025-03-23 10:13:31 +10:00
parent 7a7f4f82cb
commit 721688265a
2 changed files with 24 additions and 5 deletions

View File

@ -29,6 +29,10 @@ class CallMedicalService(models.Model):
class CallMedicalSpeciality(models.Model): class CallMedicalSpeciality(models.Model):
class Type(models.TextChoices):
SPECIALITY = 'SPECIALITY', 'Специальность'
SERVICE = 'SERVICE', 'Услуга'
speciality = models.ForeignKey('medicine.MedicalSpeciality', db_constraint=False, on_delete=models.CASCADE, speciality = models.ForeignKey('medicine.MedicalSpeciality', db_constraint=False, on_delete=models.CASCADE,
verbose_name='Специальность (МИС)') verbose_name='Специальность (МИС)')
name = models.CharField(max_length=100, verbose_name='Произношение роботом') name = models.CharField(max_length=100, verbose_name='Произношение роботом')

View File

@ -1,3 +1,5 @@
import re
import pytz import pytz
import datetime import datetime
@ -47,21 +49,34 @@ def update_call_requests_task(self):
call_specialities = {medical_speciality.speciality_id: medical_speciality call_specialities = {medical_speciality.speciality_id: medical_speciality
for medical_speciality in CallMedicalSpeciality.objects.all()} for medical_speciality in CallMedicalSpeciality.objects.all()}
call_services = {
'A29\.004.+': 'На узи',
'A29\.011.+': 'На эндоскопию'
}
now = datetime.datetime.now().astimezone(pytz.timezone('Asia/Vladivostok')) now = datetime.datetime.now().astimezone(pytz.timezone('Asia/Vladivostok'))
bookings = medicine_api.get_bookings(now.date() + datetime.timedelta(days=1)) bookings = medicine_api.get_bookings(now.date() + datetime.timedelta(days=1))
for booking in bookings: for booking in bookings:
lpu = None lpu = None
speciality = None
if booking['lpu']['code'] in call_lpu: if booking['lpu']['code'] in call_lpu:
lpu = call_lpu[booking['lpu']['code']] lpu = call_lpu[booking['lpu']['code']]
if booking['user'] is None: if booking['user'] is None:
continue continue
if booking['user']['doctor']['speciality'] in call_specialities: service_name = None
speciality = call_specialities[booking['user']['doctor']['speciality']]
if lpu is None or speciality is None: if booking['user']['doctor']['speciality'] in call_specialities:
service_name = call_specialities[booking['user']['doctor']['speciality']].name
for booking_service in booking['services']:
service_code = booking_service['service']['code']
for regex, bot_talking in call_services.items():
if re.match(regex, service_code):
service_name = bot_talking
break
if lpu is None or service_name is None:
continue continue
if not booking['patient']['phone_mobile']: if not booking['patient']['phone_mobile']:
@ -78,7 +93,7 @@ def update_call_requests_task(self):
patient_phone='7' + booking['patient']['phone_mobile'], patient_phone='7' + booking['patient']['phone_mobile'],
doctor_name=booking['user']['display'], doctor_name=booking['user']['display'],
doctor_speciality=booking['user']['doctor']['speciality_display'], doctor_speciality=booking['user']['doctor']['speciality_display'],
service_name=speciality.name, service_name=service_name,
organization=lpu.name, organization=lpu.name,
address=lpu.address, address=lpu.address,
), ),