作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用的是 django v1.8。
我扩展了现有的用户模型。
models.py
class Institution(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
department = models.CharField(max_length=100)
class Demographic(models.Model):
patient_id = models.IntegerField(unique= True ,primary_key=True)
pub_date = models.DateTimeField(auto_now=True)
author = models.ForeignKey(User)
history = HistoricalRecords()
def __str__(self):
return str(self.patient_id)
我有两个属于同一部门的用户doctor
和nurse
,我希望他们都能够访问相同的患者。
在模板中,我使用搜索引擎来搜索患者。
在views.py
中我有这个过滤器:
patient = Demographic.objects.filter(patient_id__icontains=id)
但这 2 个用户只能在各自部门的患者之间进行搜索。
如何在过滤器中实现此目的?我应该包含什么参数?
最佳答案
A user belongs to a department when he inserts a patient as author then this patient belongs to that department.
因此,让我们首先获取给定用户
的部门
:
user = request.user # the doctor, the nurse etc
department = Institution.objects.get(user=user).department
现在您想要所有患者(人口统计
实例),其中author.institution.department = 部门
patients = Demographic.objects.filter(author__institution__department=department)
关于python - Django:如何过滤某个科室的患者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37679702/
我正在使用 HAPI FHIR 服务器,并且对 java 客户端有些陌生。我希望完成的是创建 FHIR 患者 bundle ,其中包含一个完整的 bundle 中的单个识别患者资源和所有其他资源,并将
嗨,我不断收到此错误,但不知道为什么 java.lang.ClassCastException: com.sun.proxy.$Proxy0 cannot be cast to interfaces.
我是一名优秀的程序员,十分优秀!