瀏覽代碼

Merge branch 'xt_statistics_branch'

csx 4 年之前
父節點
當前提交
a888644f44

+ 5 - 2
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go 查看文件

685
 	adminUserInfo := this.GetMobileAdminUserInfo()
685
 	adminUserInfo := this.GetMobileAdminUserInfo()
686
 	statistics_type, _ := this.GetInt("statistics_type")
686
 	statistics_type, _ := this.GetInt("statistics_type")
687
 	start_time := this.GetString("start_time")
687
 	start_time := this.GetString("start_time")
688
+	admin_user_id, _ := this.GetInt64("admin_user_id")
688
 	end_time := this.GetString("end_time")
689
 	end_time := this.GetString("end_time")
689
 	timeLayout := "2006-01-02"
690
 	timeLayout := "2006-01-02"
690
 	loc, _ := time.LoadLocation("Local")
691
 	loc, _ := time.LoadLocation("Local")
706
 		theEndtTIme = theTime.Unix()
707
 		theEndtTIme = theTime.Unix()
707
 	}
708
 	}
708
 
709
 
709
-	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type)
710
+	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
710
 	this.ServeSuccessJSON(map[string]interface{}{
711
 	this.ServeSuccessJSON(map[string]interface{}{
711
 		"data": data,
712
 		"data": data,
712
 	})
713
 	})
755
 	adminUserInfo := this.GetMobileAdminUserInfo()
756
 	adminUserInfo := this.GetMobileAdminUserInfo()
756
 	statistics_type, _ := this.GetInt("statistics_type")
757
 	statistics_type, _ := this.GetInt("statistics_type")
757
 	start_time := this.GetString("start_time")
758
 	start_time := this.GetString("start_time")
759
+	admin_user_id, _ := this.GetInt64("admin_user_id")
760
+
758
 	end_time := this.GetString("end_time")
761
 	end_time := this.GetString("end_time")
759
 	timeLayout := "2006-01-02"
762
 	timeLayout := "2006-01-02"
760
 	loc, _ := time.LoadLocation("Local")
763
 	loc, _ := time.LoadLocation("Local")
776
 		theEndtTIme = theTime.Unix()
779
 		theEndtTIme = theTime.Unix()
777
 	}
780
 	}
778
 
781
 
779
-	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type)
782
+	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
780
 	this.ServeSuccessJSON(map[string]interface{}{
783
 	this.ServeSuccessJSON(map[string]interface{}{
781
 		"data": data,
784
 		"data": data,
782
 	})
785
 	})

+ 6 - 2
controllers/pc_index_evaluation_api_controller.go 查看文件

719
 	adminUserInfo := this.GetAdminUserInfo()
719
 	adminUserInfo := this.GetAdminUserInfo()
720
 	statistics_type, _ := this.GetInt("statistics_type")
720
 	statistics_type, _ := this.GetInt("statistics_type")
721
 	start_time := this.GetString("start_time")
721
 	start_time := this.GetString("start_time")
722
+	admin_user_id, _ := this.GetInt64("admin_user_id")
723
+
722
 	end_time := this.GetString("end_time")
724
 	end_time := this.GetString("end_time")
723
 	timeLayout := "2006-01-02"
725
 	timeLayout := "2006-01-02"
724
 	loc, _ := time.LoadLocation("Local")
726
 	loc, _ := time.LoadLocation("Local")
740
 		theEndtTIme = theTime.Unix()
742
 		theEndtTIme = theTime.Unix()
741
 	}
743
 	}
742
 
744
 
743
-	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
745
+	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
744
 	this.ServeSuccessJSON(map[string]interface{}{
746
 	this.ServeSuccessJSON(map[string]interface{}{
745
 		"data": data,
747
 		"data": data,
746
 	})
748
 	})
790
 	statistics_type, _ := this.GetInt("statistics_type")
792
 	statistics_type, _ := this.GetInt("statistics_type")
791
 	start_time := this.GetString("start_time")
793
 	start_time := this.GetString("start_time")
792
 	end_time := this.GetString("end_time")
794
 	end_time := this.GetString("end_time")
795
+	admin_user_id, _ := this.GetInt64("admin_user_id")
796
+
793
 	timeLayout := "2006-01-02"
797
 	timeLayout := "2006-01-02"
794
 	loc, _ := time.LoadLocation("Local")
798
 	loc, _ := time.LoadLocation("Local")
795
 
799
 
810
 		theEndtTIme = theTime.Unix()
814
 		theEndtTIme = theTime.Unix()
811
 	}
815
 	}
812
 
816
 
813
-	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
817
+	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
814
 	this.ServeSuccessJSON(map[string]interface{}{
818
 	this.ServeSuccessJSON(map[string]interface{}{
815
 		"data": data,
819
 		"data": data,
816
 	})
820
 	})

+ 16 - 13
service/statistics_service/index_evaluation_service.go 查看文件

1159
 //透析血压统计
1159
 //透析血压统计
1160
 
1160
 
1161
 //工作量统计
1161
 //工作量统计
1162
-func GetDoctorWorkloadChartData(user_org_id int64, start_time int64, end_time int64, statistics_type int) (datas []*VMUserAdminRole, err error) {
1162
+func GetDoctorWorkloadChartData(user_org_id int64, start_time int64, end_time int64, statistics_type int, admin_user_id int64) (datas []*VMUserAdminRole, err error) {
1163
 	userDb := service.UserReadDB()
1163
 	userDb := service.UserReadDB()
1164
 	db := service.XTReadDB()
1164
 	db := service.XTReadDB()
1165
-	userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 2 ", user_org_id).Scan(&datas)
1165
+	if admin_user_id == 0 {
1166
+		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 2 ", user_org_id).Scan(&datas)
1167
+	} else {
1168
+		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 2  AND admin_user_id = ?", user_org_id, admin_user_id).Scan(&datas)
1169
+	}
1166
 
1170
 
1167
 	switch statistics_type {
1171
 	switch statistics_type {
1168
 	case 1:
1172
 	case 1:
1169
 		var Total int64
1173
 		var Total int64
1170
-		db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1  AND record_date >= ? AND  record_date <= ? AND prescription_doctor <> 0 ", user_org_id, start_time, end_time).Count(&Total)
1174
+		db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1  AND record_date >= ? AND  record_date <= ? AND creater <> 0 ", user_org_id, start_time, end_time).Count(&Total)
1171
 
1175
 
1172
 		for _, item := range datas {
1176
 		for _, item := range datas {
1173
 			var total int64
1177
 			var total int64
1174
-			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)
1178
+			db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1 AND creater = ? AND record_date >= ? AND  record_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1175
 			item.PCount = total
1179
 			item.PCount = total
1176
 
1180
 
1177
 			if math.IsNaN(float64(item.PCount) / float64(Total)) {
1181
 			if math.IsNaN(float64(item.PCount) / float64(Total)) {
1242
 		var Total int64
1246
 		var Total int64
1243
 		var TotalOne int64
1247
 		var TotalOne int64
1244
 		var TotalTwo int64
1248
 		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)
1249
+		db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1 AND creater = ?  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 record_time >= ? AND record_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
1250
 		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)
1251
 		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
1252
 		item.PCount = Total
1255
 	return datas, nil
1259
 	return datas, nil
1256
 
1260
 
1257
 }
1261
 }
1258
-func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int64, statistics_type int) (datas []*VMUserAdminRole, err error) {
1262
+func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int64, statistics_type int, admin_user_id int64) (datas []*VMUserAdminRole, err error) {
1259
 	userDb := service.UserReadDB()
1263
 	userDb := service.UserReadDB()
1260
 	db := service.XTReadDB()
1264
 	db := service.XTReadDB()
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)
1265
+
1266
+	if admin_user_id == 0 {
1267
+		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)
1268
+	} else {
1269
+		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  AND admin_user_id = ?", user_org_id, admin_user_id).Scan(&datas)
1270
+	}
1262
 
1271
 
1263
 	var NewTotalOne int64
1272
 	var NewTotalOne int64
1264
 	var NewTotalThree int64
1273
 	var NewTotalThree int64
1265
 	var NewTotalFour int64
1274
 	var NewTotalFour int64
1266
 
1275
 
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)
1272
-
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)
1276
 	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)
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)
1277
 	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)
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)
1278
 	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)