|
@@ -15,20 +15,192 @@ type StatisticsApiController struct {
|
15
|
15
|
}
|
16
|
16
|
|
17
|
17
|
func StatisticsApiRegistRouters() {
|
18
|
|
-
|
19
|
18
|
beego.Router("/api/statistisc/index", &StatisticsApiController{}, "get:GetStatistics")
|
20
|
19
|
beego.Router("/api/qc/statistiscall/get", &StatisticsApiController{}, "get:GetAllInspectionStatistisc")
|
21
|
20
|
beego.Router("/api/qc/statistiscperson/get", &StatisticsApiController{}, "get:GetPersonInspectionStatistisc")
|
22
|
|
-
|
|
21
|
+ beego.Router("/api/qc/statistiscperson/list", &StatisticsApiController{}, "get:GetInsepctionList")
|
23
|
22
|
beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
|
|
23
|
+ beego.Router("/api/qc/patientinspectionstatistis/get", &StatisticsApiController{}, "get:GetFivePatientInspectionStatistisc")
|
24
|
24
|
|
25
|
|
- //beego.Router("/api/qc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientInspectionStatistisc")
|
|
25
|
+ beego.Router("/api/commonqc/statistiscall/get", &StatisticsApiController{}, "get:GetAllCommonInspectionStatistisc")
|
|
26
|
+ beego.Router("/api/commonqc/statistiscperson/get", &StatisticsApiController{}, "get:GetPersonCommonInspectionStatistisc")
|
|
27
|
+ beego.Router("/api/commonqc/patientstatistiscall/get", &StatisticsApiController{}, "get:GetPatientCommonInspectionStatistisc")
|
26
|
28
|
|
27
|
|
- //beego.Router("/api/qc/statistiscperson/export", &StatisticsApiController{}, "get:ExportPersonInspectionStatistisc")
|
|
29
|
+}
|
28
|
30
|
|
29
|
|
- beego.Router("/api/qc/patientinspectionstatistis/get", &StatisticsApiController{}, "get:GetFivePatientInspectionStatistisc")
|
|
31
|
+// 配置检验数据查询
|
|
32
|
+func (this *StatisticsApiController) GetInsepctionList() {
|
|
33
|
+ adminUser := this.GetAdminUserInfo()
|
|
34
|
+ orgid := adminUser.CurrentOrgId
|
|
35
|
+ configurationlist, err := service.GetInsepctionConfigurationList(orgid)
|
|
36
|
+ if err != nil {
|
|
37
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
38
|
+ return
|
|
39
|
+ }
|
|
40
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
41
|
+ "configurationlist": configurationlist,
|
|
42
|
+ })
|
|
43
|
+}
|
|
44
|
+func (c *StatisticsApiController) GetAllCommonInspectionStatistisc() {
|
|
45
|
+ start_date := c.GetString("start_date")
|
|
46
|
+ end_date := c.GetString("end_date")
|
|
47
|
+ project_id, _ := c.GetInt64("project_id")
|
|
48
|
+ item_id, _ := c.GetInt64("item_id")
|
|
49
|
+
|
|
50
|
+ timeLayout := "2006-01-02"
|
|
51
|
+ loc, _ := time.LoadLocation("Local")
|
|
52
|
+ var startTime int64
|
|
53
|
+ if len(start_date) > 0 {
|
|
54
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
|
|
55
|
+ fmt.Println("err-----------", err)
|
|
56
|
+ if err != nil {
|
|
57
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
58
|
+ return
|
|
59
|
+ }
|
|
60
|
+ startTime = theTime.Unix()
|
|
61
|
+ }
|
|
62
|
+ var endTime int64
|
|
63
|
+ if len(end_date) > 0 {
|
|
64
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
|
|
65
|
+ if err != nil {
|
|
66
|
+ utils.ErrorLog(err.Error())
|
|
67
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
68
|
+ return
|
|
69
|
+ }
|
|
70
|
+ endTime = theTime.Unix()
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ //患者总数
|
|
74
|
+ patientCount := service.GetPatientCount(c.GetAdminUserInfo().CurrentOrgId)
|
|
75
|
+ //获取配置
|
|
76
|
+ reference, _ := service.GetInspectionReferenceFour(project_id, item_id)
|
|
77
|
+ //获取数值在正常范围内的总数
|
|
78
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
79
|
+ max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
|
80
|
+ min, _ := strconv.ParseFloat(config.MinRange, 64)
|
|
81
|
+
|
|
82
|
+ normalTotal, _ := service.GetNormalInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min)
|
|
83
|
+ //获取数值异常的总数
|
|
84
|
+ unusualTotal, _ := service.GetUnusualInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min)
|
|
85
|
+ //获取没有检查的患者总数
|
|
86
|
+ noCheckTotal, _ := service.GetPatientNotInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID)
|
|
87
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
88
|
+ "patient_count": patientCount,
|
|
89
|
+ "normal_total": normalTotal,
|
|
90
|
+ "unusual_total": unusualTotal,
|
|
91
|
+ "no_check_total": noCheckTotal,
|
|
92
|
+ "reference": reference,
|
|
93
|
+ "config": config,
|
|
94
|
+ })
|
30
|
95
|
|
31
|
96
|
}
|
|
97
|
+func (c *StatisticsApiController) GetPersonCommonInspectionStatistisc() {
|
|
98
|
+ start_date := c.GetString("start_time")
|
|
99
|
+ end_date := c.GetString("end_time")
|
|
100
|
+ project_id, _ := c.GetInt64("project_id")
|
|
101
|
+ item_id, _ := c.GetInt64("item_id")
|
|
102
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
103
|
+
|
|
104
|
+ timeLayout := "2006-01-02"
|
|
105
|
+ loc, _ := time.LoadLocation("Local")
|
|
106
|
+ var startTime int64
|
|
107
|
+ if len(start_date) > 0 {
|
|
108
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
|
|
109
|
+ fmt.Println("err-----------", err)
|
|
110
|
+ if err != nil {
|
|
111
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
112
|
+ return
|
|
113
|
+ }
|
|
114
|
+ startTime = theTime.Unix()
|
|
115
|
+ }
|
|
116
|
+ var endTime int64
|
|
117
|
+ if len(end_date) > 0 {
|
|
118
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
|
|
119
|
+ if err != nil {
|
|
120
|
+ utils.ErrorLog(err.Error())
|
|
121
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
122
|
+ return
|
|
123
|
+ }
|
|
124
|
+ endTime = theTime.Unix()
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ patient, _ := service.GetFaPiaoPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
|
|
128
|
+ //获取配置
|
|
129
|
+ reference, _ := service.GetInspectionReferenceFour(project_id, item_id)
|
|
130
|
+ //获取数值在正常范围内的总数
|
|
131
|
+ inspections, _ := service.GetPatientInspectionByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.SysItemId, patient_id)
|
|
132
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
133
|
+ "patient": patient,
|
|
134
|
+ "reference": reference,
|
|
135
|
+ "inspections": inspections,
|
|
136
|
+ })
|
|
137
|
+
|
|
138
|
+}
|
|
139
|
+func (c *StatisticsApiController) GetPatientCommonInspectionStatistisc() {
|
|
140
|
+ start_date := c.GetString("start_date")
|
|
141
|
+ end_date := c.GetString("end_date")
|
|
142
|
+ project_id, _ := c.GetInt64("project_id")
|
|
143
|
+ item_id, _ := c.GetInt64("item_id")
|
|
144
|
+ item_type, _ := c.GetInt64("item_type")
|
|
145
|
+ keyword := c.GetString("keyword")
|
|
146
|
+ timeLayout := "2006-01-02"
|
|
147
|
+ loc, _ := time.LoadLocation("Local")
|
|
148
|
+ var startTime int64
|
|
149
|
+ if len(start_date) > 0 {
|
|
150
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
|
|
151
|
+ fmt.Println("err-----------", err)
|
|
152
|
+ if err != nil {
|
|
153
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
154
|
+ return
|
|
155
|
+ }
|
|
156
|
+ startTime = theTime.Unix()
|
|
157
|
+ }
|
|
158
|
+ var endTime int64
|
|
159
|
+ if len(end_date) > 0 {
|
|
160
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
|
|
161
|
+ if err != nil {
|
|
162
|
+ utils.ErrorLog(err.Error())
|
|
163
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
164
|
+ return
|
|
165
|
+ }
|
|
166
|
+ endTime = theTime.Unix()
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+ //获取配置
|
|
170
|
+ reference, _ := service.GetInspectionReferenceFour(project_id, item_id)
|
|
171
|
+ //获取数值在正常范围内的总数
|
|
172
|
+
|
|
173
|
+ config, _ := service.GetConfigurationById(project_id, item_id, c.GetAdminUserInfo().CurrentOrgId)
|
|
174
|
+ max, _ := strconv.ParseFloat(config.LargeRange, 64)
|
|
175
|
+ min, _ := strconv.ParseFloat(config.MinRange, 64)
|
|
176
|
+
|
|
177
|
+ //max, _ := strconv.ParseFloat(reference.RangeMax, 64)
|
|
178
|
+ //min, _ := strconv.ParseFloat(reference.RangeMin, 64)
|
|
179
|
+
|
|
180
|
+ switch item_type {
|
|
181
|
+ case 1:
|
|
182
|
+ list, _ := service.GetUnusualInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, keyword)
|
|
183
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
184
|
+ "list": list,
|
|
185
|
+ "reference": reference,
|
|
186
|
+ })
|
|
187
|
+ break
|
|
188
|
+ case 2:
|
|
189
|
+ list, _ := service.GetPatientNotInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, keyword)
|
|
190
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
191
|
+ "list": list,
|
|
192
|
+ "reference": reference,
|
|
193
|
+ })
|
|
194
|
+ break
|
|
195
|
+ case 3:
|
|
196
|
+ list, _ := service.GetNormalInspectionPatientList(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min, keyword)
|
|
197
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
198
|
+ "list": list,
|
|
199
|
+ "reference": reference,
|
|
200
|
+ })
|
|
201
|
+ break
|
|
202
|
+ }
|
|
203
|
+}
|
32
|
204
|
|
33
|
205
|
func (c *StatisticsApiController) GetFivePatientInspectionStatistisc() {
|
34
|
206
|
start_date := c.GetString("start_date")
|
|
@@ -60,7 +232,6 @@ func (c *StatisticsApiController) GetFivePatientInspectionStatistisc() {
|
60
|
232
|
"list": list,
|
61
|
233
|
})
|
62
|
234
|
}
|
63
|
|
-
|
64
|
235
|
func (c *StatisticsApiController) GetPatientInspectionStatistisc() {
|
65
|
236
|
start_date := c.GetString("start_date")
|
66
|
237
|
end_date := c.GetString("end_date")
|
|
@@ -170,7 +341,6 @@ func (c *StatisticsApiController) GetPatientInspectionStatistisc() {
|
170
|
341
|
break
|
171
|
342
|
}
|
172
|
343
|
}
|
173
|
|
-
|
174
|
344
|
func (c *StatisticsApiController) GetAllInspectionStatistisc() {
|
175
|
345
|
start_date := c.GetString("start_date")
|
176
|
346
|
end_date := c.GetString("end_date")
|
|
@@ -214,12 +384,9 @@ func (c *StatisticsApiController) GetAllInspectionStatistisc() {
|
214
|
384
|
if s_type == 2 {
|
215
|
385
|
normalTotal, _ := service.GetNormalKTVORURRInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1014, 10950, 1.2)
|
216
|
386
|
//获取数值异常的总数
|
217
|
|
- //unusualTotal, _ := service.GetUnusualKTVORURRInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1.2)
|
218
|
387
|
unusualTotal, _ := service.GetUnusualKTVORURRInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1014, 10950, 1.2)
|
219
|
|
-
|
220
|
388
|
//获取没有检查的患者总数
|
221
|
389
|
noCheckTotal, _ := service.GetPatientNotKTVORURRInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1014, 10950)
|
222
|
|
-
|
223
|
390
|
c.ServeSuccessJSON(map[string]interface{}{
|
224
|
391
|
"patient_count": patientCount,
|
225
|
392
|
"normal_total": normalTotal,
|
|
@@ -228,30 +395,24 @@ func (c *StatisticsApiController) GetAllInspectionStatistisc() {
|
228
|
395
|
})
|
229
|
396
|
|
230
|
397
|
} else if s_type == 3 {
|
231
|
|
-
|
232
|
398
|
normalTotal, _ := service.GetNormalKTVORURRInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1014, 10951, 65)
|
233
|
399
|
//获取数值异常的总数
|
234
|
400
|
//unusualTotal, _ := service.GetUnusualKTVORURRInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1.2)
|
235
|
401
|
unusualTotal, _ := service.GetUnusualKTVORURRInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1014, 10951, 65)
|
236
|
|
-
|
237
|
402
|
//获取没有检查的患者总数
|
238
|
403
|
noCheckTotal, _ := service.GetPatientNotKTVORURRInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, 1014, 10951)
|
239
|
|
-
|
240
|
404
|
c.ServeSuccessJSON(map[string]interface{}{
|
241
|
405
|
"patient_count": patientCount,
|
242
|
406
|
"normal_total": normalTotal,
|
243
|
407
|
"unusual_total": unusualTotal,
|
244
|
408
|
"no_check_total": noCheckTotal,
|
245
|
409
|
})
|
246
|
|
-
|
247
|
410
|
} else {
|
248
|
|
-
|
249
|
411
|
normalTotal, _ := service.GetNormalInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min)
|
250
|
412
|
//获取数值异常的总数
|
251
|
413
|
unusualTotal, _ := service.GetUnusualInspectionTotalByID(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID, max, min)
|
252
|
414
|
//获取没有检查的患者总数
|
253
|
415
|
noCheckTotal, _ := service.GetPatientNotInspectionTotal(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, reference.SystemProjectId, reference.ID)
|
254
|
|
-
|
255
|
416
|
c.ServeSuccessJSON(map[string]interface{}{
|
256
|
417
|
"patient_count": patientCount,
|
257
|
418
|
"normal_total": normalTotal,
|
|
@@ -259,7 +420,6 @@ func (c *StatisticsApiController) GetAllInspectionStatistisc() {
|
259
|
420
|
"no_check_total": noCheckTotal,
|
260
|
421
|
"reference": reference,
|
261
|
422
|
})
|
262
|
|
-
|
263
|
423
|
}
|
264
|
424
|
|
265
|
425
|
}
|
|
@@ -332,7 +492,6 @@ func (c *StatisticsApiController) GetPersonInspectionStatistisc() {
|
332
|
492
|
}
|
333
|
493
|
|
334
|
494
|
}
|
335
|
|
-
|
336
|
495
|
func (c *StatisticsApiController) GetStatistics() {
|
337
|
496
|
adminUserInfo := c.GetAdminUserInfo()
|
338
|
497
|
|