class Phieukhambenh(db.Model): phieu_kham_benh_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ngay_kham = db.Column(db.DateTime, nullable=False) trieu_chung = db.Column(db.String(1500)) benh_nhan_id = db.Column(db.Integer, db.ForeignKey('benhnhan.benh_nhan_id')) loai_benh_id = db.Column(db.Integer, db.ForeignKey('loaibenh.loai_benh_id')) loai_benh_du_doan_id = db.Column(db.String(1500)) hoa_don = db.relationship('Hoadon', backref='phieu_kham_benh', lazy=True) def __str__(self): return str(self.phieu_kham_benh_id) + ' - ' + self.trieu_chung def serialize(self): return { 'phieu_kham_benh_id': self.phieu_kham_benh_id, 'ngay_kham': self.ngay_kham, 'trieu_chung': self.trieu_chung, 'benh_nhan_id': self.benh_nhan_id, 'loai_benh_id': self.loai_benh_id, 'loai_benh_du_doan_id': self.loai_benh_du_doan_id }
class Benhnhan(db.Model): benh_nhan_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ho_ten = db.Column(db.String(200)) gioi_tinh = db.Column(db.Boolean) nam_sinh = db.Column(db.DateTime) dia_chi = db.Column(db.String(500)) chung_minh_thu = db.Column(db.String(13)) ds_phieu_kham_benh = db.relationship('Phieukhambenh', backref='benh_nhan', lazy=True) def __str__(self): return str( self.benh_nhan_id ) + '-' + self.ho_ten + '-' + 'Nam' if self.gioi_tinh else 'Nữ' + self.dia_chi + str( self.nam_sinh) def serialize(self): return { 'benh_nhan_id': self.benh_nhan_id, 'ho_ten': self.ho_ten, 'gioi_tinh': self.gioi_tinh, 'nam_sinh': self.nam_sinh, 'dia_chi': self.dia_chi, }
class Bacsi(db.Model): bac_si_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ho_ten = db.Column(db.String(200)) gioi_tinh = db.Column(db.Boolean) nam_sinh = db.Column(db.DateTime) mieu_ta = db.Column(db.String(200)) khoa_id = db.Column(db.Integer, db.ForeignKey('khoa.khoa_id')) nguoi_dung_id = db.Column(db.Integer, db.ForeignKey('users.id'), unique=True) def save(self, *args, **kwargs): return super(Bacsi, self).save(*args, **kwargs) def __str__(self): return str(self.bac_si_id) + '-' + self.ho_ten def serialize(self): return { 'bac_si_id': self.bac_si_id, 'ho_ten': self.ho_ten, 'nam_sinh': self.nam_sinh, 'mieu_ta': self.mieu_ta, 'khoa': self.khoa.serialize(), }
class Users(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True, autoincrement=True) code_id = db.Column(db.Integer, db.ForeignKey(Code.code_id), nullable=False) name = db.Column(db.String(50), nullable=False) is_active = db.Column(db.Boolean, default=True) user_name = db.Column(db.String(50), nullable=False) password = db.Column(db.String(50), nullable=False) email = db.Column(db.String(50), nullable=False) chuc_vu_id = db.Column(db.Integer, db.ForeignKey('chucvu.chuc_vu_id')) ds_hoa_don = db.relationship('Hoadon', backref='user', lazy=True) bac_si = db.relationship('Bacsi', backref='user', lazy=True) def __str__(self): return str(self.id) + ' - ' + self.name + ' - ' + self.user_name def serialize(self): return { 'id': self.id, 'code_id': self.code_id, 'name': self.name, 'is_active': self.is_active, 'user_name': self.user_name, 'password': self.password, 'email': self.email }
class Khoa(db.Model): khoa_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ten_khoa = db.Column(db.String(200)) mieu_ta = db.Column(db.String(2000)) ds_bac_si = db.relationship('Bacsi', backref='khoa', lazy=True) def __str__(self): return str(self.khoa_id) + '-' + self.ten_khoa def serialize(self): return { 'ten_khoa': self.ten_khoa, 'mieu_ta': self.mieu_ta, 'ds_bac_si': util.ConvertModelListToDictList(self.ds_bac_si), }
class Loaibenh(db.Model): loai_benh_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ten_loai_benh = db.Column(db.String(300)) trieu_chung = db.Column(db.String(300)) ds_phieu_kham_benh = db.relationship('Phieukhambenh', backref='loai_benh', lazy=True) def __str__(self): return str(self.loai_benh_id) + '-' + self.ten_loai_benh def serialize(self): return { 'loai_benh_id': self.loai_benh_id, 'ten_loai_benh': self.ten_loai_benh, 'trieu_chung': self.trieu_chung }
class Chidan(db.Model): chi_dan_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) noi_dung = db.Column(db.String(1500)) ds_chi_tiet_hoa_don = db.relationship('Chitiethoadon', backref='chi_dan', lazy=True) def __str__(self): return str(self.chi_dan_id) + '-' + self.noi_dung def serialize(self): return {'chi_dan_id': self.chi_dan_id, 'noi_dung': self.noi_dung}
class Donvi(db.Model): don_vi_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ten_don_vi = db.Column(db.String(300)) ds_chi_tiet_hoa_don = db.relationship('Chitiethoadon', backref='don_vi', lazy=True) def __str__(self): return str(self.don_vi_id) + '-' + self.ten_don_vi def serialize(self): return { 'thuoc_id': self.thuoc_id, 'ten_thuoc': self.ten_thuoc, 'don_gia': self.don_gia }
class Thuoc(db.Model): thuoc_id = db.Column(db.Integer, primary_key=True, nullable=False, autoincrement=True) ten_thuoc = db.Column(db.String(300)) don_gia = db.Column(db.Float) ds_chi_tiet_hoa_don = db.relationship('Chitiethoadon', backref='thuoc', lazy=True) def __str__(self): return str(self.thuoc_id) + '-' + self.ten_thuoc + '-' + str( self.don_gia) def serialize(self): return { 'thuoc_id': self.hoa_don_id, 'ten_thuoc': self.phieu_kham_benh_id, 'don_gia': self.tien_kham }
class GopY(db.Model): gop_y_id = db.Column(db.Integer, primary_key=True, autoincrement=True) ten_nguoi_gui = db.Column(db.String(50), nullable=False) email_nguoi_gui = db.Column(db.String(50), nullable=False) tieu_de = db.Column(db.String(100), nullable=False) noi_dung = db.Column(db.String(5000), nullable=False)
class Chucvu(db.Model): chuc_vu_id = db.Column(db.Integer, primary_key=True, autoincrement=True) ten_chuc_vu = db.Column(db.String(50)) users = db.relationship('Users', backref="chuc_vu", lazy=True)