You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
838 B
24 lines
838 B
from tortoise import fields, models
|
|
from tortoise.expressions import Q
|
|
|
|
class Taboo(models.Model):
|
|
name = fields.CharField(max_length = 50, description = '药剂种类')
|
|
mutex = fields.CharField(max_length = 50, description = '禁忌种类')
|
|
reason = fields.CharField(max_length = 255, description = '禁忌描述')
|
|
|
|
class Meta:
|
|
table = 'taboos'
|
|
table_description = '禁忌表'
|
|
|
|
@classmethod
|
|
async def conflict(cls, mine, othn):
|
|
'''是否存在存储禁忌'''
|
|
mtags = mine.split(',')
|
|
otags = othn.split(',')
|
|
for mtag in mtags:
|
|
for otag in otags:
|
|
taboo = await Taboo.get_or_none(Q(name=mtag, mutex=otag) | Q(name=otag, mutex=mtag))
|
|
if taboo:
|
|
return True, taboo.reason
|
|
return False, None
|