blob: ae6beb369cf43fa42e3bae8a6e055f6390c81829 (
plain)
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
|
# -*- coding: utf-8 -*-
import json
from django.db import models
from django.contrib.auth.models import AnonymousUser
class AnnotationManager(models.Manager):
use_for_related_fields = True
def paracomments(self):
u'''
获取段落注释
'''
return self.filter(type = 0)
def propernouns(self):
u'''
获取专有名词
'''
return self.filter(type = 1)
def all_json(self, user = AnonymousUser()):
u'''
通过json格式获取专有名词和段落注释
'''
result = {p.id:{'id':p.id,
'name':p.firstkeyword() if p.type == 1 else p.brief_content,
'type':p.type,
'content':p.detail,
'collected_times':p.collected_by.count(),
'is_collected': p.is_collected_by(user)}
for p in self.all()}
return json.dumps(result)
class KnowledgePieceManager(models.Manager):
use_for_related_fields = True
def knowledges(self):
u'''
获取科普知识类型的条目
'''
return self.filter(type = 0)
def comments(self):
u'''
获取科学评论类型的条目
'''
return self.filter(type = 1)
class EndPointManager(models.Manager):
use_for_related_fields = True
def primary(self):
u'''
获取主要治疗终点
'''
return self.filter(type = 1)
def secondary(self):
u'''
获取次要治疗终点
'''
return self.filter(type = 2)
class ClinicConditionManager(models.Manager):
use_for_related_fields = True
def inclusive(self):
u'''
获取允许类型的临床条件
'''
return self.filter(type = 0)
def exclusive(self):
u'''
获取排除类型的临床条件
'''
return self.filter(type = 1)
|