37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, Text
|
|
from sqlalchemy.orm import relationship
|
|
import enum
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class AppointmentStatus(str, enum.Enum):
|
|
SCHEDULED = "scheduled"
|
|
CONFIRMED = "confirmed"
|
|
COMPLETED = "completed"
|
|
CANCELLED = "cancelled"
|
|
NO_SHOW = "no_show"
|
|
|
|
|
|
class Appointment(Base):
|
|
__tablename__ = "appointments"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
patient_id = Column(Integer, ForeignKey("patients.id"), nullable=False)
|
|
doctor_id = Column(Integer, ForeignKey("doctors.id"), nullable=False)
|
|
appointment_datetime = Column(DateTime, nullable=False)
|
|
duration_minutes = Column(Integer, default=30, nullable=False)
|
|
status = Column(
|
|
Enum(AppointmentStatus),
|
|
default=AppointmentStatus.SCHEDULED,
|
|
nullable=False
|
|
)
|
|
reason = Column(Text, nullable=True)
|
|
notes = Column(Text, nullable=True)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
# Relationships
|
|
patient = relationship("Patient", back_populates="appointments")
|
|
doctor = relationship("Doctor", back_populates="appointments") |