|
@@ -1080,3 +1080,444 @@ func GetProjectStandList(orgid int64, lapseto int64, modetype int64, startime in
|
1080
|
1080
|
}
|
1081
|
1081
|
return
|
1082
|
1082
|
}
|
|
1083
|
+
|
|
1084
|
+func GetMonthProjectList(orgid int64, lapseto int64, modetype int64, januaryStartStrUnix int64, januaryEndStrUnix int64, febStartStrStrUnix int64, febEndStrUnix int64, marchStartStrUnix int64, marchEndStrUnix int64, aprStartStrUnix int64, aprEndStrsUnix int64, mayStartStrUnix int64, mayEndStrsUnix int64, junStartStrUnix int64, junEndStrsUnix int64, julStartStrUnix int64, julEndStrsUnix int64, augStartStrUnix int64, augEndStrsUnix int64, sepStartStrUnix int64, sepEndStrsUnix int64, octStartStrUnix int64, octEndStrsUnix int64, novStartStrUnix int64, novEndStrsUnix int64, decStartStrUnix int64, decEndStrsUnix int64) (inspection []*models.ProjectCountOne, err error) {
|
|
1085
|
+
|
|
1086
|
+ if lapseto == 0 {
|
|
1087
|
+
|
|
1088
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1089
|
+ fmt.Println("d", d)
|
|
1090
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1091
|
+
|
|
1092
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1093
|
+ "SELECT " +
|
|
1094
|
+ "CASE " +
|
|
1095
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '一月'" +
|
|
1096
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '二月'" +
|
|
1097
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '三月'" +
|
|
1098
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '四月'" +
|
|
1099
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '五月'" +
|
|
1100
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '六月'" +
|
|
1101
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '七月'" +
|
|
1102
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '八月'" +
|
|
1103
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '九月'" +
|
|
1104
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十月'" +
|
|
1105
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十一月'" +
|
|
1106
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十二月'" +
|
|
1107
|
+ " ELSE '其他'" +
|
|
1108
|
+ "END AS nnd FROM xt_inspection as x left join xt_patients as s on s.id = x.patient_id WHERE x.status=1 and (s.lapseto = 1 or s.lapseto = 2)"
|
|
1109
|
+ countParams := make([]interface{}, 0)
|
|
1110
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1111
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1112
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1113
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1114
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1115
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1116
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1117
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1118
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1119
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1120
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1121
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1122
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1123
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1124
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1125
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1126
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1127
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1128
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1129
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1130
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1131
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1132
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1133
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1134
|
+ if orgid > 0 {
|
|
1135
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1136
|
+ countSQL += " AND x.org_id=?"
|
|
1137
|
+ countParams = append(countParams, orgid)
|
|
1138
|
+ }
|
|
1139
|
+ if modetype > 0 {
|
|
1140
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1141
|
+ countSQL += " AND x.item_id=?"
|
|
1142
|
+ countParams = append(countParams, modetype)
|
|
1143
|
+ }
|
|
1144
|
+ if januaryStartStrUnix > 0 {
|
|
1145
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1146
|
+ countSQL += " AND x.inspect_date >=?"
|
|
1147
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1148
|
+ }
|
|
1149
|
+ if decEndStrsUnix > 0 {
|
|
1150
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1151
|
+ countSQL += " AND x.inspect_date <=?"
|
|
1152
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1153
|
+ }
|
|
1154
|
+ countSQL += ")a GROUP BY nnd"
|
|
1155
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1156
|
+ }
|
|
1157
|
+
|
|
1158
|
+ if lapseto == 1 {
|
|
1159
|
+
|
|
1160
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1161
|
+ fmt.Println("d", d)
|
|
1162
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1163
|
+
|
|
1164
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1165
|
+ "SELECT " +
|
|
1166
|
+ "CASE " +
|
|
1167
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '一月'" +
|
|
1168
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '二月'" +
|
|
1169
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '三月'" +
|
|
1170
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '四月'" +
|
|
1171
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '五月'" +
|
|
1172
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '六月'" +
|
|
1173
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '七月'" +
|
|
1174
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '八月'" +
|
|
1175
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '九月'" +
|
|
1176
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十月'" +
|
|
1177
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十一月'" +
|
|
1178
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十二月'" +
|
|
1179
|
+ " ELSE '其他'" +
|
|
1180
|
+ "END AS nnd FROM xt_inspection as x left join xt_patients as s on s.id = x.patient_id WHERE x.status=1 and (s.lapseto = 1)"
|
|
1181
|
+ countParams := make([]interface{}, 0)
|
|
1182
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1183
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1184
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1185
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1186
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1187
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1188
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1189
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1190
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1191
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1192
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1193
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1194
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1195
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1196
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1197
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1198
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1199
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1200
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1201
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1202
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1203
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1204
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1205
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1206
|
+ if orgid > 0 {
|
|
1207
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1208
|
+ countSQL += " AND x.org_id=?"
|
|
1209
|
+ countParams = append(countParams, orgid)
|
|
1210
|
+ }
|
|
1211
|
+ if modetype > 0 {
|
|
1212
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1213
|
+ countSQL += " AND x.item_id=?"
|
|
1214
|
+ countParams = append(countParams, modetype)
|
|
1215
|
+ }
|
|
1216
|
+ if januaryStartStrUnix > 0 {
|
|
1217
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1218
|
+ countSQL += " AND x.inspect_date >=?"
|
|
1219
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1220
|
+ }
|
|
1221
|
+ if decEndStrsUnix > 0 {
|
|
1222
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1223
|
+ countSQL += " AND x.inspect_date <=?"
|
|
1224
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1225
|
+ }
|
|
1226
|
+ countSQL += ")a GROUP BY nnd"
|
|
1227
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1228
|
+ }
|
|
1229
|
+
|
|
1230
|
+ if lapseto == 2 {
|
|
1231
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1232
|
+ fmt.Println("d", d)
|
|
1233
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1234
|
+
|
|
1235
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1236
|
+ "SELECT " +
|
|
1237
|
+ "CASE " +
|
|
1238
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '一月'" +
|
|
1239
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '二月'" +
|
|
1240
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '三月'" +
|
|
1241
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '四月'" +
|
|
1242
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '五月'" +
|
|
1243
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '六月'" +
|
|
1244
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '七月'" +
|
|
1245
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '八月'" +
|
|
1246
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '九月'" +
|
|
1247
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十月'" +
|
|
1248
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十一月'" +
|
|
1249
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? THEN '十二月'" +
|
|
1250
|
+ " ELSE '其他'" +
|
|
1251
|
+ "END AS nnd FROM xt_inspection as x left join xt_patients as s on s.id = x.patient_id WHERE x.status=1 and (s.lapseto = 2)"
|
|
1252
|
+ countParams := make([]interface{}, 0)
|
|
1253
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1254
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1255
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1256
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1257
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1258
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1259
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1260
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1261
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1262
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1263
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1264
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1265
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1266
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1267
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1268
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1269
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1270
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1271
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1272
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1273
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1274
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1275
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1276
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1277
|
+ if orgid > 0 {
|
|
1278
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1279
|
+ countSQL += " AND x.org_id=?"
|
|
1280
|
+ countParams = append(countParams, orgid)
|
|
1281
|
+ }
|
|
1282
|
+ if modetype > 0 {
|
|
1283
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1284
|
+ countSQL += " AND x.item_id=?"
|
|
1285
|
+ countParams = append(countParams, modetype)
|
|
1286
|
+ }
|
|
1287
|
+ if januaryStartStrUnix > 0 {
|
|
1288
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1289
|
+ countSQL += " AND x.inspect_date >=?"
|
|
1290
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1291
|
+ }
|
|
1292
|
+ if decEndStrsUnix > 0 {
|
|
1293
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1294
|
+ countSQL += " AND x.inspect_date <=?"
|
|
1295
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1296
|
+ }
|
|
1297
|
+ countSQL += ")a GROUP BY nnd"
|
|
1298
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1299
|
+ }
|
|
1300
|
+ return
|
|
1301
|
+}
|
|
1302
|
+
|
|
1303
|
+func GetMonthProjectListTwo(orgid int64, lapseto int64, modetype int64, januaryStartStrUnix int64, januaryEndStrUnix int64, febStartStrStrUnix int64, febEndStrUnix int64, marchStartStrUnix int64, marchEndStrUnix int64, aprStartStrUnix int64, aprEndStrsUnix int64, mayStartStrUnix int64, mayEndStrsUnix int64, junStartStrUnix int64, junEndStrsUnix int64, julStartStrUnix int64, julEndStrsUnix int64, augStartStrUnix int64, augEndStrsUnix int64, sepStartStrUnix int64, sepEndStrsUnix int64, octStartStrUnix int64, octEndStrsUnix int64, novStartStrUnix int64, novEndStrsUnix int64, decStartStrUnix int64, decEndStrsUnix int64) (inspection []*models.ProjectCount, err error) {
|
|
1304
|
+
|
|
1305
|
+ if lapseto == 0 {
|
|
1306
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1307
|
+ fmt.Println("d", d)
|
|
1308
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1309
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
1310
|
+ fmt.Println(table)
|
|
1311
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1312
|
+ "SELECT " +
|
|
1313
|
+ "CASE " +
|
|
1314
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '一月'" +
|
|
1315
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '二月'" +
|
|
1316
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '三月'" +
|
|
1317
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '四月'" +
|
|
1318
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '五月'" +
|
|
1319
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '六月'" +
|
|
1320
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '七月'" +
|
|
1321
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '八月'" +
|
|
1322
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '九月'" +
|
|
1323
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十月'" +
|
|
1324
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十一月'" +
|
|
1325
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十二月'" +
|
|
1326
|
+ " ELSE '其他'" +
|
|
1327
|
+ "END AS nnd FROM xt_inspection as x left join xt_inspection_reference as r on r.id = x.item_id left join xt_patients as s on s.id = x.patient_id WHERE x.status=1 and (s.lapseto = 1 or s.lapseto = 2) and (x.inspect_value + 0 >= r.range_min + 0 AND x.inspect_value + 0 <= r.range_max + 0)"
|
|
1328
|
+ countParams := make([]interface{}, 0)
|
|
1329
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1330
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1331
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1332
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1333
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1334
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1335
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1336
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1337
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1338
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1339
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1340
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1341
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1342
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1343
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1344
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1345
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1346
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1347
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1348
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1349
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1350
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1351
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1352
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1353
|
+ if orgid > 0 {
|
|
1354
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1355
|
+ countSQL += " AND x.org_id=?"
|
|
1356
|
+ countParams = append(countParams, orgid)
|
|
1357
|
+ }
|
|
1358
|
+ if modetype > 0 {
|
|
1359
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1360
|
+ countSQL += " AND x.item_id=?"
|
|
1361
|
+ countParams = append(countParams, modetype)
|
|
1362
|
+ }
|
|
1363
|
+ if januaryStartStrUnix > 0 {
|
|
1364
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1365
|
+ countSQL += " AND x.inspect_date >=?"
|
|
1366
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1367
|
+ }
|
|
1368
|
+ if decEndStrsUnix > 0 {
|
|
1369
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1370
|
+ countSQL += " AND x.inspect_date <=?"
|
|
1371
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1372
|
+ }
|
|
1373
|
+ countSQL += ")a GROUP BY nnd"
|
|
1374
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1375
|
+ }
|
|
1376
|
+
|
|
1377
|
+ if lapseto == 1 {
|
|
1378
|
+
|
|
1379
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1380
|
+ fmt.Println("d", d)
|
|
1381
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1382
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
1383
|
+ fmt.Println(table)
|
|
1384
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1385
|
+ "SELECT " +
|
|
1386
|
+ "CASE " +
|
|
1387
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '一月'" +
|
|
1388
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '二月'" +
|
|
1389
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '三月'" +
|
|
1390
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '四月'" +
|
|
1391
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '五月'" +
|
|
1392
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '六月'" +
|
|
1393
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '七月'" +
|
|
1394
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '八月'" +
|
|
1395
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '九月'" +
|
|
1396
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十月'" +
|
|
1397
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十一月'" +
|
|
1398
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十二月'" +
|
|
1399
|
+ " ELSE '其他'" +
|
|
1400
|
+ "END AS nnd FROM xt_inspection as x left join xt_inspection_reference as r on r.id = x.item_id left join xt_patients as s on s.id = x.patient_id WHERE x.status=1 and (s.lapseto = 1) and (x.inspect_value + 0 >= r.range_min + 0 AND x.inspect_value + 0 <= r.range_max + 0)"
|
|
1401
|
+ countParams := make([]interface{}, 0)
|
|
1402
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1403
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1404
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1405
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1406
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1407
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1408
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1409
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1410
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1411
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1412
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1413
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1414
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1415
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1416
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1417
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1418
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1419
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1420
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1421
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1422
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1423
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1424
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1425
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1426
|
+ if orgid > 0 {
|
|
1427
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1428
|
+ countSQL += " AND x.org_id=?"
|
|
1429
|
+ countParams = append(countParams, orgid)
|
|
1430
|
+ }
|
|
1431
|
+ if modetype > 0 {
|
|
1432
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1433
|
+ countSQL += " AND x.item_id=?"
|
|
1434
|
+ countParams = append(countParams, modetype)
|
|
1435
|
+ }
|
|
1436
|
+ if januaryStartStrUnix > 0 {
|
|
1437
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1438
|
+ countSQL += " AND x.inspect_date >=?"
|
|
1439
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1440
|
+ }
|
|
1441
|
+ if decEndStrsUnix > 0 {
|
|
1442
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1443
|
+ countSQL += " AND x.inspect_date <=?"
|
|
1444
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1445
|
+ }
|
|
1446
|
+ countSQL += ")a GROUP BY nnd"
|
|
1447
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1448
|
+
|
|
1449
|
+ if lapseto == 2 {
|
|
1450
|
+
|
|
1451
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1452
|
+ fmt.Println("d", d)
|
|
1453
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1454
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
1455
|
+ fmt.Println(table)
|
|
1456
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1457
|
+ "SELECT " +
|
|
1458
|
+ "CASE " +
|
|
1459
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '一月'" +
|
|
1460
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '二月'" +
|
|
1461
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '三月'" +
|
|
1462
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '四月'" +
|
|
1463
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '五月'" +
|
|
1464
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '六月'" +
|
|
1465
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '七月'" +
|
|
1466
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '八月'" +
|
|
1467
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '九月'" +
|
|
1468
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十月'" +
|
|
1469
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十一月'" +
|
|
1470
|
+ " WHEN x.inspect_date>=? AND x.inspect_date<=? and x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 THEN '十二月'" +
|
|
1471
|
+ " ELSE '其他'" +
|
|
1472
|
+ "END AS nnd FROM xt_inspection as x left join xt_inspection_reference as r on r.id = x.item_id left join xt_patients as s on s.id = x.patient_id WHERE x.status=1 and (s.lapseto = 2) and (x.inspect_value + 0 >= r.range_min + 0 AND x.inspect_value + 0 <= r.range_max + 0)"
|
|
1473
|
+ countParams := make([]interface{}, 0)
|
|
1474
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1475
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1476
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1477
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1478
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1479
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1480
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1481
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1482
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1483
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1484
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1485
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1486
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1487
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1488
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1489
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1490
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1491
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1492
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1493
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1494
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1495
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1496
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1497
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1498
|
+ if orgid > 0 {
|
|
1499
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1500
|
+ countSQL += " AND x.org_id=?"
|
|
1501
|
+ countParams = append(countParams, orgid)
|
|
1502
|
+ }
|
|
1503
|
+ if modetype > 0 {
|
|
1504
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1505
|
+ countSQL += " AND x.item_id=?"
|
|
1506
|
+ countParams = append(countParams, modetype)
|
|
1507
|
+ }
|
|
1508
|
+ if januaryStartStrUnix > 0 {
|
|
1509
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1510
|
+ countSQL += " AND x.inspect_date >=?"
|
|
1511
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1512
|
+ }
|
|
1513
|
+ if decEndStrsUnix > 0 {
|
|
1514
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1515
|
+ countSQL += " AND x.inspect_date <=?"
|
|
1516
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1517
|
+ }
|
|
1518
|
+ countSQL += ")a GROUP BY nnd"
|
|
1519
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1520
|
+ }
|
|
1521
|
+ }
|
|
1522
|
+ return
|
|
1523
|
+}
|