15
This commit is contained in:
parent
e840e99388
commit
7a7b51382b
@ -444,6 +444,8 @@ func (r *OrderPrescriptionDao) GetOrderTransferPrescriptionExportListSearch(req
|
||||
|
||||
prescriptionTable := (&model.OrderPrescription{}).TableName()
|
||||
inquiryTable := (&model.OrderInquiry{}).TableName()
|
||||
userTable := (&model.User{}).TableName()
|
||||
|
||||
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.OrderPrescription{})
|
||||
@ -485,9 +487,13 @@ func (r *OrderPrescriptionDao) GetOrderTransferPrescriptionExportListSearch(req
|
||||
query = query.Where("prescription_code = ?", req.PrescriptionCode)
|
||||
}
|
||||
|
||||
// 医生名称
|
||||
// // 医生名称
|
||||
// if req.DoctorName != "" {
|
||||
// query = query.Where("doctor_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
// }
|
||||
// 医生名称 - 查询抄方医生名称
|
||||
if req.DoctorName != "" {
|
||||
query = query.Where("doctor_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
query = query.Where(userTable+".user_name LIKE ?", "%"+req.DoctorName+"%")
|
||||
}
|
||||
|
||||
// 患者姓名-就诊人
|
||||
@ -495,7 +501,7 @@ func (r *OrderPrescriptionDao) GetOrderTransferPrescriptionExportListSearch(req
|
||||
query = query.Where("patient_name LIKE ?", "%"+req.PatientName+"%")
|
||||
}
|
||||
|
||||
// 手机号-医生/患者/就诊人
|
||||
// 手机号-医生/患者/就诊人(医生部分改为抄方医生)
|
||||
if req.Mobile != "" {
|
||||
// 就诊人
|
||||
patientFamilySubQuery := global.Db.Model(&model.PatientFamily{}).
|
||||
@ -511,16 +517,20 @@ func (r *OrderPrescriptionDao) GetOrderTransferPrescriptionExportListSearch(req
|
||||
Select("patient_id").
|
||||
Where(gorm.Expr("user_id IN (?)", patientUserSubQuery))
|
||||
|
||||
// 医生
|
||||
doctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
// 抄方医生:通过手机号找到 user_id -> doctor_id(抄方医生)
|
||||
transferDoctorUserSubQuery := global.Db.Model(&model.User{}).
|
||||
Select("user_id").
|
||||
Where("mobile = ?", req.Mobile)
|
||||
|
||||
doctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
transferDoctorSubQuery := global.Db.Model(&model.UserDoctor{}).
|
||||
Select("doctor_id").
|
||||
Where(gorm.Expr("user_id IN (?)", doctorUserSubQuery))
|
||||
Where(gorm.Expr("user_id IN (?)", transferDoctorUserSubQuery))
|
||||
|
||||
query = query.Where("patient_id IN (?)", patientSubQuery).Or("doctor_id IN (?)", doctorSubQuery).Or("family_id IN (?)", patientFamilySubQuery)
|
||||
// 使用 OR 条件:患者匹配 OR 抄方医生匹配 OR 就诊人匹配(整体加括号)
|
||||
query = query.Where(
|
||||
gorm.Expr("("+prescriptionTable+".patient_id IN (?) OR "+inquiryTable+".doctor_id IN (?) OR "+prescriptionTable+".family_id IN (?))",
|
||||
patientSubQuery, transferDoctorSubQuery, patientFamilySubQuery),
|
||||
)
|
||||
}
|
||||
|
||||
// 处方状态
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user