visus-plus/api/app/domain/models/scheduled_appointments.py

20 lines
821 B
Python

from sqlalchemy import Column, Integer, ForeignKey, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.domain.models.base import BaseModel
class ScheduledAppointment(BaseModel):
__tablename__ = 'scheduled_appointments'
scheduled_datetime = Column(DateTime, nullable=False, server_default=func.now())
patient_id = Column(Integer, ForeignKey('patients.id'), nullable=False)
doctor_id = Column(Integer, ForeignKey('users.id'), nullable=False)
type_id = Column(Integer, ForeignKey('appointment_types.id'), nullable=False)
patient = relationship('Patient', back_populates='scheduled_appointments')
doctor = relationship('User', back_populates='scheduled_appointments')
type = relationship('AppointmentType', back_populates='scheduled_appointments')