|
@@ -1272,7 +1272,16 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
|
1272
|
1272
|
var NewTotalThree int64
|
1273
|
1273
|
var NewTotalFour int64
|
1274
|
1274
|
|
|
1275
|
+ var NewTotalFive int64
|
|
1276
|
+ var NewTotalSix int64
|
|
1277
|
+ var NewTotalSeven int64
|
|
1278
|
+ var NewTotalEight int64
|
|
1279
|
+
|
1275
|
1280
|
db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalOne)
|
|
1281
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalFive)
|
|
1282
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalSix)
|
|
1283
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalSeven)
|
|
1284
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalEight)
|
1276
|
1285
|
db.Table("xt_monitoring_record as monitor ").Joins("join xt_schedule sch On sch.schedule_date = monitor.monitoring_date AND sch.patient_id = monitor.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("monitor.user_org_id = ? AND monitor.status = 1 AND monitor.monitoring_date >= ? AND monitor.monitoring_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalThree)
|
1277
|
1286
|
db.Table("xt_treatment_summary as summary").Joins("join xt_schedule sch On sch.schedule_date = summary.assessment_date AND sch.patient_id = summary.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("summary.user_org_id = ? AND summary.status = 1 AND summary.assessment_date >= ? AND summary.assessment_date <= ?", user_org_id, start_time, end_time).Count(&NewTotalFour)
|
1278
|
1287
|
|
|
@@ -1320,6 +1329,67 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
|
1320
|
1329
|
}
|
1321
|
1330
|
break
|
1322
|
1331
|
|
|
1332
|
+ case 4:
|
|
1333
|
+ for _, item := range datas {
|
|
1334
|
+ var Total int64
|
|
1335
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.change_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
|
|
1336
|
+ item.ChangeNuserCount = Total
|
|
1337
|
+ if math.IsNaN(float64(item.ChangeNuserCount) / float64(NewTotalFive)) {
|
|
1338
|
+ item.ChangeRatio = "0.0"
|
|
1339
|
+ } else {
|
|
1340
|
+ float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.ChangeNuserCount)/float64(NewTotalFive))*100), 64)
|
|
1341
|
+ item.ChangeRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
|
|
1342
|
+ }
|
|
1343
|
+
|
|
1344
|
+ }
|
|
1345
|
+
|
|
1346
|
+ break
|
|
1347
|
+
|
|
1348
|
+ case 5:
|
|
1349
|
+ for _, item := range datas {
|
|
1350
|
+ var Total int64
|
|
1351
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.difficult_puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
|
|
1352
|
+ item.DiffiCultPuntureNuserCount = Total
|
|
1353
|
+ if math.IsNaN(float64(item.DiffiCultPuntureNuserCount) / float64(NewTotalSix)) {
|
|
1354
|
+ item.DiffiCultNuserRatio = "0.0"
|
|
1355
|
+ } else {
|
|
1356
|
+ float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.DiffiCultPuntureNuserCount)/float64(NewTotalSix))*100), 64)
|
|
1357
|
+ item.DiffiCultNuserRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
|
|
1358
|
+ }
|
|
1359
|
+
|
|
1360
|
+ }
|
|
1361
|
+ break
|
|
1362
|
+
|
|
1363
|
+ case 6:
|
|
1364
|
+ for _, item := range datas {
|
|
1365
|
+ var Total int64
|
|
1366
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.new_fistula_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
|
|
1367
|
+ item.NewNuserCount = Total
|
|
1368
|
+ if math.IsNaN(float64(item.NewNuserCount) / float64(NewTotalSeven)) {
|
|
1369
|
+ item.NewNuserRatio = "0.0"
|
|
1370
|
+ } else {
|
|
1371
|
+ float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.NewNuserCount)/float64(NewTotalSeven))*100), 64)
|
|
1372
|
+ item.NewNuserRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
|
|
1373
|
+ }
|
|
1374
|
+
|
|
1375
|
+ }
|
|
1376
|
+ break
|
|
1377
|
+
|
|
1378
|
+ case 7:
|
|
1379
|
+ for _, item := range datas {
|
|
1380
|
+ var Total int64
|
|
1381
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.start_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
|
|
1382
|
+ item.StartNuserCount = Total
|
|
1383
|
+ if math.IsNaN(float64(item.StartNuserCount) / float64(NewTotalEight)) {
|
|
1384
|
+ item.StartNuserRatio = "0.0"
|
|
1385
|
+ } else {
|
|
1386
|
+ float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.StartNuserCount)/float64(NewTotalEight))*100), 64)
|
|
1387
|
+ item.StartNuserRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
|
|
1388
|
+ }
|
|
1389
|
+
|
|
1390
|
+ }
|
|
1391
|
+ break
|
|
1392
|
+
|
1323
|
1393
|
}
|
1324
|
1394
|
|
1325
|
1395
|
if err != nil {
|
|
@@ -1346,14 +1416,28 @@ func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int
|
1346
|
1416
|
var Total int64
|
1347
|
1417
|
var TotalTwo int64
|
1348
|
1418
|
var TotalThree int64
|
|
1419
|
+ var TotalFour int64
|
|
1420
|
+ var TotalFive int64
|
|
1421
|
+ var TotalSix int64
|
|
1422
|
+ var TotalSeven int64
|
1349
|
1423
|
//db.Raw("select count(*) as total from (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from xt_assessment_before_dislysis as d JOIN `xt_data_config` config on d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('内瘘',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ? Group by d.id) b JOIN `xt_dialysis_order` on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1 AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
|
1350
|
1424
|
//db.Raw("select count(*) as total_one from (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from xt_assessment_before_dislysis as d JOIN `xt_data_config` config on d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Where d.user_org_id = ? AND d.assessment_date >=? AND d.assessment_date <= ? Group by d.id) b JOIN `xt_dialysis_order` on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1 AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.dialysis_date >= ? AND xt_dialysis_order.dialysis_date <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time, user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalOne)
|
1351
|
1425
|
db.Table("xt_monitoring_record as monitor ").Joins("join xt_schedule sch On sch.schedule_date = monitor.monitoring_date AND sch.patient_id = monitor.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("monitor.user_org_id = ? AND monitor.status = 1 AND monitor.monitoring_nurse = ? AND monitor.monitoring_date >= ? AND monitor.monitoring_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalTwo)
|
1352
|
1426
|
db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&Total)
|
1353
|
1427
|
db.Table("xt_treatment_summary as summary").Joins("join xt_schedule sch On sch.schedule_date = summary.assessment_date AND sch.patient_id = summary.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("summary.user_org_id = ? AND summary.status = 1 AND summary.creater = ? AND summary.assessment_date >= ? AND summary.assessment_date <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalThree)
|
|
1428
|
+
|
|
1429
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.change_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalFour)
|
|
1430
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.difficult_puncture_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalFive)
|
|
1431
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.new_fistula_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalSix)
|
|
1432
|
+ db.Table("xt_dialysis_order as o").Joins("join xt_schedule sch On sch.schedule_date = o.dialysis_date AND sch.patient_id = o.patient_id AND sch.user_org_id = ? AND sch.status = 1", user_org_id).Where("o.user_org_id = ? AND o.status = 1 AND o.dialysis_date >= ? AND o.dialysis_date <= ? AND o.start_nurse = ?", user_org_id, start_time, end_time, item.AdminUserId).Count(&TotalSeven)
|
|
1433
|
+
|
1354
|
1434
|
item.PunctureCount = Total
|
1355
|
1435
|
item.CureCount = TotalTwo
|
1356
|
1436
|
item.MissionCount = TotalThree
|
|
1437
|
+ item.ChangeNuserCount = TotalFour
|
|
1438
|
+ item.DiffiCultPuntureNuserCount = TotalFive
|
|
1439
|
+ item.NewNuserCount = TotalSix
|
|
1440
|
+ item.StartNuserCount = TotalSeven
|
1357
|
1441
|
}
|
1358
|
1442
|
|
1359
|
1443
|
if err != nil {
|
|
@@ -1776,3 +1860,23 @@ func FindOrgInspectionCount(user_org_id int64) (count int64, err error) {
|
1776
|
1860
|
err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ?", user_org_id).Count(&count).Error
|
1777
|
1861
|
return
|
1778
|
1862
|
}
|
|
1863
|
+
|
|
1864
|
+func GetOrderDialysisCount(orgid int64, startime int64, endtime int64) (order []*models.BloodDialysisOrderOne, err error) {
|
|
1865
|
+ db := service.XTReadDB()
|
|
1866
|
+ table := db.Table("xt_schedule as s")
|
|
1867
|
+ fmt.Println(table)
|
|
1868
|
+ d := db.Table("xt_patients as p")
|
|
1869
|
+ fmt.Println(d)
|
|
1870
|
+ db = db.Table("xt_dialysis_order as o").Where("o.status = 1")
|
|
1871
|
+ if orgid > 0 {
|
|
1872
|
+ db = db.Where("o.user_org_id = ?", orgid)
|
|
1873
|
+ }
|
|
1874
|
+ if startime > 0 {
|
|
1875
|
+ db = db.Where("o.dialysis_date>=?", startime)
|
|
1876
|
+ }
|
|
1877
|
+ if endtime > 0 {
|
|
1878
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
|
1879
|
+ }
|
|
1880
|
+ err = db.Group("o.start_nurse,s.mode_id").Select("s.mode_id,s.patient_id,count(s.mode_id) as count,o.start_nurse").Joins("left join xt_schedule as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id ").Where("s.schedule_date = o.dialysis_date and s.status = 1 and o.user_org_id = ?", orgid).Scan(&order).Error
|
|
1881
|
+ return order, err
|
|
1882
|
+}
|