|
@@ -331,7 +331,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
|
331
|
331
|
}
|
332
|
332
|
|
333
|
333
|
if item.Name == "60~70kg" {
|
334
|
|
- isHasConditionTwo = true
|
|
334
|
+ isHasConditionThree = true
|
335
|
335
|
}
|
336
|
336
|
|
337
|
337
|
if item.Name == "大于70kg" {
|
|
@@ -414,7 +414,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
|
414
|
414
|
}
|
415
|
415
|
|
416
|
416
|
if item.Name == "60~70kg" {
|
417
|
|
- isHasConditionTwo = true
|
|
417
|
+ isHasConditionThree = true
|
418
|
418
|
}
|
419
|
419
|
|
420
|
420
|
if item.Name == "大于70kg" {
|
|
@@ -585,7 +585,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
|
585
|
585
|
}
|
586
|
586
|
|
587
|
587
|
if item.Name == "60~70kg" {
|
588
|
|
- isHasConditionTwo = true
|
|
588
|
+ isHasConditionThree = true
|
589
|
589
|
}
|
590
|
590
|
|
591
|
591
|
if item.Name == "大于70kg" {
|
|
@@ -844,7 +844,7 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
844
|
844
|
}
|
845
|
845
|
|
846
|
846
|
if item.Name == "140-160mmHg/90-100mmHg" {
|
847
|
|
- isHasConditionTwo = true
|
|
847
|
+ isHasConditionThree = true
|
848
|
848
|
}
|
849
|
849
|
}
|
850
|
850
|
if !isHasConditionOne {
|
|
@@ -906,7 +906,7 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
906
|
906
|
}
|
907
|
907
|
|
908
|
908
|
if item.Name == "140-160mmHg/90-100mmHg" {
|
909
|
|
- isHasConditionTwo = true
|
|
909
|
+ isHasConditionThree = true
|
910
|
910
|
}
|
911
|
911
|
}
|
912
|
912
|
if !isHasConditionOne {
|
|
@@ -1168,23 +1168,23 @@ func FindOrgInspectionCount(user_org_id int64) (count int64, err error) {
|
1168
|
1168
|
|
1169
|
1169
|
func FindOrgInspectionReference(user_org_id int64) (references []*models.InspectionReference, err error) {
|
1170
|
1170
|
db := service.XTReadDB()
|
1171
|
|
- err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ?", user_org_id).Find(&references).Error
|
|
1171
|
+ err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ? AND range_max REGEXP '(^[0-9]+.[0-9]+$)|(^[0-9]$)' AND range_min REGEXP '(^[0-9]+.[0-9]+$)|(^[0-9]$)' ", user_org_id).Find(&references).Error
|
1172
|
1172
|
return
|
1173
|
1173
|
}
|
1174
|
1174
|
|
1175
|
1175
|
func FindProcjectInspectionReference(user_org_id int64, project_id int64, item_id int64) (references models.InspectionReference, err error) {
|
1176
|
1176
|
db := service.XTReadDB()
|
1177
|
|
- err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ? AND project_id = ? AND item_id = ?", user_org_id, project_id, item_id).First(&references).Error
|
|
1177
|
+ err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ? AND project_id = ? AND id = ?", user_org_id, project_id, item_id).First(&references).Error
|
1178
|
1178
|
return
|
1179
|
1179
|
}
|
1180
|
1180
|
|
1181
|
|
-func FindOrgInspectionReferenceRnageTypeValue(user_org_id int64, project_id int64, item_id int64) (inspection []*models.Inspection, err error) {
|
|
1181
|
+func FindOrgInspectionReferenceRangeTypeValue(user_org_id int64, project_id int64, item_id int64) (inspection []*models.Inspection, err error) {
|
1182
|
1182
|
db := service.XTReadDB()
|
1183
|
|
- err = db.Model(&models.Inspection{}).Where("status = 1 AND org_id = ? AND project_id = ? AND item_id = ? AND inspect_type = 2", user_org_id, project_id, item_id).Group("inspect_value").Find(&inspection).Error
|
|
1183
|
+ err = db.Model(&models.Inspection{}).Where("status = 1 AND org_id = ? AND project_id = ? AND item_id = ? AND inspect_type = 2 AND inspect_value <> ''", user_org_id, project_id, item_id).Group("inspect_value").Find(&inspection).Error
|
1184
|
1184
|
return
|
1185
|
1185
|
}
|
1186
|
1186
|
|
1187
|
|
-func FindOrgConfigRnageTypeValue(user_org_id int64, project_id int64, item_id int64) (qcs models.QualityControlStandard, err error) {
|
|
1187
|
+func FindOrgConfigRangeTypeValue(user_org_id int64, project_id int64, item_id int64) (qcs QualityControlStandard, err error) {
|
1188
|
1188
|
db := service.XTReadDB()
|
1189
|
1189
|
err = db.Model(&QualityControlStandard{}).Where("status = 1 AND user_org_id = ? AND inspection_major = ? AND inspection_minor = ?", user_org_id, project_id, item_id).First(&qcs).Error
|
1190
|
1190
|
return
|
|
@@ -1197,49 +1197,179 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
|
1197
|
1197
|
selectContent := "CASE"
|
1198
|
1198
|
range_value_arr := strings.Split(range_value, ",")
|
1199
|
1199
|
|
|
1200
|
+ fmt.Println(range_value_arr)
|
|
1201
|
+
|
1200
|
1202
|
if range_type == 1 {
|
1201
|
|
- tempErr = db.Table("xt_inspection").Where("user_org_id=? and status=1 and created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, project_id, item_id).
|
1202
|
|
- Select("CASE WHEN inspect_value < ? THEN 小于" + range_value_arr[0] +
|
1203
|
|
- " WHEN inspect_value >= ? AND inspect_value <= ? THEN " + range_value_arr[0] + "~" + range_value_arr[1] +
|
1204
|
|
- " WHEN inspect_value > ? THEN 大于" + range_value_arr[1] +
|
|
1203
|
+ tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, project_id, item_id).
|
|
1204
|
+ Select("CASE WHEN inspect_value < " + range_value_arr[0] + "THEN" + "'" + "小于" + range_value_arr[0] + "'" +
|
|
1205
|
+ " WHEN inspect_value >= " + range_value_arr[0] + "AND inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +
|
|
1206
|
+ " WHEN inspect_value > " + range_value_arr[1] + "THEN " + "'" + "大于" + range_value_arr[1] + "'" +
|
1205
|
1207
|
" ELSE '未知' END AS name, COUNT(*) AS total",
|
1206
|
1208
|
).Group("name").Scan(&items).Error
|
|
1209
|
+
|
|
1210
|
+ var isHasConditionOne bool = false
|
|
1211
|
+ var isHasConditionTwo bool = false
|
|
1212
|
+ var isHasConditionThree bool = false
|
|
1213
|
+
|
|
1214
|
+ for _, item := range items {
|
|
1215
|
+ if item.Name == "大于"+range_value_arr[1] {
|
|
1216
|
+ isHasConditionOne = true
|
|
1217
|
+ }
|
|
1218
|
+ if item.Name == "小于"+range_value_arr[0] {
|
|
1219
|
+ isHasConditionTwo = true
|
|
1220
|
+ }
|
|
1221
|
+ if item.Name == range_value_arr[0]+"~"+range_value_arr[1] {
|
|
1222
|
+ isHasConditionThree = true
|
|
1223
|
+ }
|
|
1224
|
+ }
|
|
1225
|
+ if !isHasConditionOne {
|
|
1226
|
+ newItem := &otherItemAmount{
|
|
1227
|
+ Total: 0,
|
|
1228
|
+ Name: "大于" + range_value_arr[1],
|
|
1229
|
+ Ratio: "0",
|
|
1230
|
+ }
|
|
1231
|
+ items = append(items, newItem)
|
|
1232
|
+ }
|
|
1233
|
+
|
|
1234
|
+ if !isHasConditionTwo {
|
|
1235
|
+ newItem := &otherItemAmount{
|
|
1236
|
+ Total: 0,
|
|
1237
|
+ Name: "小于" + range_value_arr[0],
|
|
1238
|
+ Ratio: "0",
|
|
1239
|
+ }
|
|
1240
|
+ items = append(items, newItem)
|
|
1241
|
+ }
|
|
1242
|
+ if !isHasConditionThree {
|
|
1243
|
+ newItem := &otherItemAmount{
|
|
1244
|
+ Total: 0,
|
|
1245
|
+ Name: range_value_arr[0] + "~" + range_value_arr[1],
|
|
1246
|
+ Ratio: "0",
|
|
1247
|
+ }
|
|
1248
|
+ items = append(items, newItem)
|
|
1249
|
+ }
|
|
1250
|
+ return items, tempErr
|
|
1251
|
+
|
1207
|
1252
|
} else {
|
|
1253
|
+
|
1208
|
1254
|
for _, item := range range_value_arr {
|
1209
|
|
- selectContent = selectContent + " WHEN inspect_value =" + item + " THEN " + "'" + item + "'"
|
|
1255
|
+ //selectContent = selectContent + " WHEN inspect_value =" + item + " THEN " + "'" + item + "'"
|
|
1256
|
+ selectContent = selectContent + " WHEN inspect_value =" + "'" + item + "'" + " THEN " + "'" + item + "'"
|
|
1257
|
+
|
1210
|
1258
|
}
|
1211
|
|
- tempErr = db.Table("xt_inspection").Where("user_org_id=? and status=1 and created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).
|
|
1259
|
+ tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, project_id, item_id).
|
1212
|
1260
|
Select(selectContent +
|
1213
|
1261
|
" ELSE '未知' END AS name, COUNT(*) AS total",
|
1214
|
1262
|
).Group("name").Scan(&items).Error
|
1215
|
|
-
|
|
1263
|
+ return items, tempErr
|
1216
|
1264
|
}
|
1217
|
|
- return items, tempErr
|
1218
|
1265
|
|
1219
|
1266
|
}
|
1220
|
1267
|
|
1221
|
|
-type Patient struct {
|
1222
|
|
- ID int64 `gorm:"column:id" json:"id" form:"id"`
|
1223
|
|
- Name string `gorm:"column:name" json:"name" form:"name"`
|
1224
|
|
- Inspection models.Inspection `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
|
|
1268
|
+type Inspection struct {
|
|
1269
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
1270
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
1271
|
+ OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
|
|
1272
|
+ ProjectId int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
|
|
1273
|
+ ItemId int64 `gorm:"column:item_id" json:"item_id" form:"item_id"`
|
|
1274
|
+ ItemName string `gorm:"column:item_name" json:"item_name" form:"item_name"`
|
|
1275
|
+ ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
|
|
1276
|
+ InspectType int64 `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
|
|
1277
|
+ InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
|
|
1278
|
+ InspectDate int64 `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
|
|
1279
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
1280
|
+ CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
|
|
1281
|
+ UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
|
|
1282
|
+ Patient models.Patients `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patient"`
|
1225
|
1283
|
}
|
1226
|
1284
|
|
1227
|
|
-func (Patient) TableName() string {
|
1228
|
|
- return "xt_patients"
|
|
1285
|
+func (Inspection) TableName() string {
|
|
1286
|
+ return "xt_inspection"
|
1229
|
1287
|
}
|
1230
|
1288
|
|
1231
|
|
-func GetInspectionChartTableData(user_org_id int64, start_time int64, end_time int64, project_id int64, item_id int64, patient_id int64, page, limit int64) (datas []*Patient, total int64, err error) {
|
1232
|
|
- db := service.XTReadDB()
|
1233
|
|
- offset := (page - 1) * limit
|
1234
|
|
- err = db.Select("id, name from xt_patients RIGHT JOIN xt_inspection ON xt_inspection.patient_id = xt_patients.id AND xt_inspection.created_time >= ? AND xt_inspection.created_time >= ? AND xt_inspection.project_id = ? AND xt_inspection.item_id = ?", start_time, end_time, project_id, item_id).Where("user_org_id = ? AND status = 1", user_org_id).Preload("Inspection", func(db *gorm.DB) *gorm.DB {
|
1235
|
|
- return db.Where("status = 1 AND created_time >= ? AND created_time >= ? AND project_id = ? AND item_id = ?", start_time, end_time, project_id, item_id).Order("created_time DESC")
|
1236
|
|
- }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
1237
|
|
- return datas, total, err
|
|
1289
|
+func GetInspectionChartTableData(user_org_id int64, start_time int64, end_time int64, project_id int64, item_id int64, patient_id int64, page, limit int64, range_type int, range_value string) (datas []*Inspection, total int64, err error) {
|
|
1290
|
+
|
|
1291
|
+ if range_type == 1 {
|
|
1292
|
+
|
|
1293
|
+ index := strings.Index(range_value, "小于")
|
|
1294
|
+ indexTwo := strings.Index(range_value, "大于")
|
|
1295
|
+ indexThree := strings.Index(range_value, "~")
|
|
1296
|
+
|
|
1297
|
+ if index != -1 {
|
|
1298
|
+ value, _ := strconv.ParseFloat(strings.Replace(range_value, "小于", "", 1), 64)
|
|
1299
|
+ db := service.XTReadDB()
|
|
1300
|
+ offset := (page - 1) * limit
|
|
1301
|
+ err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ? AND project_id = ? AND item_id = ? AND status = 1 AND inspect_value < ?", user_org_id, start_time, end_time, project_id, item_id, value).Preload("Patient", func(db *gorm.DB) *gorm.DB {
|
|
1302
|
+ return db.Where("status = 1")
|
|
1303
|
+ }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
|
1304
|
+ return datas, total, err
|
|
1305
|
+ } else if indexTwo != -1 {
|
|
1306
|
+ value, _ := strconv.ParseFloat(strings.Replace(range_value, "大于", "", 1), 64)
|
|
1307
|
+
|
|
1308
|
+ db := service.XTReadDB()
|
|
1309
|
+ offset := (page - 1) * limit
|
|
1310
|
+ err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ? AND project_id = ? AND item_id = ? AND status = 1 AND inspect_value > ?", user_org_id, start_time, end_time, project_id, item_id, value).Preload("Patient", func(db *gorm.DB) *gorm.DB {
|
|
1311
|
+ return db.Where("status = 1")
|
|
1312
|
+ }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
|
1313
|
+ return datas, total, err
|
|
1314
|
+ } else if indexThree != -1 {
|
|
1315
|
+ range_value_arr := strings.Split(range_value, "~")
|
|
1316
|
+ fmt.Println(range_value_arr)
|
|
1317
|
+
|
|
1318
|
+ float1, err := strconv.ParseFloat(range_value_arr[0], 64)
|
|
1319
|
+ float2, err := strconv.ParseFloat(range_value_arr[1], 64)
|
|
1320
|
+ fmt.Println(err)
|
|
1321
|
+ fmt.Println(float1)
|
|
1322
|
+
|
|
1323
|
+ fmt.Println(float2)
|
|
1324
|
+
|
|
1325
|
+ db := service.XTReadDB()
|
|
1326
|
+ offset := (page - 1) * limit
|
|
1327
|
+ err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ? AND project_id = ? AND item_id = ? AND status = 1 AND inspect_value >= ? AND inspect_value <= ?", user_org_id, start_time, end_time, project_id, item_id, float1, float2).Preload("Patient", func(db *gorm.DB) *gorm.DB {
|
|
1328
|
+ return db.Where("status = 1")
|
|
1329
|
+ }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
|
1330
|
+ return datas, total, err
|
|
1331
|
+ } else {
|
|
1332
|
+ db := service.XTReadDB()
|
|
1333
|
+ offset := (page - 1) * limit
|
|
1334
|
+ err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ? AND project_id = ? AND item_id = ? AND status = 1 ", user_org_id, start_time, end_time, project_id, item_id).Preload("Patient", func(db *gorm.DB) *gorm.DB {
|
|
1335
|
+ return db.Where("status = 1")
|
|
1336
|
+ }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
|
1337
|
+ return datas, total, err
|
|
1338
|
+ }
|
|
1339
|
+
|
|
1340
|
+ } else {
|
|
1341
|
+
|
|
1342
|
+ if range_value == "全部" {
|
|
1343
|
+ db := service.XTReadDB()
|
|
1344
|
+ offset := (page - 1) * limit
|
|
1345
|
+ err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ? AND project_id = ? AND item_id = ? AND status = 1 ", user_org_id, start_time, end_time, project_id, item_id).Preload("Patient", func(db *gorm.DB) *gorm.DB {
|
|
1346
|
+ return db.Where("status = 1")
|
|
1347
|
+ }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
|
1348
|
+ return datas, total, err
|
|
1349
|
+
|
|
1350
|
+ } else {
|
|
1351
|
+
|
|
1352
|
+ db := service.XTReadDB()
|
|
1353
|
+ offset := (page - 1) * limit
|
|
1354
|
+ err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ? AND project_id = ? AND item_id = ? AND status = 1 AND inspect_value = ?", user_org_id, start_time, end_time, project_id, item_id, range_value).Preload("Patient", func(db *gorm.DB) *gorm.DB {
|
|
1355
|
+ return db.Where("status = 1")
|
|
1356
|
+ }).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
|
|
1357
|
+ return datas, total, err
|
|
1358
|
+
|
|
1359
|
+ }
|
|
1360
|
+
|
|
1361
|
+ }
|
|
1362
|
+
|
|
1363
|
+}
|
|
1364
|
+
|
|
1365
|
+type NewIndexDataStruct struct {
|
|
1366
|
+ Date string `json:"date"`
|
|
1367
|
+ Value string `json:"value"`
|
1238
|
1368
|
}
|
1239
|
1369
|
|
1240
|
|
-func GetPatientInspectionChartData(user_org_id int64, start_time int64, end_time int64, project_id int64, item_id int64, patient_id int64) (datas []*ProcessIndexDataStruct, err error) {
|
|
1370
|
+func GetPatientInspectionChartData(user_org_id int64, start_time int64, end_time int64, project_id int64, item_id int64, patient_id int64) (datas []*NewIndexDataStruct, err error) {
|
1241
|
1371
|
db := service.XTReadDB()
|
1242
|
|
- err = db.Raw("select from_unixtime(inspect_date, '%Y-%m-%d') as date, inspect_value as value from xt_inspection Where status = 1 AND user_org_id = ? AND patient_id = ? AND project_id = ? AND item_id = ? created_time <= ? AND created_time >= ? ", user_org_id, patient_id, project_id, item_id, end_time, start_time).Scan(&datas).Error
|
|
1372
|
+ err = db.Raw("select from_unixtime(inspect_date, '%Y-%m-%d') as date, inspect_value as value from xt_inspection Where status = 1 AND org_id = ? AND patient_id = ? AND project_id = ? AND item_id = ? AND created_time <= ? AND created_time >= ? ", user_org_id, patient_id, project_id, item_id, end_time, start_time).Scan(&datas).Error
|
1243
|
1373
|
if err != nil {
|
1244
|
1374
|
return nil, err
|
1245
|
1375
|
}
|
|
@@ -1255,22 +1385,65 @@ func GetPatientInspectionBarChartData(user_org_id int64, start_time int64, end_t
|
1255
|
1385
|
range_value_arr := strings.Split(range_value, ",")
|
1256
|
1386
|
|
1257
|
1387
|
if range_type == 1 {
|
1258
|
|
- tempErr = db.Table("xt_inspection").Where("user_org_id=? and status=1 and created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND patient_id = ?", user_org_id, start_time, end_time, project_id, item_id, patient_id).
|
1259
|
|
- Select("CASE WHEN inspect_value < ? THEN 小于" + range_value_arr[0] +
|
1260
|
|
- " WHEN inspect_value >= ? AND inspect_value <= ? THEN " + range_value_arr[0] + "~" + range_value_arr[1] +
|
1261
|
|
- " WHEN inspect_value > ? THEN 大于" + range_value_arr[1] +
|
|
1388
|
+ tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND patient_id = ?", user_org_id, start_time, end_time, project_id, item_id, patient_id).
|
|
1389
|
+ Select("CASE WHEN inspect_value < " + range_value_arr[0] + "THEN" + "'" + "小于" + range_value_arr[0] + "'" +
|
|
1390
|
+ " WHEN inspect_value >= " + range_value_arr[0] + "AND inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +
|
|
1391
|
+ " WHEN inspect_value > " + range_value_arr[1] + "THEN " + "'" + "大于" + range_value_arr[1] + "'" +
|
1262
|
1392
|
" ELSE '未知' END AS name, COUNT(*) AS total",
|
1263
|
1393
|
).Group("name").Scan(&items).Error
|
|
1394
|
+
|
|
1395
|
+ var isHasConditionOne bool = false
|
|
1396
|
+ var isHasConditionTwo bool = false
|
|
1397
|
+ var isHasConditionThree bool = false
|
|
1398
|
+
|
|
1399
|
+ for _, item := range items {
|
|
1400
|
+ if item.Name == "大于"+range_value_arr[1] {
|
|
1401
|
+ isHasConditionOne = true
|
|
1402
|
+ }
|
|
1403
|
+ if item.Name == "小于"+range_value_arr[0] {
|
|
1404
|
+ isHasConditionTwo = true
|
|
1405
|
+ }
|
|
1406
|
+ if item.Name == range_value_arr[0]+"~"+range_value_arr[1] {
|
|
1407
|
+ isHasConditionThree = true
|
|
1408
|
+ }
|
|
1409
|
+ }
|
|
1410
|
+ if !isHasConditionOne {
|
|
1411
|
+ newItem := &otherItemAmount{
|
|
1412
|
+ Total: 0,
|
|
1413
|
+ Name: "大于" + range_value_arr[1],
|
|
1414
|
+ Ratio: "0",
|
|
1415
|
+ }
|
|
1416
|
+ items = append(items, newItem)
|
|
1417
|
+ }
|
|
1418
|
+
|
|
1419
|
+ if !isHasConditionTwo {
|
|
1420
|
+ newItem := &otherItemAmount{
|
|
1421
|
+ Total: 0,
|
|
1422
|
+ Name: "小于" + range_value_arr[0],
|
|
1423
|
+ Ratio: "0",
|
|
1424
|
+ }
|
|
1425
|
+ items = append(items, newItem)
|
|
1426
|
+ }
|
|
1427
|
+ if !isHasConditionThree {
|
|
1428
|
+ newItem := &otherItemAmount{
|
|
1429
|
+ Total: 0,
|
|
1430
|
+ Name: range_value_arr[0] + "~" + range_value_arr[1],
|
|
1431
|
+ Ratio: "0",
|
|
1432
|
+ }
|
|
1433
|
+ items = append(items, newItem)
|
|
1434
|
+ }
|
|
1435
|
+ return items, tempErr
|
|
1436
|
+
|
1264
|
1437
|
} else {
|
|
1438
|
+
|
1265
|
1439
|
for _, item := range range_value_arr {
|
1266
|
|
- selectContent = selectContent + " WHEN inspect_value =" + item + " THEN " + "'" + item + "'"
|
|
1440
|
+ selectContent = selectContent + " WHEN inspect_value =" + "'" + item + "'" + " THEN " + "'" + item + "'"
|
1267
|
1441
|
}
|
1268
|
|
- tempErr = db.Table("xt_inspection").Where("user_org_id=? and status=1 and created_time >= ? and created_time <= ? AND patient_id = ?", user_org_id, start_time, end_time, patient_id).
|
|
1442
|
+ tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and created_time >= ? and created_time <= ? AND patient_id = ?", user_org_id, start_time, end_time, patient_id).
|
1269
|
1443
|
Select(selectContent +
|
1270
|
1444
|
" ELSE '未知' END AS name, COUNT(*) AS total",
|
1271
|
1445
|
).Group("name").Scan(&items).Error
|
1272
|
|
-
|
|
1446
|
+ return items, tempErr
|
1273
|
1447
|
}
|
1274
|
|
- return items, tempErr
|
1275
|
1448
|
|
1276
|
1449
|
}
|