208 lines
9.1 KiB
Go
208 lines
9.1 KiB
Go
package dto
|
||
|
||
import (
|
||
"fmt"
|
||
"hospital-admin-api/api/model"
|
||
"hospital-admin-api/utils"
|
||
"strings"
|
||
)
|
||
|
||
type OrderPrescriptionDto struct {
|
||
OrderPrescriptionId string `json:"order_prescription_id"` // 主键id
|
||
OrderInquiryId string `json:"order_inquiry_id"` // 订单-问诊id;NOT NULL
|
||
DoctorId string `json:"doctor_id"` // 医生id;NOT NULL
|
||
PatientId string `json:"patient_id"` // 患者id
|
||
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||
PharmacistId string `json:"pharmacist_id"` // 药师id
|
||
OrderProductId string `json:"order_product_id"` // 药品订单id
|
||
PrescriptionStatus int `json:"prescription_status"` // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||
PharmacistAuditStatus int `json:"pharmacist_audit_status"` // 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
PharmacistVerifyTime model.LocalTime `json:"pharmacist_verify_time"` // 药师审核时间
|
||
PharmacistFailReason string `json:"pharmacist_fail_reason"` // 药师审核驳回原因
|
||
PlatformAuditStatus int `json:"platform_audit_status"` // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||
PlatformFailTime model.LocalTime `json:"platform_fail_time"` // 平台审核失败时间
|
||
PlatformFailReason string `json:"platform_fail_reason"` // 处方平台驳回原因
|
||
IsAutoPharVerify int `json:"is_auto_phar_verify"` // 是否药师自动审核(0:否 1:是)
|
||
DoctorCreatedTime model.LocalTime `json:"doctor_created_time"` // 医生开具处方时间
|
||
ExpiredTime model.LocalTime `json:"expired_time"` // 处方过期时间
|
||
IsDelete int `json:"is_delete"` // 是否删除(0:否 1:是)
|
||
PrescriptionCode string `json:"prescription_code"` // 处方编号
|
||
DoctorName string `json:"doctor_name"` // 医生名称
|
||
PatientName string `json:"patient_name"` // 患者姓名-就诊人
|
||
PatientSex int `json:"patient_sex"` // 患者性别-就诊人(1:男 2:女)
|
||
PatientAge int `json:"patient_age"` // 患者年龄-就诊人
|
||
DoctorAdvice string `json:"doctor_advice"` // 医嘱
|
||
PharmacistName string `json:"pharmacist_name"` // 药师姓名
|
||
Mobile string `json:"mobile"` // 手机号
|
||
OrderPrescriptionIcd string `json:"order_prescription_icd"` // 处方诊断疾病
|
||
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
|
||
OrderPrescriptionProduct []*OrderPrescriptionProductDto `json:"order_prescription_product"` // 处方商品
|
||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||
}
|
||
|
||
func GetOrderPrescriptionDto(m *model.OrderPrescription) *OrderPrescriptionDto {
|
||
return &OrderPrescriptionDto{
|
||
OrderPrescriptionId: fmt.Sprintf("%d", m.OrderPrescriptionId),
|
||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||
DoctorId: fmt.Sprintf("%d", m.DoctorId),
|
||
PatientId: fmt.Sprintf("%d", m.PatientId),
|
||
FamilyId: fmt.Sprintf("%d", m.FamilyId),
|
||
PharmacistId: fmt.Sprintf("%d", m.PharmacistId),
|
||
PrescriptionStatus: m.PrescriptionStatus,
|
||
PharmacistAuditStatus: m.PharmacistAuditStatus,
|
||
PharmacistVerifyTime: m.PharmacistVerifyTime,
|
||
PharmacistFailReason: m.PharmacistFailReason,
|
||
PlatformAuditStatus: m.PlatformAuditStatus,
|
||
PlatformFailTime: m.PlatformFailTime,
|
||
PlatformFailReason: m.PlatformFailReason,
|
||
IsAutoPharVerify: m.IsAutoPharVerify,
|
||
DoctorCreatedTime: m.DoctorCreatedTime,
|
||
ExpiredTime: m.ExpiredTime,
|
||
IsDelete: m.IsDelete,
|
||
PrescriptionCode: m.PrescriptionCode,
|
||
DoctorName: m.DoctorName,
|
||
PatientName: m.PatientName,
|
||
PatientSex: m.PatientSex,
|
||
PatientAge: m.PatientAge,
|
||
DoctorAdvice: m.DoctorAdvice,
|
||
CreatedAt: m.CreatedAt,
|
||
UpdatedAt: m.UpdatedAt,
|
||
}
|
||
}
|
||
|
||
func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescriptionDto {
|
||
// 处理返回值
|
||
responses := make([]*OrderPrescriptionDto, len(m))
|
||
|
||
if len(m) > 0 {
|
||
for i, v := range m {
|
||
response := &OrderPrescriptionDto{
|
||
OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId),
|
||
OrderInquiryId: fmt.Sprintf("%d", v.OrderInquiryId),
|
||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||
PharmacistId: fmt.Sprintf("%d", v.PharmacistId),
|
||
PrescriptionStatus: v.PrescriptionStatus,
|
||
PharmacistAuditStatus: v.PharmacistAuditStatus,
|
||
PharmacistVerifyTime: v.PharmacistVerifyTime,
|
||
PharmacistFailReason: v.PharmacistFailReason,
|
||
PlatformAuditStatus: v.PlatformAuditStatus,
|
||
PlatformFailTime: v.PlatformFailTime,
|
||
PlatformFailReason: v.PlatformFailReason,
|
||
IsAutoPharVerify: v.IsAutoPharVerify,
|
||
DoctorCreatedTime: v.DoctorCreatedTime,
|
||
ExpiredTime: v.ExpiredTime,
|
||
IsDelete: v.IsDelete,
|
||
PrescriptionCode: v.PrescriptionCode,
|
||
DoctorName: v.DoctorName,
|
||
PatientName: v.PatientName,
|
||
PatientSex: v.PatientSex,
|
||
PatientAge: v.PatientAge,
|
||
DoctorAdvice: v.DoctorAdvice,
|
||
CreatedAt: v.CreatedAt,
|
||
UpdatedAt: v.UpdatedAt,
|
||
}
|
||
|
||
// 加载药师名称
|
||
if v.UserPharmacist != nil {
|
||
response = response.LoadPharmacisName(v.UserPharmacist)
|
||
}
|
||
|
||
// 加载患者家庭成员手机号
|
||
if v.PatientFamily != nil {
|
||
response = response.LoadPatientFamilyMobileMask(v.PatientFamily)
|
||
}
|
||
|
||
// 加载患者手机号
|
||
if response.Mobile == "" && v.UserPatient.User != nil {
|
||
response = response.LoadPatientMobileMask(v.UserPatient.User)
|
||
}
|
||
|
||
// 加载处方诊断疾病-字符串
|
||
if len(v.OrderPrescriptionIcd) > 0 {
|
||
response = response.LoadOrderPrescriptionIcdString(v.OrderPrescriptionIcd)
|
||
}
|
||
|
||
// 将转换后的结构体添加到新切片中
|
||
responses[i] = response
|
||
}
|
||
}
|
||
|
||
return responses
|
||
}
|
||
|
||
// LoadPharmacisName 加载药师名称
|
||
func (r *OrderPrescriptionDto) LoadPharmacisName(m *model.UserPharmacist) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
r.PharmacistName = m.UserName
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadDoctorName 加载医生名称
|
||
func (r *OrderPrescriptionDto) LoadDoctorName(m *model.UserDoctor) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
r.DoctorName = m.UserName
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadPatientFamilyMobileMask 加载患者家庭成员手机号
|
||
func (r *OrderPrescriptionDto) LoadPatientFamilyMobileMask(m *model.PatientFamily) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
r.Mobile = m.MobileMask
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadPatientMobileMask 加载患者手机号
|
||
func (r *OrderPrescriptionDto) LoadPatientMobileMask(m *model.User) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
r.Mobile = utils.MaskPhoneStr(m.Mobile)
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadOrderPrescriptionIcdString 加载处方诊断疾病-字符串
|
||
func (r *OrderPrescriptionDto) LoadOrderPrescriptionIcdString(m []*model.OrderPrescriptionIcd) *OrderPrescriptionDto {
|
||
if len(m) > 0 {
|
||
var orderPrescriptionIcd []string
|
||
for _, icd := range m {
|
||
orderPrescriptionIcd = append(orderPrescriptionIcd, icd.IcdName)
|
||
}
|
||
|
||
r.OrderPrescriptionIcd = strings.Join(orderPrescriptionIcd, "、")
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadMaskOrderInquiryCase 加载问诊病例
|
||
func (r *OrderPrescriptionDto) LoadMaskOrderInquiryCase(m *model.OrderInquiryCase) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
d := GetMaskOrderInquiryCaseDto(m)
|
||
|
||
r.OrderInquiryCase = d
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadOrderPrescriptionProduct 加载处方商品
|
||
func (r *OrderPrescriptionDto) LoadOrderPrescriptionProduct(m []*model.OrderPrescriptionProduct) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
d := GetOrderPrescriptionProductListDto(m)
|
||
|
||
r.OrderPrescriptionProduct = d
|
||
}
|
||
return r
|
||
}
|
||
|
||
// LoadOrderProductId 加载药品订单id
|
||
func (r *OrderPrescriptionDto) LoadOrderProductId(m *model.OrderProduct) *OrderPrescriptionDto {
|
||
if m != nil {
|
||
r.OrderProductId = fmt.Sprintf("%d", m.OrderProductId)
|
||
}
|
||
return r
|
||
}
|