Browse Source

Merge branch 'xt_statistics_branch'

csx 4 years ago
parent
commit
87385ebf2c

+ 16 - 0
controllers/gobal_config_api_controller.go View File

@@ -59,6 +59,8 @@ func GobalConfigRegistRouters() {
59 59
 
60 60
 	beego.Router("/api/log/generate", &GobalConfigApiController{}, "get:GenerateLog")
61 61
 
62
+	beego.Router("/api/patients/search", &GobalConfigApiController{}, "Post:GetPatientsByKeyWord")
63
+
62 64
 }
63 65
 
64 66
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1200,3 +1202,17 @@ func (this *GobalConfigApiController) GenerateLog() {
1200 1202
 	})
1201 1203
 
1202 1204
 }
1205
+
1206
+func (this *GobalConfigApiController) GetPatientsByKeyWord() {
1207
+	keyWord := this.GetString("keyword")
1208
+	adminUserInfo := this.GetAdminUserInfo()
1209
+	patient, err := service.GetPatientsByKey(adminUserInfo.CurrentOrgId, keyWord)
1210
+	if err != nil {
1211
+		utils.ErrorLog(err.Error())
1212
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1213
+		return
1214
+	}
1215
+	this.ServeSuccessJSON(map[string]interface{}{
1216
+		"patient": patient,
1217
+	})
1218
+}

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -110,4 +110,6 @@ func MobileAPIControllersRegisterRouters() {
110 110
 
111 111
 	beego.Router("/m/api/getPatientid", &DialysisAPIController{}, "Get:GetPatientId")
112 112
 
113
+	beego.Router("/m/api/patient/search", &PatientApiController{}, "Get:GetSearchPatient")
114
+
113 115
 }

+ 14 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -2668,3 +2668,17 @@ func (this *PatientApiController) GetPatientsByKeyWord() {
2668 2668
 		"patient": patient,
2669 2669
 	})
2670 2670
 }
2671
+
2672
+func (this *PatientApiController) GetSearchPatient() {
2673
+	keyWord := this.GetString("keyword")
2674
+	adminUserInfo := this.GetMobileAdminUserInfo()
2675
+	patient, err := service.GetPatientsByKey(adminUserInfo.Org.Id, keyWord)
2676
+	if err != nil {
2677
+		utils.ErrorLog(err.Error())
2678
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2679
+		return
2680
+	}
2681
+	this.ServeSuccessJSON(map[string]interface{}{
2682
+		"patient": patient,
2683
+	})
2684
+}

+ 23 - 0
controllers/new_mobile_api_controllers/common_api_router.go View File

@@ -6,6 +6,29 @@ import (
6 6
 
7 7
 func CommonApiControllersRegisterRouters() {
8 8
 
9
+	beego.Router("/api/dialysisprocessindex/chart", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexChartData")
10
+	beego.Router("/api/dialysisprocessindex/table", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexTableData")
11
+
12
+	beego.Router("/api/dialysiswatch/chart", &IndexEvaluationApiController{}, "Get:GetDialysisWatchChartData")
13
+	beego.Router("/api/dialysiswatch/table", &IndexEvaluationApiController{}, "Get:GetDialysisWatchTableData")
14
+
15
+	beego.Router("/api/dialysisbloodpressure/chart", &IndexEvaluationApiController{}, "Get:GetDialysisBloodPressureChartData")
16
+	beego.Router("/api/dialysisbloodpressure/table", &IndexEvaluationApiController{}, "Get:GetDialysisBloodPressureTableData")
17
+	beego.Router("/api/patientdialysisbloodpressure/chart", &IndexEvaluationApiController{}, "Get:GetDialysisPatientBloodPressureChartData")
18
+
19
+	beego.Router("/api/dialysisweight/chart", &IndexEvaluationApiController{}, "Get:GetDialysisWeightChartData")
20
+	beego.Router("/api/dialysisweight/table", &IndexEvaluationApiController{}, "Get:GetDialysisWeightTableData")
21
+	beego.Router("/api/patientdialysisweight/chart", &IndexEvaluationApiController{}, "Get:GetDialysisPatientWeightChartData")
22
+
23
+	beego.Router("/api/doctorworkload/chart", &IndexEvaluationApiController{}, "Get:GetDoctorWorkloadChartData")
24
+	beego.Router("/api/doctorworkload/table", &IndexEvaluationApiController{}, "Get:GetDoctorWorkloadTableData")
25
+
26
+	beego.Router("/api/nurseworkload/chart", &IndexEvaluationApiController{}, "Get:GetNurseWorkloadChartData")
27
+	beego.Router("/api/nurseworkload/table", &IndexEvaluationApiController{}, "Get:GetNurseWorkloadTableData")
28
+
29
+	beego.Router("/api/adminuser/all", &IndexEvaluationApiController{}, "Get:GetAdminUser")
30
+	beego.Router("/api/defalutpatient/get", &IndexEvaluationApiController{}, "Get:GetDefaultPatient")
31
+
9 32
 	beego.Router("/com/api/getinspectionmajor", &CommonApiController{}, "Get:GetInspectionMajor")
10 33
 	beego.Router("/com/api/getinspectionminor", &CommonApiController{}, "Get:GetInspectionMinor")
11 34
 	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")

+ 617 - 0
controllers/pc_index_evaluation_api_controller.go View File

@@ -0,0 +1,617 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service/statistics_service"
6
+	"XT_New/utils"
7
+	"time"
8
+)
9
+
10
+type PCIndexEvaluationApiController struct {
11
+	BaseAuthAPIController
12
+}
13
+
14
+func (this *PCIndexEvaluationApiController) GetAdminUser() {
15
+	admins, _ := statistics_service.GetAllAdminUser(this.GetAdminUserInfo().CurrentOrgId)
16
+	this.ServeSuccessJSON(map[string]interface{}{
17
+		"admin": admins,
18
+	})
19
+}
20
+
21
+func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexChartData() {
22
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId)
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.CurrentOrgId, 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.CurrentOrgId, 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.CurrentOrgId, 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.CurrentOrgId, 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 *PCIndexEvaluationApiController) GetDialysisProcessIndexTableData() {
88
+	adminUserInfo := this.GetAdminUserInfo()
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
+	}
122
+
123
+	if patient_id == 0 {
124
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
125
+		if patientInfo == nil {
126
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
127
+			return
128
+		}
129
+
130
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
131
+
132
+		this.ServeSuccessJSON(map[string]interface{}{
133
+			"data":  data,
134
+			"total": total,
135
+		})
136
+
137
+	} else {
138
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, 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 *PCIndexEvaluationApiController) GetDialysisWatchChartData() {
149
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId)
176
+		if patientInfo == nil {
177
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
178
+			return
179
+		}
180
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
181
+		this.ServeSuccessJSON(map[string]interface{}{
182
+			"data": data,
183
+		})
184
+	} else {
185
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
186
+		this.ServeSuccessJSON(map[string]interface{}{
187
+			"data": data,
188
+		})
189
+	}
190
+
191
+}
192
+func (this *PCIndexEvaluationApiController) GetDialysisWatchTableData() {
193
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId)
228
+		if patientInfo == nil {
229
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
230
+			return
231
+		}
232
+
233
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, 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.CurrentOrgId, 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 *PCIndexEvaluationApiController) GetDialysisBloodPressureChartData() {
253
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, patient_id)
280
+	this.ServeSuccessJSON(map[string]interface{}{
281
+		"data": data,
282
+	})
283
+
284
+}
285
+func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureTableData() {
286
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
320
+	this.ServeSuccessJSON(map[string]interface{}{
321
+		"data":  data,
322
+		"total": total,
323
+	})
324
+
325
+}
326
+func (this *PCIndexEvaluationApiController) GetDialysisPatientBloodPressureChartData() {
327
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
354
+	this.ServeSuccessJSON(map[string]interface{}{
355
+		"data": data,
356
+	})
357
+
358
+}
359
+
360
+func (this *PCIndexEvaluationApiController) GetDialysisWeightChartData() {
361
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
386
+	this.ServeSuccessJSON(map[string]interface{}{
387
+		"data": data,
388
+	})
389
+
390
+}
391
+func (this *PCIndexEvaluationApiController) GetDialysisWeightTableData() {
392
+	adminUserInfo := this.GetAdminUserInfo()
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()
423
+	}
424
+
425
+	data, total, _ := statistics_service.GetDialysisWeightTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
426
+	this.ServeSuccessJSON(map[string]interface{}{
427
+		"data":  data,
428
+		"total": total,
429
+	})
430
+}
431
+func (this *PCIndexEvaluationApiController) GetDialysisPatientWeightChartData() {
432
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
459
+	this.ServeSuccessJSON(map[string]interface{}{
460
+		"data": data,
461
+	})
462
+
463
+}
464
+
465
+func (this *PCIndexEvaluationApiController) GetDoctorWorkloadChartData() {
466
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
491
+	this.ServeSuccessJSON(map[string]interface{}{
492
+		"data": data,
493
+	})
494
+
495
+}
496
+func (this *PCIndexEvaluationApiController) GetDoctorWorkloadTableData() {
497
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id)
530
+	this.ServeSuccessJSON(map[string]interface{}{
531
+		"data": data,
532
+	})
533
+}
534
+
535
+func (this *PCIndexEvaluationApiController) GetNurseWorkloadChartData() {
536
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
561
+	this.ServeSuccessJSON(map[string]interface{}{
562
+		"data": data,
563
+	})
564
+
565
+}
566
+func (this *PCIndexEvaluationApiController) GetNurseWorkloadTableData() {
567
+	adminUserInfo := this.GetAdminUserInfo()
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.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id)
600
+	this.ServeSuccessJSON(map[string]interface{}{
601
+		"data": data,
602
+	})
603
+}
604
+
605
+func (this *PCIndexEvaluationApiController) GetDefaultPatient() {
606
+	adminUserInfo := this.GetAdminUserInfo()
607
+	patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
608
+	if patientInfo == nil {
609
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
610
+		return
611
+	}
612
+
613
+	this.ServeSuccessJSON(map[string]interface{}{
614
+		"patient": patientInfo,
615
+	})
616
+
617
+}

+ 11 - 0
service/patient_service.go View File

@@ -1328,3 +1328,14 @@ func UpdateDoctorEditAdvice(advice models.XtDoctorAdvice, orgid int64, groupno i
1328 1328
 	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and groupno = ? and advice_date = ? and patient_id = ?", orgid, groupno, date, patientid).Update(map[string]interface{}{"start_time": advice.StartTime, "updated_time": advice.UpdatedTime}).Error
1329 1329
 	return err
1330 1330
 }
1331
+
1332
+func GetPatientsByKey(orgID int64, keywords string) (patient []*models.Patients, err error) {
1333
+	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 ", orgID)
1334
+	if len(keywords) > 0 {
1335
+		likekey := "%" + keywords + "%"
1336
+		err = db.Where("(name LIKE ? OR dialysis_no LIKE ?)", likekey, likekey).Find(&patient).Error
1337
+	} else {
1338
+		err = db.Find(&patient).Error
1339
+	}
1340
+	return
1341
+}