feat: initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from sqlalchemy import Column, DateTime, Enum, Integer, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from enums.enums import AppointmentStatus
|
||||
from database import Base
|
||||
from .CustomBase import CustomBase
|
||||
|
||||
|
||||
class Appointments(Base, CustomBase):
|
||||
__tablename__ = "appointments"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
appointment_time = Column(DateTime)
|
||||
status = Column(Enum(AppointmentStatus))
|
||||
|
||||
doctor_id = Column(Integer, ForeignKey("doctors.id"), index=True)
|
||||
doctor = relationship("Doctors", back_populates="appointments")
|
||||
|
||||
patient_id = Column(Integer, ForeignKey("patients.id"), index=True)
|
||||
patient = relationship("Patients", back_populates="appointments")
|
||||
@@ -0,0 +1,16 @@
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
from .CustomBase import CustomBase
|
||||
|
||||
|
||||
class Calenders(Base, CustomBase):
|
||||
__tablename__ = "calenders"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
doc_id = Column(Integer, ForeignKey("doctors.id"), nullable=False, index=True)
|
||||
# rrule = Column(String)
|
||||
time = Column(String)
|
||||
|
||||
doctor = relationship("Doctors", back_populates="calendars")
|
||||
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
from .CustomBase import CustomBase
|
||||
|
||||
|
||||
class Clinics(Base, CustomBase):
|
||||
__tablename__ = "clinics"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String)
|
||||
address = Column(String, nullable=True)
|
||||
phone = Column(String, unique=True, index=True)
|
||||
email = Column(String, unique=True, index=True, nullable=True)
|
||||
|
||||
doctors = relationship("Doctors", back_populates="clinic")
|
||||
@@ -0,0 +1,8 @@
|
||||
from sqlalchemy import Column, DateTime, func
|
||||
|
||||
|
||||
class CustomBase:
|
||||
create_time = Column(DateTime(timezone=True), server_default=func.now())
|
||||
update_time = Column(
|
||||
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
from .CustomBase import CustomBase
|
||||
|
||||
|
||||
class Doctors(Base, CustomBase):
|
||||
__tablename__ = "doctors"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String)
|
||||
age = Column(Integer, nullable=True)
|
||||
email = Column(String, unique=True, index=True, nullable=True)
|
||||
phone = Column(String, unique=True, index=True)
|
||||
address = Column(String, nullable=True)
|
||||
|
||||
clinic_id = Column(Integer, ForeignKey("clinics.id"), nullable=False, index=True)
|
||||
clinic = relationship("Clinics", back_populates="doctors")
|
||||
|
||||
appointments = relationship("Appointments", back_populates="doctor")
|
||||
calendars = relationship("Calenders", back_populates="doctor")
|
||||
@@ -0,0 +1,19 @@
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from database import Base
|
||||
from .CustomBase import CustomBase
|
||||
|
||||
|
||||
class Patients(Base, CustomBase):
|
||||
__tablename__ = "patients"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String)
|
||||
age = Column(Integer, nullable=True)
|
||||
email = Column(String, unique=True, index=True, nullable=True)
|
||||
phone = Column(String, unique=True, index=True)
|
||||
address = Column(String, nullable=True)
|
||||
dob = Column(String, nullable=True)
|
||||
|
||||
appointments = relationship("Appointments", back_populates="patient")
|
||||
@@ -0,0 +1,14 @@
|
||||
from sqlalchemy import Column, Integer, String
|
||||
from database import Base
|
||||
from sqlalchemy import Enum
|
||||
from enums.enums import ClinicUserRoles, UserType
|
||||
from models.CustomBase import CustomBase
|
||||
|
||||
class Users(Base, CustomBase):
|
||||
__tablename__ = "users"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String, index=True)
|
||||
email = Column(String, unique=True, index=True)
|
||||
password = Column(String)
|
||||
clinicRole = Column(Enum(ClinicUserRoles), nullable=True)
|
||||
userType = Column(Enum(UserType), nullable=True)
|
||||
@@ -0,0 +1,15 @@
|
||||
from .Users import Users
|
||||
from .Clinics import Clinics
|
||||
from .Doctors import Doctors
|
||||
from .Patients import Patients
|
||||
from .Appointments import Appointments
|
||||
from .Calendar import Calenders
|
||||
|
||||
__all__ = [
|
||||
"Users",
|
||||
"Clinics",
|
||||
"Doctors",
|
||||
"Patients",
|
||||
"Appointments",
|
||||
"Calenders",
|
||||
]
|
||||
Reference in New Issue
Block a user