from sqlalchemy import Column, VARCHAR, Date, String from sqlalchemy.orm import relationship from app.domain.models.base import BaseModel from app.settings import settings class Patient(BaseModel): __tablename__ = 'patients' __table_args__ = {"schema": settings.SCHEMA} first_name = Column(VARCHAR(200), nullable=False) last_name = Column(VARCHAR(200), nullable=False) patronymic = Column(VARCHAR(200)) birthday = Column(Date, nullable=False) address = Column(String) email = Column(VARCHAR(350)) phone = Column(VARCHAR(25)) diagnosis = Column(String) correction = Column(String) lens_issues = relationship('LensIssue', back_populates='patient', cascade="all, delete") appointments = relationship('Appointment', back_populates='patient', cascade="all, delete") mailing = relationship('Recipient', back_populates='patient', cascade="all, delete") scheduled_appointments = relationship('ScheduledAppointment', back_populates='patient', cascade="all, delete")