159 lines
8.0 KiB
Go
159 lines
8.0 KiB
Go
package patientFamilyResponse
|
||
|
||
import (
|
||
"fmt"
|
||
"hospital-admin-api/api/model"
|
||
"hospital-admin-api/api/responses/userResponse"
|
||
"hospital-admin-api/utils"
|
||
)
|
||
|
||
type PatientFamily struct {
|
||
FamilyId string `json:"family_id"` // 主键id
|
||
PatientId string `json:"patient_id"` // 患者id
|
||
Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
|
||
Status *int `json:"status"` // 状态(1:正常 2:删除)
|
||
IsDefault *int `json:"is_default"` // 是否默认(0:否 1:是)
|
||
CardName string `json:"card_name"` // 姓名
|
||
CardNameMask string `json:"card_name_mask"` // 姓名(掩码)
|
||
Mobile string `json:"mobile"` // 电话
|
||
MobileMask string `json:"mobile_mask"` // 电话(掩码)
|
||
Type *int `json:"type"` // 身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
||
IdNumber string `json:"id_number"` // 证件号码
|
||
IdNumberMask string `json:"id_number_mask"` // 证件号码(掩码)
|
||
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
Age int `json:"age"` // 年龄
|
||
ProvinceId string `json:"province_id"` // 省份id
|
||
Province string `json:"province"` // 省份
|
||
CityId string `json:"city_id"` // 城市id
|
||
City string `json:"city"` // 城市
|
||
CountyId string `json:"county_id"` // 区县id
|
||
County string `json:"county"` // 区县
|
||
Height string `json:"height"` // 身高(cm)
|
||
Weight string `json:"weight"` // 体重(kg)
|
||
MaritalStatus *int `json:"marital_status"` // 婚姻状况(0:未婚 1:已婚 2:离异)
|
||
NationId string `json:"nation_id"` // 民族
|
||
NationName string `json:"nation_name"` // 民族名称
|
||
JobId string `json:"job_id"` // 职业
|
||
JobName string `json:"job_name"` // 职业名称
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// GetUserPatient 患者详情
|
||
type GetUserPatient struct {
|
||
FamilyId string `json:"family_id"` // 主键id
|
||
PatientId string `json:"patient_id"` // 患者id
|
||
Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
|
||
Status *int `json:"status"` // 状态(1:正常 2:删除)
|
||
IsDefault *int `json:"is_default"` // 是否默认(0:否 1:是)
|
||
CardNameMask string `json:"card_name_mask"` // 姓名(掩码)
|
||
MobileMask string `json:"mobile_mask"` // 电话(掩码)
|
||
IdNumberMask string `json:"id_number_mask"` // 证件号码(掩码)
|
||
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
Age int `json:"age"` // 年龄
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// 获取就诊人列表-分页
|
||
type getPatientFamilyPage struct {
|
||
FamilyId string `json:"family_id"` // 主键id
|
||
PatientId string `json:"patient_id"` // 患者id
|
||
Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
|
||
Status *int `json:"status"` // 状态(1:正常 2:删除)
|
||
CardName string `json:"card_name"` // 姓名
|
||
MobileMask string `json:"mobile_mask"` // 电话(掩码)
|
||
UserName string `json:"user_name"` // 账号名称
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// GetPatientFamily 就诊人详情
|
||
type GetPatientFamily struct {
|
||
FamilyId string `json:"family_id"` // 主键id
|
||
PatientId string `json:"patient_id"` // 患者id
|
||
Relation *int `json:"relation"` // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他)
|
||
Status *int `json:"status"` // 状态(1:正常 2:删除)
|
||
IsDefault *int `json:"is_default"` // 是否默认(0:否 1:是)
|
||
CardName string `json:"card_name"` // 姓名
|
||
CardNameMask string `json:"card_name_mask"` // 姓名(掩码)
|
||
MobileMask string `json:"mobile_mask"` // 电话(掩码)
|
||
Type *int `json:"type"` // 身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
||
IdNumberMask string `json:"id_number_mask"` // 证件号码(掩码)
|
||
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||
Age int `json:"age"` // 年龄
|
||
ProvinceId string `json:"province_id"` // 省份id
|
||
Province string `json:"province"` // 省份
|
||
CityId string `json:"city_id"` // 城市id
|
||
City string `json:"city"` // 城市
|
||
CountyId string `json:"county_id"` // 区县id
|
||
County string `json:"county"` // 区县
|
||
Height string `json:"height"` // 身高(cm)
|
||
Weight string `json:"weight"` // 体重(kg)
|
||
MaritalStatus *int `json:"marital_status"` // 婚姻状况(0:未婚 1:已婚 2:离异)
|
||
NationId string `json:"nation_id"` // 民族
|
||
NationName string `json:"nation_name"` // 民族名称
|
||
JobId string `json:"job_id"` // 职业
|
||
JobName string `json:"job_name"` // 职业名称
|
||
User *userResponse.User `json:"user"` // 用户
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||
}
|
||
|
||
// GetUserPatientResponse 获取患者详情
|
||
func GetUserPatientResponse(patientFamilys []*model.PatientFamily) []*GetUserPatient {
|
||
// 处理返回值
|
||
items := make([]*GetUserPatient, len(patientFamilys))
|
||
|
||
if len(patientFamilys) > 0 {
|
||
for i, v := range patientFamilys {
|
||
// 将原始结构体转换为新结构体
|
||
item := &GetUserPatient{
|
||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||
Relation: v.Relation,
|
||
Status: &v.Status,
|
||
IsDefault: &v.IsDefault,
|
||
CardNameMask: v.CardNameMask,
|
||
IdNumberMask: v.IdNumberMask,
|
||
Sex: &v.Sex,
|
||
Age: v.Age,
|
||
CreatedAt: v.CreatedAt,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
items[i] = item
|
||
}
|
||
}
|
||
|
||
return items
|
||
}
|
||
|
||
// GetPatientFamilyPageResponse 获取用户列表-分页
|
||
func GetPatientFamilyPageResponse(patientFamily []*model.PatientFamily) []getPatientFamilyPage {
|
||
// 处理返回值
|
||
patientFamilyResponses := make([]getPatientFamilyPage, len(patientFamily))
|
||
|
||
if len(patientFamily) > 0 {
|
||
for i, v := range patientFamily {
|
||
// 将原始结构体转换为新结构体
|
||
patientFamilyResponse := getPatientFamilyPage{
|
||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||
Relation: v.Relation,
|
||
Status: &v.Status,
|
||
CardName: v.CardName,
|
||
MobileMask: utils.MaskPhoneStr(v.UserPatient.User.Mobile),
|
||
UserName: v.UserPatient.UserName,
|
||
CreatedAt: v.CreatedAt,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
patientFamilyResponses[i] = patientFamilyResponse
|
||
}
|
||
}
|
||
return patientFamilyResponses
|
||
}
|