示例#1
0
class Results(SurrogatePK, Model):
    """Test results"""

    __tablename__ = "results"
    user_id = reference_col("users", nullable=True)
    user = relationship("User", backref="results")
    start_time = Column(db.DateTime,
                        nullable=False,
                        default=roundSeconds(dt.datetime.now()))
    updated_time = Column(db.DateTime, nullable=False, default=None)
    result_id = Column(db.String(200), nullable=True, default=None)
    result = Column(db.Boolean, nullable=True, default=None)
    result_text = Column(db.String(500),
                         nullable=True,
                         default="Sample pending")
    reported = Column(db.Boolean, default=False, nullable=True)
    tube_id = Column(db.String(10), default=None, nullable=True)
    survey = Column(db.Boolean, default=False, nullable=True)

    def __init__(self, user_id, result_id, **kwargs):
        """Create instance."""
        db.Model.__init__(self, user_id=user_id, result_id=result_id, **kwargs)

    def __repr__(self):
        """Represent instance as a unique string."""
        return f"<Result({self.result_id})>"
示例#2
0
class Role(SurrogatePK, Model):
    """A role for a user."""

    __tablename__ = "roles"
    name = Column(db.String(80), unique=False, nullable=False)
    user_id = reference_col("users", nullable=True)
    user = relationship("User", backref="roles")

    def __init__(self, name, **kwargs):
        """Create instance."""
        db.Model.__init__(self, name=name, **kwargs)

    def __repr__(self):
        """Represent instance as a unique string."""
        return f"<Role({self.name})>"
示例#3
0
class AuditLog(SurrogatePK, Model):
    """Audit log for samples"""

    __tablename__ = "log"
    user_id = reference_col("users", nullable=True)
    user = relationship("User", backref="user_log")
    result_id = reference_col("results", nullable=True)
    result = relationship("Results", backref="rid_log")
    ts = Column(db.DateTime,
                nullable=False,
                default=roundSeconds(dt.datetime.utcnow()))
    status = Column(db.String(100), nullable=False)

    def __init__(self, user_id, result_id, status, **kwargs):
        """Create instance."""
        db.Model.__init__(self,
                          user_id=user_id,
                          result_id=result_id,
                          status=status,
                          **kwargs)

    def __repr__(self):
        """Represent instance as a unique string."""
        return f"<entry({self.id!r})>"
示例#4
0
class Consent(SurrogatePK, Model):
    """Consent data"""

    __tablename__ = "consent"
    user_id = reference_col("users", nullable=True)
    user = relationship("User", backref="consent")
    consented = Column(db.Boolean, nullable=True, default=None)
    consent_id = Column(db.String(200),
                        nullable=True,
                        default="No consent id available")

    def __init__(self, name, **kwargs):
        """Create instance."""
        db.Model.__init__(self, user_id=user_id, **kwargs)

    def __repr__(self):
        """Represent instance as a unique string."""
        return f"<ConsentID({self.consent_id})>"
示例#5
0
class UserInfo(SurrogatePK, Model):
    """Required demo and personal info for federal and state reporting"""

    __tablename__ = "user_info"
    user_id = reference_col("users", nullable=False)
    user = relationship("User", backref="log")
    age = Column(db.Integer)
    sex = Column(db.String(10))
    race = Column(db.String(50))
    ethnicity = Column(db.String(50))
    zipcode = Column(db.String(5), default="30332")
    county = Column(db.String(40), default="Fulton")
    address = Column(db.String(40))
    dob = Column(db.Date)

    def __init__(self, user_id, **kwargs):
        """Create instance."""
        db.Model.__init__(self, user_id=user_id, **kwargs)

    def __repr__(self):
        """Represent instance as a unique string."""
        return f"<UI({self.id!r},{self.user_id!r})>"