|
@@ -11019,32 +11019,33 @@ func SaveDrugOpen(open models.XtDrugCodeOpen) error {
|
11019
|
11019
|
return err
|
11020
|
11020
|
}
|
11021
|
11021
|
|
11022
|
|
-func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit int64, page int64, is_sale int64) (list []*models.HisDoctorAdviceInfo, total int64, err error) {
|
|
11022
|
+func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit int64, page int64, is_sale int64, is_settle int64) (list []*models.NewHisDoctorAdviceInfo, total int64, err error) {
|
11023
|
11023
|
|
11024
|
|
- offset := (page - 1) * limit
|
11025
|
|
- db := XTReadDB().Model(&models.HisDoctorAdviceInfo{}).Where("status=1")
|
|
11024
|
+ db := XTReadDB().Model(&models.NewHisDoctorAdviceInfo{}).Preload("NewHisPrescription", "status = 1").Where("his_doctor_advice_info.status=1")
|
|
11025
|
+ if is_settle == 2 {
|
|
11026
|
+ db = db.Joins("join his_prescription on his_prescription.id = his_doctor_advice_info.prescription_id and his_prescription.order_status = 2 and his_prescription.status = 1")
|
|
11027
|
+
|
|
11028
|
+ } else if is_settle == 1 {
|
|
11029
|
+ db = db.Joins("join his_prescription on his_prescription.id = his_doctor_advice_info.prescription_id and his_prescription.order_status <> 2 and his_prescription.status = 1")
|
|
11030
|
+ }
|
11026
|
11031
|
|
11027
|
11032
|
if orgId > 0 {
|
11028
|
|
- db = db.Where("user_org_id=?", orgId)
|
|
11033
|
+ db = db.Where("his_doctor_advice_info.user_org_id=?", orgId)
|
11029
|
11034
|
}
|
11030
|
11035
|
if start_time > 0 {
|
11031
|
|
- db = db.Where("advice_date >= ?", start_time)
|
|
11036
|
+ db = db.Where("his_doctor_advice_info.advice_date >= ?", start_time)
|
11032
|
11037
|
}
|
11033
|
|
-
|
11034
|
11038
|
if end_time > 0 {
|
11035
|
|
- db = db.Where("advice_date<=?", end_time)
|
|
11039
|
+ db = db.Where("his_doctor_advice_info.advice_date<=?", end_time)
|
11036
|
11040
|
}
|
11037
|
|
-
|
|
11041
|
+ offset := (page - 1) * limit
|
11038
|
11042
|
if is_sale == 1 {
|
11039
|
|
- db = db.Where("is_upload = 1")
|
|
11043
|
+ db = db.Where("his_doctor_advice_info.is_upload = 1")
|
11040
|
11044
|
}
|
11041
|
11045
|
if is_sale == 2 {
|
11042
|
|
- db = db.Where("is_upload = 2 or is_upload =0")
|
|
11046
|
+ db = db.Where("his_doctor_advice_info.is_upload = 2 or his_doctor_advice_info.is_upload =0")
|
11043
|
11047
|
}
|
11044
|
|
-
|
11045
|
|
- err = db.Count(&total).Error
|
11046
|
|
-
|
11047
|
|
- err = db.Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
|
|
11048
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Order("his_doctor_advice_info.record_date desc").Find(&list).Error
|
11048
|
11049
|
|
11049
|
11050
|
return list, total, err
|
11050
|
11051
|
}
|