from django.db import models # 患者表 class Patient(models.Model): phone = models.CharField(u'患者号码', max_length=11) password = models.CharField(u'患者密码', max_length=32) name = models.CharField(u'患者姓名', max_length=32) sex = models.CharField(u'患者性别', max_length=10) age = models.CharField(u'患者年龄', max_length=3) class Meta: verbose_name = u'患者' verbose_name_plural = u'患者列表' def __str__(self): return self.name class Department(models.Model): name = models.CharField(u'科室名称', max_length=32) address = models.CharField(u'科室地址', max_length=32) class Meta: verbose_name = u'科室' verbose_name_plural = u'科室列表' def __str__(self): return self.name class Doctor(models.Model): phone = models.CharField(u'医生号码', max_length=11) password = models.CharField(u'医生密码', max_length=32) name = models.CharField(u'医生姓名', max_length=32) sex = models.CharField(u'医生性别', max_length=1) age = models.CharField(u'医生年龄', max_length=3) img = models.ImageField(u'医生照片', upload_to='doctor/') level = models.CharField(u'职位等级', max_length=32) description = models.CharField(u'详情描述', max_length=256) registration_price = models.IntegerField(u'挂号价格') department = models.ForeignKey(Department, verbose_name=u'科室', on_delete=models.CASCADE) def getDepartment(self): return Department.objects.get(id=self.department) class Meta: verbose_name = u'医生' verbose_name_plural = u'医生列表' def __str__(self): return self.name class TimeNumber(models.Model): eight = models.IntegerField(u'八点可预约人数') nine = models.IntegerField(u'九点可预约人数') ten = models.IntegerField(u'十点可预约人数') eleven = models.IntegerField(u'十一点可预约人数') fourteen = models.IntegerField(u'十四点可预约人数') fifteen = models.IntegerField(u'十五点可预约人数') sixteen = models.IntegerField(u'十六点可预约人数') seventeen = models.IntegerField(u'十七点可预约人数') doctor = models.ForeignKey(Doctor, verbose_name=u'医生', on_delete=models.CASCADE) default_number = models.PositiveSmallIntegerField(u'默认一个时间点可预约人数') def allNumberSetDefault(self): # 设置默认一个时间点可预约人数 self.eight = self.default_number self.nine = self.default_number self.ten = self.default_number self.eleven = self.default_number self.fourteen = self.default_number self.fifteen = self.default_number self.sixteen = self.default_number self.seventeen = self.default_number class Meta: verbose_name = u'某时间点可预约人数' verbose_name_plural = u'某时间点可预约人数列表' class Register(models.Model): patient = models.ForeignKey(Patient, verbose_name=u'患者姓名', on_delete=models.CASCADE) doctor = models.ForeignKey(Doctor, verbose_name=u'医生姓名', on_delete=models.CASCADE) registration_time = models.DateTimeField(u'挂号时间') consultation_hour = models.DateTimeField(u'会诊时间') illness = models.CharField(u'病情描述', max_length=256) address = models.CharField(u'会诊地址', max_length=256) out_trade_num = models.UUIDField(u'商户订单号') status = models.CharField(u'状态', max_length=32,default='未支付') payway = models.CharField(u'支付方式', max_length=32,default='alipay') def getPatient(self): return Patient.objects.get(id=self.patient) def getDoctor(self): return Doctor.objects.get(id=self.doctor) class Meta: verbose_name = u'挂号单' verbose_name_plural = u'挂号单列表' def __str__ (self): return str(self.id)