抄方 处方列表处理
This commit is contained in:
parent
4133c7e26b
commit
a04a499a43
@ -2,12 +2,13 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/model"
|
||||
"hospital-admin-api/api/requests"
|
||||
"hospital-admin-api/global"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type OrderPrescriptionDao struct {
|
||||
@ -100,6 +101,15 @@ func (r *OrderPrescriptionDao) GetOrderPrescriptionPageSearch(req requests.GetOr
|
||||
// 处方关联疾病表
|
||||
query = query.Preload("OrderPrescriptionIcd")
|
||||
|
||||
// 处方关联问诊表(抄方用)
|
||||
query = query.Preload("OrderInquiry", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("UserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
}).Preload("TransferUserDoctor", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Omit("open_id", "union_id", "wx_session_key")
|
||||
})
|
||||
})
|
||||
|
||||
// 患者家庭成员表
|
||||
query = query.Preload("PatientFamily")
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ type OrderInquiryDto struct {
|
||||
UserId string `json:"user_id"` // 用户id-患者
|
||||
PatientId string `json:"patient_id"` // 患者id
|
||||
DoctorId string `json:"doctor_id"` // 医生id(未分配时为null)
|
||||
TransferDoctorId string `json:"transfer_doctor_id"` // 接受抄方的医生id
|
||||
FamilyId string `json:"family_id"` // 家庭成员id(就诊用户)
|
||||
InquiryType int `json:"inquiry_type"` // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
|
||||
InquiryMode int `json:"inquiry_mode"` // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
@ -61,11 +62,17 @@ func GetOrderInquiryDto(m *model.OrderInquiry) *OrderInquiryDto {
|
||||
doctorId = fmt.Sprintf("%v", m.DoctorId)
|
||||
}
|
||||
|
||||
var transferDoctorId string
|
||||
if m.TransferDoctorId != 0 {
|
||||
transferDoctorId = fmt.Sprintf("%v", m.TransferDoctorId)
|
||||
}
|
||||
|
||||
return &OrderInquiryDto{
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
OrderId: fmt.Sprintf("%d", m.OrderId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
DoctorId: doctorId,
|
||||
TransferDoctorId: transferDoctorId,
|
||||
PatientId: fmt.Sprintf("%d", m.PatientId),
|
||||
FamilyId: fmt.Sprintf("%d", m.FamilyId),
|
||||
InquiryType: m.InquiryType,
|
||||
@ -113,6 +120,7 @@ func GetOrderInquiryListDto(m []*model.OrderInquiry) []*OrderInquiryDto {
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TransferDoctorId: fmt.Sprintf("%d", v.TransferDoctorId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
@ -172,6 +180,7 @@ func GetOrderInquiryRecordListDto(m []*model.OrderInquiry) []*OrderInquiryDto {
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TransferDoctorId: fmt.Sprintf("%d", v.TransferDoctorId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
@ -228,6 +237,7 @@ func GetOrderInquiryForAccountListDto(m []*model.OrderInquiry) []*OrderInquiryDt
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
PatientId: fmt.Sprintf("%d", v.PatientId),
|
||||
DoctorId: fmt.Sprintf("%d", v.DoctorId),
|
||||
TransferDoctorId: fmt.Sprintf("%d", v.TransferDoctorId),
|
||||
FamilyId: fmt.Sprintf("%d", v.FamilyId),
|
||||
InquiryType: v.InquiryType,
|
||||
InquiryMode: v.InquiryMode,
|
||||
@ -279,11 +289,17 @@ func GetOrderInquiryRecordDto(m *model.OrderInquiry) *OrderInquiryDto {
|
||||
doctorId = fmt.Sprintf("%v", m.DoctorId)
|
||||
}
|
||||
|
||||
var transferDoctorId string
|
||||
if m.TransferDoctorId != 0 {
|
||||
transferDoctorId = fmt.Sprintf("%v", m.TransferDoctorId)
|
||||
}
|
||||
|
||||
return &OrderInquiryDto{
|
||||
OrderInquiryId: fmt.Sprintf("%d", m.OrderInquiryId),
|
||||
OrderId: fmt.Sprintf("%d", m.OrderId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
DoctorId: doctorId,
|
||||
TransferDoctorId: transferDoctorId,
|
||||
PatientId: fmt.Sprintf("%d", m.PatientId),
|
||||
FamilyId: fmt.Sprintf("%d", m.FamilyId),
|
||||
InquiryType: m.InquiryType,
|
||||
|
||||
@ -37,6 +37,8 @@ type OrderPrescriptionDto struct {
|
||||
OrderPrescriptionIcd string `json:"order_prescription_icd"` // 处方诊断疾病
|
||||
OrderInquiryCase *OrderInquiryCaseDto `json:"order_inquiry_case"` // 问诊病例
|
||||
OrderPrescriptionProduct []*OrderPrescriptionProductDto `json:"order_prescription_product"` // 处方商品
|
||||
UserDoctor *UserDoctorDto `json:"user_doctor"` // 原始医生
|
||||
TransferUserDoctor *UserDoctorDto `json:"transfer_user_doctor"` // 接受抄方的医生
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
|
||||
}
|
||||
@ -125,6 +127,16 @@ func GetOrderPrescriptionListDto(m []*model.OrderPrescription) []*OrderPrescript
|
||||
response = response.LoadOrderPrescriptionIcdString(v.OrderPrescriptionIcd)
|
||||
}
|
||||
|
||||
// 加载原始医生信息
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.UserDoctor != nil {
|
||||
response = response.LoadUserDoctor(v.OrderInquiry.UserDoctor)
|
||||
}
|
||||
|
||||
// 加载接受抄方的医生信息
|
||||
if v.OrderInquiry != nil && v.OrderInquiry.TransferUserDoctor != nil {
|
||||
response = response.LoadTransferUserDoctor(v.OrderInquiry.TransferUserDoctor)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
@ -205,3 +217,19 @@ func (r *OrderPrescriptionDto) LoadOrderProductId(m *model.OrderProduct) *OrderP
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserDoctor 加载原始医生信息
|
||||
func (r *OrderPrescriptionDto) LoadUserDoctor(m *model.UserDoctor) *OrderPrescriptionDto {
|
||||
if m != nil {
|
||||
r.UserDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadTransferUserDoctor 加载接受抄方的医生信息
|
||||
func (r *OrderPrescriptionDto) LoadTransferUserDoctor(m *model.UserDoctor) *OrderPrescriptionDto {
|
||||
if m != nil {
|
||||
r.TransferUserDoctor = GetUserDoctorDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// OrderInquiry 订单-问诊表
|
||||
@ -13,6 +14,7 @@ type OrderInquiry struct {
|
||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id-患者;NOT NULL" json:"user_id"`
|
||||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id;NOT NULL" json:"patient_id"`
|
||||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id(未分配时为null)" json:"doctor_id"`
|
||||
TransferDoctorId int64 `gorm:"column:transfer_doctor_id;type:bigint(19);comment:接受抄方的医生id" json:"transfer_doctor_id"`
|
||||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
||||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测);NOT NULL" json:"inquiry_type"`
|
||||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);comment:订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||||
@ -42,6 +44,7 @@ type OrderInquiry struct {
|
||||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);default:0;comment:患者性别-就诊人(0:未知 1:男 2:女)" json:"patient_sex"`
|
||||
PatientAge int `gorm:"column:patient_age;type:int(1);comment:患者年龄-就诊人" json:"patient_age"`
|
||||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||||
TransferUserDoctor *UserDoctor `gorm:"foreignKey:TransferDoctorId;references:doctor_id" json:"transfer_user_doctor"` // 接受抄方的医生
|
||||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 患者
|
||||
Model
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user