|
@@ -626,7 +626,7 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
|
626
|
626
|
|
627
|
627
|
err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date = ?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
|
628
|
628
|
return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
|
629
|
|
- }).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date =?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
|
|
629
|
+ }).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ? and user_org_id = ? ", scheduleDate, orgid).Preload("DialysisPrescription", "status = 1 and record_date =? and user_org_id = ?", scheduleDate, orgid).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
|
630
|
630
|
return db.Where("status =1").Order("id asc")
|
631
|
631
|
}).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
|
632
|
632
|
return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, scheduleDate)
|
|
@@ -814,7 +814,7 @@ func UpdateNewScheduleTemplateStatus(id int64, org_id int64) (err error) {
|
814
|
814
|
return
|
815
|
815
|
}
|
816
|
816
|
|
817
|
|
-func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string) (schedules []*models.WeekScheduleSix, err error) {
|
|
817
|
+func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSix, err error) {
|
818
|
818
|
|
819
|
819
|
db := readDb.Table("xt_schedule as s ").Where("s.status =1")
|
820
|
820
|
if orgID > 0 {
|
|
@@ -838,14 +838,14 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
|
838
|
838
|
err = db.
|
839
|
839
|
Preload("DeviceZone", "status = 1 ").
|
840
|
840
|
Preload("DeviceNumber", "status = 1 ").
|
841
|
|
- Preload("XtAssessmentBeforeDislysis", "status = 1").
|
|
841
|
+ Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date = ?", record_date).
|
842
|
842
|
Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
|
843
|
843
|
return db.Where("status = 1").Order("id asc")
|
844
|
844
|
}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
|
845
|
845
|
return db.Where("status = 1").Order("id asc")
|
846
|
846
|
}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
|
847
|
|
- return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
|
848
|
|
- }).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
|
|
847
|
+ return db.Where("status =1 and parent_id = 0 and advice_date = ?", record_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", record_date)
|
|
848
|
+ }).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", record_date).Joins("JOIN xt_patients as p ON p.id = s.patient_id").
|
849
|
849
|
Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
|
850
|
850
|
Order("s.partition_id desc").
|
851
|
851
|
Find(&schedules).Error
|