新增了用户病例处理
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
)
|
||||
|
||||
// UserCaseDto 用户表-病例
|
||||
type UserCaseDto struct {
|
||||
UserCaseId string `json:"user_case_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
IsHospital *int `json:"is_hospital"` // 是否医院就诊(0:否 1:是)
|
||||
LiverStatus string `json:"liver_status"` // 肝脏状态
|
||||
IsMedication *int `json:"is_medication"` // 是否服药(0:否 1:是)
|
||||
Medication string `json:"medication"` // 服药名称
|
||||
ChronicDisease string `json:"chronic_disease"` // 慢性疾病名称(逗号分隔)
|
||||
IsAllergyHistory *int `json:"is_allergy_history"` // 过敏史(0:否 1:是)
|
||||
AllergyHistory string `json:"allergy_history"` // 过敏史描述
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
UserCaseDiseaseItem []*UserCaseDiseaseItemDto `json:"user_case_disease_item"` // 所患疾病列表
|
||||
}
|
||||
|
||||
// GetUserCaseDto 详情
|
||||
func GetUserCaseDto(m *model.UserCase) *UserCaseDto {
|
||||
return &UserCaseDto{
|
||||
UserCaseId: fmt.Sprintf("%d", m.UserCaseId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
IsHospital: m.IsHospital,
|
||||
LiverStatus: m.LiverStatus,
|
||||
IsMedication: m.IsMedication,
|
||||
Medication: m.Medication,
|
||||
ChronicDisease: m.ChronicDisease,
|
||||
IsAllergyHistory: m.IsAllergyHistory,
|
||||
AllergyHistory: m.AllergyHistory,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadUserCaseDiseaseItem 加载数据-疾病列表
|
||||
func (r *UserCaseDto) LoadUserCaseDiseaseItem(m []*model.UserCaseDiseaseItem) *UserCaseDto {
|
||||
if len(m) > 0 {
|
||||
r.UserCaseDiseaseItem = GetUserCaseDiseaseItemListDto(m)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
)
|
||||
|
||||
// UserCaseDiseaseItemDto 用户-病例-所患疾病列表
|
||||
type UserCaseDiseaseItemDto struct {
|
||||
ItemId string `json:"item_id"` // 主键id
|
||||
UserCaseId string `json:"user_case_id"` // 用户病例id
|
||||
DiseaseClassId string `json:"disease_class_id"` // 疾病分类id
|
||||
DiseaseClassName string `json:"disease_class_name"` // 疾病分类名称
|
||||
AppIden string `json:"app_iden"` // app唯一标识
|
||||
Duration *int `json:"duration"` // 患病时长(年)
|
||||
Genotype string `json:"genotype"` // 基因型(仅丙肝存在)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetUserCaseDiseaseItemListDto 列表-分页
|
||||
func GetUserCaseDiseaseItemListDto(m []*model.UserCaseDiseaseItem) []*UserCaseDiseaseItemDto {
|
||||
// 处理返回值
|
||||
responses := make([]*UserCaseDiseaseItemDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &UserCaseDiseaseItemDto{
|
||||
ItemId: fmt.Sprintf("%d", v.ItemId),
|
||||
UserCaseId: fmt.Sprintf("%d", v.UserCaseId),
|
||||
DiseaseClassId: fmt.Sprintf("%d", v.DiseaseClassId),
|
||||
AppIden: v.AppIden,
|
||||
Duration: v.Duration,
|
||||
Genotype: v.Genotype,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载数据-疾病名称
|
||||
if v.BaseDiseaseClass != nil {
|
||||
response = response.LoadDiseaseClassName(v.BaseDiseaseClass)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadDiseaseClassName 加载数据-疾病名称
|
||||
func (r *UserCaseDiseaseItemDto) LoadDiseaseClassName(m *model.BaseDiseaseClass) *UserCaseDiseaseItemDto {
|
||||
if m != nil {
|
||||
r.DiseaseClassName = m.DiseaseClassName
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user