|
@@ -2,6 +2,7 @@ package new_mobile_api_controllers
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
5
|
6
|
"XT_New/service/statistics_service"
|
6
|
7
|
"XT_New/utils"
|
7
|
8
|
"time"
|
|
@@ -18,6 +19,217 @@ func (this *IndexEvaluationApiController) GetAdminUser() {
|
18
|
19
|
})
|
19
|
20
|
}
|
20
|
21
|
|
|
22
|
+//化验指标
|
|
23
|
+
|
|
24
|
+//初始化数据
|
|
25
|
+func (this *IndexEvaluationApiController) GetLaboratoryIndexInitData() {
|
|
26
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
27
|
+ var references []*models.InspectionReference
|
|
28
|
+ count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
|
|
29
|
+ if count <= 0 {
|
|
30
|
+ references, _ = statistics_service.FindOrgInspectionReference(0)
|
|
31
|
+ } else {
|
|
32
|
+ references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id)
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
36
|
+ "references": references,
|
|
37
|
+ })
|
|
38
|
+
|
|
39
|
+}
|
|
40
|
+
|
|
41
|
+//获取取值范围
|
|
42
|
+func (this *IndexEvaluationApiController) GetLaboratoryIndexProjectRangeValueData() {
|
|
43
|
+ range_type, _ := this.GetInt64("range_type")
|
|
44
|
+ project_id, _ := this.GetInt64("project_id")
|
|
45
|
+ item_id, _ := this.GetInt64("item_id")
|
|
46
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
47
|
+ var range_vaule []string
|
|
48
|
+ if range_type == 1 {
|
|
49
|
+ qcs, _ := statistics_service.FindOrgConfigRnageTypeValue(adminUserInfo.Org.Id, project_id, item_id)
|
|
50
|
+ if qcs.ID == 0 { //没有配置选项
|
|
51
|
+ count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id) //判断是否为集成过来的数据
|
|
52
|
+ if count <= 0 { //不是,读系统参考值
|
|
53
|
+ reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
|
|
54
|
+ range_vaule = append(range_vaule, "小于"+reference.RangeMin)
|
|
55
|
+ range_vaule = append(range_vaule, reference.RangeMin+"~"+reference.RangeMax)
|
|
56
|
+ range_vaule = append(range_vaule, "大于"+reference.RangeMax)
|
|
57
|
+
|
|
58
|
+ } else { //是,读集成过来的参考值
|
|
59
|
+ reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.Org.Id, project_id, item_id)
|
|
60
|
+ range_vaule = append(range_vaule, "小于"+reference.RangeMin)
|
|
61
|
+ range_vaule = append(range_vaule, reference.RangeMin+"~"+reference.RangeMax)
|
|
62
|
+ range_vaule = append(range_vaule, "大于"+reference.RangeMax)
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ } else { //有配置
|
|
66
|
+ range_vaule = append(range_vaule, "小于"+qcs.MinRange)
|
|
67
|
+ range_vaule = append(range_vaule, qcs.MinRange+"~"+qcs.LargeRange)
|
|
68
|
+ range_vaule = append(range_vaule, "大于"+qcs.LargeRange)
|
|
69
|
+
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ } else {
|
|
73
|
+
|
|
74
|
+ inspection, _ := statistics_service.FindOrgInspectionReferenceRnageTypeValue(adminUserInfo.Org.Id, project_id, item_id)
|
|
75
|
+ for _, item := range inspection {
|
|
76
|
+ range_vaule = append(range_vaule, item.InspectValue)
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ }
|
|
80
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
81
|
+ "range_vaule": range_vaule,
|
|
82
|
+ })
|
|
83
|
+
|
|
84
|
+}
|
|
85
|
+func (this *IndexEvaluationApiController) GetInspectionChartData() {
|
|
86
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
87
|
+ start_time := this.GetString("start_time")
|
|
88
|
+ end_time := this.GetString("end_time")
|
|
89
|
+ project_id, _ := this.GetInt64("project_id")
|
|
90
|
+ item_id, _ := this.GetInt64("item_id")
|
|
91
|
+ range_type, _ := this.GetInt("range_type")
|
|
92
|
+ range_value := this.GetString("range_value")
|
|
93
|
+
|
|
94
|
+ timeLayout := "2006-01-02"
|
|
95
|
+ loc, _ := time.LoadLocation("Local")
|
|
96
|
+
|
|
97
|
+ var theStartTIme int64
|
|
98
|
+ if len(start_time) > 0 {
|
|
99
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
100
|
+ if err != nil {
|
|
101
|
+ utils.ErrorLog(err.Error())
|
|
102
|
+ }
|
|
103
|
+ theStartTIme = theTime.Unix()
|
|
104
|
+ }
|
|
105
|
+ var theEndtTIme int64
|
|
106
|
+ if len(end_time) > 0 {
|
|
107
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
108
|
+ if err != nil {
|
|
109
|
+ utils.ErrorLog(err.Error())
|
|
110
|
+ }
|
|
111
|
+ theEndtTIme = theTime.Unix()
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+ data, _ := statistics_service.GetInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value)
|
|
115
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
116
|
+ "data": data,
|
|
117
|
+ })
|
|
118
|
+
|
|
119
|
+}
|
|
120
|
+func (this *IndexEvaluationApiController) GetInspectionChartTableData() {
|
|
121
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
122
|
+ start_time := this.GetString("start_time")
|
|
123
|
+ end_time := this.GetString("end_time")
|
|
124
|
+ patient_id, _ := this.GetInt64("patient_id")
|
|
125
|
+ page, _ := this.GetInt64("page")
|
|
126
|
+ limit, _ := this.GetInt64("limit")
|
|
127
|
+ project_id, _ := this.GetInt64("project_id")
|
|
128
|
+ item_id, _ := this.GetInt64("item_id")
|
|
129
|
+
|
|
130
|
+ if page == 0 {
|
|
131
|
+ page = 1
|
|
132
|
+ }
|
|
133
|
+ if limit == 0 {
|
|
134
|
+ limit = 20
|
|
135
|
+ }
|
|
136
|
+ timeLayout := "2006-01-02"
|
|
137
|
+ loc, _ := time.LoadLocation("Local")
|
|
138
|
+
|
|
139
|
+ var theStartTIme int64
|
|
140
|
+ if len(start_time) > 0 {
|
|
141
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
142
|
+ if err != nil {
|
|
143
|
+ utils.ErrorLog(err.Error())
|
|
144
|
+ }
|
|
145
|
+ theStartTIme = theTime.Unix()
|
|
146
|
+ }
|
|
147
|
+ var theEndtTIme int64
|
|
148
|
+ if len(end_time) > 0 {
|
|
149
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
150
|
+ if err != nil {
|
|
151
|
+ utils.ErrorLog(err.Error())
|
|
152
|
+ }
|
|
153
|
+ theEndtTIme = theTime.Unix()
|
|
154
|
+ }
|
|
155
|
+ data, total, _ := statistics_service.GetInspectionChartTableData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, patient_id, page, limit)
|
|
156
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
157
|
+ "data": data,
|
|
158
|
+ "total": total,
|
|
159
|
+ })
|
|
160
|
+
|
|
161
|
+}
|
|
162
|
+func (this *IndexEvaluationApiController) GetPatientInspectionChartData() {
|
|
163
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
164
|
+ start_time := this.GetString("start_time")
|
|
165
|
+ end_time := this.GetString("end_time")
|
|
166
|
+ project_id, _ := this.GetInt64("project_id")
|
|
167
|
+ item_id, _ := this.GetInt64("item_id")
|
|
168
|
+ patient_id, _ := this.GetInt64("patient_id")
|
|
169
|
+
|
|
170
|
+ timeLayout := "2006-01-02"
|
|
171
|
+ loc, _ := time.LoadLocation("Local")
|
|
172
|
+
|
|
173
|
+ var theStartTIme int64
|
|
174
|
+ if len(start_time) > 0 {
|
|
175
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
|
|
176
|
+ if err != nil {
|
|
177
|
+ utils.ErrorLog(err.Error())
|
|
178
|
+ }
|
|
179
|
+ theStartTIme = theTime.Unix()
|
|
180
|
+ }
|
|
181
|
+ var theEndtTIme int64
|
|
182
|
+ if len(end_time) > 0 {
|
|
183
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
|
|
184
|
+ if err != nil {
|
|
185
|
+ utils.ErrorLog(err.Error())
|
|
186
|
+ }
|
|
187
|
+ theEndtTIme = theTime.Unix()
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+ data, _ := statistics_service.GetPatientInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, patient_id)
|
|
191
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
192
|
+ "data": data,
|
|
193
|
+ })
|
|
194
|
+
|
|
195
|
+}
|
|
196
|
+func (this *IndexEvaluationApiController) GetPatientInspectionBarChartData() {
|
|
197
|
+ adminUserInfo := this.GetMobileAdminUserInfo()
|
|
198
|
+ start_time := this.GetString("start_time")
|
|
199
|
+ end_time := this.GetString("end_time")
|
|
200
|
+ project_id, _ := this.GetInt64("project_id")
|
|
201
|
+ item_id, _ := this.GetInt64("item_id")
|
|
202
|
+ range_type, _ := this.GetInt("range_type")
|
|
203
|
+ range_value := this.GetString("range_value")
|
|
204
|
+ patient_id, _ := this.GetInt64("patient_id")
|
|
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
|
+ data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
|
|
227
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
228
|
+ "data": data,
|
|
229
|
+ })
|
|
230
|
+
|
|
231
|
+}
|
|
232
|
+
|
21
|
233
|
func (this *IndexEvaluationApiController) GetDialysisProcessIndexChartData() {
|
22
|
234
|
adminUserInfo := this.GetMobileAdminUserInfo()
|
23
|
235
|
statistics_type, _ := this.GetInt("statistics_type")
|