Exemple #1
0
class Session(ActiveRecord):
    """
    Session Table
    """
    __tablename__ = "sessions"
    __amf_class__ = "vrs.shared.Session"

    id = Column(Integer, primary_key=True)
    zone_guid = Column(String, ForeignKey('zones.guid'), nullable=False)
    station_guid = Column(String, ForeignKey('stations.guid'), nullable=False)
    activity_guid = Column(String,
                           ForeignKey('activities.guid'),
                           nullable=False)
    patient_guid = Column(String, ForeignKey('patients.guid'), nullable=False)
    guid = Column(String, unique=True, nullable=False, index=True)

    modified = Column(DateTime,
                      default=datetime.datetime.utcnow,
                      onupdate=datetime.datetime.utcnow,
                      nullable=False)
    revision = Column(Integer, default=0, nullable=False)

    version_activity = Column(String, nullable=False)
    version_system = Column(String, nullable=False)
    version_haptics = Column(String, nullable=False)

    timestamp = Column(DateTime,
                       default=datetime.datetime.utcnow,
                       nullable=False)
    duration = Column(Integer, nullable=False)
    score = deferred(Column(PropertyDict(typemap=SCORE_PROPERTY_TYPEMAP)))

    is_processed = Column(Boolean, default=False, nullable=False, index=True)
    is_valid = Column(Boolean, default=False, nullable=False, index=True)

    zone = has_one(Zone)
    station = has_one(Station)
    activity = has_one(Activity)
    patient = has_one(Patient)

    year = computed_field(int)
    week = computed_field(int)
    weekday = computed_field(int)

    @orm.reconstructor
    def _onload(self):
        (self.year, self.week, self.weekday) = self.timestamp.isocalendar()

    @classmethod
    def __serialize__(cls):
        return [
            Session.id, Session.guid, Session.timestamp, Session.duration,
            Session.score, Session.year, Session.week, Session.weekday,
            Session.zone, Session.activity, Session.patient
        ]
Exemple #2
0
class SyncMetaData(ActiveRecord):
    __tablename__ = "syncmetadata"

    id           = Column(Integer, primary_key=True)

    zone_guid    = Column(String, ForeignKey('zones.guid'), nullable=False)
    station_guid = Column(String, ForeignKey('stations.guid'), nullable=False)

    last_ping    = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)

    curr_sync    = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
    last_sync    = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
    need_sync    = Column(Boolean, default=False, nullable=False)

    zone         = has_one(Zone)
    station      = has_one(Station)
Exemple #3
0
class Station(ActiveRecord):
    """
    Station Table
    """
    __tablename__ = "stations"
    __amf_class__ = "vrs.shared.Station"

    id = Column(Integer, primary_key=True)
    zone_guid = Column(String, ForeignKey('zones.guid'), nullable=False)
    guid = Column(String, unique=True, nullable=False, index=True)

    modified = Column(DateTime,
                      default=datetime.datetime.utcnow,
                      onupdate=datetime.datetime.utcnow,
                      nullable=False)
    revision = Column(Integer, default=0, nullable=False)

    alias = Column(String, unique=True, nullable=False)
    ip = Column(String, nullable=False)
    version = Column(String, nullable=False)

    zone = has_one(Zone)

    @classmethod
    def __serialize__(cls):
        return [
            Station.id, Station.guid, Station.alias, Station.ip,
            Station.version
        ]
Exemple #4
0
class Customer(ActiveRecord):
    __tablename__ = "customers"

    guid = Column(String,
                  primary_key=True,
                  unique=True,
                  nullable=False,
                  index=True,
                  default=makeguid)
    contact_guid = Column(String, ForeignKey('contacts.guid'), nullable=False)

    name = Column(UnicodeText, nullable=False)
    kind = Column(String,
                  CheckConstraint("kind in ('live', 'beta', 'stage')"),
                  nullable=False)
    contact = has_one(Contact)
    users = has_many("User")
Exemple #5
0
class Comment(ActiveRecord):
    __tablename__ = "comments"

    id = Column(Integer, primary_key=True)
    guid = Column(String,
                  unique=True,
                  nullable=False,
                  index=True,
                  default=makeguid)
    created = Column(DateTime,
                     default=datetime.datetime.utcnow,
                     nullable=False)
    modified = Column(DateTime,
                      default=datetime.datetime.utcnow,
                      onupdate=datetime.datetime.utcnow,
                      nullable=False)
    text = Column(UnicodeCompressedText, nullable=False, default=u"")
    user_guid = Column(String, ForeignKey('users.guid'), nullable=False)
    user = has_one(User)
Exemple #6
0
class User(ActiveRecord):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True)
    guid = Column(String,
                  unique=True,
                  nullable=False,
                  index=True,
                  default=makeguid)
    customer_guid = Column(String,
                           ForeignKey('customers.guid'),
                           nullable=False)

    email = Column(String(32), unique=True, nullable=False, index=True)
    kind = Column(Bitfield(UserKind),
                  nullable=False,
                  default=UserKind.Customer)
    customer = has_one(Customer)
    issues = has_many("Issue", secondary=bind_users)
Exemple #7
0
class Patient(ActiveRecord):
    """
    Patient Table
    """
    __tablename__ = "patients"
    __amf_class__ = "vrs.shared.Patient"

    id = Column(Integer, primary_key=True)
    zone_guid = Column(String, ForeignKey('zones.guid'), nullable=False)
    guid = Column(String, unique=True, nullable=False, index=True)

    active = Column(Boolean, default=True, nullable=False)
    modified = Column(DateTime,
                      default=datetime.datetime.utcnow,
                      onupdate=datetime.datetime.utcnow,
                      nullable=False)
    revision = Column(Integer, default=0, nullable=False)

    alias = Column(String, nullable=False, index=True)
    pincode = Column(String, nullable=False, index=True)

    medical_record = deferred(
        Column(PropertyDict(typemap=MEDICAL_RECORD_PROPERTY_TYPEMAP)))
    settings_game = deferred(
        Column(PropertyDict(typemap=SETTINGS_GAME_PROPERTY_TYPEMAP)))
    settings_system = deferred(Column(PropertyDict))

    zone = has_one(Zone)
    sessions = has_many("Session",
                        primaryjoin="Patient.guid==Session.patient_guid")

    @classmethod
    def __serialize__(cls):
        return [
            Patient.id, Patient.guid, Patient.alias, Patient.pincode,
            Patient.active, Patient.medical_record
        ]