class ethernet_packet(db.Model): __tablename__ = 'ethernet_packet' packet_id = db.Column(BIGINT(20), primary_key=True) dst_mac_add = db.Column(db.BINARY(6)) src_mac_add = db.Column(db.BINARY(6)) ether_type = db.Column(SMALLINT(5)) def __repr__(self): return '<packet_id: {0}, dst_mac_add: {1}, src_mac_add: {2}, ether_type: {3} >'.format( self.packet_id, self.dst_mac_add, self.src_mac_add, self.ether_type)
class udp_ip_packet(db.Model): __tablename__ = 'udp_ip_packet' packet_id = db.Column(BIGINT(20), primary_key=True) ip_header = db.Column(db.BINARY(60)) src_ip = db.Column(db.BINARY(4)) dst_ip = db.Column(db.BINARY(4)) src_port = db.Column(SMALLINT(5)) dst_port = db.Column(SMALLINT(5)) payload_data = db.Column(MEDIUMBLOB) def __repr__(self): return '<packet_id: {0}, ip_header: {1}, src_ip: {2}, dst_ip: {3}, src_port: {4}, dst_port: {5}, payload_data: {6} >'.format( self.packet_id, self.ip_header, self.src_ip, self.dst_ip, self.src_port, self.dst_port, self.payload_data)
class User(db.Model): """ Defines attributes for a user """ __tablename__ = 'Users' id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(20), unique=True, index=True) password_hash = db.Column(db.BINARY(60)) date_created = db.Column(db.DATETIME, default=db.func.current_timestamp()) token = db.Column(db.String) def __init__(self, username, password): self.username = username self.password_hash = generate_password_hash(password) self.token = self.generate_auth_token() def verify_password_hash(self, password): return check_password_hash(self.password_hash, password) def generate_auth_token(self): return token_signer.sign(str(self.username)) def save(self): db.session.add(self) db.session.commit() def refresh_from_db(self): return db.session.query(User).filter_by(id=str(self.id))
class Referral(db.Model): id = db.Column(db.Integer, primary_key=True) firstname = db.Column(db.String(50), nullable=True) lastname = db.Column(db.String(50), nullable=True) phone = db.Column(db.String(50), nullable=True) email = db.Column(db.String(255), nullable=True) dob = db.Column(db.DateTime, nullable=True, default=datetime.utcnow) poa = db.Column(db.String(120), nullable=True) poa_phone = db.Column(db.String(120), nullable=True) poa_address1 = db.Column(db.String(120), nullable=True) city = db.Column(db.String(50), nullable=True) state = db.Column(db.String(2), nullable=True) zip_code = db.Column(db.String(10), nullable=True) medicare = db.Column(db.BINARY(255), nullable=True) secondary = db.Column(db.BINARY(255), nullable=True) discharge_date = db.Column(db.DateTime, nullable=True, default=datetime.utcnow) notes = db.Column(db.String(255), nullable=True) disc_slp = db.Column(db.Boolean, nullable=True, default=False) disc_ot = db.Column(db.Boolean, nullable=True, default=False) disc_pt = db.Column(db.Boolean, nullable=True, default=False) treat_oral = db.Column(db.Boolean, nullable=True, default=False) treat_speech = db.Column(db.Boolean, nullable=True, default=False) treat_cognitive = db.Column(db.Boolean, nullable=True, default=False) treat_caregiver = db.Column(db.Boolean, nullable=True, default=False) treat_dementia = db.Column(db.Boolean, nullable=True, default=False) treat_adl = db.Column(db.Boolean, nullable=True, default=False) treat_safety = db.Column(db.Boolean, nullable=True, default=False) treat_upper_extremity = db.Column(db.Boolean, nullable=True, default=False) treat_ther_exercise = db.Column(db.Boolean, nullable=True, default=False) treat_balance = db.Column(db.Boolean, nullable=True, default=False) treat_ther_activity = db.Column(db.Boolean, nullable=True, default=False) treat_coordination = db.Column(db.Boolean, nullable=True, default=False) treat_transfer = db.Column(db.Boolean, nullable=True, default=False) treat_range = db.Column(db.Boolean, nullable=True, default=False) treat_massage = db.Column(db.Boolean, nullable=True, default=False) treat_pain = db.Column(db.Boolean, nullable=True, default=False) treat_wheelchair = db.Column(db.Boolean, nullable=True, default=False) treat_lower_extremity = db.Column(db.Boolean, nullable=True, default=False) treat_cane = db.Column(db.Boolean, nullable=True, default=False) treat_postural = db.Column(db.Boolean, nullable=True, default=False) treat_gait = db.Column(db.Boolean, nullable=True, default=False) treat_other = db.Column(db.Boolean, nullable=True, default=False) treat_other_desc = db.Column(db.String(120), nullable=True) med_type = db.Column(db.String(50), nullable=True) med_firstname = db.Column(db.String(50), nullable=True) med_lastname = db.Column(db.String(50), nullable=True) med_npi = db.Column(db.String(10), nullable=True) med_address1 = db.Column(db.String(120), nullable=True) med_address2 =db.Column(db.String(120), nullable=True) med_city = db.Column(db.String(50), nullable=True) med_state = db.Column(db.String(2), nullable=True) med_zip_code = db.Column(db.String(10), nullable=True) med_email = db.Column(db.String(120), nullable=True) med_phone = db.Column(db.String(50), nullable=True) med_fax = db.Column(db.String(50), nullable=True) referral_status = db.Column(db.String(50), nullable=True, autoincrement=True, default='new') referral_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) source_id = db.Column(db.Integer, db.ForeignKey('source.id')) users = db.relationship('User', backref='user_ref', lazy=True) source = db.relationship('Source', backref='loc_ref', lazy=True) # Encrypt def encrypt_data(field): e = field.encode() f = Fernet(app.config['ENCRYPT_KEY']) encrypted = f.encrypt(e) return encrypted # Decrypt def decrypt_data(field): d = field f = Fernet(app.config['ENCRYPT_KEY']) decrypted = f.decrypt(d).decode('utf-8') return decrypted def __repr__(self): return f"Referral('{self.firstname}', '{self.lastname}', '{self.discharge_date}')"