|
@@ -2,18 +2,20 @@ package service
|
2
|
2
|
|
3
|
3
|
import (
|
4
|
4
|
"XT_Admin_Api/models"
|
|
5
|
+ "XT_Admin_Api/models/admin_models"
|
5
|
6
|
"XT_Admin_Api/utils"
|
|
7
|
+ "fmt"
|
6
|
8
|
"github.com/jinzhu/gorm"
|
7
|
9
|
"time"
|
8
|
10
|
)
|
9
|
11
|
|
10
|
12
|
func GetAllOrgList(active_status int64,depth_active_status int64,start_time int64,end_time int64,province int64,city int64,district int64,follow int64,keyword string,page int64, limit int64) (list []*models.Org, err error, total int64){
|
11
|
13
|
offset := (page - 1) * limit
|
12
|
|
-
|
|
14
|
+ fmt.Println(offset)
|
13
|
15
|
db := readUserDb.Model(&models.Org{})
|
14
|
16
|
if len(keyword) > 0{
|
15
|
17
|
likeKey := "%" + keyword + "%"
|
16
|
|
- db = db.Where("contact_name LIKE ?",likeKey)
|
|
18
|
+ db = db.Where("contact_name LIKE ? Or org_name LIKE ? Or org_short_name Like ? ",likeKey,likeKey,likeKey)
|
17
|
19
|
}else{
|
18
|
20
|
|
19
|
21
|
switch active_status {
|
|
@@ -23,13 +25,13 @@ func GetAllOrgList(active_status int64,depth_active_status int64,start_time int6
|
23
|
25
|
db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND sgj_user_admin_login_log.ctime >= ? AND sgj_user_admin_login_log.ctime <= ? AND sgj_user_admin_login_log.app_type = 3",zeroHourTimeOfToday.Unix(),now.Unix())
|
24
|
26
|
break
|
25
|
27
|
case 2:
|
26
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3")
|
|
28
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
27
|
29
|
break
|
28
|
30
|
case 3:
|
29
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3")
|
|
31
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
30
|
32
|
break
|
31
|
33
|
case 4:
|
32
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 Year) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3")
|
|
34
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 Year) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
33
|
35
|
break
|
34
|
36
|
}
|
35
|
37
|
|
|
@@ -37,23 +39,23 @@ func GetAllOrgList(active_status int64,depth_active_status int64,start_time int6
|
37
|
39
|
case 1:
|
38
|
40
|
now := time.Now()
|
39
|
41
|
zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
|
40
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND sgj_user_admin_login_log.ctime >= ? AND sgj_user_admin_login_log.ctime <= ? AND sgj_user_admin_login_log.app_type = 3",zeroHourTimeOfToday.Unix(),now.Unix())
|
41
|
|
- db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3",zeroHourTimeOfToday.Unix(),now.Unix())
|
|
42
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND sgj_user_admin_login_log.ctime >= ? AND sgj_user_admin_login_log.ctime <= ? AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ",zeroHourTimeOfToday.Unix(),now.Unix())
|
|
43
|
+ db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
42
|
44
|
|
43
|
45
|
break
|
44
|
46
|
case 2:
|
45
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3")
|
46
|
|
- db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3")
|
|
47
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
|
48
|
+ db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
47
|
49
|
|
48
|
50
|
break
|
49
|
51
|
case 3:
|
50
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3")
|
51
|
|
- db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3")
|
|
52
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
|
53
|
+ db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
52
|
54
|
|
53
|
55
|
break
|
54
|
56
|
case 4:
|
55
|
|
- db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 Year) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3")
|
56
|
|
- db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3")
|
|
57
|
+ db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 Year) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
|
58
|
+ db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
|
57
|
59
|
|
58
|
60
|
break
|
59
|
61
|
}
|
|
@@ -62,49 +64,423 @@ func GetAllOrgList(active_status int64,depth_active_status int64,start_time int6
|
62
|
64
|
}
|
63
|
65
|
|
64
|
66
|
if city > 0{
|
65
|
|
- db = db.Where("sgj_user_org.province = ?",city)
|
|
67
|
+ db = db.Where("sgj_user_org.city = ?",city)
|
66
|
68
|
}
|
67
|
69
|
|
68
|
70
|
if district > 0{
|
69
|
|
- db = db.Where("sgj_user_org.province = ?",district)
|
|
71
|
+ db = db.Where("sgj_user_org.district = ?",district)
|
70
|
72
|
}
|
71
|
73
|
|
72
|
74
|
if start_time != 0 {
|
73
|
|
- db = db.Where("ctime>=?", start_time)
|
|
75
|
+ db = db.Where("sgj_user_org.ctime>=?", start_time)
|
74
|
76
|
}
|
75
|
77
|
if end_time != 0 {
|
76
|
|
- db = db.Where("ctime<=?", end_time)
|
|
78
|
+ db = db.Where("sgj_user_org.ctime<=?", end_time)
|
77
|
79
|
}
|
78
|
80
|
|
79
|
81
|
}
|
80
|
|
- err = db.Where("status = 1").Count(&total).Offset(offset).Limit(limit).Find(&list).Error
|
|
82
|
+ err = db.Where("sgj_user_org.status = 1").Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
|
|
83
|
+ return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
|
|
84
|
+ }).Count(&total).Offset(offset).Limit(limit).Group("id").Find(&list).Error
|
81
|
85
|
return
|
82
|
86
|
}
|
83
|
87
|
|
84
|
88
|
|
85
|
89
|
func GetOrgDetailInfo(org_id int64) (info models.Org, err error){
|
86
|
|
- err = readUserDb.Model(&models.Org{}).Where("org_id = ? AND status = 1",org_id).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
|
87
|
|
- return db.Model(&models.AdminUserLoginLog{}).Where("status = 1 AND id = (SELECT max(id))")
|
88
|
|
- }).Find(&info).Error
|
|
90
|
+ err = readUserDb.Model(&models.Org{}).Where("id = ? AND status = 1",org_id).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
|
|
91
|
+ return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
|
|
92
|
+ }).Preload("AdminUser","status = 1").Find(&info).Error
|
89
|
93
|
return
|
90
|
94
|
}
|
91
|
95
|
|
|
96
|
+func GetDistrictsById(id int64)(district models.District, err error){
|
|
97
|
+ err = readUserDb.Model(&models.District{}).Where("id = ? ", id).First(&district).Error
|
|
98
|
+ return
|
|
99
|
+}
|
92
|
100
|
|
|
101
|
+func GetAllOrgType()(types []*models.OrgType, err error){
|
|
102
|
+ err = readUserDb.Model(&models.OrgType{}).Find(&types).Error
|
|
103
|
+ return
|
|
104
|
+}
|
|
105
|
+//设置今天和昨天的数据
|
|
106
|
+func GetOrgDialysisCount(statices_type int64, org_id int64, from int64,to int64) (count int64, err error){
|
|
107
|
+ var counts int64
|
93
|
108
|
|
94
|
|
-func GetOrgNewPatientInfo(org_id int64, from int64,to int64) (count int64, err error){
|
|
109
|
+ switch statices_type {
|
|
110
|
+ case 1: //病人管理
|
|
111
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_patients WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
112
|
+ if err != nil {
|
|
113
|
+ return 0, err
|
|
114
|
+ }
|
|
115
|
+ if rows.Next() {
|
|
116
|
+ rows.Scan(&counts)
|
|
117
|
+ }
|
|
118
|
+ break
|
|
119
|
+ case 2: //透析处方
|
|
120
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_dialysis_prescription WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
121
|
+ if err != nil {
|
|
122
|
+ return 0, err
|
|
123
|
+ }
|
|
124
|
+ if rows.Next() {
|
|
125
|
+ rows.Scan(&counts)
|
|
126
|
+ }
|
|
127
|
+ break
|
|
128
|
+ case 3: //接诊评估
|
|
129
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_receive_treatment_asses WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
130
|
+ if err != nil {
|
|
131
|
+ return 0, err
|
|
132
|
+ }
|
|
133
|
+ if rows.Next() {
|
|
134
|
+ rows.Scan(&counts)
|
|
135
|
+ }
|
|
136
|
+ break
|
|
137
|
+ case 4: //透前评估
|
|
138
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_assessment_before_dislysis WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
139
|
+ if err != nil {
|
|
140
|
+ return 0, err
|
|
141
|
+ }
|
|
142
|
+ if rows.Next() {
|
|
143
|
+ rows.Scan(&counts)
|
|
144
|
+ }
|
|
145
|
+ break
|
|
146
|
+ case 5://临时医嘱
|
|
147
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT patient_id) AS count FROM xt_doctor_advice WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
148
|
+ if err != nil {
|
|
149
|
+ return 0, err
|
|
150
|
+ }
|
|
151
|
+ if rows.Next() {
|
|
152
|
+ rows.Scan(&counts)
|
|
153
|
+ }
|
|
154
|
+ break
|
|
155
|
+ case 6: //双人核对
|
|
156
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_double_check WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
157
|
+ if err != nil {
|
|
158
|
+ return 0, err
|
|
159
|
+ }
|
|
160
|
+ if rows.Next() {
|
|
161
|
+ rows.Scan(&counts)
|
|
162
|
+ }
|
|
163
|
+ break
|
|
164
|
+ case 7: //透析上机
|
|
165
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_dialysis_order WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1 AND (stage = 2 OR stage = 1)",org_id ,from, to).Rows()
|
|
166
|
+ if err != nil {
|
|
167
|
+ return 0, err
|
|
168
|
+ }
|
|
169
|
+ if rows.Next() {
|
|
170
|
+ rows.Scan(&counts)
|
|
171
|
+ }
|
|
172
|
+ break
|
95
|
173
|
|
96
|
|
- var counts int64
|
97
|
|
- rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_patients WHERE org_id = ? AND created_time >= ? AND created_time <= ?",org_id ,from, to).Rows()
|
98
|
|
- if err != nil {
|
99
|
|
- return 0, err
|
100
|
|
- }
|
101
|
|
- if rows.Next() {
|
102
|
|
- rows.Scan(&counts)
|
|
174
|
+ case 8: //透析监测
|
|
175
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT patient_id) AS count FROM xt_monitoring_record WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
176
|
+ if err != nil {
|
|
177
|
+ return 0, err
|
|
178
|
+ }
|
|
179
|
+ if rows.Next() {
|
|
180
|
+ rows.Scan(&counts)
|
|
181
|
+ }
|
|
182
|
+ break
|
|
183
|
+ case 9: //透析下机
|
|
184
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_dialysis_order WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND stage = 2 AND status = 1",org_id ,from, to).Rows()
|
|
185
|
+ if err != nil {
|
|
186
|
+ return 0, err
|
|
187
|
+ }
|
|
188
|
+ if rows.Next() {
|
|
189
|
+ rows.Scan(&counts)
|
|
190
|
+ }
|
|
191
|
+ break
|
|
192
|
+ case 10: //透后评估
|
|
193
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_assessment_after_dislysis WHERE user_org_id = ? AND created_time >= ? AND created_time <= ? AND status = 1",org_id ,from, to).Rows()
|
|
194
|
+ if err != nil {
|
|
195
|
+ return 0, err
|
|
196
|
+ }
|
|
197
|
+ if rows.Next() {
|
|
198
|
+ rows.Scan(&counts)
|
|
199
|
+ }
|
|
200
|
+ break
|
|
201
|
+ case 11: //入库单
|
|
202
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_warehouse WHERE org_id = ? AND ctime >= ? AND mtime <= ? AND status = 1",org_id ,from, to).Rows()
|
|
203
|
+ if err != nil {
|
|
204
|
+ return 0, err
|
|
205
|
+ }
|
|
206
|
+ if rows.Next() {
|
|
207
|
+ rows.Scan(&counts)
|
|
208
|
+ }
|
|
209
|
+ break
|
|
210
|
+ case 12: //出库单
|
|
211
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM xt_warehouse_out WHERE org_id = ? AND ctime >= ? AND mtime <= ? AND status = 1",org_id ,from, to).Rows()
|
|
212
|
+ if err != nil {
|
|
213
|
+ return 0, err
|
|
214
|
+ }
|
|
215
|
+ if rows.Next() {
|
|
216
|
+ rows.Scan(&counts)
|
|
217
|
+ }
|
|
218
|
+ break
|
103
|
219
|
}
|
104
|
220
|
return counts, nil
|
105
|
221
|
}
|
106
|
222
|
|
|
223
|
+//获取近七天的数据
|
|
224
|
+func GetWeekOrgDialysisCount(statices_type int64,org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
|
|
225
|
+ fmt.Println(statices_type)
|
|
226
|
+
|
|
227
|
+ switch statices_type {
|
|
228
|
+ case 1: //病人管理
|
|
229
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
|
|
230
|
+
|
|
231
|
+ break
|
|
232
|
+ case 2: //透析处方
|
|
233
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_dialysis_prescription where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
234
|
+
|
|
235
|
+ break
|
|
236
|
+ case 3: //接诊评估
|
|
237
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_receive_treatment_asses where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
238
|
+
|
|
239
|
+ break
|
|
240
|
+ case 4: //透前评估
|
|
241
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_assessment_before_dislysis where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
242
|
+ break
|
|
243
|
+
|
|
244
|
+ case 5://临时医嘱
|
|
245
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_doctor_advice where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
246
|
+
|
|
247
|
+ break
|
|
248
|
+ case 6: //双人核对
|
|
249
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_double_check where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
250
|
+
|
|
251
|
+ break
|
|
252
|
+ case 7: //透析上机
|
|
253
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? AND (stage = 2 OR stage = 1) GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
254
|
+ break
|
|
255
|
+
|
|
256
|
+ case 8: //透析监测
|
|
257
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_monitoring_record where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
258
|
+ break
|
|
259
|
+ case 9: //透析下机
|
|
260
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND stage = 2 AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
261
|
+
|
|
262
|
+ break
|
|
263
|
+ case 10: //透后评估
|
|
264
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_assessment_after_dislysis where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
265
|
+ break
|
|
266
|
+ case 11: //入库单
|
|
267
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from xt_warehouse where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
268
|
+ break
|
|
269
|
+ case 12: //出库单
|
|
270
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from xt_warehouse_out where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
271
|
+ break
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ return
|
|
275
|
+}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+func GetMonthOrgDialysisCount(statices_type int64,org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
|
|
280
|
+ switch statices_type {
|
|
281
|
+ case 1: //病人管理
|
|
282
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
|
|
283
|
+
|
|
284
|
+ break
|
|
285
|
+ case 2: //透析处方
|
|
286
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_dialysis_prescription where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
287
|
+
|
|
288
|
+ break
|
|
289
|
+ case 3: //接诊评估
|
|
290
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_receive_treatment_asses where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
107
|
291
|
|
|
292
|
+ break
|
|
293
|
+ case 4: //透前评估
|
|
294
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_assessment_before_dislysis where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
295
|
+ break
|
|
296
|
+
|
|
297
|
+ case 5://临时医嘱
|
|
298
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_doctor_advice where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
299
|
+
|
|
300
|
+ break
|
|
301
|
+ case 6: //双人核对
|
|
302
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_double_check where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
303
|
+
|
|
304
|
+ break
|
|
305
|
+ case 7: //透析下机
|
|
306
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? AND (stage = 2 OR stage = 1) GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
307
|
+ break
|
|
308
|
+
|
|
309
|
+ case 8: //透析监测
|
|
310
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_monitoring_record where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
311
|
+ break
|
|
312
|
+ case 9: //透析下机
|
|
313
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND stage = 2 AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
314
|
+
|
|
315
|
+ break
|
|
316
|
+ case 10: //透后评估
|
|
317
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_assessment_after_dislysis where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
318
|
+ break
|
|
319
|
+ case 11: //入库单
|
|
320
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from xt_warehouse where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
321
|
+ break
|
|
322
|
+ case 12: //出库单
|
|
323
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from xt_warehouse_out where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
324
|
+ break
|
|
325
|
+ }
|
|
326
|
+ return
|
|
327
|
+}
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+func GetThreeMonthOrgDialysisCount(statices_type int64,org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
|
|
331
|
+ switch statices_type {
|
|
332
|
+ case 1: //病人管理
|
|
333
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
|
|
334
|
+
|
|
335
|
+ break
|
|
336
|
+ case 2: //透析处方
|
|
337
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_prescription where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
338
|
+
|
|
339
|
+ break
|
|
340
|
+ case 3: //接诊评估
|
|
341
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_receive_treatment_asses where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
342
|
+
|
|
343
|
+ break
|
|
344
|
+ case 4: //透前评估
|
|
345
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_assessment_before_dislysis where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
346
|
+ break
|
|
347
|
+
|
|
348
|
+ case 5://临时医嘱
|
|
349
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_doctor_advice where DATE_SUB(CURDATE(),INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
350
|
+
|
|
351
|
+ break
|
|
352
|
+ case 6: //双人核对
|
|
353
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_double_check where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
354
|
+
|
|
355
|
+ break
|
|
356
|
+ case 7: //透析上机
|
|
357
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? AND (stage = 2 OR stage = 1) GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
358
|
+ break
|
|
359
|
+
|
|
360
|
+ case 8: //透析监测
|
|
361
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_monitoring_record where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times ",org_id).Scan(&weekStatistics).Error
|
|
362
|
+ break
|
|
363
|
+ case 9: //透析下机
|
|
364
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND stage = 2 AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
365
|
+
|
|
366
|
+ break
|
|
367
|
+ case 10: //透后评估
|
|
368
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_assessment_after_dislysis where DATE_SUB(CURDATE(),INTERVAL 3 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
369
|
+ break
|
|
370
|
+ case 11: //入库单
|
|
371
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times from xt_warehouse where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times ",org_id).Scan(&weekStatistics).Error
|
|
372
|
+ break
|
|
373
|
+ case 12: //出库单
|
|
374
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times from xt_warehouse_out where DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
375
|
+ break
|
|
376
|
+ }
|
|
377
|
+ return
|
|
378
|
+}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+func GetSixMonthOrgDialysisCount(statices_type int64,org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
|
|
383
|
+ switch statices_type {
|
|
384
|
+ case 1: //病人管理
|
|
385
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
|
|
386
|
+
|
|
387
|
+ break
|
|
388
|
+ case 2: //透析处方
|
|
389
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_prescription where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
390
|
+
|
|
391
|
+ break
|
|
392
|
+ case 3: //接诊评估
|
|
393
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_receive_treatment_asses where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
394
|
+
|
|
395
|
+ break
|
|
396
|
+ case 4: //透前评估
|
|
397
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_assessment_before_dislysis where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
398
|
+ break
|
|
399
|
+
|
|
400
|
+ case 5://临时医嘱
|
|
401
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_doctor_advice where DATE_SUB(CURDATE(),INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
402
|
+
|
|
403
|
+ break
|
|
404
|
+ case 6: //双人核对
|
|
405
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_double_check where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
406
|
+
|
|
407
|
+ break
|
|
408
|
+ case 7: //透析上机
|
|
409
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? AND (stage = 2 OR stage = 1) GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
410
|
+ break
|
|
411
|
+
|
|
412
|
+ case 8: //透析监测
|
|
413
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_monitoring_record where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times ",org_id).Scan(&weekStatistics).Error
|
|
414
|
+ break
|
|
415
|
+ case 9: //透析下机
|
|
416
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND stage = 2 AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
417
|
+
|
|
418
|
+ break
|
|
419
|
+ case 10: //透后评估
|
|
420
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_assessment_after_dislysis where DATE_SUB(CURDATE(),INTERVAL 6 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
421
|
+ break
|
|
422
|
+ case 11: //入库单
|
|
423
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times from xt_warehouse where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times ",org_id).Scan(&weekStatistics).Error
|
|
424
|
+ break
|
|
425
|
+ case 12: //出库单
|
|
426
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times from xt_warehouse_out where DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
427
|
+ break
|
|
428
|
+ }
|
|
429
|
+ return
|
|
430
|
+}
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+func GetYearOrgDialysisCount(statices_type int64,org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
|
|
436
|
+ switch statices_type {
|
|
437
|
+ case 1: //病人管理
|
|
438
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
|
|
439
|
+
|
|
440
|
+ break
|
|
441
|
+ case 2: //透析处方
|
|
442
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_prescription where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
443
|
+
|
|
444
|
+ break
|
|
445
|
+ case 3: //接诊评估
|
|
446
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_receive_treatment_asses where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
447
|
+
|
|
448
|
+ break
|
|
449
|
+ case 4: //透前评估
|
|
450
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_assessment_before_dislysis where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
451
|
+ break
|
|
452
|
+
|
|
453
|
+ case 5://临时医嘱
|
|
454
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_doctor_advice where DATE_SUB(CURDATE(),INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
455
|
+
|
|
456
|
+ break
|
|
457
|
+ case 6: //双人核对
|
|
458
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_double_check where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
459
|
+
|
|
460
|
+ break
|
|
461
|
+ case 7: //透析上机
|
|
462
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? AND (stage = 2 OR stage = 1) GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
463
|
+ break
|
|
464
|
+
|
|
465
|
+ case 8: //透析监测
|
|
466
|
+ err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_monitoring_record where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times ",org_id).Scan(&weekStatistics).Error
|
|
467
|
+ break
|
|
468
|
+ case 9: //透析下机
|
|
469
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_dialysis_order where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND stage = 2 AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
470
|
+
|
|
471
|
+ break
|
|
472
|
+ case 10: //透后评估
|
|
473
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times from xt_assessment_after_dislysis where DATE_SUB(CURDATE(),INTERVAL 12 MONTH) <= date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
474
|
+ break
|
|
475
|
+ case 11: //入库单
|
|
476
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times from xt_warehouse where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times ",org_id).Scan(&weekStatistics).Error
|
|
477
|
+ break
|
|
478
|
+ case 12: //出库单
|
|
479
|
+ err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times from xt_warehouse_out where DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times",org_id).Scan(&weekStatistics).Error
|
|
480
|
+ break
|
|
481
|
+ }
|
|
482
|
+ return
|
|
483
|
+}
|
108
|
484
|
|
109
|
485
|
func GetDistrictsByUpid(id int64) (dis []*models.District, err error) {
|
110
|
486
|
err = readUserDb.Model(&models.District{}).Where("upid=?", id).Find(&dis).Error
|