基于Django的web的病历管理系统模型类
时间: 2024-06-11 22:11:06 浏览: 12
以下是一个基于Django的病历管理系统模型类示例:
```python
from django.db import models
class Patient(models.Model):
name = models.CharField(max_length=100)
age = models.PositiveIntegerField()
gender = models.CharField(max_length=10)
address = models.CharField(max_length=200)
phone_number = models.CharField(max_length=20)
def __str__(self):
return self.name
class MedicalRecord(models.Model):
patient = models.ForeignKey(Patient, on_delete=models.CASCADE)
date = models.DateTimeField(auto_now_add=True)
diagnosis = models.CharField(max_length=200)
symptoms = models.CharField(max_length=200)
treatment = models.CharField(max_length=200)
def __str__(self):
return f"{self.patient} - {self.date}"
```
这个模型类包含两个模型:`Patient`和`MedicalRecord`。`Patient`模型用于存储患者的个人信息,包括姓名、年龄、性别、地址和电话号码。`MedicalRecord`模型用于存储患者的病历记录,包括就诊日期、诊断、症状和治疗方案。`MedicalRecord`模型与`Patient`模型之间建立了外键关系,即每个病历记录都对应一个患者。
在这个模型类中,`__str__`方法被定义为返回模型实例的字符串表示形式,以便在后台管理界面中更好地显示实例。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![tar](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)