From 523b6d5b890b5fd607a3c9cf8b1831579c54102a Mon Sep 17 00:00:00 2001 From: Andrei Duvakin Date: Sun, 2 Feb 2025 14:33:21 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D1=82=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/domain/models/appointment_types.py | 13 +++++++++++++ api/app/domain/models/appointments.py | 20 ++++++++++++++++++++ api/app/domain/models/lens.py | 1 + api/app/domain/models/lens_issues.py | 19 +++++++++++++++++++ api/app/domain/models/patients.py | 22 ++++++++++++++++++++++ api/app/domain/models/users.py | 3 +++ 6 files changed, 78 insertions(+) create mode 100644 api/app/domain/models/appointment_types.py create mode 100644 api/app/domain/models/appointments.py create mode 100644 api/app/domain/models/lens_issues.py create mode 100644 api/app/domain/models/patients.py diff --git a/api/app/domain/models/appointment_types.py b/api/app/domain/models/appointment_types.py new file mode 100644 index 0000000..b7dc75f --- /dev/null +++ b/api/app/domain/models/appointment_types.py @@ -0,0 +1,13 @@ +from sqlalchemy import Column, Integer, VARCHAR +from sqlalchemy.orm import relationship + +from app.domain.models import Base + + +class AppointmentType(Base): + __tablename__ = 'appointment_types' + + id = Column(Integer, primary_key=True, autoincrement=True) + title = Column(VARCHAR(150), nullable=False, unique=True) + + appointments = relationship('Appointment', back_populates='type') diff --git a/api/app/domain/models/appointments.py b/api/app/domain/models/appointments.py new file mode 100644 index 0000000..29f00fa --- /dev/null +++ b/api/app/domain/models/appointments.py @@ -0,0 +1,20 @@ +from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy.orm import relationship + +from app.domain.models import Base + + +class Appointment(Base): + __tablename__ = 'appointments' + + id = Column(Integer, primary_key=True, autoincrement=True) + results = Column(String) + days_until_the_next_appointment = Column(Integer) + + 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='appointments') + doctor = relationship('User', back_populates='appointments') + type = relationship('AppointmentType', back_populates='appointments') diff --git a/api/app/domain/models/lens.py b/api/app/domain/models/lens.py index 627d211..8781622 100644 --- a/api/app/domain/models/lens.py +++ b/api/app/domain/models/lens.py @@ -28,3 +28,4 @@ class Lens(Base): type = relationship('LensesType', back_populates='lenses') set = relationship('SetLens', back_populates='lens') + lens_issues = relationship('LensIssue', back_populates='lens') diff --git a/api/app/domain/models/lens_issues.py b/api/app/domain/models/lens_issues.py new file mode 100644 index 0000000..2f40564 --- /dev/null +++ b/api/app/domain/models/lens_issues.py @@ -0,0 +1,19 @@ +from sqlalchemy import Column, Integer, ForeignKey, Date +from sqlalchemy.orm import relationship + +from app.domain.models import Base + + +class LensIssue(Base): + __tablename__ = 'lens_issues' + + id = Column(Integer, primary_key=True, autoincrement=True) + issue_date = Column(Date, nullable=False) + + patient_id = Column(Integer, ForeignKey('patients.id'), nullable=False) + doctor_id = Column(Integer, ForeignKey('user.id'), nullable=False) + lens_id = Column(Integer, ForeignKey('lens.id'), nullable=False) + + patient = relationship('Patient', back_populates='lens_issues') + doctor = relationship('User', back_populates='lens_issues') + lens = relationship('Lens', back_populates='lens_issues') diff --git a/api/app/domain/models/patients.py b/api/app/domain/models/patients.py new file mode 100644 index 0000000..4de950e --- /dev/null +++ b/api/app/domain/models/patients.py @@ -0,0 +1,22 @@ +from sqlalchemy import Column, Integer, VARCHAR, Date, String +from sqlalchemy.orm import relationship + +from app.domain.models import Base + + +class Patient(Base): + __tablename__ = 'patients' + + id = Column(Integer, primary_key=True, autoincrement=True) + 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') + appointments = relationship('Appointment', back_populates='patient') diff --git a/api/app/domain/models/users.py b/api/app/domain/models/users.py index 7baad62..f6ca4c7 100644 --- a/api/app/domain/models/users.py +++ b/api/app/domain/models/users.py @@ -17,3 +17,6 @@ class User(Base): role_id = Column(Integer, ForeignKey('roles.id'), nullable=False) role = relationship('Role', back_populates='users') + + lens_issues = relationship('LensIssue', back_populates='doctor') + appointments = relationship('Appointment', back_populates='doctor')