поиск пациента через полимед
This commit is contained in:
@@ -258,12 +258,28 @@ def request_patient_information():
|
|||||||
# taxpayer_fio = data.get('taxpayer_fio')
|
# taxpayer_fio = data.get('taxpayer_fio')
|
||||||
patient_fio = data.get('patient_fio')
|
patient_fio = data.get('patient_fio')
|
||||||
|
|
||||||
sheet = authorize_google().open("Пациенты клиники").sheet1
|
url = "http://192.168.1.10:8081/AppFindPacFromTel"
|
||||||
records = sheet.get_all_values()
|
data = {"telegram_id": user_id}
|
||||||
|
|
||||||
|
response = requests.post(url, json=data)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
patients = [] # Список пациентов
|
||||||
|
birthday_pac = {} # Словарь для хранения ФИО и даты рождения
|
||||||
|
|
||||||
|
for patient in result.get("Pacients", []):
|
||||||
|
# Формируем строку ФИО
|
||||||
|
fio = f"{patient['last_name']} {patient['first_name']} {patient['second_name']}"
|
||||||
|
patients.append(fio)
|
||||||
|
|
||||||
|
# Сохраняем дату рождения в словарь с ключом ФИО
|
||||||
|
birthday_pac[fio] = patient['birthday']
|
||||||
|
print("список:", patients)
|
||||||
|
print("даты рождения:", birthday_pac)
|
||||||
|
birthday_users = birthday_pac.get(patient_fio)
|
||||||
|
|
||||||
|
|
||||||
# Получаем список всех людей с таким user_id
|
|
||||||
birthday_users = [datetime.strptime(row[2], "%Y-%m-%d").strftime("%Y-%m-%dT00:00:00.000Z") for row in records[1:] if row[0] == patient_fio]
|
|
||||||
print(birthday_users)
|
|
||||||
|
|
||||||
|
|
||||||
if not user_id or not patient_fio: #or not taxpayer_fio
|
if not user_id or not patient_fio: #or not taxpayer_fio
|
||||||
@@ -276,7 +292,7 @@ def request_patient_information():
|
|||||||
"last_name": patient_fio.split()[0],
|
"last_name": patient_fio.split()[0],
|
||||||
"pac_poluchat": "True",
|
"pac_poluchat": "True",
|
||||||
"poluchat_status": "",
|
"poluchat_status": "",
|
||||||
"birthday": birthday_users[0] if birthday_users else None
|
"birthday": birthday_users
|
||||||
}
|
}
|
||||||
print(payload)
|
print(payload)
|
||||||
headers = {"User-Agent": "Mozilla/5.0", "Content-Type": "application/json"}
|
headers = {"User-Agent": "Mozilla/5.0", "Content-Type": "application/json"}
|
||||||
@@ -481,11 +497,27 @@ def request_patient2():
|
|||||||
taxpayer_status_zapros = data.get('taxpayer_status')
|
taxpayer_status_zapros = data.get('taxpayer_status')
|
||||||
patient_fio = data.get('patient_fio')
|
patient_fio = data.get('patient_fio')
|
||||||
|
|
||||||
sheet = authorize_google().open("Пациенты клиники").sheet1
|
url = "http://192.168.1.10:8081/AppFindPacFromTel"
|
||||||
records = sheet.get_all_values()
|
data = {"telegram_id": user_id}
|
||||||
|
|
||||||
|
response = requests.post(url, json=data)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
patients = [] # Список пациентов
|
||||||
|
birthday_pac = {} # Словарь для хранения ФИО и даты рождения
|
||||||
|
|
||||||
|
for patient in result.get("Pacients", []):
|
||||||
|
# Формируем строку ФИО
|
||||||
|
fio = f"{patient['last_name']} {patient['first_name']} {patient['second_name']}"
|
||||||
|
patients.append(fio)
|
||||||
|
|
||||||
|
# Сохраняем дату рождения в словарь с ключом ФИО
|
||||||
|
birthday_pac[fio] = patient['birthday']
|
||||||
|
print("список:", patients)
|
||||||
|
print("даты рождения:", birthday_pac)
|
||||||
|
birthday_users = birthday_pac.get(patient_fio)
|
||||||
|
|
||||||
# Получаем список всех людей с таким user_id
|
|
||||||
birthday_users = [datetime.strptime(row[2], "%Y-%m-%d").strftime("%Y-%m-%dT00:00:00.000Z") for row in records[1:] if row[0] == patient_fio]
|
|
||||||
print(birthday_users)
|
print(birthday_users)
|
||||||
|
|
||||||
|
|
||||||
@@ -496,7 +528,7 @@ def request_patient2():
|
|||||||
"last_name": patient_fio.split()[0],
|
"last_name": patient_fio.split()[0],
|
||||||
"pac_poluchat": "False",
|
"pac_poluchat": "False",
|
||||||
"poluchat_status": data.get('taxpayer_status'),
|
"poluchat_status": data.get('taxpayer_status'),
|
||||||
"birthday": birthday_users[0] if birthday_users else None
|
"birthday": birthday_users
|
||||||
}
|
}
|
||||||
print(payload)
|
print(payload)
|
||||||
headers = {"User-Agent": "Mozilla/5.0", "Content-Type": "application/json"}
|
headers = {"User-Agent": "Mozilla/5.0", "Content-Type": "application/json"}
|
||||||
@@ -754,18 +786,25 @@ def main_page_2_0_fns_test():
|
|||||||
if not user_id:
|
if not user_id:
|
||||||
return "Ошибка: не передан user_id", 400
|
return "Ошибка: не передан user_id", 400
|
||||||
|
|
||||||
sheet = authorize_google().open("Пациенты клиники").sheet1
|
url = "http://192.168.1.10:8081/AppFindPacFromTel"
|
||||||
records = sheet.get_all_values()
|
data = {"telegram_id": user_id}
|
||||||
|
|
||||||
# Получаем список всех людей с таким user_id
|
response = requests.post(url, json=data)
|
||||||
matching_users = [row[0] for row in records[1:] if row[3] == user_id]
|
patients = []
|
||||||
matching_users = sum(matching_users, []) if any(isinstance(i, list) for i in matching_users) else matching_users
|
|
||||||
|
|
||||||
print(matching_users)
|
if response.status_code == 200:
|
||||||
|
result = response.json()
|
||||||
|
for patient in result.get("Pacients", []):
|
||||||
|
# Формируем строку ФИО
|
||||||
|
fio = f"{patient['last_name']} {patient['first_name']} {patient['second_name']}"
|
||||||
|
patients.append(fio)
|
||||||
|
print("список:", patients)
|
||||||
|
birthday_pac = {patient['birthday']}
|
||||||
|
|
||||||
if not matching_users:
|
|
||||||
|
if not patients:
|
||||||
return "Ошибка: пользователь не найден", 404
|
return "Ошибка: пользователь не найден", 404
|
||||||
|
|
||||||
return render_template('2.0/main_page_fns2.pug', user_id=user_id, users=matching_users)
|
return render_template('2.0/main_page_fns2.pug', user_id=user_id, users=patients, birthday_paci=birthday_pac)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Произошла ошибка: {e}", 500
|
return f"Произошла ошибка: {e}", 500
|
||||||
Reference in New Issue
Block a user