コード例 #1
0
ファイル: main_tables.py プロジェクト: datblag/stat_site
class Patients(db.Model, DatExtDB):
    # пациенты
    __tablename__ = 'patients'
    patient_id = db.Column(db.Integer, primary_key=True)
    fam = db.Column(db.String(40))
    im = db.Column(db.String(40))
    ot = db.Column(db.String(40))
    birthday = db.Column(db.Date)
    num = db.Column(db.String(40))
    mis_id = db.Column(db.Integer)
    is_deleted = db.Column(db.Integer)
    defects_smo_expert = db.relationship('DefectList',
                                         backref='patient',
                                         lazy='dynamic')
    mse_referral = db.relationship('MseReferral',
                                   backref='patient',
                                   lazy='dynamic')
    med_services = db.relationship('MedicalServices',
                                   backref='patient',
                                   lazy='dynamic')

    def get_age(self):
        today = datetime.date.today()
        return today.year - self.birthday.year - (
            (today.month, today.day) <
            (self.birthday.month, self.birthday.day))

    def __repr__(self):
        return '{} {} {} {}'.format(
            self.fam, self.im, self.ot,
            datetime.datetime.strftime(self.birthday, '%d.%m.%Y'))
コード例 #2
0
class RefDoctors(db.Model):
    # врачи
    __tablename__ = 'ref_doctors'
    doctor_id = db.Column(db.Integer, primary_key=True)
    doctor_stat_code = db.Column(db.String(4))
    doctor_name = db.Column(db.String(35))
    defects = db.relationship('DefectList', backref='doctor', lazy='dynamic')
    mse_referral = db.relationship('MseReferral', backref='doctor', lazy='dynamic')
    med_services = db.relationship('MedicalServices', backref='doctor', lazy='dynamic')
    otdel_id_ref = db.Column(db.Integer, db.ForeignKey('ref_otdels.otdel_id'))

    def __repr__(self):
        return '<Врач {}>'.format(self.doctor_stat_code+' '+self.doctor_name)
コード例 #3
0
class Mkb10(db.Model):
    # диагнозы
    __tablename__ = 'mkb10'
    rec_code = db.Column(db.String(9))
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(6))
    name = db.Column(db.Text, nullable=False)
    parent_code = db.Column(db.Integer, db.ForeignKey('mkb10.id'), index=True)
    parent = db.relationship(lambda: Mkb10, remote_side=id, backref='sub_mkb10')
    addl_code = db.Column(db.Integer)
    actual = db.Column(db.Boolean)
    date = db.Column(db.Date)
    med_services = db.relationship('MedicalServices', backref='disease', lazy='dynamic')

    def __repr__(self):
        return '<{}{}>'.format(self.code, self.name)
コード例 #4
0
ファイル: medical_services.py プロジェクト: datblag/stat_site
class RefKmu(db.Model, DatExtDB):
    # справочник мед услуг
    __tablename__ = 'ref_kmu'
    kmu_id = db.Column(db.Integer, primary_key=True)
    kmu_name = db.Column(db.String(100))
    oms_code = db.Column(db.String(16))
    med_services = db.relationship('MedicalServices',
                                   backref='kmu',
                                   lazy='dynamic')
コード例 #5
0
class RefDisabilityGroup(db.Model):
    # группа инвалидности
    __tablename__ = 'ref_disability_group'
    disability_group_id = db.Column(db.Integer, primary_key=True)
    disability_group_name = db.Column(db.String(15))
    mse_referral = db.relationship('MseReferral', backref='disability_group', lazy='dynamic')

    def __repr__(self):
        return '{}'.format(self.disability_group_name)
コード例 #6
0
class RefBureauMse(db.Model):
    # бюро мсэ
    __tablename__ = 'ref_bureau_mse'
    bureau_id = db.Column(db.Integer, primary_key=True)
    bureau_name = db.Column(db.String(15))
    mse_referral = db.relationship('MseReferral', backref='bureau', lazy='dynamic')

    def __repr__(self):
        return '{}'.format(self.bureau_name)
コード例 #7
0
class RefOtdels(db.Model):
    # отделения
    __tablename__ = 'ref_otdels'
    otdel_id = db.Column(db.Integer, primary_key=True)
    otdel_stat_code = db.Column(db.String(2))
    otdel_name = db.Column(db.String(50))
    doctors = db.relationship('RefDoctors', backref='otdel', lazy='dynamic')

    def __repr__(self):
        return 'Отделение: {}'.format(self.otdel_name)
コード例 #8
0
ファイル: authorization.py プロジェクト: datblag/stat_site
class Role(db.Model):
    __tablename__ = 'roles'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True)
    permissions = db.Column(db.Integer)
    users = db.relationship('User', backref='role', lazy='dynamic')

    def __init__(self, **kwargs):
        super(Role, self).__init__(**kwargs)
        if self.permissions is None:
            self.permissions = 0

    def has_permission(self, perm):
        return self.permissions & perm == perm