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'))
class DiagonasticMaster(db.Model): __tablename__ = 'DiagonasticMaster' dName = db.Column(db.String(20), primary_key=True, nullable=False) amt = db.Column(db.Integer, nullable=False) def __repr__(self): return f"Diagonastic('{self.dName}','{self.amt}')"
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}')"
class User(db.Model, UserMixin): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True) password = db.Column(db.String(80), nullable=False) utype = db.Column(db.String(80), nullable=False) def __repr__(self): return f"user('{self.username}','{self.password}')"
class MedicineMaster(db.Model): __tablename__ = 'MedicineMaster' 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) status = db.Column(db.String, ) def __repr__(self): return f"Medicine('{self.mName}','{self.qty}','{self.rate}','{self.status}')"
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}')"
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))
class Admin(db.Model, UserMixin): id_number = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), nullable=False) surname = db.Column(db.String(20), nullable=False) id = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) role = db.Column(db.String(10), nullable=False, default='admin') #function for setting values, that class will return when calling the database def __repr__(self): return f"Admin('{self.name}','{self.surname}' ,'{self.id}', '{self.image_file}','{self.role}','{self.password}')"
class Doctor(db.Model, UserMixin): id_number = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(20), nullable=False) surname = db.Column(db.String(20), nullable=False) id = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) diagnosis = db.relationship('Diagnosis', backref='doctor', lazy=True) role = db.Column(db.String(10), nullable=False, default='doctor') #function for setting values, that class will return when calling the database def __repr__(self): return f"Doctor('{self.name}','{self.surname}' ,'{self.id}', '{self.image_file}','{self.role}')"
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}')"
class Patient(db.Model): __tablename__ = 'Patient' id = db.Column(db.Integer, primary_key=True) ssnid = db.Column( db.Integer, unique=True, nullable=False, ) name = db.Column(db.String(20), nullable=False) age = db.Column(db.String(100), nullable=False) address = db.Column(db.String(100), nullable=False) city = db.Column(db.String(100), nullable=False) state = db.Column(db.String(100), nullable=False) bed = db.Column(db.String(50), nullable=False) status = db.Column(db.String(50), nullable=False) doj = db.Column(db.String(50), nullable=False) dodc = db.Column(db.String(50)) medrelo = db.relationship('Medicine', backref='diag', lazy=True) diagrelo = db.relationship('Diagonastic', backref='med', lazy=True) def __repr__(self): return f"Patient('{self.id}','{self.ssnid}','{self.name}','{self.age}','{self.address}','{self.city}','{self.state}','{self.bed}','{self.doj}','{self.dodc}')"