40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-admin-api/global"
|
||
"time"
|
||
)
|
||
|
||
// PatientFamilyHealth 患者家庭成员信息表-健康情况
|
||
type PatientFamilyHealth struct {
|
||
FamilyHealthId int64 `gorm:"column:family_health_id;type:bigint(19);primary_key;comment:主键id" json:"family_health_id"`
|
||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id" json:"family_id"`
|
||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
|
||
DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);comment:疾病分类id-系统" json:"disease_class_id"`
|
||
DiseaseClassName string `gorm:"column:disease_class_name;type:varchar(255);comment:疾病名称-系统" json:"disease_class_name"`
|
||
DiagnosisDate LocalTime `gorm:"column:diagnosis_date;type:date;comment:确诊日期" json:"diagnosis_date"`
|
||
DiagnosisHospital string `gorm:"column:diagnosis_hospital;type:varchar(255);comment:确诊医院" json:"diagnosis_hospital"`
|
||
IsTakeMedicine *int `gorm:"column:is_take_medicine;type:tinyint(1);comment:正在服药(0:否 1:是)" json:"is_take_medicine"`
|
||
DrugsName string `gorm:"column:drugs_name;type:varchar(255);comment:正在服药名称" json:"drugs_name"`
|
||
Model
|
||
}
|
||
|
||
func (m *PatientFamilyHealth) TableName() string {
|
||
return "gdxz_patient_family_health"
|
||
}
|
||
|
||
func (m *PatientFamilyHealth) BeforeCreate(tx *gorm.DB) error {
|
||
if m.FamilyHealthId == 0 {
|
||
m.FamilyHealthId = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|