Not a member of GistPad yet?
Sign Up,
it unlocks many cool features!
- import os
- from datetime import date
- full_name_input = input("Enter the full name of the patient separated by space (Ivanov Ivan Ivanovich): ")
- name_parts = full_name_input.strip().split()
- if len(name_parts) != 3:
- print("There is no such patient!")
- else:
- formatted_name = name_parts[0].capitalize() + "_" + name_parts[1].capitalize() + "_" + name_parts[2].capitalize()
- patient_path = os.path.join(os.path.dirname(__file__), "materials", "patients", formatted_name)
- if not os.path.isdir(patient_path):
- print("There is no such patient!")
- else:
- # Папка для приёмов пациента
- visits_path = os.path.join(patient_path, "visits")
- os.makedirs(visits_path, exist_ok=True)
- # Имя файла = текущая дата в формате YYYY-MM-DD
- today = date.today().isoformat()
- appointment_path = os.path.join(visits_path, today + ".txt")
- # Сообщение выводится один раз перед многострочным вводом
- print("Enter records for the current appointment (to finish press Enter thrice):")
- # Многострочный ввод: 1 Enter — перенос, 2 пустые строки подряд — конец
- lines = []
- empty_count = 0
- while empty_count < 2:
- line = input()
- if line == "":
- empty_count += 1
- else:
- empty_count = 0
- lines.append(line)
- # Убираем две завершающие пустые строки (сигнал окончания ввода)
- lines = lines[:-2]
- # Записываем в файл
- with open(appointment_path, 'w', encoding='utf-8') as f:
- f.write("\n".join(lines))
RAW Paste Data
Copied
Advertisement
