コード例 #1
0
ファイル: models.py プロジェクト: Sirahi/HospitalWebApp
class User(UserMixin, db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    first_name = db.Column(db.String(64))
    last_name = db.Column(db.String(64))
    email = db.Column(db.String(120), index=True, unique=True)
    specialization = db.Column(db.String(120), nullable=True)
    checked = db.Column(db.Boolean)
    password_hash = db.Column(db.String(128))
    doctor = db.relationship('User',
                             backref='assigned_patients',
                             remote_side=[id])
    doctor_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    diagnosis = db.relationship('Diagnosis', backref='patient')

    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)

    @login.user_loader
    def load_user(id):
        return User.query.get(int(id))
コード例 #2
0
ファイル: models.py プロジェクト: Sirahi/HospitalWebApp
class Diagnosis(UserMixin, db.Model):
    __tablename__ = 'diagnosis'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True, unique=True)
    explanation = db.Column(db.String(1024))
    diagnosed_by = db.Column(db.String(64))
    patient_id = db.Column(db.Integer, db.ForeignKey('user.id'))
コード例 #3
0
class Diagonastic(db.Model):
    __tablename__ = 'Diagonastic'
    dName = db.Column(db.String(20), primary_key=True, nullable=False)
    amt = db.Column(db.Integer, nullable=False)
    pid = db.Column(db.Integer, db.ForeignKey('Patient.id'), nullable=False)

    def __repr__(self):
        return f"Diagonastic('{self.dName}','{self.amt}')"
コード例 #4
0
class Medicine(db.Model):
    __tablename__ = 'Medicine'
    mName = db.Column(db.String(20), primary_key=True, nullable=False)
    qty = db.Column(db.Integer, nullable=False)
    rate = db.Column(db.Integer, nullable=False)
    amount = db.Column(db.Integer, nullable=False)
    pid = db.Column(db.Integer, db.ForeignKey('Patient.id'), nullable=False)

    def __repr__(self):
        return f"Medicine('{self.mName}','{self.qty}','{self.rate}','{self.amount}')"
コード例 #5
0
class Diagnosis(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    status = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.Date, nullable=False, default=date.today())
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.png')
    content = db.Column(db.Text, nullable=False)
    #foregin keys from patient and doctor tables
    patient_id = db.Column(db.Integer,
                           db.ForeignKey('patient.id_number'),
                           nullable=False)
    doctor_id = db.Column(db.Integer,
                          db.ForeignKey('doctor.id_number'),
                          nullable=False)

    #function for setting values, that class will return when calling the database
    def __repr__(self):
        return f"Diagnosis('{self.status}', '{self.date_posted}', '{self.image_file}')"