处方-导出
This commit is contained in:
@@ -279,6 +279,31 @@ type OrderProductData struct {
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// OrderPrescriptionData 处方
|
||||
type OrderPrescriptionData struct {
|
||||
DoctorName string // 医生姓名
|
||||
PharmacistName string // 药师姓名
|
||||
PrescriptionStatus string // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||||
PharmacistAuditStatus string // 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
PharmacistVerifyTime time.Time // 药师审核时间
|
||||
PharmacistFailReason string // 药师审核驳回原因
|
||||
PlatformAuditStatus string // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
PlatformFailTime time.Time // 平台审核失败时间
|
||||
PlatformFailReason string // 处方平台驳回原因
|
||||
IsAutoPharVerify string // 是否药师自动审核(0:否 1:是)
|
||||
DoctorCreatedTime time.Time // 医生开具处方时间
|
||||
ExpiredTime time.Time // 处方过期时间
|
||||
IsDelete string // 是否删除(0:否 1:是)
|
||||
PrescriptionCode string // 处方编号
|
||||
PatientName string // 患者姓名-就诊人
|
||||
PatientSex string // 患者性别-就诊人(1:男 2:女)
|
||||
PatientAge string // 患者年龄-就诊人
|
||||
PatientMobile string // 患者电话
|
||||
DoctorAdvice string // 医嘱
|
||||
OrderPrescriptionIcd string // 处方诊断疾病
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -1556,3 +1581,121 @@ func (r *ExportService) OrderProduct(d []*model.OrderProduct) (string, error) {
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// OrderPrescription 处方
|
||||
func (r *ExportService) OrderPrescription(d []*model.OrderPrescription) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "医生姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "药师姓名", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "处方状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "药师审核状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "药师审核时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
{Value: "药师审核驳回原因", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "处方平台审核状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "平台审核失败时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
{Value: "处方平台驳回原因", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "是否药师自动审核", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医生开具处方时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
{Value: "处方过期时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
{Value: "是否删除", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "处方编号", CellType: "string", NumberFmt: "", ColWidth: 28},
|
||||
{Value: "患者姓名-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "患者性别-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "患者年龄-就诊人", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "患者电话", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "医嘱", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "处方诊断疾病", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := OrderPrescriptionData{
|
||||
PrescriptionStatus: utils.PrescriptionStatusToString(v.PrescriptionStatus),
|
||||
PharmacistAuditStatus: utils.PharmacistAuditStatusToString(v.PharmacistAuditStatus),
|
||||
PharmacistFailReason: v.PharmacistFailReason,
|
||||
PlatformAuditStatus: utils.PlatformAuditStatusToString(v.PlatformAuditStatus),
|
||||
PlatformFailReason: v.PlatformFailReason,
|
||||
IsAutoPharVerify: utils.IsAutoPharVerifyToString(v.IsAutoPharVerify),
|
||||
IsDelete: utils.IsDeleteToString(v.IsDelete),
|
||||
PrescriptionCode: v.PrescriptionCode,
|
||||
PatientName: v.PatientName,
|
||||
PatientSex: utils.SexToString(v.PatientSex),
|
||||
PatientAge: fmt.Sprintf("%d", v.PatientAge),
|
||||
DoctorAdvice: v.DoctorAdvice,
|
||||
}
|
||||
|
||||
if v.UserDoctor != nil {
|
||||
// 医生姓名
|
||||
data.DoctorName = v.UserDoctor.UserName
|
||||
}
|
||||
|
||||
if v.UserPharmacist != nil {
|
||||
// 医生姓名
|
||||
data.PharmacistName = v.UserPharmacist.UserName
|
||||
}
|
||||
|
||||
if v.UserPatient != nil {
|
||||
if v.UserPatient.User != nil {
|
||||
data.PatientMobile = v.UserPatient.User.Mobile
|
||||
}
|
||||
}
|
||||
|
||||
// 处方诊断疾病
|
||||
if len(v.OrderPrescriptionIcd) > 0 {
|
||||
var orderPrescriptionIcd []string
|
||||
for _, icd := range v.OrderPrescriptionIcd {
|
||||
orderPrescriptionIcd = append(orderPrescriptionIcd, icd.IcdName)
|
||||
}
|
||||
|
||||
data.OrderPrescriptionIcd = strings.Join(orderPrescriptionIcd, "、")
|
||||
}
|
||||
|
||||
if v.PharmacistVerifyTime != (model.LocalTime{}) {
|
||||
t := time.Time(v.PharmacistVerifyTime)
|
||||
data.PharmacistVerifyTime = t
|
||||
}
|
||||
|
||||
if v.PlatformFailTime != (model.LocalTime{}) {
|
||||
t := time.Time(v.PlatformFailTime)
|
||||
data.PlatformFailTime = t
|
||||
}
|
||||
|
||||
if v.DoctorCreatedTime != (model.LocalTime{}) {
|
||||
t := time.Time(v.DoctorCreatedTime)
|
||||
data.DoctorCreatedTime = t
|
||||
}
|
||||
|
||||
if v.ExpiredTime != (model.LocalTime{}) {
|
||||
t := time.Time(v.ExpiredTime)
|
||||
data.ExpiredTime = t
|
||||
}
|
||||
|
||||
if v.CreatedAt != (model.LocalTime{}) {
|
||||
t := time.Time(v.CreatedAt)
|
||||
data.CreatedAt = t
|
||||
}
|
||||
|
||||
dataSlice = append(dataSlice, data)
|
||||
}
|
||||
|
||||
file, err := utils.Export(header, dataSlice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 设置文件名字
|
||||
now := time.Now()
|
||||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||
rand.Seed(time.Now().UnixNano()) // 设置随机数
|
||||
ossPath := "admin/export/output" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx"
|
||||
|
||||
// 上传oss
|
||||
_, err = aliyun.PutObjectByte(ossPath, file.Bytes())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user