修正返回目录
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/responses/orderPrescriptionIcdResponse"
|
||||
"hospital-admin-api/api/responses/orderPrescriptionProductResponse"
|
||||
"hospital-admin-api/api/responses/orderPrescriptionResponse"
|
||||
)
|
||||
|
||||
@@ -47,3 +51,124 @@ func (r *OrderPrescriptionService) GetOrderPrescriptionById(OrderPrescriptionId
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// GetOrderPrescription 处方详情
|
||||
func (r *OrderPrescriptionService) GetOrderPrescription(OrderPrescriptionId int64) (getOrderPrescriptionResponse *orderPrescriptionResponse.GetOrderPrescription, err error) {
|
||||
orderPrescriptionDao := dao.OrderPrescriptionDao{}
|
||||
orderPrescription, err := orderPrescriptionDao.GetById(OrderPrescriptionId)
|
||||
if orderPrescription == nil {
|
||||
return nil, errors.New("处方错误")
|
||||
}
|
||||
|
||||
// 获取处方关联疾病数据
|
||||
orderPrescriptionIcds, err := r.GetOrderPrescriptionIcdByOrderPrescriptionId(OrderPrescriptionId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
|
||||
fmt.Println(orderPrescriptionIcds)
|
||||
// 获取问诊病例
|
||||
orderInquiryService := OrderInquiryService{}
|
||||
orderInquiryCase, err := orderInquiryService.GetOrderInquiryCaseByOrderInquiryId(orderPrescription.OrderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
fmt.Println(orderInquiryCase)
|
||||
|
||||
// 获取处方关联问诊数据
|
||||
orderInquiry, err := orderInquiryService.GetOrderInquiryById(orderPrescription.OrderInquiryId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
fmt.Println(orderInquiry)
|
||||
|
||||
// 获取处方商品数据
|
||||
orderPrescriptionProducts, err := r.GetOrderPrescriptionProductByOrderPrescriptionId(OrderPrescriptionId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
fmt.Println(orderPrescriptionProducts)
|
||||
|
||||
// 获取医生数据
|
||||
userDoctorService := UserDoctorService{}
|
||||
userDoctor, err := userDoctorService.GetUserDoctorById(orderPrescription.DoctorId)
|
||||
if err != nil {
|
||||
return nil, errors.New(err.Error())
|
||||
}
|
||||
fmt.Println(userDoctor)
|
||||
|
||||
// 获取药师数据
|
||||
|
||||
result := &orderPrescriptionResponse.GetOrderPrescription{
|
||||
|
||||
CreatedAt: model.LocalTime{},
|
||||
UpdatedAt: model.LocalTime{},
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionIcdByOrderPrescriptionId 获取处方关联疾病数据-处方id
|
||||
func (r *OrderPrescriptionService) GetOrderPrescriptionIcdByOrderPrescriptionId(OrderPrescriptionId int64) (res *orderPrescriptionIcdResponse.OrderPrescriptionIcd, err error) {
|
||||
orderPrescriptionIcdDao := dao.OrderPrescriptionIcdDao{}
|
||||
orderPrescriptionIcd, err := orderPrescriptionIcdDao.GetOrderPrescriptionIcdById(OrderPrescriptionId)
|
||||
if orderPrescriptionIcd == nil {
|
||||
return nil, errors.New("处方病例错误")
|
||||
}
|
||||
|
||||
result := &orderPrescriptionIcdResponse.OrderPrescriptionIcd{
|
||||
PrescriptionIcdId: fmt.Sprintf("%d", orderPrescriptionIcd.PrescriptionIcdId),
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", orderPrescriptionIcd.OrderPrescriptionId),
|
||||
IcdId: fmt.Sprintf("%d", orderPrescriptionIcd.IcdId),
|
||||
IcdName: orderPrescriptionIcd.IcdName,
|
||||
IcdCode: orderPrescriptionIcd.IcdCode,
|
||||
CreatedAt: orderPrescriptionIcd.CreatedAt,
|
||||
UpdatedAt: orderPrescriptionIcd.UpdatedAt,
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetOrderPrescriptionProductByOrderPrescriptionId 获取处方关联商品数据-处方id
|
||||
func (r *OrderPrescriptionService) GetOrderPrescriptionProductByOrderPrescriptionId(orderPrescriptionId int64) (res []*orderPrescriptionProductResponse.OrderPrescriptionProduct, err error) {
|
||||
orderPrescriptionProductDao := dao.OrderPrescriptionProductDao{}
|
||||
orderPrescriptionProducts, err := orderPrescriptionProductDao.GetOrderPrescriptionProductListByOrderPrescriptionId(orderPrescriptionId)
|
||||
if err != nil {
|
||||
return nil, errors.New("数据错误,无处方药品数据")
|
||||
}
|
||||
|
||||
if len(orderPrescriptionProducts) == 0 {
|
||||
return nil, errors.New("数据错误,无处方药品数据")
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
items := make([]*orderPrescriptionProductResponse.OrderPrescriptionProduct, len(orderPrescriptionProducts))
|
||||
|
||||
if len(orderPrescriptionProducts) > 0 {
|
||||
for i, v := range orderPrescriptionProducts {
|
||||
// 将原始结构体转换为新结构体
|
||||
item := &orderPrescriptionProductResponse.OrderPrescriptionProduct{
|
||||
PrescriptionProductId: fmt.Sprintf("%d", v.OrderPrescriptionId),
|
||||
OrderPrescriptionId: fmt.Sprintf("%d", v.OrderPrescriptionId),
|
||||
ProductId: fmt.Sprintf("%d", v.ProductId),
|
||||
UseStatus: v.UseStatus,
|
||||
PrescriptionProductNum: v.PrescriptionProductNum,
|
||||
ProductName: v.ProductName,
|
||||
ProductSpec: v.ProductSpec,
|
||||
LicenseNumber: v.LicenseNumber,
|
||||
Manufacturer: v.Manufacturer,
|
||||
SingleUnit: v.SingleUnit,
|
||||
SingleUse: v.SingleUse,
|
||||
PackagingUnit: v.PackagingUnit,
|
||||
FrequencyUse: v.FrequencyUse,
|
||||
AvailableDays: v.AvailableDays,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
items[i] = item
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user