Files
hospital-admin-api/api/model/patientFamily.go
T
2023-09-19 17:49:20 +08:00

59 lines
3.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// PatientFamily 患者家庭成员信息表-基本信息
type PatientFamily struct {
FamilyId int64 `gorm:"column:family_id;type:bigint(19);primary_key;comment:主键id" json:"family_id"`
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id" json:"patient_id"`
Relation *int `gorm:"column:relation;type:tinyint(1);comment:与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 " json:"relation"`
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"status"`
IsDefault int `gorm:"column:is_default;type:tinyint(1);default:0;comment:是否默认(0:否 1:是)" json:"is_default"`
CardName string `gorm:"column:card_name;type:varchar(50);comment:姓名" json:"card_name"`
CardNameMask string `gorm:"column:card_name_mask;type:varchar(50);comment:姓名(掩码)" json:"card_name_mask"`
Mobile string `gorm:"column:mobile;type:varchar(20);comment:电话" json:"mobile"`
MobileMask string `gorm:"column:mobile_mask;type:varchar(20);comment:电话(掩码)" json:"mobile_mask"`
Type int `gorm:"column:type;type:tinyint(1);default:1;comment:身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)" json:"type"`
IdNumber string `gorm:"column:id_number;type:varchar(30);comment:证件号码" json:"id_number"`
IdNumberMask string `gorm:"column:id_number_mask;type:varchar(30);comment:证件号码(掩码)" json:"id_number_mask"`
Sex int `gorm:"column:sex;type:tinyint(1);default:0;comment:性别(0:未知 1:男 2:女)" json:"sex"`
Age int `gorm:"column:age;type:int(11);comment:年龄" json:"age"`
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
Height string `gorm:"column:height;type:varchar(100);comment:身高(cm" json:"height"`
Weight string `gorm:"column:weight;type:varchar(100);comment:体重(kg" json:"weight"`
MaritalStatus int `gorm:"column:marital_status;type:tinyint(1);comment:婚姻状况(0:未婚 1:已婚 2:离异)" json:"marital_status"`
NationId int64 `gorm:"column:nation_id;type:bigint(19);comment:民族" json:"nation_id"`
NationName string `gorm:"column:nation_name;type:varchar(50);comment:民族名称" json:"nation_name"`
JobId int64 `gorm:"column:job_id;type:bigint(19);comment:职业" json:"job_id"`
JobName string `gorm:"column:job_name;type:varchar(50);comment:职业名称" json:"job_name"`
UserPatient *UserPatient `gorm:"foreignKey:PatientId;references:patient_id" json:"user_patient"` // 患者
Model
}
func (m *PatientFamily) TableName() string {
return "gdxz_patient_family"
}
func (m *PatientFamily) BeforeCreate(tx *gorm.DB) error {
if m.FamilyId == 0 {
m.FamilyId = 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
}