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
ada7988a68

+ 59 - 57
controllers/base_api_controller.go View File

@@ -2,6 +2,8 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
6
+
5 7
 	//"XT_New/models"
6 8
 	"XT_New/service"
7 9
 	"fmt"
@@ -65,36 +67,36 @@ type BaseAuthAPIController struct {
65 67
 func (this *BaseAuthAPIController) Prepare() {
66 68
 	this.BaseAPIController.Prepare()
67 69
 	if this.GetAdminUserInfo() == nil {
68
-		//var userAdmin models.AdminUser
69
-		//userAdmin.Id = 400
70
-		//userAdmin.Mobile = "13535547901"
71
-		//
70
+		var userAdmin models.AdminUser
71
+		userAdmin.Id = 400
72
+		userAdmin.Mobile = "13535547901"
73
+
72 74
 		//userAdmin.Id = 597
73 75
 		//userAdmin.Mobile = "19874122664"
74
-		//userAdmin.IsSuperAdmin = false
75
-		//userAdmin.Status = 1
76
-		//userAdmin.CreateTime = 1530786071
77
-		//userAdmin.ModifyTime = 1530786071
78
-		//var subscibe models.ServeSubscibe
79
-		//subscibe.ID = 1
80
-		//subscibe.OrgId = 12
81
-		//subscibe.PeriodStart = 1538035409
82
-		//subscibe.PeriodEnd = 1569571409
83
-		//subscibe.State = 1
84
-		//subscibe.Status = 1
85
-		//subscibe.CreatedTime = 1538035409
86
-		//subscibe.UpdatedTime = 1538035409
87
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
88
-		//subscibes[4] = &subscibe
89
-		//var adminUserInfo service.AdminUserInfo
90
-		//adminUserInfo.CurrentOrgId = 12
91
-		//adminUserInfo.CurrentAppId = 18
92
-		//adminUserInfo.AdminUser = &userAdmin
93
-		//adminUserInfo.Subscibes = subscibes
94
-		//this.SetSession("admin_user_info", &adminUserInfo)
95
-
96
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
97
-		this.StopRun()
76
+		userAdmin.IsSuperAdmin = false
77
+		userAdmin.Status = 1
78
+		userAdmin.CreateTime = 1530786071
79
+		userAdmin.ModifyTime = 1530786071
80
+		var subscibe models.ServeSubscibe
81
+		subscibe.ID = 1
82
+		subscibe.OrgId = 12
83
+		subscibe.PeriodStart = 1538035409
84
+		subscibe.PeriodEnd = 1569571409
85
+		subscibe.State = 1
86
+		subscibe.Status = 1
87
+		subscibe.CreatedTime = 1538035409
88
+		subscibe.UpdatedTime = 1538035409
89
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
90
+		subscibes[4] = &subscibe
91
+		var adminUserInfo service.AdminUserInfo
92
+		adminUserInfo.CurrentOrgId = 12
93
+		adminUserInfo.CurrentAppId = 18
94
+		adminUserInfo.AdminUser = &userAdmin
95
+		adminUserInfo.Subscibes = subscibes
96
+		this.SetSession("admin_user_info", &adminUserInfo)
97
+
98
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
99
+		//this.StopRun()
98 100
 	}
99 101
 
100 102
 	adminUserInfo := this.GetAdminUserInfo()
@@ -316,35 +318,35 @@ type BaseServeAPIController struct {
316 318
 func (this *BaseServeAPIController) Prepare() {
317 319
 	this.BaseAPIController.Prepare()
318 320
 	if this.GetAdminUserInfo() == nil {
319
-		//var userAdmin models.AdminUser
320
-		//userAdmin.Id = 400
321
-		//userAdmin.Mobile = "13535547901"
322
-		//userAdmin.Id = 597
323
-		//userAdmin.Mobile = "19874122664"
324
-		//userAdmin.IsSuperAdmin = false
325
-		//userAdmin.Status = 1
326
-		//userAdmin.CreateTime = 1530786071
327
-		//userAdmin.ModifyTime = 1530786071
328
-		//var subscibe models.ServeSubscibe
329
-		//subscibe.ID = 1
330
-		//subscibe.OrgId = 12
331
-		//subscibe.PeriodStart = 1538035409
332
-		//subscibe.PeriodEnd = 1569571409
333
-		//subscibe.State = 1
334
-		//subscibe.Status = 1
335
-		//subscibe.CreatedTime = 1538035409
336
-		//subscibe.UpdatedTime = 1538035409
337
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
-		//subscibes[4] = &subscibe
339
-		//var adminUserInfo service.AdminUserInfo
340
-		//adminUserInfo.CurrentOrgId = 12
341
-		//adminUserInfo.CurrentAppId = 18
342
-		//adminUserInfo.AdminUser = &userAdmin
343
-		//adminUserInfo.Subscibes = subscibes
344
-		//this.SetSession("admin_user_info", &adminUserInfo)
345
-
346
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
-		this.StopRun()
321
+		var userAdmin models.AdminUser
322
+		userAdmin.Id = 400
323
+		userAdmin.Mobile = "13535547901"
324
+		userAdmin.Id = 597
325
+		userAdmin.Mobile = "19874122664"
326
+		userAdmin.IsSuperAdmin = false
327
+		userAdmin.Status = 1
328
+		userAdmin.CreateTime = 1530786071
329
+		userAdmin.ModifyTime = 1530786071
330
+		var subscibe models.ServeSubscibe
331
+		subscibe.ID = 1
332
+		subscibe.OrgId = 12
333
+		subscibe.PeriodStart = 1538035409
334
+		subscibe.PeriodEnd = 1569571409
335
+		subscibe.State = 1
336
+		subscibe.Status = 1
337
+		subscibe.CreatedTime = 1538035409
338
+		subscibe.UpdatedTime = 1538035409
339
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340
+		subscibes[4] = &subscibe
341
+		var adminUserInfo service.AdminUserInfo
342
+		adminUserInfo.CurrentOrgId = 12
343
+		adminUserInfo.CurrentAppId = 18
344
+		adminUserInfo.AdminUser = &userAdmin
345
+		adminUserInfo.Subscibes = subscibes
346
+		this.SetSession("admin_user_info", &adminUserInfo)
347
+
348
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
349
+		//this.StopRun()
348 350
 	}
349 351
 
350 352
 	//if adminUserInfo.AppRole != nil {

+ 595 - 8
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go View File

@@ -3,28 +3,615 @@ package new_mobile_api_controllers
3 3
 import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/service/statistics_service"
6
+	"XT_New/utils"
7
+	"time"
6 8
 )
7 9
 
8 10
 type IndexEvaluationApiController struct {
9 11
 	NewMobileBaseAPIAuthController
10 12
 }
11 13
 
12
-func (this IndexEvaluationApiController) GetDialysisProcessIndexData() {
13
-	adminUserInfo := this.GetAdminUserInfo()
14
-	//statistics_type, _ := this.GetInt64("statistics_type")
15
-	//start_time := this.GetString("start_time")
16
-	//end_time := this.GetString("end_time")
17
-	patinent_id, _ := this.GetInt64("patinent_id")
14
+func (this *IndexEvaluationApiController) GetAdminUser() {
15
+	admins, _ := statistics_service.GetAllAdminUser(this.GetMobileAdminUserInfo().Org.Id)
16
+	this.ServeSuccessJSON(map[string]interface{}{
17
+		"admin": admins,
18
+	})
19
+}
20
+
21
+func (this *IndexEvaluationApiController) GetDialysisProcessIndexChartData() {
22
+	adminUserInfo := this.GetMobileAdminUserInfo()
23
+	statistics_type, _ := this.GetInt("statistics_type")
24
+	start_time := this.GetString("start_time")
25
+	end_time := this.GetString("end_time")
26
+	patient_id, _ := this.GetInt64("patient_id")
27
+	timeLayout := "2006-01-02"
28
+	loc, _ := time.LoadLocation("Local")
29
+
30
+	var theStartTIme int64
31
+	if len(start_time) > 0 {
32
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
33
+		if err != nil {
34
+			utils.ErrorLog(err.Error())
35
+		}
36
+		theStartTIme = theTime.Unix()
37
+	}
38
+	var theEndtTIme int64
39
+	if len(end_time) > 0 {
40
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
41
+		if err != nil {
42
+			utils.ErrorLog(err.Error())
43
+		}
44
+		theEndtTIme = theTime.Unix()
45
+	}
46
+
47
+	if patient_id == 0 {
48
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
49
+		if patientInfo == nil {
50
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
51
+			return
52
+		}
53
+		if statistics_type == 9 || statistics_type == 10 {
54
+			data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.Org.Id, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
55
+
56
+			this.ServeSuccessJSON(map[string]interface{}{
57
+				"data": data,
58
+			})
59
+		} else {
60
+
61
+			data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.Org.Id, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
62
+
63
+			this.ServeSuccessJSON(map[string]interface{}{
64
+				"data": data,
65
+			})
66
+
67
+		}
68
+	} else {
69
+		if statistics_type == 9 || statistics_type == 10 {
70
+			data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
71
+
72
+			this.ServeSuccessJSON(map[string]interface{}{
73
+				"data": data,
74
+			})
75
+
76
+		} else {
77
+			data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
78
+
79
+			this.ServeSuccessJSON(map[string]interface{}{
80
+				"data": data,
81
+			})
82
+
83
+		}
84
+	}
85
+
86
+}
87
+func (this *IndexEvaluationApiController) GetDialysisProcessIndexTableData() {
88
+	adminUserInfo := this.GetMobileAdminUserInfo()
89
+	start_time := this.GetString("start_time")
90
+	end_time := this.GetString("end_time")
91
+	patient_id, _ := this.GetInt64("patient_id")
92
+
93
+	page, _ := this.GetInt64("page")
94
+	limit, _ := this.GetInt64("limit")
95
+
96
+	if page == 0 {
97
+		page = 1
98
+	}
99
+	if limit == 0 {
100
+		limit = 20
101
+	}
102
+
103
+	timeLayout := "2006-01-02"
104
+	loc, _ := time.LoadLocation("Local")
105
+
106
+	var theStartTIme int64
107
+	if len(start_time) > 0 {
108
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
109
+		if err != nil {
110
+			utils.ErrorLog(err.Error())
111
+		}
112
+		theStartTIme = theTime.Unix()
113
+	}
114
+	var theEndtTIme int64
115
+	if len(end_time) > 0 {
116
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
117
+		if err != nil {
118
+			utils.ErrorLog(err.Error())
119
+		}
120
+		theEndtTIme = theTime.Unix()
121
+	}
18 122
 
19
-	if patinent_id == 0 {
20
-		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
123
+	if patient_id == 0 {
124
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
21 125
 		if patientInfo == nil {
22 126
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
23 127
 			return
24 128
 		}
25 129
 
130
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.Org.Id, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
131
+
132
+		this.ServeSuccessJSON(map[string]interface{}{
133
+			"data":  data,
134
+			"total": total,
135
+		})
136
+
26 137
 	} else {
138
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
139
+		this.ServeSuccessJSON(map[string]interface{}{
140
+			"data":  data,
141
+			"total": total,
142
+		})
143
+
144
+	}
145
+
146
+}
147
+
148
+func (this *IndexEvaluationApiController) GetDialysisWatchChartData() {
149
+	adminUserInfo := this.GetMobileAdminUserInfo()
150
+	statistics_type, _ := this.GetInt("statistics_type")
151
+	start_time := this.GetString("start_time")
152
+	end_time := this.GetString("end_time")
153
+	patient_id, _ := this.GetInt64("patient_id")
154
+	timeLayout := "2006-01-02"
155
+	loc, _ := time.LoadLocation("Local")
156
+
157
+	var theStartTIme int64
158
+	if len(start_time) > 0 {
159
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
160
+		if err != nil {
161
+			utils.ErrorLog(err.Error())
162
+		}
163
+		theStartTIme = theTime.Unix()
164
+	}
165
+	var theEndtTIme int64
166
+	if len(end_time) > 0 {
167
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
168
+		if err != nil {
169
+			utils.ErrorLog(err.Error())
170
+		}
171
+		theEndtTIme = theTime.Unix()
172
+	}
173
+
174
+	if patient_id == 0 {
175
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
176
+		if patientInfo == nil {
177
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
178
+			return
179
+		}
180
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.Org.Id, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
181
+		this.ServeSuccessJSON(map[string]interface{}{
182
+			"data": data,
183
+		})
184
+	} else {
185
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
186
+		this.ServeSuccessJSON(map[string]interface{}{
187
+			"data": data,
188
+		})
189
+	}
190
+
191
+}
192
+func (this *IndexEvaluationApiController) GetDialysisWatchTableData() {
193
+	adminUserInfo := this.GetMobileAdminUserInfo()
194
+	start_time := this.GetString("start_time")
195
+	end_time := this.GetString("end_time")
196
+	patient_id, _ := this.GetInt64("patient_id")
197
+	page, _ := this.GetInt64("page")
198
+	limit, _ := this.GetInt64("limit")
199
+
200
+	if page == 0 {
201
+		page = 1
202
+	}
203
+	if limit == 0 {
204
+		limit = 20
205
+	}
206
+	timeLayout := "2006-01-02"
207
+	loc, _ := time.LoadLocation("Local")
208
+
209
+	var theStartTIme int64
210
+	if len(start_time) > 0 {
211
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
212
+		if err != nil {
213
+			utils.ErrorLog(err.Error())
214
+		}
215
+		theStartTIme = theTime.Unix()
216
+	}
217
+	var theEndtTIme int64
218
+	if len(end_time) > 0 {
219
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
220
+		if err != nil {
221
+			utils.ErrorLog(err.Error())
222
+		}
223
+		theEndtTIme = theTime.Unix()
224
+	}
225
+
226
+	if patient_id == 0 {
227
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
228
+		if patientInfo == nil {
229
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
230
+			return
231
+		}
232
+
233
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.Org.Id, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
234
+
235
+		this.ServeSuccessJSON(map[string]interface{}{
236
+			"data":  data,
237
+			"total": total,
238
+		})
239
+
240
+	} else {
241
+
242
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
243
+		this.ServeSuccessJSON(map[string]interface{}{
244
+			"data":  data,
245
+			"total": total,
246
+		})
247
+
248
+	}
249
+
250
+}
251
+
252
+func (this *IndexEvaluationApiController) GetDialysisBloodPressureChartData() {
253
+	adminUserInfo := this.GetMobileAdminUserInfo()
254
+	statistics_type, _ := this.GetInt("statistics_type")
255
+	start_time := this.GetString("start_time")
256
+	end_time := this.GetString("end_time")
257
+	patient_id, _ := this.GetInt64("patient_id")
258
+
259
+	timeLayout := "2006-01-02"
260
+	loc, _ := time.LoadLocation("Local")
261
+
262
+	var theStartTIme int64
263
+	if len(start_time) > 0 {
264
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
265
+		if err != nil {
266
+			utils.ErrorLog(err.Error())
267
+		}
268
+		theStartTIme = theTime.Unix()
269
+	}
270
+	var theEndtTIme int64
271
+	if len(end_time) > 0 {
272
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
273
+		if err != nil {
274
+			utils.ErrorLog(err.Error())
275
+		}
276
+		theEndtTIme = theTime.Unix()
277
+	}
278
+
279
+	data, _ := statistics_service.GetBloodPressureChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type, patient_id)
280
+	this.ServeSuccessJSON(map[string]interface{}{
281
+		"data": data,
282
+	})
27 283
 
284
+}
285
+func (this *IndexEvaluationApiController) GetDialysisBloodPressureTableData() {
286
+	adminUserInfo := this.GetMobileAdminUserInfo()
287
+	start_time := this.GetString("start_time")
288
+	end_time := this.GetString("end_time")
289
+	patient_id, _ := this.GetInt64("patient_id")
290
+	page, _ := this.GetInt64("page")
291
+	limit, _ := this.GetInt64("limit")
292
+
293
+	if page == 0 {
294
+		page = 1
295
+	}
296
+	if limit == 0 {
297
+		limit = 20
298
+	}
299
+	timeLayout := "2006-01-02"
300
+	loc, _ := time.LoadLocation("Local")
301
+
302
+	var theStartTIme int64
303
+	if len(start_time) > 0 {
304
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
305
+		if err != nil {
306
+			utils.ErrorLog(err.Error())
307
+		}
308
+		theStartTIme = theTime.Unix()
309
+	}
310
+	var theEndtTIme int64
311
+	if len(end_time) > 0 {
312
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
313
+		if err != nil {
314
+			utils.ErrorLog(err.Error())
315
+		}
316
+		theEndtTIme = theTime.Unix()
317
+	}
318
+
319
+	data, total, _ := statistics_service.GetBloodPressureTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
320
+	this.ServeSuccessJSON(map[string]interface{}{
321
+		"data":  data,
322
+		"total": total,
323
+	})
324
+
325
+}
326
+func (this *IndexEvaluationApiController) GetDialysisPatientBloodPressureChartData() {
327
+	adminUserInfo := this.GetMobileAdminUserInfo()
328
+	statistics_type, _ := this.GetInt("statistics_type")
329
+	start_time := this.GetString("start_time")
330
+	end_time := this.GetString("end_time")
331
+	patient_id, _ := this.GetInt64("patient_id")
332
+
333
+	timeLayout := "2006-01-02"
334
+	loc, _ := time.LoadLocation("Local")
335
+
336
+	var theStartTIme int64
337
+	if len(start_time) > 0 {
338
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
339
+		if err != nil {
340
+			utils.ErrorLog(err.Error())
341
+		}
342
+		theStartTIme = theTime.Unix()
343
+	}
344
+	var theEndtTIme int64
345
+	if len(end_time) > 0 {
346
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
347
+		if err != nil {
348
+			utils.ErrorLog(err.Error())
349
+		}
350
+		theEndtTIme = theTime.Unix()
351
+	}
352
+
353
+	data, _ := statistics_service.GetPatientBloodPressureChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
354
+	this.ServeSuccessJSON(map[string]interface{}{
355
+		"data": data,
356
+	})
357
+
358
+}
359
+
360
+func (this *IndexEvaluationApiController) GetDialysisWeightChartData() {
361
+	adminUserInfo := this.GetMobileAdminUserInfo()
362
+	statistics_type, _ := this.GetInt("statistics_type")
363
+	start_time := this.GetString("start_time")
364
+	end_time := this.GetString("end_time")
365
+	timeLayout := "2006-01-02"
366
+	loc, _ := time.LoadLocation("Local")
367
+
368
+	var theStartTIme int64
369
+	if len(start_time) > 0 {
370
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
371
+		if err != nil {
372
+			utils.ErrorLog(err.Error())
373
+		}
374
+		theStartTIme = theTime.Unix()
375
+	}
376
+	var theEndtTIme int64
377
+	if len(end_time) > 0 {
378
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
379
+		if err != nil {
380
+			utils.ErrorLog(err.Error())
381
+		}
382
+		theEndtTIme = theTime.Unix()
383
+	}
384
+
385
+	data, _ := statistics_service.GetDialysisWeightChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type)
386
+	this.ServeSuccessJSON(map[string]interface{}{
387
+		"data": data,
388
+	})
389
+
390
+}
391
+func (this *IndexEvaluationApiController) GetDialysisWeightTableData() {
392
+	adminUserInfo := this.GetMobileAdminUserInfo()
393
+	start_time := this.GetString("start_time")
394
+	end_time := this.GetString("end_time")
395
+	patient_id, _ := this.GetInt64("patient_id")
396
+	page, _ := this.GetInt64("page")
397
+	limit, _ := this.GetInt64("limit")
398
+
399
+	if page == 0 {
400
+		page = 1
401
+	}
402
+	if limit == 0 {
403
+		limit = 20
404
+	}
405
+	timeLayout := "2006-01-02"
406
+	loc, _ := time.LoadLocation("Local")
407
+
408
+	var theStartTIme int64
409
+	if len(start_time) > 0 {
410
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
411
+		if err != nil {
412
+			utils.ErrorLog(err.Error())
413
+		}
414
+		theStartTIme = theTime.Unix()
415
+	}
416
+	var theEndtTIme int64
417
+	if len(end_time) > 0 {
418
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
419
+		if err != nil {
420
+			utils.ErrorLog(err.Error())
421
+		}
422
+		theEndtTIme = theTime.Unix()
28 423
 	}
29 424
 
425
+	data, total, _ := statistics_service.GetDialysisWeightTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
426
+	this.ServeSuccessJSON(map[string]interface{}{
427
+		"data":  data,
428
+		"total": total,
429
+	})
430
+}
431
+func (this *IndexEvaluationApiController) GetDialysisPatientWeightChartData() {
432
+	adminUserInfo := this.GetMobileAdminUserInfo()
433
+	statistics_type, _ := this.GetInt("statistics_type")
434
+	start_time := this.GetString("start_time")
435
+	end_time := this.GetString("end_time")
436
+	patient_id, _ := this.GetInt64("patient_id")
437
+
438
+	timeLayout := "2006-01-02"
439
+	loc, _ := time.LoadLocation("Local")
440
+
441
+	var theStartTIme int64
442
+	if len(start_time) > 0 {
443
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
444
+		if err != nil {
445
+			utils.ErrorLog(err.Error())
446
+		}
447
+		theStartTIme = theTime.Unix()
448
+	}
449
+	var theEndtTIme int64
450
+	if len(end_time) > 0 {
451
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
452
+		if err != nil {
453
+			utils.ErrorLog(err.Error())
454
+		}
455
+		theEndtTIme = theTime.Unix()
456
+	}
457
+
458
+	data, _ := statistics_service.GetPatientDialysisWeightChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
459
+	this.ServeSuccessJSON(map[string]interface{}{
460
+		"data": data,
461
+	})
462
+
463
+}
464
+
465
+func (this *IndexEvaluationApiController) GetDoctorWorkloadChartData() {
466
+	adminUserInfo := this.GetMobileAdminUserInfo()
467
+	statistics_type, _ := this.GetInt("statistics_type")
468
+	start_time := this.GetString("start_time")
469
+	end_time := this.GetString("end_time")
470
+	timeLayout := "2006-01-02"
471
+	loc, _ := time.LoadLocation("Local")
472
+
473
+	var theStartTIme int64
474
+	if len(start_time) > 0 {
475
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
476
+		if err != nil {
477
+			utils.ErrorLog(err.Error())
478
+		}
479
+		theStartTIme = theTime.Unix()
480
+	}
481
+	var theEndtTIme int64
482
+	if len(end_time) > 0 {
483
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
484
+		if err != nil {
485
+			utils.ErrorLog(err.Error())
486
+		}
487
+		theEndtTIme = theTime.Unix()
488
+	}
489
+
490
+	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type)
491
+	this.ServeSuccessJSON(map[string]interface{}{
492
+		"data": data,
493
+	})
494
+
495
+}
496
+func (this *IndexEvaluationApiController) GetDoctorWorkloadTableData() {
497
+	adminUserInfo := this.GetMobileAdminUserInfo()
498
+	start_time := this.GetString("start_time")
499
+	end_time := this.GetString("end_time")
500
+	admin_user_id, _ := this.GetInt64("admin_user_id")
501
+	page, _ := this.GetInt64("page")
502
+	limit, _ := this.GetInt64("limit")
503
+
504
+	if page == 0 {
505
+		page = 1
506
+	}
507
+	if limit == 0 {
508
+		limit = 20
509
+	}
510
+	timeLayout := "2006-01-02"
511
+	loc, _ := time.LoadLocation("Local")
512
+
513
+	var theStartTIme int64
514
+	if len(start_time) > 0 {
515
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
516
+		if err != nil {
517
+			utils.ErrorLog(err.Error())
518
+		}
519
+		theStartTIme = theTime.Unix()
520
+	}
521
+	var theEndtTIme int64
522
+	if len(end_time) > 0 {
523
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
524
+		if err != nil {
525
+			utils.ErrorLog(err.Error())
526
+		}
527
+		theEndtTIme = theTime.Unix()
528
+	}
529
+	data, _ := statistics_service.GetDoctorWorkloadTableData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, admin_user_id)
530
+	this.ServeSuccessJSON(map[string]interface{}{
531
+		"data": data,
532
+	})
533
+}
534
+
535
+func (this *IndexEvaluationApiController) GetNurseWorkloadChartData() {
536
+	adminUserInfo := this.GetMobileAdminUserInfo()
537
+	statistics_type, _ := this.GetInt("statistics_type")
538
+	start_time := this.GetString("start_time")
539
+	end_time := this.GetString("end_time")
540
+	timeLayout := "2006-01-02"
541
+	loc, _ := time.LoadLocation("Local")
542
+
543
+	var theStartTIme int64
544
+	if len(start_time) > 0 {
545
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
546
+		if err != nil {
547
+			utils.ErrorLog(err.Error())
548
+		}
549
+		theStartTIme = theTime.Unix()
550
+	}
551
+	var theEndtTIme int64
552
+	if len(end_time) > 0 {
553
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
554
+		if err != nil {
555
+			utils.ErrorLog(err.Error())
556
+		}
557
+		theEndtTIme = theTime.Unix()
558
+	}
559
+
560
+	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type)
561
+	this.ServeSuccessJSON(map[string]interface{}{
562
+		"data": data,
563
+	})
564
+
565
+}
566
+func (this *IndexEvaluationApiController) GetNurseWorkloadTableData() {
567
+	adminUserInfo := this.GetMobileAdminUserInfo()
568
+	start_time := this.GetString("start_time")
569
+	end_time := this.GetString("end_time")
570
+	admin_user_id, _ := this.GetInt64("admin_user_id")
571
+	page, _ := this.GetInt64("page")
572
+	limit, _ := this.GetInt64("limit")
573
+
574
+	if page == 0 {
575
+		page = 1
576
+	}
577
+	if limit == 0 {
578
+		limit = 20
579
+	}
580
+	timeLayout := "2006-01-02"
581
+	loc, _ := time.LoadLocation("Local")
582
+
583
+	var theStartTIme int64
584
+	if len(start_time) > 0 {
585
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
586
+		if err != nil {
587
+			utils.ErrorLog(err.Error())
588
+		}
589
+		theStartTIme = theTime.Unix()
590
+	}
591
+	var theEndtTIme int64
592
+	if len(end_time) > 0 {
593
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
594
+		if err != nil {
595
+			utils.ErrorLog(err.Error())
596
+		}
597
+		theEndtTIme = theTime.Unix()
598
+	}
599
+	data, _ := statistics_service.GetNurseWorkloadTableData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, admin_user_id)
600
+	this.ServeSuccessJSON(map[string]interface{}{
601
+		"data": data,
602
+	})
603
+}
604
+
605
+func (this *IndexEvaluationApiController) GetDefaultPatient() {
606
+	adminUserInfo := this.GetMobileAdminUserInfo()
607
+	patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
608
+	if patientInfo == nil {
609
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
610
+		return
611
+	}
612
+
613
+	this.ServeSuccessJSON(map[string]interface{}{
614
+		"patient": patientInfo,
615
+	})
616
+
30 617
 }

+ 23 - 1
controllers/new_mobile_api_controllers/statistics_api_controllers.go View File

@@ -4,5 +4,27 @@ import "github.com/astaxie/beego"
4 4
 
5 5
 func StatisticsAPIControllersRegisterRouters() {
6 6
 
7
-	beego.Router("/m/api/dialysisprocess/index", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexData")
7
+	beego.Router("/m/api/dialysisprocessindex/chart", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexChartData")
8
+	beego.Router("/m/api/dialysisprocessindex/table", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexTableData")
9
+
10
+	beego.Router("/m/api/dialysiswatch/chart", &IndexEvaluationApiController{}, "Get:GetDialysisWatchChartData")
11
+	beego.Router("/m/api/dialysiswatch/table", &IndexEvaluationApiController{}, "Get:GetDialysisWatchTableData")
12
+
13
+	beego.Router("/m/api/dialysisbloodpressure/chart", &IndexEvaluationApiController{}, "Get:GetDialysisBloodPressureChartData")
14
+	beego.Router("/m/api/dialysisbloodpressure/table", &IndexEvaluationApiController{}, "Get:GetDialysisBloodPressureTableData")
15
+	beego.Router("/m/api/patientdialysisbloodpressure/chart", &IndexEvaluationApiController{}, "Get:GetDialysisPatientBloodPressureChartData")
16
+
17
+	beego.Router("/m/api/dialysisweight/chart", &IndexEvaluationApiController{}, "Get:GetDialysisWeightChartData")
18
+	beego.Router("/m/api/dialysisweight/table", &IndexEvaluationApiController{}, "Get:GetDialysisWeightTableData")
19
+	beego.Router("/m/api/patientdialysisweight/chart", &IndexEvaluationApiController{}, "Get:GetDialysisPatientWeightChartData")
20
+
21
+	beego.Router("/m/api/doctorworkload/chart", &IndexEvaluationApiController{}, "Get:GetDoctorWorkloadChartData")
22
+	beego.Router("/m/api/doctorworkload/table", &IndexEvaluationApiController{}, "Get:GetDoctorWorkloadTableData")
23
+
24
+	beego.Router("/m/api/nurseworkload/chart", &IndexEvaluationApiController{}, "Get:GetNurseWorkloadChartData")
25
+	beego.Router("/m/api/nurseworkload/table", &IndexEvaluationApiController{}, "Get:GetNurseWorkloadTableData")
26
+
27
+	beego.Router("/m/api/adminuser/all", &IndexEvaluationApiController{}, "Get:GetAdminUser")
28
+	beego.Router("/m/api/defalutpatient/get", &IndexEvaluationApiController{}, "Get:GetDefaultPatient")
29
+
8 30
 }

File diff suppressed because it is too large
+ 950 - 88
service/statistics_service/index_evaluation_service.go


+ 102 - 11
service/statistics_service/index_models.go View File

@@ -23,17 +23,20 @@ func (VMDialysisPrescription) TableName() string {
23 23
 }
24 24
 
25 25
 type VMPredialysisEvaluation struct {
26
-	ID                     int64   `gorm:"column:id" json:"id"`
27
-	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id"`
28
-	PatientId              int64   `gorm:"column:patient_id" json:"patient_id"`
29
-	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date"`
30
-	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
31
-	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
32
-	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
33
-	DryWeight              float64 `gorm:"column:dry_weight" json:"dry_weight"`
34
-	WeighingBefore         float64 `gorm:"column:weighing_before" json:"weighing_before"`
35
-	WeightBefore           float64 `gorm:"column:weight_before" json:"weight_before"`
36
-	BloodAccessPartId      int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
26
+	ID                        int64                     `gorm:"column:id" json:"id"`
27
+	UserOrgId                 int64                     `gorm:"column:user_org_id" json:"user_org_id"`
28
+	PatientId                 int64                     `gorm:"column:patient_id" json:"patient_id"`
29
+	AssessmentDate            int64                     `gorm:"column:assessment_date" json:"assessment_date"`
30
+	PulseFrequency            float64                   `gorm:"column:pulse_frequency" json:"pulse_frequency"`
31
+	SystolicBloodPressure     float64                   `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
32
+	DiastolicBloodPressure    float64                   `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
33
+	DryWeight                 float64                   `gorm:"column:dry_weight" json:"dry_weight"`
34
+	WeighingBefore            float64                   `gorm:"column:weighing_before" json:"weighing_before"`
35
+	WeightBefore              float64                   `gorm:"column:weight_before" json:"weight_before"`
36
+	BloodAccessPartId         int64                     `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
37
+	VMAssessmentAfterDislysis VMAssessmentAfterDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,AssessmentDate" json:"after"`
38
+	VMPatients                VMPatients                `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
39
+	LastAfterWeight           float64                   `gorm:"-" json:"last_after_weight"`
37 40
 }
38 41
 
39 42
 func (VMPredialysisEvaluation) TableName() string {
@@ -56,3 +59,91 @@ type VMAssessmentAfterDislysis struct {
56 59
 func (VMAssessmentAfterDislysis) TableName() string {
57 60
 	return "xt_assessment_after_dislysis"
58 61
 }
62
+
63
+type VMPatients struct {
64
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
65
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
66
+	Name      string `gorm:"column:name" json:"name" form:"name"`
67
+	Lapseto   int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
68
+}
69
+
70
+func (VMPatients) TableName() string {
71
+	return "xt_patients"
72
+}
73
+
74
+type VMSchedule struct {
75
+	UserOrgId                 int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
76
+	BedId                     int64                     `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
77
+	ScheduleDate              int64                     `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
78
+	PatientId                 int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
79
+	Status                    int64                     `gorm:"column:status" json:"status" form:"status"`
80
+	VMPredialysisEvaluation   VMPredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"before"`
81
+	VMAssessmentAfterDislysis VMAssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"after"`
82
+	VMMinMonitoringRecord     VMMonitoringRecord        `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"min_monitor"`
83
+	VMMaxMonitoringRecord     VMMonitoringRecord        `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"max_monitor"`
84
+	VMPatients                VMPatients                `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
85
+}
86
+
87
+func (VMSchedule) TableName() string {
88
+	return "xt_schedule"
89
+}
90
+
91
+type VMMonitoringRecord struct {
92
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
93
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
94
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
95
+	MonitoringDate         int64   `gorm:"column:monitoring_date" json:"monitoring_date" form:"monitoring_date"`
96
+	MonitoringTime         string  `gorm:"column:monitoring_time" json:"monitoring_time" form:"monitoring_time"`
97
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
98
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
99
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
100
+	OperateTime            int64   `gorm:"column:operate_time" json:"operate_time" form:"operate_time"`
101
+	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
102
+	BreathingRate          float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
103
+	Temperature            float64 `gorm:"column:temperature" json:"temperature"`
104
+	BloodFlowVolume        float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
105
+	VenousPressure         float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
106
+	ArterialPressure       float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
107
+	TransmembranePressure  float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
108
+	DialysateTemperature   float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
109
+	UltrafiltrationRate    float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
110
+	UltrafiltrationVolume  float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
111
+}
112
+
113
+func (VMMonitoringRecord) TableName() string {
114
+	return "xt_monitoring_record"
115
+}
116
+
117
+type VMUserAdminRole struct {
118
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
119
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
120
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
121
+	UserName    string `gorm:"column:user_name" json:"user_name" form:"user_name"`
122
+	PCount      int64  `gorm:"-" json:"p_count"`
123
+	CourseCount int64  `gorm:"-" json:"course_count" `
124
+
125
+	PunctureCount       int64 `gorm:"-" json:"puncture_count" `
126
+	ChangemedicineCount int64 `gorm:"-" json:"change_medicine_count" `
127
+	RescueCount         int64 `gorm:"-" json:"rescue_count" `
128
+	CureCount           int64 `gorm:"-" json:"cure_count" `
129
+	MissionCount        int64 `gorm:"-" json:"mission_count" `
130
+}
131
+
132
+func (VMUserAdminRole) TableName() string {
133
+	return "sgj_user_admin_role"
134
+}
135
+
136
+type VMDeviceNumber struct {
137
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
138
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
139
+	Number  string `gorm:"column:number" json:"number" form:"number"`
140
+	GroupId int64  `gorm:"column:group_id" json:"group_id" form:"group_id"`
141
+	ZoneId  int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
142
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
143
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
144
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
145
+}
146
+
147
+func (VMDeviceNumber) TableName() string {
148
+	return "xt_device_number"
149
+}