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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
# -*- coding: utf-8 -*-
from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from utils import get_abstract
from .managers import *
# Create your models here.
# SciBlog {{{
class SciBlog(models.Model):
title = models.CharField(u"标题", max_length=400)
subhead = models.CharField(u"副标题", max_length=400, blank=True)
entitle = models.CharField(u"英文标题", max_length=400, blank=True)
journal = models.CharField(u"期刊", max_length=400, blank= True)
publish_date = models.DateField(u"出版日期", blank=True, null=True)
readed_count = models.PositiveIntegerField(u"被阅读次数", default=0)
understanded_count = models.PositiveIntegerField(u"懂按钮被按次数", default=0)
confused_count = models.PositiveIntegerField(u"不懂按钮被按次数", default=0)
ifvalue = models.FloatField(u"影响因子", default=1.0)
authors = models.CharField(u"作者", max_length=1000, default="default authors")
method = models.TextField(u"治疗手段", blank=True)
aim = models.TextField(u"目标", blank=True)
abstract_result = models.TextField(u"结果简述", blank=True)
abstractAE = models.TextField(u"abstractAE", blank=True)
treatment_content = models.TextField(u"treatmentContent", blank=True)
safety = models.TextField(u"安全性", blank=True)
hospital = models.ManyToManyField("location.Hospital", verbose_name=u"作者医院", related_name="sciblogs", null=True, blank=True)
guidline = models.OneToOneField("Guideline", verbose_name=u"临床策略", related_name="blog", null=True, blank=True)
baseline = models.ManyToManyField("BaseLine", verbose_name=u"研究基线", related_name="blog", null=True, blank=True)
endpoint_content = models.TextField(u"治疗终点文本", blank=True)
endpoints = models.ManyToManyField("EndPoint", verbose_name=u"治疗终点", related_name="blogs", null=True, blank=True)
clinic_conditions = models.ManyToManyField("ClinicCondition", verbose_name=u"临床条件", related_name="blogs", null=True, blank=True)
detectionAssay = models.TextField(u"检测方法", blank=True)
collected_by = models.ManyToManyField(User, verbose_name=u"收藏者", related_name="blog_collection", null=True, blank=True)
catched_by = models.ManyToManyField(User, verbose_name=u"懂了的", related_name="blogs_catched", null=True, blank=True)
# 从原BlogBlock拷贝过来的fields
conclusion = models.TextField(u"本文结论", blank=True)
konwledge_piece = models.ManyToManyField("KnowledgePiece", verbose_name=u"知识条目", related_name="blogs", null=True, blank=True)
sample = models.ManyToManyField("subjects.Sample", verbose_name=u"人群", related_name="blogs", null=True, blank=True)
source = models.OneToOneField("Source", verbose_name=u"出处", related_name="blog", null=True, blank=True)
references = models.ManyToManyField("Reference", verbose_name=u"参考信息", related_name="blogs", null=True, blank=True)
query = models.ManyToManyField("info.Query", verbose_name=u"问题", related_name="blogs", null=True, blank=True)
class Meta:
verbose_name_plural = u"文章"
def __unicode__(self):
return "< SciBlog: %s >" % self.title
def show(self):
"""
used in 'search/search.html'
to show search result
"""
return self.__unicode__()
def level(self):
u'''
计算文章难度等级
'''
return 1 #TODO:添加实现代码
def quality_value(self):
u'''
计算文章质量
'''
return 1.0 #TODO:添加实现代码
def communication_author(self):
u'''
找出通讯作者放在blog list
'''
return self.authors.split(',')[0]
# }}}
# ResultContent {{{
class ResultContent(models.Model):
u'''
实验结果内容
'''
type_choices = ((1, "total"),
(2, "now"),
(3, "future"))
type = models.IntegerField(u"类型", choices=type_choices, null=True, blank=True)
shorttitle = models.CharField(u"简标题", max_length=36, blank=True)
abstract = models.CharField(u"摘要", max_length=100, blank=True)
content = models.TextField(u"内容", blank = True)
card_content = models.TextField(u"卡片内容", blank=True)
sample = models.ManyToManyField("subjects.Sample", verbose_name=u"人群", related_name="results", null=True, blank=True)
blog = models.ForeignKey("SciBlog", verbose_name=u"文章", related_name="results", null=True, blank=True)
indicators = models.ManyToManyField("indicator.Indicator", null=True, blank=True)
class Meta:
verbose_name_plural = u"实验结果"
def __unicode__(self):
return "<ResultContent: %s>" % get_abstract(self.content)
def color(self):
u'''
根据type返回卡片颜色
'''
return ['grey', 'green', 'blue'][self.type - 1]
# }}}
# Source {{{
class Source(models.Model):
u'''
这篇文章原论文的来源
'''
ensrc = models.CharField(u"英文出处", max_length=400, blank= True)
chsrc = models.CharField(u"中文出处", max_length=400, blank= True)
link = models.URLField(verify_exists=False, max_length=400, blank=True, verbose_name = u"外网链接")
class Meta:
verbose_name_plural = u"出处"
def __unicode__(self):
return "< Source: %s >" % self.id
# }}}
# Reference {{{
class Reference(models.Model):
u'''
参考消息:这篇文章其他相关论文等信息的来源
'''
description = models.TextField(u"描述", blank=True)
link = models.URLField(verify_exists=False, max_length=400, blank=True, verbose_name = u"链接")
class Meta:
verbose_name_plural = u"参考信息"
def __unicode__(self):
return "< Reference: %s >" % self.description
# }}}
# KnowledgePiece {{{
class KnowledgePiece(models.Model):
u'''
知识条目:知识条目很可能是问题的答案。
'''
type_choices = ((0, u"科普知识"),
(1, u"科学评论"),
)
title = models.CharField(u"标题", max_length=100, blank= True)
content = models.TextField(u"条目内容", blank=True)
type = models.IntegerField(u"种类", choices=type_choices)
objects = KnowledgePieceManager()
class Meta:
verbose_name_plural = u"知识条目"
def __unicode__(self):
return "< KnowledgePiece: %s %s >" % (self.id, self.content if len(self.content) < 20 else self.content[0:20])
# }}}
# BlogAnnotation {{{
class BlogAnnotation(models.Model):
u'''
文章注释
'''
type_choices = ((0, u"段落注释"),
(1, u"专有名词"),)
type = models.IntegerField(u"注释类型", choices=type_choices)
no = models.IntegerField(u"编号", blank=True, null=True)
brief_content = models.CharField(u"简短内容", max_length=400, blank= True)
detail = models.TextField(u"详细内容", blank=True)
blogs = models.ManyToManyField("SciBlog", verbose_name=u"文章", related_name="annotations", null=True, blank=True)
keywords = models.ManyToManyField("info.KeyWord", verbose_name=u"关键词", related_name="annotations", null=True, blank=True)
figures = models.ManyToManyField("figure.Figure", verbose_name=u"图片", related_name="annotations", null=True, blank=True)
collected_by = models.ManyToManyField(User, verbose_name=u"收藏者", related_name="annotation_collection", null=True, blank=True)
objects = AnnotationManager()
class Meta:
verbose_name_plural = u"文章注释"
def __unicode__(self):
return "<BlogAnnotation: %s>" % get_abstract(self.brief_content)
def show(self):
"""
used in 'search/search.html'
to show search result
"""
return self.__unicode__()
def firstkeyword(self):
u'''
第一个关键词,注意对于专有名词,通常只有一个
'''
return self.keywords.all()[0].content
def firstparagraph(self):
u'''
bloglist页面二上内容的阶段,django里面的注释第一段的末尾都是一个空格
'''
return self.detail.split(' ')[0]
def is_collected_by(self, user):
u'''
该注释是否已经被user收藏
'''
if user.is_authenticated() and user.annotation_collection.filter(id=self.id):
return True
return False
# }}}
# Guideline {{{
class Guideline(models.Model):
u'''
临床策略
'''
content = models.TextField(u"内容", blank=True)
figures = models.ManyToManyField("figure.Figure", verbose_name=u"图片", related_name="guidlines", null=True, blank=True)
class Meta:
verbose_name_plural = u"临床策略"
def __unicode__(self):
return "<Guideline: %s>" % get_abstract(self.content)
# }}}
# EndPoint {{{
class EndPoint(models.Model):
u'''
治疗终点
'''
type_choices = ((1, "primary"),
(2, "secondary"),)
content = models.TextField(u"内容", blank=True)
type = models.IntegerField(u"类型", choices=type_choices, blank=True)
indicator = models.ForeignKey("indicator.Indicator", verbose_name=u"医学指标", related_name="endpoints", null=True, blank=True)
objects = EndPointManager()
class Meta:
verbose_name_plural = u"治疗终点"
def __unicode__(self):
return "<EndPoint: %s>" % get_abstract(self.content)
# }}}
# ClinicCondition {{{
class ClinicCondition(models.Model):
u'''
临床条件
'''
type_choices = ((0, "允许"),
(1, "排除"),)
content = models.TextField(u"内容", blank=True)
type = models.IntegerField(u"类型", choices=type_choices, blank=True)
indicator = models.ForeignKey("indicator.Indicator", verbose_name=u"医学指标", related_name="clinic_conditions", null=True, blank=True)
objects = ClinicConditionManager()
class Meta:
verbose_name_plural = u"临床条件"
def __unicode__(self):
return "<ClinicCondition: %s>" % get_abstract(self.content)
# }}}
# BaseLine {{{
class BaseLine(models.Model):
u'''
基线水平
'''
content = models.TextField(u"内容", blank=True)
figures = models.ManyToManyField("figure.Figure", verbose_name=u"图片", related_name="baselines", null=True, blank=True)
base_line_items = models.ManyToManyField("subjects.BaseLineItem", verbose_name=u"研究基线项目", related_name="baselines", null=True, blank=True)
class Meta:
verbose_name_plural = u"基线水平"
def __unicode__(self):
return "<BaseLine: %s>" % get_abstract(self.content)
# }}}
import signals
admin.site.register([
Source,
Reference,
KnowledgePiece,
Guideline,
ClinicCondition,
BaseLine,
ResultContent,
BlogAnnotation,
])
|