feat(health-profiles): 添加健康档案模块,支持健康史记录、家庭健康管理和档案概览功能
This commit is contained in:
64
src/health-profiles/models/health-history.model.ts
Normal file
64
src/health-profiles/models/health-history.model.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { Column, Model, Table, DataType, HasMany, ForeignKey, BelongsTo } from 'sequelize-typescript';
|
||||
import { HealthHistoryCategory } from '../enums/health-profile.enum';
|
||||
import { User } from '../../users/models/user.model';
|
||||
import { HealthHistoryItem } from './health-history-item.model';
|
||||
|
||||
/**
|
||||
* 健康史主表
|
||||
* 记录用户各分类的健康史状态
|
||||
*/
|
||||
@Table({
|
||||
tableName: 't_health_histories',
|
||||
underscored: true,
|
||||
})
|
||||
export class HealthHistory extends Model {
|
||||
@Column({
|
||||
type: DataType.STRING(50),
|
||||
primaryKey: true,
|
||||
comment: '健康史记录ID',
|
||||
})
|
||||
declare id: string;
|
||||
|
||||
@ForeignKey(() => User)
|
||||
@Column({
|
||||
type: DataType.STRING(50),
|
||||
allowNull: false,
|
||||
comment: '用户ID',
|
||||
})
|
||||
declare userId: string;
|
||||
|
||||
@Column({
|
||||
type: DataType.STRING(50),
|
||||
allowNull: false,
|
||||
comment: '健康史分类:allergy | disease | surgery | familyDisease',
|
||||
})
|
||||
declare category: HealthHistoryCategory;
|
||||
|
||||
@Column({
|
||||
type: DataType.BOOLEAN,
|
||||
allowNull: true,
|
||||
comment: '是否有该类健康史:null=未回答, true=有, false=无',
|
||||
})
|
||||
declare hasHistory: boolean | null;
|
||||
|
||||
@Column({
|
||||
type: DataType.DATE,
|
||||
defaultValue: DataType.NOW,
|
||||
comment: '创建时间',
|
||||
})
|
||||
declare createdAt: Date;
|
||||
|
||||
@Column({
|
||||
type: DataType.DATE,
|
||||
defaultValue: DataType.NOW,
|
||||
comment: '更新时间',
|
||||
})
|
||||
declare updatedAt: Date;
|
||||
|
||||
// 关联关系
|
||||
@BelongsTo(() => User, 'userId')
|
||||
declare user: User;
|
||||
|
||||
@HasMany(() => HealthHistoryItem, 'healthHistoryId')
|
||||
declare items: HealthHistoryItem[];
|
||||
}
|
||||
Reference in New Issue
Block a user