package entity import "time" // EMR 电子病历实体(对应数据库表 emr) type EMR struct { ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` PatientID string `json:"patient_id" gorm:"index;not null"` DoctorID string `json:"doctor_id" gorm:"index"` Draft string `json:"draft" gorm:"type:text"` // 病历全文 Structured string `json:"structured" gorm:"type:json"` // 结构化字段(JSON) Status string `json:"status" gorm:"index"` // success/need_revision/draft SessionID string `json:"session_id" gorm:"index"` // Agent会话ID IsFinal bool `json:"is_final" gorm:"default:false"` // 是否为最终版 CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Prescription 处方实体(对应数据库表 prescription) type Prescription struct { ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` PatientID string `json:"patient_id" gorm:"index;not null"` DoctorID string `json:"doctor_id" gorm:"index"` SessionID string `json:"session_id" gorm:"index"` Draft string `json:"draft" gorm:"type:text"` // 处方全文 FormulaName string `json:"formula_name"` // 方剂名 Herbs string `json:"herbs" gorm:"type:json"` // 药材列表(JSON) Status string `json:"status" gorm:"index"` // success/blocked/need_review Blocked bool `json:"blocked" gorm:"default:false"` // 是否被规则拦截 Warnings string `json:"warnings" gorm:"type:json"` // 警告列表(JSON) Approved bool `json:"approved" gorm:"default:false"` // 医生是否已审核 ApprovedBy string `json:"approved_by"` // 审核医生ID CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // AuditLog 审计日志实体(对应数据库表 audit_log) // 记录所有关键操作,满足医疗合规要求 type AuditLog struct { ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` Action string `json:"action" gorm:"index"` // emr_create/emr_update/rx_generate/rx_approve UserID string `json:"user_id" gorm:"index"` // 操作人 TargetType string `json:"target_type"` // emr/prescription TargetID string `json:"target_id" gorm:"index"` // 目标ID Detail string `json:"detail" gorm:"type:text"` // 操作详情 IPAddress string `json:"ip_address"` // 操作IP CreatedAt time.Time `json:"created_at"` } // KnowledgeDoc 知识库文档实体(对应数据库表 knowledge_doc) type KnowledgeDoc struct { ID int64 `json:"id" gorm:"primaryKey;autoIncrement"` Title string `json:"title" gorm:"index"` Category string `json:"category" gorm:"index"` // 方剂/药典/指南/病历模板 Content string `json:"content" gorm:"type:longtext"` Source string `json:"source"` // 来源 MaxKBID string `json:"maxkb_id"` // MaxKB中的文档ID Status string `json:"status" gorm:"default:pending"` // pending/vectorized/failed CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }