XMLWAN пре 2 година
родитељ
комит
45543282db

+ 3 - 3
controllers/dialysis_api_controller.go Прегледај датотеку

4803
 				}
4803
 				}
4804
 			}
4804
 			}
4805
 		}
4805
 		}
4806
-
4806
+		creater := this.GetAdminUserInfo().AdminUser.Id
4807
 		//执行出库逻辑
4807
 		//执行出库逻辑
4808
 		for _, item := range list {
4808
 		for _, item := range list {
4809
 			hisadvice := &models.HisDoctorAdviceInfo{
4809
 			hisadvice := &models.HisDoctorAdviceInfo{
4836
 				StopState:             item.StopState,
4836
 				StopState:             item.StopState,
4837
 				ParentId:              item.ParentId,
4837
 				ParentId:              item.ParentId,
4838
 				ExecutionTime:         item.ExecutionTime,
4838
 				ExecutionTime:         item.ExecutionTime,
4839
-				ExecutionStaff:        item.ExecutionStaff,
4839
+				ExecutionStaff:        creater,
4840
 				ExecutionState:        item.ExecutionState,
4840
 				ExecutionState:        item.ExecutionState,
4841
 				Checker:               item.Checker,
4841
 				Checker:               item.Checker,
4842
-				RecordDate:            item.ReminderDate,
4842
+				RecordDate:            item.RecordDate,
4843
 				DialysisOrderId:       item.DialysisOrderId,
4843
 				DialysisOrderId:       item.DialysisOrderId,
4844
 				CheckTime:             item.CheckTime,
4844
 				CheckTime:             item.CheckTime,
4845
 				CheckState:            item.CheckState,
4845
 				CheckState:            item.CheckState,

+ 1 - 0
controllers/doctors_api_controller.go Прегледај датотеку

1374
 	partition_type, _ := c.GetInt64("partition_type")
1374
 	partition_type, _ := c.GetInt64("partition_type")
1375
 	patient_id, _ := c.GetInt64("patient_id")
1375
 	patient_id, _ := c.GetInt64("patient_id")
1376
 	excution_way, _ := c.GetInt64("excution_way")
1376
 	excution_way, _ := c.GetInt64("excution_way")
1377
+	//cost_type, _ := c.GetInt64("cost_type")
1377
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
1378
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
1378
 		adviceType = 0
1379
 		adviceType = 0
1379
 	}
1380
 	}

+ 24 - 11
controllers/mobile_api_controllers/dialysis_api_controller.go Прегледај датотеку

105
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
105
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
106
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
106
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
107
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
107
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
108
+				dobulecheck, _ := service.GetAllDobuleCheckList(orgID, date.Unix())
108
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
109
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
109
-
110
 				for key, item := range scheduals {
110
 				for key, item := range scheduals {
111
 					// 获取患者信息
111
 					// 获取患者信息
112
 					for _, patient := range patients {
112
 					for _, patient := range patients {
178
 							break
178
 							break
179
 						}
179
 						}
180
 					}
180
 					}
181
+
182
+					for _, check := range dobulecheck {
183
+						if item.PatientId == check.PatientId {
184
+							scheduals[key].DoubleCheck = check
185
+							break
186
+						}
187
+					}
181
 				}
188
 				}
182
 				//缓存数据
189
 				//缓存数据
183
 				scheduals_json, err := json.Marshal(&scheduals)
190
 				scheduals_json, err := json.Marshal(&scheduals)
743
 		return
750
 		return
744
 	}
751
 	}
745
 
752
 
746
-	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
747
-
748
-		list, _ := service.GetRoleList(adminUserInfo.Org.Id, modifier)
749
-		if employee_number != list.JobNumber {
750
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorEmployeeNumber)
751
-			return
752
-		}
753
-	}
754
-
755
 	if len(recordDateStr) == 0 {
753
 	if len(recordDateStr) == 0 {
756
 		recordDateStr = time.Now().Format("2006-01-02")
754
 		recordDateStr = time.Now().Format("2006-01-02")
757
 	}
755
 	}
780
 		firstCheckDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", firstCheckTimeStr)
778
 		firstCheckDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", firstCheckTimeStr)
781
 		firstCheckDate = firstCheckDateUnix.Unix()
779
 		firstCheckDate = firstCheckDateUnix.Unix()
782
 	}
780
 	}
781
+
782
+	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
783
+
784
+		list, _ := service.GetRoleList(adminUserInfo.Org.Id, modifier)
785
+		if employee_number != list.JobNumber {
786
+			_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
787
+			c.ServeSuccessJSON(map[string]interface{}{
788
+				"doubleCheck": check,
789
+				"msg":         "2",
790
+			})
791
+			return
792
+		}
793
+	}
794
+
783
 	//now := time.Now()
795
 	//now := time.Now()
784
 	//year, month, day := now.Date()
796
 	//year, month, day := now.Date()
785
 	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
797
 	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
841
 		if err == nil {
853
 		if err == nil {
842
 			c.ServeSuccessJSON(map[string]interface{}{
854
 			c.ServeSuccessJSON(map[string]interface{}{
843
 				"doubleCheck": &doubleCheck,
855
 				"doubleCheck": &doubleCheck,
856
+				"msg":         "1",
844
 			})
857
 			})
845
 		}
858
 		}
846
 
859
 
2443
 		}
2456
 		}
2444
 		//针对兰溪人民医院的需求
2457
 		//针对兰溪人民医院的需求
2445
 		if adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 9671 {
2458
 		if adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 9671 {
2446
-			befor, _ := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
2459
+			befor, _ := service.GetAssessmentBeforThrity(adminUserInfo.Org.Id, patientID, recordDate.Unix())
2447
 			record.SystolicBloodPressure = befor.SystolicBloodPressure
2460
 			record.SystolicBloodPressure = befor.SystolicBloodPressure
2448
 			record.DiastolicBloodPressure = befor.DiastolicBloodPressure
2461
 			record.DiastolicBloodPressure = befor.DiastolicBloodPressure
2449
 			record.Temperature = befor.Temperature
2462
 			record.Temperature = befor.Temperature

+ 1 - 0
controllers/mobile_api_controllers/dialysis_api_controller_extend.go Прегледај датотеку

509
 				Status:       1,
509
 				Status:       1,
510
 				CreatedTime:  time.Now().Unix(),
510
 				CreatedTime:  time.Now().Unix(),
511
 				UpdatedTime:  time.Now().Unix(),
511
 				UpdatedTime:  time.Now().Unix(),
512
+				IsExport:     5,
512
 			}
513
 			}
513
 			createErr := service.CreateSchedule(newSchedule)
514
 			createErr := service.CreateSchedule(newSchedule)
514
 			redis := service.RedisClient()
515
 			redis := service.RedisClient()

+ 1 - 0
controllers/schedule_api_controller.go Прегледај датотеку

332
 	schedule.UpdatedTime = time.Now().Unix()
332
 	schedule.UpdatedTime = time.Now().Unix()
333
 	schedule.Status = 1
333
 	schedule.Status = 1
334
 	schedule.UserOrgId = adminUserInfo.CurrentOrgId
334
 	schedule.UserOrgId = adminUserInfo.CurrentOrgId
335
+	schedule.IsExport = 5
335
 
336
 
336
 	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
337
 	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
337
 	if bed == nil {
338
 	if bed == nil {

+ 1 - 0
models/his_models.go Прегледај датотеку

258
 	IsMedicine            int64                  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
258
 	IsMedicine            int64                  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
259
 	ExecutionFrequencyId  int64                  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
259
 	ExecutionFrequencyId  int64                  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
260
 	Child                 []*HisDoctorAdviceInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
260
 	Child                 []*HisDoctorAdviceInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
261
+	IsSettle              int64                  `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
261
 }
262
 }
262
 
263
 
263
 func (HisDoctorAdviceInfo) TableName() string {
264
 func (HisDoctorAdviceInfo) TableName() string {

+ 1 - 0
models/patient_models.go Прегледај датотеку

459
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
459
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
460
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
460
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
461
 	MaxUltrafiltrationRate     string  `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
461
 	MaxUltrafiltrationRate     string  `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
462
+	WaterMachine               string  `gorm:"column:water_machine" json:"water_machine" form:"water_machine"`
462
 }
463
 }
463
 
464
 
464
 func (DialysisPrescriptionList) TableName() string {
465
 func (DialysisPrescriptionList) TableName() string {

+ 1 - 1
service/dialysis_service.go Прегледај датотеку

1900
 
1900
 
1901
 func UpdateHisDoctorAdviceExecution(info models.HisDoctorAdviceInfo, id int64) error {
1901
 func UpdateHisDoctorAdviceExecution(info models.HisDoctorAdviceInfo, id int64) error {
1902
 
1902
 
1903
-	err := XTWriteDB().Where("id = ? and status = 1", id).Update(map[string]interface{}{"execution_staff": info.ExecutionStaff, "execution_state": info.ExecutionState, "execution_time": info.ExecutionTime, "updated_time": info.ExecutionTime}).Error
1903
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Update(map[string]interface{}{"execution_staff": info.ExecutionStaff, "execution_state": info.ExecutionState, "execution_time": info.ExecutionTime, "updated_time": info.ExecutionTime}).Error
1904
 	return err
1904
 	return err
1905
 }
1905
 }
1906
 
1906
 

+ 384 - 2
service/mobile_dialysis_service.go Прегледај датотеку

139
 	Advices                  []models.VMDoctorAdviceForList    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
139
 	Advices                  []models.VMDoctorAdviceForList    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
140
 	TreatmentSummary         *models.VMTreatmentSummaryForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
140
 	TreatmentSummary         *models.VMTreatmentSummaryForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
141
 	DialysisSolution         *models.DialysisSolution          `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
141
 	DialysisSolution         *models.DialysisSolution          `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
142
+	DoubleCheck              *models.DoubleCheck               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dobule_check"`
142
 }
143
 }
143
 
144
 
144
 func (MDialysisScheduleVMForList) TableName() string {
145
 func (MDialysisScheduleVMForList) TableName() string {
446
 	var vm MDialysisScheduleVM
447
 	var vm MDialysisScheduleVM
447
 
448
 
448
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedualDate, 10) + ":schedual_detail"
449
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedualDate, 10) + ":schedual_detail"
450
+	redis.Set(key, "", time.Second)
449
 	schedual_detail_str, _ := redis.Get(key).Result()
451
 	schedual_detail_str, _ := redis.Get(key).Result()
450
 
452
 
451
 	if len(schedual_detail_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
453
 	if len(schedual_detail_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
829
 	return &record, nil
831
 	return &record, nil
830
 }
832
 }
831
 
833
 
834
+//func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
835
+//  var record models.DialysisOrder
836
+//
837
+//  err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
838
+//
839
+//
840
+//  return &record,err
841
+//}
842
+
832
 // 透析记录
843
 // 透析记录
833
 func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
844
 func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
834
 	var record models.DialysisOrder
845
 	var record models.DialysisOrder
836
 	defer redis.Close()
847
 	defer redis.Close()
837
 
848
 
838
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
849
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
839
-	redis.Set(key, "", time.Second)
840
 	dialysis_order_str, _ := redis.Get(key).Result()
850
 	dialysis_order_str, _ := redis.Get(key).Result()
851
+
841
 	if len(dialysis_order_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
852
 	if len(dialysis_order_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
842
 		err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
853
 		err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
843
 		if err != nil {
854
 		if err != nil {
1358
 	TemplateId            string  `gorm:"column:template_id" json:"template_id"`
1369
 	TemplateId            string  `gorm:"column:template_id" json:"template_id"`
1359
 	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
1370
 	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
1360
 	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1371
 	IsMedicine            int64   `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1372
+	IsSettle              int64   `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
1361
 }
1373
 }
1362
 
1374
 
1363
 func (MDoctorAdviceVM) TableName() string {
1375
 func (MDoctorAdviceVM) TableName() string {
2928
 	return &evaluation, nil
2940
 	return &evaluation, nil
2929
 }
2941
 }
2930
 
2942
 
2943
+func GetAssessmentBeforThrity(orgid int64, patientid int64, recorddate int64) (models.PredialysisEvaluation, error) {
2944
+
2945
+	evaluation := models.PredialysisEvaluation{}
2946
+
2947
+	err := XTReadDB().Model(&evaluation).Where("user_org_id = ? and patient_id = ? and assessment_date = ? and status = 1", orgid, patientid, recorddate).Find(&evaluation).Error
2948
+
2949
+	return evaluation, err
2950
+}
2951
+
2931
 func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
2952
 func GetAllHisDoctorAdvice(orgid int64, patientid int64, recorddate int64) (his []*models.HisDoctorAdviceInfo, err error) {
2932
 	redis := RedisClient()
2953
 	redis := RedisClient()
2933
 	defer redis.Close()
2954
 	defer redis.Close()
3110
 	return advice, err
3131
 	return advice, err
3111
 }
3132
 }
3112
 
3133
 
3113
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64) ([]*MScheduleDoctorAdviceVM, error) {
3134
+func MobileGetScheduleDoctorAdvicesSix(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64) ([]*MScheduleDoctorAdviceVM, error) {
3114
 	var vms []*MScheduleDoctorAdviceVM
3135
 	var vms []*MScheduleDoctorAdviceVM
3115
 	adviceWhere := ""
3136
 	adviceWhere := ""
3116
 	adviceCondition := []interface{}{}
3137
 	adviceCondition := []interface{}{}
4142
 	err := XTReadDB().Where("org_id = ? and patient_id = ? and monitoring_date = ? and status = 1", orgid, patient_id, dialysis_date).Find(&record).Error
4163
 	err := XTReadDB().Where("org_id = ? and patient_id = ? and monitoring_date = ? and status = 1", orgid, patient_id, dialysis_date).Find(&record).Error
4143
 	return record, err
4164
 	return record, err
4144
 }
4165
 }
4166
+
4167
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64) ([]*MScheduleDoctorAdviceVM, error) {
4168
+	var vms []*MScheduleDoctorAdviceVM
4169
+	adviceWhere := ""
4170
+	adviceCondition := []interface{}{}
4171
+	if adviceType == 0 {
4172
+		if patientType == 0 {
4173
+			if patient_id > 0 {
4174
+				if execution_state > 0 {
4175
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
4176
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4177
+				} else {
4178
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
4179
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4180
+				}
4181
+
4182
+			} else {
4183
+				if execution_state > 0 {
4184
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ?"
4185
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4186
+				} else {
4187
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
4188
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4189
+				}
4190
+
4191
+			}
4192
+
4193
+		} else if patientType == 1 {
4194
+			if patient_id > 0 {
4195
+				if execution_state > 0 {
4196
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
4197
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
4198
+				} else {
4199
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
4200
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
4201
+				}
4202
+
4203
+			} else {
4204
+				if execution_state > 0 {
4205
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
4206
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
4207
+				} else {
4208
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
4209
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
4210
+				}
4211
+
4212
+			}
4213
+
4214
+		} else if patientType == 2 {
4215
+			if patient_id > 0 {
4216
+				if execution_state > 0 {
4217
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ?"
4218
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4219
+				} else {
4220
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
4221
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4222
+				}
4223
+
4224
+			} else {
4225
+				if execution_state > 0 {
4226
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
4227
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4228
+				} else {
4229
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
4230
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4231
+				}
4232
+
4233
+			}
4234
+
4235
+		}
4236
+
4237
+	} else if adviceType == 1 {
4238
+		if patientType == 0 {
4239
+			if patient_id > 0 {
4240
+				if execution_state > 0 {
4241
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ?"
4242
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4243
+				} else {
4244
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
4245
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4246
+				}
4247
+
4248
+			} else {
4249
+				if execution_state > 0 {
4250
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and execution_state = ?"
4251
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4252
+				} else {
4253
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
4254
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4255
+				}
4256
+
4257
+			}
4258
+
4259
+		} else if patientType == 1 {
4260
+			if patient_id > 0 {
4261
+				if execution_state > 0 {
4262
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ? and execution_state = ?"
4263
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
4264
+				} else {
4265
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
4266
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
4267
+				}
4268
+
4269
+			} else {
4270
+				if execution_state > 0 {
4271
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and execution_state=?"
4272
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
4273
+				} else {
4274
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
4275
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
4276
+				}
4277
+
4278
+			}
4279
+
4280
+		} else if patientType == 2 {
4281
+			if patient_id > 0 {
4282
+				if execution_state > 0 {
4283
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ? and execution_state = ?"
4284
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4285
+				} else {
4286
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
4287
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4288
+				}
4289
+
4290
+			} else {
4291
+				if execution_state > 0 {
4292
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and execution_state = ?"
4293
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4294
+				} else {
4295
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
4296
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4297
+				}
4298
+
4299
+			}
4300
+
4301
+		}
4302
+
4303
+	} else if adviceType == 3 {
4304
+		if patientType == 0 {
4305
+			if patient_id > 0 {
4306
+				if execution_state > 0 {
4307
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ? and  execution_state = ?"
4308
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4309
+				} else {
4310
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ?  "
4311
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4312
+				}
4313
+
4314
+			} else {
4315
+				if execution_state > 0 {
4316
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and execution_state =? "
4317
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4318
+				} else {
4319
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
4320
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4321
+				}
4322
+
4323
+			}
4324
+
4325
+		} else if patientType == 1 {
4326
+			if patient_id > 0 {
4327
+				if execution_state > 0 {
4328
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ? and execution_state = ?"
4329
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
4330
+				} else {
4331
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
4332
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
4333
+				}
4334
+
4335
+			} else {
4336
+				if execution_state > 0 {
4337
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and execution_state =? "
4338
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
4339
+				} else {
4340
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
4341
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
4342
+				}
4343
+
4344
+			}
4345
+
4346
+		} else if patientType == 2 {
4347
+			if patient_id > 0 {
4348
+				if execution_state > 0 {
4349
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0 and patient_id = ? and execution_state = ?"
4350
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4351
+				} else {
4352
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0 and patient_id = ?"
4353
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4354
+				}
4355
+
4356
+			} else {
4357
+				if execution_state > 0 {
4358
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0 and execution_state= ?"
4359
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4360
+				} else {
4361
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
4362
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4363
+				}
4364
+
4365
+			}
4366
+
4367
+		}
4368
+
4369
+	} else if adviceType == 2 && len(deliverWay) > 0 {
4370
+		if patientType == 0 {
4371
+			if patient_id > 0 {
4372
+				if execution_state > 0 {
4373
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ? and execution_state = ?"
4374
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id, execution_state)
4375
+				} else {
4376
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
4377
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
4378
+				}
4379
+
4380
+			} else {
4381
+				if execution_state > 0 {
4382
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and execution_state = ?"
4383
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, execution_state)
4384
+				} else {
4385
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
4386
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
4387
+				}
4388
+
4389
+			}
4390
+
4391
+		} else if patientType == 1 {
4392
+			if patient_id > 0 {
4393
+				if execution_state > 0 {
4394
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? and patient_id = ? and execution_state = ?"
4395
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id, execution_state)
4396
+				} else {
4397
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? and patient_id = ?"
4398
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
4399
+				}
4400
+
4401
+			} else {
4402
+				if execution_state > 0 {
4403
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? and execution_state = ?"
4404
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, execution_state)
4405
+				} else {
4406
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
4407
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
4408
+				}
4409
+
4410
+			}
4411
+
4412
+		} else if patientType == 2 {
4413
+			if patient_id > 0 {
4414
+				if execution_state > 0 {
4415
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ? and patient_id = ? and execution_state = ?"
4416
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id, execution_state)
4417
+				} else {
4418
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ? and patient_id = ?"
4419
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
4420
+				}
4421
+
4422
+			} else {
4423
+				if execution_state > 0 {
4424
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ? and execution_state = ?"
4425
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, execution_state)
4426
+				} else {
4427
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
4428
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
4429
+				}
4430
+
4431
+			}
4432
+
4433
+		}
4434
+
4435
+	} else if adviceType == 2 && len(deliverWay) <= 0 {
4436
+		if patientType == 0 {
4437
+			if patient_id > 0 {
4438
+				if execution_state > 0 {
4439
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ? and execution_state = ?"
4440
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4441
+				} else {
4442
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
4443
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4444
+				}
4445
+
4446
+			} else {
4447
+				if execution_state > 0 {
4448
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and execution_state = ?"
4449
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4450
+				} else {
4451
+					adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
4452
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4453
+				}
4454
+
4455
+			}
4456
+
4457
+		} else if patientType == 1 {
4458
+			if patient_id > 0 {
4459
+				if execution_state > 0 {
4460
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ? and execution_state = ?"
4461
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
4462
+				} else {
4463
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
4464
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
4465
+				}
4466
+
4467
+			} else {
4468
+				if execution_state > 0 {
4469
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and execution_state = ?"
4470
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
4471
+				} else {
4472
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
4473
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
4474
+				}
4475
+
4476
+			}
4477
+
4478
+		} else if patientType == 2 {
4479
+			if patient_id > 0 {
4480
+				if execution_state > 0 {
4481
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and patient_id = ? and execution_state = ?"
4482
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4483
+				} else {
4484
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and patient_id = ?"
4485
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4486
+				}
4487
+
4488
+			} else {
4489
+				if execution_state > 0 {
4490
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and execution_state = ?"
4491
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4492
+				} else {
4493
+					adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
4494
+					adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4495
+				}
4496
+
4497
+			}
4498
+
4499
+		}
4500
+
4501
+	}
4502
+
4503
+	db := readDb.Table("xt_schedule")
4504
+	if scheduleType > 0 {
4505
+		db = db.Where("schedule_type = ?", scheduleType)
4506
+	}
4507
+	if partitonType > 0 {
4508
+		db = db.Where("partition_id = ?", partitonType)
4509
+	}
4510
+	db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
4511
+		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
4512
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
4513
+		}).
4514
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
4515
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
4516
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
4517
+		Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
4518
+		Preload("DoctorAdvices", adviceCondition...).
4519
+		Where("status = 1 AND user_org_id = ?", orgID)
4520
+	if scheduleDate != 0 {
4521
+		db = db.Where("schedule_date = ?", scheduleDate)
4522
+	}
4523
+
4524
+	err := db.Find(&vms).Error
4525
+	return vms, err
4526
+}

+ 89 - 71
service/patient_service.go Прегледај датотеку

221
 }
221
 }
222
 
222
 
223
 func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
223
 func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
224
-	redis := RedisClient()
225
-	defer redis.Close()
226
-	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
227
-	prescriptions_list_all, _ := redis.Get(key).Result()
228
 
224
 
229
-	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
230
-		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
231
-		if err != nil {
232
-			if err == gorm.ErrRecordNotFound {
233
-				if len(prescriptions) <= 0 {
234
-					redis.Set(key, "null", time.Second*60*60*18)
235
-				}
236
-				return nil, nil
237
-			} else {
238
-				return nil, err
239
-			}
240
-		} else {
241
-			if len(prescriptions) > 0 {
242
-				//缓存数据
243
-				prescriptions_list_all, err := json.Marshal(&prescriptions)
244
-				if err == nil {
245
-					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
246
-				}
247
-			} else {
248
-				redis.Set(key, "null", time.Second*60*60*18)
249
-			}
250
-			return prescriptions, nil
251
-		}
252
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
253
-		if prescriptions_list_all == "null" {
254
-			return nil, nil
255
-		} else {
256
-			json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
257
-			return prescriptions, nil
258
-		}
259
-
260
-	}
261
-}
225
+	err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
226
+	return prescriptions, err
227
+}
228
+
229
+//func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
230
+//	redis := RedisClient()
231
+//	defer redis.Close()
232
+//	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
233
+//	prescriptions_list_all, _ := redis.Get(key).Result()
234
+//  redis.Set(prescriptions_list_all, "", time.Second)
235
+//	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
236
+//		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
237
+//		if err != nil {
238
+//			if err == gorm.ErrRecordNotFound {
239
+//				if len(prescriptions) <= 0 {
240
+//					redis.Set(key, "null", time.Second*60*60*18)
241
+//				}
242
+//				return nil, nil
243
+//			} else {
244
+//				return nil, err
245
+//			}
246
+//		} else {
247
+//			if len(prescriptions) > 0 {
248
+//				//缓存数据
249
+//				prescriptions_list_all, err := json.Marshal(&prescriptions)
250
+//				if err == nil {
251
+//					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
252
+//				}
253
+//			} else {
254
+//				redis.Set(key, "null", time.Second*60*60*18)
255
+//			}
256
+//			return prescriptions, nil
257
+//		}
258
+//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
259
+//		if prescriptions_list_all == "null" {
260
+//			return nil, nil
261
+//		} else {
262
+//			json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
263
+//			return prescriptions, nil
264
+//		}
265
+//
266
+//	}
267
+//}
262
 
268
 
263
 func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluationList, err error) {
269
 func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluationList, err error) {
264
 	redis := RedisClient()
270
 	redis := RedisClient()
300
 }
306
 }
301
 
307
 
302
 func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
308
 func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
303
-	redis := RedisClient()
304
-	defer redis.Close()
305
-	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
306
-	dialysis_orders_list_all, _ := redis.Get(key).Result()
307
-	redis.Set(dialysis_orders_list_all, "", time.Second)
308
-	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
309
-		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
310
 
309
 
311
-		if err != nil {
312
-			if err == gorm.ErrRecordNotFound {
313
-				return nil, nil
314
-			} else {
315
-				return nil, err
316
-			}
317
-		} else {
318
-			if len(dialysisOrders) > 0 {
319
-				//缓存数据
320
-				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
321
-				if err == nil {
322
-					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
323
-				}
324
-			} else {
325
-				redis.Set(key, "null", time.Second*60*60*18)
326
-			}
327
-			return dialysisOrders, nil
328
-		}
329
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
330
-		if dialysis_orders_list_all == "null" {
331
-			return nil, nil
332
-		} else {
333
-			json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
334
-			return dialysisOrders, nil
335
-		}
336
-
337
-	}
310
+	err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
311
+	return dialysisOrders, err
338
 }
312
 }
339
 
313
 
314
+//func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
315
+//	redis := RedisClient()
316
+//	defer redis.Close()
317
+//	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
318
+//	dialysis_orders_list_all, _ := redis.Get(key).Result()
319
+//	redis.Set(dialysis_orders_list_all, "", time.Second)
320
+//	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
321
+//		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
322
+//
323
+//		if err != nil {
324
+//			if err == gorm.ErrRecordNotFound {
325
+//				return nil, nil
326
+//			} else {
327
+//				return nil, err
328
+//			}
329
+//		} else {
330
+//			if len(dialysisOrders) > 0 {
331
+//				//缓存数据
332
+//				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
333
+//				if err == nil {
334
+//					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
335
+//				}
336
+//			} else {
337
+//				redis.Set(key, "null", time.Second*60*60*18)
338
+//			}
339
+//			return dialysisOrders, nil
340
+//		}
341
+//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
342
+//		if dialysis_orders_list_all == "null" {
343
+//			return nil, nil
344
+//		} else {
345
+//			json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
346
+//			return dialysisOrders, nil
347
+//		}
348
+//
349
+//	}
350
+//}
351
+
340
 func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*models.VMTreatmentSummaryForList, err error) {
352
 func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*models.VMTreatmentSummaryForList, err error) {
341
 	redis := RedisClient()
353
 	redis := RedisClient()
342
 	defer redis.Close()
354
 	defer redis.Close()
416
 	}
428
 	}
417
 }
429
 }
418
 
430
 
431
+func GetAllDobuleCheckList(orgID int64, scheduleDate int64) (dobulecheck []*models.DoubleCheck, err error) {
432
+
433
+	err = XTReadDB().Where("check_date = ? and user_org_id = ? and status = 1", scheduleDate, orgID).Find(&dobulecheck).Error
434
+	return dobulecheck, err
435
+}
436
+
419
 func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHisDoctorAdviceInfo, err error) {
437
 func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHisDoctorAdviceInfo, err error) {
420
 	redis := RedisClient()
438
 	redis := RedisClient()
421
 	defer redis.Close()
439
 	defer redis.Close()