Esempio n. 1
0
class ConfigVariables(db.Model):
    __bind_key__ = 'caesar'
    __tablename__ = '%s_config' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.String(25), unique=True, nullable=False)
    name = db.Column(db.Unicode(50), unique=True, nullable=False)
    value = db.Column(db.Unicode(100))
    value_type = db.Column(db.String(30))

    def __unicode__(self):
        return self.code
Esempio n. 2
0
class Street(db.Model):
    __bind_key__ = 'kladr'
    __tablename__ = 'STREET'
    __table_args__ = (db.Index('NAME_SOCR', 'NAME', 'SOCR', 'CODE'), )

    NAME = db.Column(db.Unicode(40), nullable=False)
    SOCR = db.Column(db.Unicode(10), nullable=False)
    CODE = db.Column(db.String(17), primary_key=True)
    INDEX = db.Column(db.String(6), nullable=False)
    GNINMB = db.Column(db.String(4), nullable=False)
    UNO = db.Column(db.String(4), nullable=False)
    OCATD = db.Column(db.String(11), nullable=False)
    infis = db.Column(db.String(5), nullable=False, index=True)
Esempio n. 3
0
class rbReceptionType(db.Model):
    __tablename__ = 'rbReceptionType'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.Unicode(32), nullable=False)
    name = db.Column(db.Unicode(64), nullable=False)

    def __unicode__(self):
        return u'(%s) %s' % (self.code, self.name)

    def __json__(self):
        return {
            'code': self.code,
            'name': self.name,
        }
Esempio n. 4
0
class Template(db.Model):
    """Шаблоны"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_template' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.Unicode(80), unique=True, nullable=False)
    archive = db.Column(db.Boolean, default=False)
    is_active = db.Column(db.Boolean, default=False)

    #user = db.Column(db.Integer, db.ForeignKey('.id'))
    type_id = db.Column(db.Integer,
                        db.ForeignKey('%s_template_type.id' % TABLE_PREFIX),
                        index=True)
    type = db.relation(TemplateType)

    tag_tree = db.relationship('TagsTree',
                               backref='template',
                               cascade="all, delete, delete-orphan")

    def __repr__(self):
        return '<Template %r>' % self.name

    def __unicode__(self):
        return self.name
Esempio n. 5
0
class Kladr(db.Model):
    __bind_key__ = 'kladr'
    __tablename__ = 'KLADR'
    __table_args__ = (db.Index('long_name', 'prefix', 'NAME', 'SOCR',
                               'STATUS'), db.Index('NAME', 'NAME', 'SOCR'),
                      db.Index('parent', 'parent', 'NAME', 'SOCR', 'CODE'))

    NAME = db.Column(db.Unicode(40), nullable=False)
    SOCR = db.Column(db.Unicode(10), nullable=False)
    CODE = db.Column(db.String(13), primary_key=True)
    INDEX = db.Column(db.String(6), nullable=False)
    GNINMB = db.Column(db.String(4), nullable=False)
    UNO = db.Column(db.String(4), nullable=False)
    OCATD = db.Column(db.String(11), nullable=False, index=True)
    STATUS = db.Column(db.String(1), nullable=False)
    parent = db.Column(db.String(13), nullable=False)
    infis = db.Column(db.String(5), nullable=False, index=True)
    prefix = db.Column(db.String(2), nullable=False)
    id = db.Column(db.Integer, nullable=False, unique=True)
Esempio n. 6
0
class Office(db.Model):
    __tablename__ = 'Office'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.Unicode(32), nullable=False)
    name = db.Column(db.Unicode(64), nullable=False)
    orgStructure_id = db.Column(db.ForeignKey('OrgStructure.id'))

    orgStructure = db.relationship('Orgstructure')

    def __unicode__(self):
        return self.code

    def __json__(self):
        return {
            'code': self.code,
            'name': self.name,
            'org_structure': self.orgStructure
        }
Esempio n. 7
0
class DownloadType(db.Model):
    """Тип выгрузки"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_download_type' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.String(10), unique=True, nullable=False)
    name = db.Column(db.Unicode(25), unique=True)

    def __repr__(self):
        return '<DownloadType %r>' % self.code

    def __unicode__(self):
        return u'%s (%s)' % (self.name, self.code)
Esempio n. 8
0
class TemplateType(db.Model):
    """Тип шаблона"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_template_type' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.String(20), unique=True, nullable=False)
    name = db.Column(db.Unicode(45), unique=True, nullable=False)

    download_type_id = db.Column(db.Integer,
                                 db.ForeignKey('%s_download_type.id' %
                                               TABLE_PREFIX),
                                 index=True)
    download_type = db.relationship(DownloadType)

    def __repr__(self):
        return '<TemplateType %r>' % self.name

    def __unicode__(self):
        return self.name
Esempio n. 9
0
class Tag(db.Model):
    """Теги"""
    __bind_key__ = 'caesar'
    __tablename__ = '%s_tag' % TABLE_PREFIX

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    code = db.Column(db.String(80), unique=True, nullable=False)
    name = db.Column(db.Unicode(80))
    is_leaf = db.Column(db.Boolean, default=False)

    # many to many TemplateType<->Tag
    template_types = db.relationship(TemplateType,
                                     secondary='%s_tag_template_type' %
                                     TABLE_PREFIX,
                                     backref='tags')

    def __repr__(self):
        return '<Tag %r>' % self.code

    def __unicode__(self):
        return self.code
Esempio n. 10
0
class ScheduleClientTicket(db.Model):
    __tablename__ = 'ScheduleClientTicket'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    client_id = db.Column(db.Integer,
                          db.ForeignKey('Client.id'),
                          nullable=False)
    ticket_id = db.Column(db.Integer,
                          db.ForeignKey('ScheduleTicket.id'),
                          nullable=False)
    isUrgent = db.Column(db.Boolean)
    note = db.Column(db.Unicode(256))
    appointmentType_id = db.Column(db.Integer,
                                   db.ForeignKey('rbAppointmentType.id'))
    createDatetime = db.Column(db.DateTime, nullable=False)
    createPerson_id = db.Column(db.Integer,
                                db.ForeignKey('Person.id'),
                                index=True)
    modifyDatetime = db.Column(db.DateTime, nullable=False)
    modifyPerson_id = db.Column(db.Integer,
                                db.ForeignKey('Person.id'),
                                index=True)
    deleted = db.Column(db.SmallInteger, nullable=False, server_default='0')
    event_id = db.Column(db.ForeignKey('Event.id'))

    client = db.relationship('Client', lazy='joined', uselist=False)
    appointmentType = db.relationship('rbAppointmentType',
                                      lazy=False,
                                      innerjoin=True)
    createPerson = db.relationship('Person', foreign_keys=[createPerson_id])
    event = db.relationship('Event')

    ticket = db.relationship(
        'ScheduleTicket',
        lazy="joined",
        innerjoin=True,
        uselist=False,
        primaryjoin='and_('
        'ScheduleClientTicket.deleted == 0, '
        'ScheduleTicket.deleted == 0, '
        'ScheduleClientTicket.ticket_id == ScheduleTicket.id)')

    @property
    def org_from(self):
        if not self.infisFrom:
            return
        from models_all import Organisation
        org = Organisation.query.filter(
            Organisation.infisCode == self.infisFrom).first()
        if not org:
            return self.infisFrom
        return org.title

    @property
    def date(self):
        return self.ticket.schedule.date

    @property
    def time(self):
        attendance_type_code = self.ticket.attendanceType.code
        if attendance_type_code == 'planned':
            time = self.ticket.begDateTime.time()
        elif attendance_type_code == 'CITO':
            time = "CITO"
        elif attendance_type_code == 'extra':
            time = u"сверх очереди"
        else:
            time = '--:--'

        return time

    @property
    def typeText(self):
        toHome = self.ticket.schedule.receptionType.code == 'home'
        if toHome:
            typeText = u'Вызов на дом'
        else:
            typeText = u'Направление на приём к врачу'
        return typeText