feat(health-profiles): 添加健康档案模块,支持健康史记录、家庭健康管理和档案概览功能

This commit is contained in:
richarjiang
2025-12-04 17:15:11 +08:00
parent 03bd0b041e
commit 2d7e067888
20 changed files with 1949 additions and 0 deletions

View 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[];
}