Browse Source

Merge branch 'xt_statistics_branch' of http://git.shengws.com/csx/XT_New into xt_statistics_branch

XMLWAN 4 years ago
parent
commit
7461812c21
1 changed files with 56 additions and 69 deletions
  1. 56 69
      service/statistics_service/index_evaluation_service.go

+ 56 - 69
service/statistics_service/index_evaluation_service.go View File

183
 	switch statistics_type {
183
 	switch statistics_type {
184
 	case 1:
184
 	case 1:
185
 		if patient_id == 0 {
185
 		if patient_id == 0 {
186
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.systolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? AND systolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
186
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.systolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? AND systolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
187
 
187
 
188
 		} else {
188
 		} else {
189
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.systolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? AND systolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
189
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.systolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? AND systolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
190
 		}
190
 		}
191
 		break
191
 		break
192
 	case 2:
192
 	case 2:
193
 
193
 
194
 		if patient_id == 0 {
194
 		if patient_id == 0 {
195
 
195
 
196
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.diastolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? AND diastolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
196
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.diastolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? AND diastolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
197
 
197
 
198
 		} else {
198
 		} else {
199
 
199
 
200
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.diastolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? AND diastolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
200
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.diastolic_blood_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? AND diastolic_blood_pressure <> 0 Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
201
 
201
 
202
 		}
202
 		}
203
 
203
 
204
 		break
204
 		break
205
 	case 3:
205
 	case 3:
206
 		if patient_id == 0 {
206
 		if patient_id == 0 {
207
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.pulse_frequency as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
207
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.pulse_frequency as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
208
 
208
 
209
 		} else {
209
 		} else {
210
 
210
 
211
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.pulse_frequency as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
211
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.pulse_frequency as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
212
 
212
 
213
 		}
213
 		}
214
 		break
214
 		break
215
 	case 4:
215
 	case 4:
216
 		if patient_id == 0 {
216
 		if patient_id == 0 {
217
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.breathing_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
217
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.breathing_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
218
 
218
 
219
 		} else {
219
 		} else {
220
 
220
 
221
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.breathing_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
221
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.breathing_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
222
 
222
 
223
 		}
223
 		}
224
 		break
224
 		break
225
 	case 5:
225
 	case 5:
226
 		if patient_id == 0 {
226
 		if patient_id == 0 {
227
 
227
 
228
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
228
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
229
 
229
 
230
 		} else {
230
 		} else {
231
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND operate_time <= ? AND  operate_time >= ?Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
231
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND operate_time <= ? AND  operate_time >= ?Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
232
 
232
 
233
 		}
233
 		}
234
 		break
234
 		break
235
 	case 6:
235
 	case 6:
236
 		if patient_id == 0 {
236
 		if patient_id == 0 {
237
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.blood_flow_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND    operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
237
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.blood_flow_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND    operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
238
 
238
 
239
 		} else {
239
 		} else {
240
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.blood_flow_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
240
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.blood_flow_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
241
 
241
 
242
 		}
242
 		}
243
 		break
243
 		break
244
 	case 7:
244
 	case 7:
245
 		if patient_id == 0 {
245
 		if patient_id == 0 {
246
 
246
 
247
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.venous_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
247
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.venous_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
248
 
248
 
249
 		} else {
249
 		} else {
250
 
250
 
251
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.venous_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
251
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.venous_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
252
 
252
 
253
 		}
253
 		}
254
 		break
254
 		break
255
 	case 8:
255
 	case 8:
256
 		if patient_id == 0 {
256
 		if patient_id == 0 {
257
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.arterial_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ?  AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
257
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.arterial_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ?  AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
258
 
258
 
259
 		} else {
259
 		} else {
260
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.arterial_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
260
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.arterial_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
261
 		}
261
 		}
262
 		break
262
 		break
263
 	case 9:
263
 	case 9:
264
 		if patient_id == 0 {
264
 		if patient_id == 0 {
265
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.transmembrane_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
265
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.transmembrane_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
266
 
266
 
267
 		} else {
267
 		} else {
268
 
268
 
269
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.transmembrane_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
269
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.transmembrane_pressure as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
270
 
270
 
271
 		}
271
 		}
272
 
272
 
273
 		break
273
 		break
274
 	case 10:
274
 	case 10:
275
 		if patient_id == 0 {
275
 		if patient_id == 0 {
276
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.dialysate_temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by  operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
276
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.dialysate_temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by  operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
277
 
277
 
278
 		} else {
278
 		} else {
279
 
279
 
280
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.dialysate_temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
280
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.dialysate_temperature as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
281
 
281
 
282
 		}
282
 		}
283
 
283
 
284
 		break
284
 		break
285
 	case 11:
285
 	case 11:
286
 		if patient_id == 0 {
286
 		if patient_id == 0 {
287
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.ultrafiltration_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
287
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.ultrafiltration_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
288
 
288
 
289
 		} else {
289
 		} else {
290
 
290
 
291
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.ultrafiltration_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
291
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.ultrafiltration_rate as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
292
 
292
 
293
 		}
293
 		}
294
 
294
 
295
 		break
295
 		break
296
 	case 12:
296
 	case 12:
297
 		if patient_id == 0 {
297
 		if patient_id == 0 {
298
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.ultrafiltration_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
298
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.ultrafiltration_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND  operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, end_time, start_time).Scan(&datas).Error
299
 
299
 
300
 		} else {
300
 		} else {
301
 
301
 
302
-			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d %H:%i') as date, monitor.ultrafiltration_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
302
+			err = db.Raw("select from_unixtime(monitor.operate_time,'%Y-%m-%d') as date, monitor.ultrafiltration_volume as value from xt_monitoring_record as monitor Where status = 1 AND user_org_id = ? AND patient_id = ?  AND operate_time <= ? AND  operate_time >= ? Order by operate_time asc", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
303
 
303
 
304
 		}
304
 		}
305
 
305
 
1121
 	db = db.Preload("VMPredialysisEvaluation", "status = 1 AND user_org_id = ?", orgID).
1121
 	db = db.Preload("VMPredialysisEvaluation", "status = 1 AND user_org_id = ?", orgID).
1122
 		Preload("VMAssessmentAfterDislysis", "status = 1 AND user_org_id = ?", orgID).
1122
 		Preload("VMAssessmentAfterDislysis", "status = 1 AND user_org_id = ?", orgID).
1123
 		Preload("VMMinMonitoringRecord", func(db *gorm.DB) *gorm.DB {
1123
 		Preload("VMMinMonitoringRecord", func(db *gorm.DB) *gorm.DB {
1124
-			return db.Where("status = 1 AND user_org_id = ?", orgID).Order("diastolic_blood_pressure DESC")
1124
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Order("diastolic_blood_pressure ASC")
1125
 		}).
1125
 		}).
1126
 		Preload("VMMaxMonitoringRecord", func(db *gorm.DB) *gorm.DB {
1126
 		Preload("VMMaxMonitoringRecord", func(db *gorm.DB) *gorm.DB {
1127
-			return db.Where("status = 1 AND user_org_id = ?", orgID).Order("systolic_blood_pressure ASC")
1127
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Order("systolic_blood_pressure DESC")
1128
 		}).
1128
 		}).
1129
 		Preload("VMPatients", "status = 1 AND user_org_id = ?", orgID)
1129
 		Preload("VMPatients", "status = 1 AND user_org_id = ?", orgID)
1130
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("sch.schedule_date desc").Select(" sch.schedule_date,sch.patient_id,sch.user_org_id").Find(&orders).Error
1130
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("sch.schedule_date desc").Select(" sch.schedule_date,sch.patient_id,sch.user_org_id").Find(&orders).Error
1185
 		break
1185
 		break
1186
 	case 2:
1186
 	case 2:
1187
 		var Total int64
1187
 		var Total int64
1188
-		db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND ctime >= ? AND ctime <= ?", user_org_id, start_time, end_time).Count(&Total)
1188
+		db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND record_time >= ? AND record_time <= ?", user_org_id, start_time, end_time).Count(&Total)
1189
 
1189
 
1190
 		for _, item := range datas {
1190
 		for _, item := range datas {
1191
 			var total int64
1191
 			var total int64
1192
-			db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND recorder = ? AND ctime >= ? AND ctime <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1192
+			db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND recorder = ? AND record_time >= ? AND record_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1193
 			item.CourseCount = total
1193
 			item.CourseCount = total
1194
 
1194
 
1195
 			if math.IsNaN(float64(item.CourseCount) / float64(Total)) {
1195
 			if math.IsNaN(float64(item.CourseCount) / float64(Total)) {
1205
 	case 3:
1205
 	case 3:
1206
 		var Total int64
1206
 		var Total int64
1207
 
1207
 
1208
-		db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1  AND ctime >= ? AND ctime <= ?", user_org_id, start_time, end_time).Count(&Total)
1208
+		db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1  AND record_time >= ? AND record_time <= ?", user_org_id, start_time, end_time).Count(&Total)
1209
 
1209
 
1210
 		for _, item := range datas {
1210
 		for _, item := range datas {
1211
 			var total int64
1211
 			var total int64
1212
-			db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1 AND recorder = ?  AND ctime >= ? AND ctime <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1212
+			db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1 AND recorder = ?  AND record_time >= ? AND record_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1213
 			item.RescueCount = total
1213
 			item.RescueCount = total
1214
 
1214
 
1215
 			if math.IsNaN(float64(item.RescueCount) / float64(Total)) {
1215
 			if math.IsNaN(float64(item.RescueCount) / float64(Total)) {
1243
 		var TotalOne int64
1243
 		var TotalOne int64
1244
 		var TotalTwo int64
1244
 		var TotalTwo int64
1245
 		db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1 AND prescription_doctor = ?  AND record_date >= ? AND  record_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1245
 		db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1 AND prescription_doctor = ?  AND record_date >= ? AND  record_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1246
-		db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND recorder = ? AND ctime >= ? AND ctime <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
1247
-		db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1 AND recorder = ? AND ctime >= ? AND ctime <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalTwo)
1246
+		db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND recorder = ? AND record_time >= ? AND record_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
1247
+		db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1 AND recorder = ? AND record_time >= ? AND record_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalTwo)
1248
 		item.PCount = Total
1248
 		item.PCount = Total
1249
 		item.CourseCount = TotalOne
1249
 		item.CourseCount = TotalOne
1250
 		item.RescueCount = TotalTwo
1250
 		item.RescueCount = TotalTwo
1261
 	userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 3 ", user_org_id).Scan(&datas)
1261
 	userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 3 ", user_org_id).Scan(&datas)
1262
 
1262
 
1263
 	var NewTotalOne int64
1263
 	var NewTotalOne int64
1264
-	var NewTotalTwo int64
1265
 	var NewTotalThree int64
1264
 	var NewTotalThree int64
1266
 	var NewTotalFour int64
1265
 	var NewTotalFour int64
1267
 
1266
 
1268
-	var tempConfig models.Dataconfig
1269
-	db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1267
+	//var tempConfig models.Dataconfig
1268
+	//db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1269
+
1270
+	//db.Raw("select count(*) as total from xt_dialysis_order where status = 1 AND dialysis_date >= ? AND dialysis_date <= ? AND user_org_id = ?",start_time,end_time,user_org_id).Count(&NewTotalOne)
1271
+	//db.Raw("select count(*) as total_one from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0  Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, start_time, end_time).Count(&NewTotalTwo)
1270
 
1272
 
1271
-	db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('内瘘',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1   AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, start_time, end_time).Count(&NewTotalOne)
1272
-	db.Raw("select count(*) as total_one from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0  Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, start_time, end_time).Count(&NewTotalTwo)
1273
+	db.Table("xt_dialysis_order ").Where("user_org_id = ? AND status = 1  AND dialysis_date >= ? AND dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalOne)
1273
 	db.Table("xt_monitoring_record ").Where("user_org_id = ? AND status = 1  AND operate_time >= ? AND operate_time <= ?", user_org_id, start_time, end_time).Count(&NewTotalThree)
1274
 	db.Table("xt_monitoring_record ").Where("user_org_id = ? AND status = 1  AND operate_time >= ? AND operate_time <= ?", user_org_id, start_time, end_time).Count(&NewTotalThree)
1274
-	db.Table("xt_treatment_summary").Where("user_org_id = ? AND status = 1  AND created_time >= ? AND created_time <= ?", user_org_id, start_time, end_time).Count(&NewTotalFour)
1275
+	db.Table("xt_treatment_summary").Where("user_org_id = ? AND status = 1  AND assessment_date >= ? AND assessment_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalFour)
1275
 
1276
 
1276
 	switch statistics_type {
1277
 	switch statistics_type {
1277
-	case 1:
1278
+	case 2:
1278
 		for _, item := range datas {
1279
 		for _, item := range datas {
1279
 			var Total int64
1280
 			var Total int64
1280
-			db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND (config.org_id = ? OR config.org_id = 0)  AND config.parent_id = ? AND  FIND_IN_SET('内瘘',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?   Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1281
+			db.Table("xt_dialysis_order ").Where("user_org_id = ? AND status = 1  AND dialysis_date >= ? AND dialysis_date <= ? AND puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
1281
 			item.PunctureCount = Total
1282
 			item.PunctureCount = Total
1282
-
1283
 			if math.IsNaN(float64(item.PunctureCount) / float64(NewTotalOne)) {
1283
 			if math.IsNaN(float64(item.PunctureCount) / float64(NewTotalOne)) {
1284
 				item.PunctureRatio = "0.0"
1284
 				item.PunctureRatio = "0.0"
1285
 			} else {
1285
 			} else {
1289
 
1289
 
1290
 		}
1290
 		}
1291
 		break
1291
 		break
1292
-	case 2:
1292
+	case 1:
1293
 		for _, item := range datas {
1293
 		for _, item := range datas {
1294
 			var Total int64
1294
 			var Total int64
1295
-			db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND  (config.org_id = ? OR config.org_id = 0) AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Where d.user_org_id = ?  AND d.assessment_date >=? AND d.assessment_date <= ? Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1296
-			item.ChangemedicineCount = Total
1297
-
1298
-			if math.IsNaN(float64(item.ChangemedicineCount) / float64(NewTotalTwo)) {
1299
-				item.ChangemedicineRatio = "0.0"
1300
-			} else {
1301
-				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.ChangemedicineCount)/float64(NewTotalTwo))*100), 64)
1302
-				item.ChangemedicineRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1303
-			}
1304
-		}
1305
-
1306
-		break
1307
-	case 3:
1308
-		for _, item := range datas {
1309
-			var total int64
1310
-			db.Table("xt_monitoring_record").Where("user_org_id = ? AND status = 1 AND monitoring_nurse = ?  AND operate_time >= ? AND operate_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1311
-			item.CureCount = total
1295
+			db.Table("xt_monitoring_record").Where("user_org_id = ? AND status = 1 AND monitoring_nurse = ?  AND operate_time >= ? AND operate_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1296
+			item.CureCount = Total
1312
 			if math.IsNaN(float64(item.CureCount) / float64(NewTotalThree)) {
1297
 			if math.IsNaN(float64(item.CureCount) / float64(NewTotalThree)) {
1313
 				item.CureRatio = "0.0"
1298
 				item.CureRatio = "0.0"
1314
 			} else {
1299
 			} else {
1319
 		}
1304
 		}
1320
 		break
1305
 		break
1321
 
1306
 
1322
-	case 4:
1307
+	case 3:
1323
 		for _, item := range datas {
1308
 		for _, item := range datas {
1324
 			var Total int64
1309
 			var Total int64
1325
-			db.Table("xt_treatment_summary ").Where("user_org_id = ? AND status = 1 AND creater = ?  AND created_time >= ? AND created_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1310
+			db.Table("xt_treatment_summary ").Where("user_org_id = ? AND status = 1 AND creater = ?  AND assessment_date >= ? AND assessment_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1326
 			item.MissionCount = Total
1311
 			item.MissionCount = Total
1327
 			if math.IsNaN(float64(item.MissionCount) / float64(NewTotalFour)) {
1312
 			if math.IsNaN(float64(item.MissionCount) / float64(NewTotalFour)) {
1328
 				item.MissionRatio = "0.0"
1313
 				item.MissionRatio = "0.0"
1332
 			}
1317
 			}
1333
 		}
1318
 		}
1334
 		break
1319
 		break
1320
+
1335
 	}
1321
 	}
1336
 
1322
 
1337
 	if err != nil {
1323
 	if err != nil {
1343
 func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int64, admin_user_id int64, page int64, limit int64) (datas []*VMUserAdminRole, AdminTotal int64, err error) {
1329
 func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int64, admin_user_id int64, page int64, limit int64) (datas []*VMUserAdminRole, AdminTotal int64, err error) {
1344
 	userDb := service.UserReadDB()
1330
 	userDb := service.UserReadDB()
1345
 	db := service.XTReadDB()
1331
 	db := service.XTReadDB()
1346
-	var tempConfig models.Dataconfig
1332
+	//var tempConfig models.Dataconfig
1347
 	offset := (page - 1) * limit
1333
 	offset := (page - 1) * limit
1348
 
1334
 
1349
-	db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1335
+	//db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1350
 
1336
 
1351
 	if admin_user_id == 0 {
1337
 	if admin_user_id == 0 {
1352
 		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 3 ", user_org_id).Offset(offset).Limit(limit).Scan(&datas)
1338
 		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 3 ", user_org_id).Offset(offset).Limit(limit).Scan(&datas)
1356
 
1342
 
1357
 	for _, item := range datas {
1343
 	for _, item := range datas {
1358
 		var Total int64
1344
 		var Total int64
1359
-		var TotalOne int64
1360
 		var TotalTwo int64
1345
 		var TotalTwo int64
1361
 		var TotalThree int64
1346
 		var TotalThree int64
1362
-		db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('内瘘',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1363
-		db.Raw("select count(*) as total_one from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Where  d.user_org_id = ?  AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
1347
+		//db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('内瘘',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1348
+		//db.Raw("select count(*) as total_one from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Where  d.user_org_id = ?  AND d.assessment_date >=? AND d.assessment_date <= ?  Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
1364
 		db.Table("xt_monitoring_record ").Where("user_org_id = ? AND status = 1 AND monitoring_nurse = ? AND operate_time >= ? AND operate_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalTwo)
1349
 		db.Table("xt_monitoring_record ").Where("user_org_id = ? AND status = 1 AND monitoring_nurse = ? AND operate_time >= ? AND operate_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalTwo)
1365
-		db.Table("xt_treatment_summary").Where("user_org_id = ? AND status = 1 AND creater = ? AND created_time >= ? AND created_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalThree)
1350
+		db.Table("xt_dialysis_order ").Where("user_org_id = ? AND status = 1  AND dialysis_date >= ? AND dialysis_date <= ? AND puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
1351
+		db.Table("xt_treatment_summary").Where("user_org_id = ? AND status = 1 AND creater = ? AND assessment_date >= ? AND assessment_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalThree)
1366
 		item.PunctureCount = Total
1352
 		item.PunctureCount = Total
1367
-		item.ChangemedicineCount = TotalOne
1368
 		item.CureCount = TotalTwo
1353
 		item.CureCount = TotalTwo
1369
 		item.MissionCount = TotalThree
1354
 		item.MissionCount = TotalThree
1370
-
1371
 	}
1355
 	}
1372
 
1356
 
1373
 	if err != nil {
1357
 	if err != nil {
1680
 		var isHasConditionThree bool = false
1664
 		var isHasConditionThree bool = false
1681
 
1665
 
1682
 		for _, item := range items {
1666
 		for _, item := range items {
1667
+
1683
 			if item.Name == "大于"+range_value_arr[1] {
1668
 			if item.Name == "大于"+range_value_arr[1] {
1684
 				isHasConditionOne = true
1669
 				isHasConditionOne = true
1685
 			}
1670
 			}
1671
+
1686
 			if item.Name == "小于"+range_value_arr[0] {
1672
 			if item.Name == "小于"+range_value_arr[0] {
1687
 				isHasConditionTwo = true
1673
 				isHasConditionTwo = true
1688
 			}
1674
 			}
1675
+
1689
 			if item.Name == range_value_arr[0]+"~"+range_value_arr[1] {
1676
 			if item.Name == range_value_arr[0]+"~"+range_value_arr[1] {
1690
 				isHasConditionThree = true
1677
 				isHasConditionThree = true
1691
 			}
1678
 			}