-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
78 lines (66 loc) · 3.56 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#coding=utf-8
from flask.ext.sqlalchemy import SQLAlchemy
from views import app
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:levis822@localhost:3306/duobiao'
db = SQLAlchemy(app)
class drug(db.Model):
DRUGid = db.Column(db.String(36), nullable=False, primary_key=True)
code = db.Column(db.String(20), nullable=False)
name = db.Column(db.String(50), nullable=False)
unit = db.Column(db.String(10), nullable=False)
alias = db.Column(db.String(100), nullable=False, default=' ')
py = db.Column(db.String(20), nullable=False, default=' ')
wb = db.Column(db.String(20), nullable=False, default=' ')
isClassical = db.Column(db.Boolean, nullable=False, default=1) #comment '1:是标准的;0:非标准的'
SPETid = db.Column(db.String(36), nullable=False, default=' ')
illustration = db.Column(db.Text, nullable=False, default=' ')
createDay = db.Column(db.DateTime, nullable=False, default='1900-1-1')
optrid = db.Column(db.String(36), nullable=False, default=' ')
state = db.Column(db.Boolean, nullable=False, default=0) #comment '0:正常;1:锁定'
@classmethod
def get_all(self, data):
tempList = []
for (i, temp) in enumerate(data['objects']):
tempList.append({})
tempList[i]['code'] = temp['code']
tempList[i]["state"] = temp['state']
data['objects'] = tempList
return data
class fixedrecipe(db.Model):
FREPid = db.Column(db.String(36), nullable=False, primary_key=True)
code = db.Column(db.String(20), nullable=False)
name = db.Column(db.String(50), nullable=False)
effect = db.Column(db.String(200), nullable=False, default=' ')
py = db.Column(db.String(20), nullable=False, default=' ')
wb = db.Column(db.String(20), nullable=False, default=' ')
isClassical = db.Column(db.Boolean, nullable=False, default=1) #comment '1:是标准的;0:非标准的'
SPETid = db.Column(db.String(36), nullable=False, default=' ')
illustration = db.Column(db.Text, nullable=False, default=' ')
createDay = db.Column(db.DateTime, nullable=False, default='1900-1-1')
optrid = db.Column(db.String(36), nullable=False, default=' ')
state = db.Column(db.Boolean, nullable=False, default=0) #comment '0:正常;1:锁定'
@classmethod
def get_all(self, data):
tempList = []
for (i, temp) in enumerate(data['object']):
tempList.append({})
tempList[i]["code"] = temp.code
tempList[i]["name"] = temp.name
tempList[i]["effect"] = temp.effect
tempList[i]["py"] = temp.py
tempList[i]["wb"] = temp.wb
tempList[i]["isClassical"] = temp.isClassical
tempList[i]["SPETid"] = temp.SPETid
tempList[i]["state"] = temp.state
data['object'] = tempList
return data
class fixedrecipeItem(db.Model):
FRITid = db.Column(db.String(36), nullable=False, primary_key=True)
DRUGid = db.Column(db.String(36),db.ForeignKey('drug.DRUGid'))
FREPid = db.Column(db.String(36),db.ForeignKey('fixedrecipe.FREPid'))
quality = db.Column(db.DECIMAL(18,4), nullable=False, default=0)
sequence = db.Column(db.INTEGER, nullable=False, default=0)
illustration = db.Column(db.Text, nullable=False, default=' ')
drug = db.relationship('drug', backref=db.backref('fixedrecipeItems', cascade='all, delete-orphan'))
fixedrecipe = db.relationship('fixedrecipe', backref=db.backref('fixedrecipeItems', cascade='all, delete-orphan'))
#primary key (FRITid)