Exemplo n.º 1
0
class Doctor(db.Model):
    id = db.Column(db.String(100),
                   db.ForeignKey('user.id'),
                   primary_key=True,
                   onupdate="CASCADE")
    #foreign key
    # user_id = db.Column(db.String(100), db.ForeignKey('user.user_id'), nullable=False, unique=True, onupdate="CASCADE")
    department_id = db.Column(db.Integer(),\
     db.ForeignKey('department.id'), nullable=False, onupdate="CASCADE")

    #one-to-many relationship
    time_slots = db.relationship('Time_slot', backref='doctor', lazy=True)
    applications = db.relationship('Application', backref='doctor', lazy=True)

    def __repr__(self):
        return f'Doctor < license_id: {self.id} >'
Exemplo n.º 2
0
class Admin(db.Model):
    id = db.Column(db.String(100),
                   db.ForeignKey('user.id'),
                   primary_key=True,
                   onupdate="CASCADE")

    def __repr__(self):
        return f'Admin < id: {self.id} >'
Exemplo n.º 3
0
class User(UserMixin, db.Model):
    # user_id = db.Column(db.String(100), primary_key=True)
    id = db.Column(db.String(100), primary_key=True)
    first_name = db.Column(db.String(100), nullable=False)
    last_name = db.Column(db.String(100), nullable=False)
    role = db.Column(
        db.Enum(RoleEnum), nullable=False
    )  # should we set a default role? default=RoleEnum.patient
    email = db.Column(db.String(100))
    phone = db.Column(db.String(20))
    password_hash = db.Column(db.String(100), nullable=False)

    #one-to-one relationship
    doctors = db.relationship('Doctor',
                              backref='user',
                              lazy=True,
                              cascade="all, delete")
    nurses = db.relationship('Nurse',
                             backref='user',
                             lazy=True,
                             cascade="all, delete")
    patients = db.relationship('Patient',
                               backref='user',
                               lazy=True,
                               cascade="all, delete")

    def set_password(self, password):
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)
Exemplo n.º 4
0
class Patient(db.Model):
    id = db.Column(db.String(100),
                   db.ForeignKey('user.id'),
                   primary_key=True,
                   onupdate="CASCADE")
    #foreign key
    # user_id = db.Column(db.String(100), db.ForeignKey('user.user_id'), nullable=False, unique=True, onupdate="CASCADE")

    age = db.Column(db.SmallInteger())
    gender = db.Column(db.Enum(GenderEnum))
    blood_type = db.Column(db.String(10))
    allergies = db.Column(db.Text())

    #one-to-many relationship
    applications = db.relationship('Application', backref='patient', lazy=True)
    medical_records = db.relationship('Medical_record',
                                      backref='patient',
                                      lazy=True)
    lab_reports = db.relationship('Lab_report', backref='patient', lazy=True)

    def __repr__(self):
        return f'Patient < id: {self.id} >'
Exemplo n.º 5
0
class Lab_report(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    file = db.Column(db.LargeBinary())
    comments = db.Column(db.Text())
    #foreign key
    lr_type = db.Column(db.String(50), \
     db.ForeignKey('lab_report_type.type'), nullable=False)
    mc_id = db.Column(db.Integer(), \
     db.ForeignKey('medical_record.id'), nullable=False)
    uploader_id = db.Column(db.String(100), \
     db.ForeignKey('nurse.id'), nullable=False)
    patient_id = db.Column(db.String(100), \
     db.ForeignKey('patient.id'), nullable=False)

    def __repr__(self):
        return f'Lab_report < id: {self.id}, (report_)type: {len(self.type)},\
Exemplo n.º 6
0
class Medical_record(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    body_temperature = db.Column(db.Float(1))
    body_pressure = db.Column(db.Float(1))
    heart_rate = db.Column(db.Integer())
    weight = db.Column(db.Float(1))
    state = db.Column(db.Enum('conscious', 'coma'), default="conscious")
    #foreign key
    patient_id = db.Column(db.String(100), \
     db.ForeignKey('patient.id'), nullable=False)
    appt_id = db.Column(db.Integer(), \
     db.ForeignKey('application.id'), nullable=False)
    nurse_id = db.Column(db.String(100), \
     db.ForeignKey('nurse.id'), nullable=False)
    #one-to-many relationship
    lab_reports = db.relationship('Lab_report',
                                  backref='medical_record',
                                  lazy=True)
    prescription = db.relationship('Prescription',
                                   backref='medical_record',
                                   lazy=True)

    def __repr__(self):
        return f'Medical_record < id: {self.id}, appt_id: {self.appt_id}, \
Exemplo n.º 7
0
class Time_slot(db.Model):
    id = db.Column(db.Integer(), primary_key=True)
    slot_date = db.Column(db.Date(), nullable=False)
    n_total = db.Column(db.Integer(), nullable=False)
    n_booked = db.Column(db.Integer())

    #foreign key
    slot_seg_id = db.Column(db.Integer(),
                            db.ForeignKey('time_segment.t_seg_id'),
                            nullable=False)
    doctor_id = db.Column(db.String(100), \
     db.ForeignKey('doctor.id'), nullable=False)

    #one-to-many relationship
    applications = db.relationship('Application',
                                   backref='time_slot',
                                   lazy=True)

    def __repr__(self):
        return f'Time_slot < id: {self.id}, slot_date: {self.slot_date}, \
Exemplo n.º 8
0
class Time_segment(db.Model):
    t_seg_id = db.Column(db.Integer(), primary_key=True)
    t_seg_starttime = db.Column(db.Time(), nullable=False)

    def __repr__(self):
        return f'Time_segment < t_seg_id: {self.t_seg_id}, t_seg_starttime: {self.t_seg_starttime} >'