119 lines
4.9 KiB
Go
119 lines
4.9 KiB
Go
package dto
|
|
|
|
import (
|
|
"fmt"
|
|
"hospital-admin-api/api/model"
|
|
)
|
|
|
|
type PharmacyDoctorDto struct {
|
|
DoctorPharmacyId string `json:"doctor_pharmacy_id"` // 绑定关系id
|
|
DoctorId string `json:"doctor_id"` // 医生id
|
|
UserId string `json:"user_id"` // 用户id
|
|
UserName string `json:"user_name"` // 医生姓名
|
|
Avatar string `json:"avatar"` // 头像
|
|
DoctorTitle int `json:"doctor_title"` // 职称代码
|
|
DoctorTitleName string `json:"doctor_title_name"` // 职称名称
|
|
DepartmentCustomId string `json:"department_custom_id"` // 科室id
|
|
DepartmentCustomName string `json:"department_custom_name"` // 科室名称
|
|
DepartmentCustomMobile string `json:"department_custom_mobile"` // 科室电话
|
|
HospitalId string `json:"hospital_id"` // 医院id
|
|
HospitalName string `json:"hospital_name"` // 医院名称
|
|
Mobile string `json:"mobile"` // 手机号
|
|
IsDefault int `json:"is_default"` // 是否为默认药房(0:否 1:是)
|
|
Status int `json:"status"` // 状态(1:正常)
|
|
BindTime model.LocalTime `json:"bind_time"` // 绑定时间
|
|
}
|
|
|
|
var doctorTitleMap = map[int]string{
|
|
1: "主任医师",
|
|
2: "主任中医师",
|
|
3: "副主任医师",
|
|
4: "副主任中医师",
|
|
5: "主治医师",
|
|
6: "住院医师",
|
|
}
|
|
|
|
func GetPharmacyDoctorDto(m *model.DoctorPharmacy) *PharmacyDoctorDto {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
|
|
dto := &PharmacyDoctorDto{
|
|
DoctorPharmacyId: fmt.Sprintf("%d", m.DoctorPharmacyId),
|
|
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
|
IsDefault: m.IsDefault,
|
|
Status: m.Status,
|
|
BindTime: m.CreatedAt,
|
|
}
|
|
|
|
if m.UserDoctor != nil {
|
|
dto.UserId = fmt.Sprintf("%d", m.UserDoctor.UserId)
|
|
dto.UserName = m.UserDoctor.UserName
|
|
dto.Avatar = m.UserDoctor.Avatar
|
|
dto.DoctorTitle = m.UserDoctor.DoctorTitle
|
|
dto.DoctorTitleName = doctorTitleMap[m.UserDoctor.DoctorTitle]
|
|
dto.DepartmentCustomId = fmt.Sprintf("%d", m.UserDoctor.DepartmentCustomId)
|
|
dto.DepartmentCustomName = m.UserDoctor.DepartmentCustomName
|
|
dto.DepartmentCustomMobile = m.UserDoctor.DepartmentCustomMobile
|
|
dto.HospitalId = fmt.Sprintf("%d", m.UserDoctor.HospitalID)
|
|
|
|
if m.UserDoctor.Hospital != nil {
|
|
dto.HospitalName = m.UserDoctor.Hospital.HospitalName
|
|
}
|
|
|
|
if m.UserDoctor.User != nil {
|
|
dto.Mobile = m.UserDoctor.User.Mobile
|
|
}
|
|
}
|
|
|
|
return dto
|
|
}
|
|
|
|
func GetPharmacyDoctorListDto(list []*model.DoctorPharmacy) []PharmacyDoctorDto {
|
|
res := make([]PharmacyDoctorDto, len(list))
|
|
for i, v := range list {
|
|
res[i] = *GetPharmacyDoctorDto(v)
|
|
}
|
|
return res
|
|
}
|
|
|
|
// GetDoctorTitleName 获取医生职称名称
|
|
func GetDoctorTitleName(title int) string {
|
|
return doctorTitleMap[title]
|
|
}
|
|
|
|
// BoundPharmacySimpleDto 医生绑定的药房简要信息
|
|
type BoundPharmacySimpleDto struct {
|
|
PharmacyId string `json:"pharmacy_id"`
|
|
PharmacyName string `json:"pharmacy_name"`
|
|
PharmacyCode string `json:"pharmacy_code"`
|
|
IsDefault int `json:"is_default"`
|
|
}
|
|
|
|
// AffectedDoctorItemDto 受影响的医生明细
|
|
type AffectedDoctorItemDto struct {
|
|
DoctorId string `json:"doctor_id"`
|
|
DoctorPharmacyId string `json:"doctor_pharmacy_id"`
|
|
UserId string `json:"user_id"`
|
|
UserName string `json:"user_name"`
|
|
Mobile string `json:"mobile"`
|
|
DoctorTitleName string `json:"doctor_title_name"`
|
|
HospitalId string `json:"hospital_id"`
|
|
HospitalName string `json:"hospital_name"`
|
|
DepartmentCustomId string `json:"department_custom_id"`
|
|
DepartmentCustomName string `json:"department_custom_name"`
|
|
IsDefault int `json:"is_default"` // 在当前待下线药房是否为默认(1:是 0:否)
|
|
OtherBoundPharmacies []BoundPharmacySimpleDto `json:"other_bound_pharmacies"` // 该医生名下绑定的其他可用药房
|
|
}
|
|
|
|
// PharmacyAffectedDoctorsDto 下线预检受影响医生列表响应
|
|
type PharmacyAffectedDoctorsDto struct {
|
|
PharmacyId string `json:"pharmacy_id"`
|
|
PharmacyName string `json:"pharmacy_name"`
|
|
PharmacyCode string `json:"pharmacy_code"`
|
|
Status int `json:"status"`
|
|
DefaultDoctorCount int64 `json:"default_doctor_count"`
|
|
TotalDoctorCount int64 `json:"total_doctor_count"`
|
|
DoctorList []AffectedDoctorItemDto `json:"doctor_list"`
|
|
}
|