|
@@ -179,10 +179,18 @@ func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*mod
|
179
|
179
|
return counts, total, err
|
180
|
180
|
}
|
181
|
181
|
|
182
|
|
-func GetTotalRollOutPatients(orgid int64) (patients []*models.XtPatients, total int64, err error) {
|
|
182
|
+func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
|
183
|
183
|
|
184
|
|
- err = XTReadDB().Model(&patients).Where("user_org_id = ? and status = 1 and lapseto = 2", orgid).Count(&total).Find(&patients).Error
|
185
|
|
- return patients, total, err
|
|
184
|
+ db := XTReadDB().Table("x.patients as x")
|
|
185
|
+ err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1 group by s.patient_id", startime, endtime, orgid).Scan(&patients).Error
|
|
186
|
+ return patients, err
|
|
187
|
+}
|
|
188
|
+
|
|
189
|
+func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
|
|
190
|
+
|
|
191
|
+ db := XTReadDB().Table("x.patients as x")
|
|
192
|
+ err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 group by s.patient_id", startime, endtime, orgid).Scan(&patients).Error
|
|
193
|
+ return patients, err
|
186
|
194
|
}
|
187
|
195
|
|
188
|
196
|
func GetPatientTotalCount(orgID int64) (total int64) {
|
|
@@ -767,8 +775,11 @@ func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto in
|
767
|
775
|
if endtime > 0 {
|
768
|
776
|
db = db.Where("x.inspect_date <=?", endtime)
|
769
|
777
|
}
|
|
778
|
+ if lapseto == 0 {
|
|
779
|
+ db = db.Where("s.lapseto = 1 or s.lapseto = 2")
|
|
780
|
+ }
|
770
|
781
|
if lapseto > 0 {
|
771
|
|
- d = d.Where("s.lapseto = ?", lapseto)
|
|
782
|
+ db = db.Where("s.lapseto = ?", lapseto)
|
772
|
783
|
}
|
773
|
784
|
err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when x.inspect_value+0>=r.range_min+0 and x.inspect_value +0 <= r.range_max+0 and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.id,x.patient_id,x.org_id,x.project_id,x.item_id,x.item_name,x.project_name,x.inspect_value,x.inspect_date,r.range_min,r.range_max,p.sort", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on r.id = x.item_id").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_quality_control_standard as p on p.inspection_minor = x.item_id").Order("p.sort asc").Scan(&inspection).Error
|
774
|
785
|
return inspection, err
|
|
@@ -1301,7 +1312,7 @@ func GetMonthProjectList(orgid int64, lapseto int64, modetype int64, januaryStar
|
1301
|
1312
|
}
|
1302
|
1313
|
|
1303
|
1314
|
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
|
|
-
|
|
1315
|
+ fmt.Println("lapseto=======", lapseto)
|
1305
|
1316
|
if lapseto == 0 {
|
1306
|
1317
|
d := XTReadDB().Table("xt_patients as s")
|
1307
|
1318
|
fmt.Println("d", d)
|
|
@@ -1445,79 +1456,78 @@ func GetMonthProjectListTwo(orgid int64, lapseto int64, modetype int64, januaryS
|
1445
|
1456
|
}
|
1446
|
1457
|
countSQL += ")a GROUP BY nnd"
|
1447
|
1458
|
err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1459
|
+ }
|
1448
|
1460
|
|
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)
|
|
1461
|
+ if lapseto == 2 {
|
|
1462
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1463
|
+ fmt.Println("d", d)
|
|
1464
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1465
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
1466
|
+ fmt.Println(table)
|
|
1467
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1468
|
+ "SELECT " +
|
|
1469
|
+ "CASE " +
|
|
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
|
+ " 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 '二月'" +
|
|
1472
|
+ " 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 '三月'" +
|
|
1473
|
+ " 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 '四月'" +
|
|
1474
|
+ " 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 '五月'" +
|
|
1475
|
+ " 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 '六月'" +
|
|
1476
|
+ " 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 '七月'" +
|
|
1477
|
+ " 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 '八月'" +
|
|
1478
|
+ " 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 '九月'" +
|
|
1479
|
+ " 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 '十月'" +
|
|
1480
|
+ " 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 '十一月'" +
|
|
1481
|
+ " 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 '十二月'" +
|
|
1482
|
+ " ELSE '其他'" +
|
|
1483
|
+ "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)"
|
|
1484
|
+ countParams := make([]interface{}, 0)
|
|
1485
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1486
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1487
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1488
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1489
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1490
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1491
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1492
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1493
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1494
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1495
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1496
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1497
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1498
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1499
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1500
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1501
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1502
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1503
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1504
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1505
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1506
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1507
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1508
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1509
|
+ if orgid > 0 {
|
|
1510
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1511
|
+ countSQL += " AND x.org_id=?"
|
|
1512
|
+ countParams = append(countParams, orgid)
|
|
1513
|
+ }
|
|
1514
|
+ if modetype > 0 {
|
|
1515
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1516
|
+ countSQL += " AND x.item_id=?"
|
|
1517
|
+ countParams = append(countParams, modetype)
|
|
1518
|
+ }
|
|
1519
|
+ if januaryStartStrUnix > 0 {
|
|
1520
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1521
|
+ countSQL += " AND x.inspect_date >=?"
|
1474
|
1522
|
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)
|
|
1523
|
+ }
|
|
1524
|
+ if decEndStrsUnix > 0 {
|
|
1525
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1526
|
+ countSQL += " AND x.inspect_date <=?"
|
1497
|
1527
|
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
|
1528
|
}
|
|
1529
|
+ countSQL += ")a GROUP BY nnd"
|
|
1530
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
1521
|
1531
|
}
|
1522
|
1532
|
return
|
1523
|
1533
|
}
|
|
@@ -1661,3 +1671,29 @@ func GetQualityControlById(orgid int64, patientid int64, startime int64, endtime
|
1661
|
1671
|
|
1662
|
1672
|
return inspection, err
|
1663
|
1673
|
}
|
|
1674
|
+
|
|
1675
|
+func GetLastPatientsControlTwo(orgid int64, patientid int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
|
|
1676
|
+
|
|
1677
|
+ db := readDb.Table("xt_inspection as x").Where("x.status =1")
|
|
1678
|
+ table := readDb.Table("xt_patients as s")
|
|
1679
|
+ fmt.Println(table)
|
|
1680
|
+ d := readDb.Table(" xt_inspection_reference as r")
|
|
1681
|
+ fmt.Println(d)
|
|
1682
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
1683
|
+ fmt.Println("d2", d2)
|
|
1684
|
+ if orgid > 0 {
|
|
1685
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
1686
|
+ }
|
|
1687
|
+ if patientid > 0 {
|
|
1688
|
+ db = db.Where("x.patient_id = ?", patientid)
|
|
1689
|
+ }
|
|
1690
|
+ if startime > 0 {
|
|
1691
|
+ db = db.Where("x.inspect_date >=?", startime)
|
|
1692
|
+ }
|
|
1693
|
+ if endtime > 0 {
|
|
1694
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
1695
|
+ }
|
|
1696
|
+ err = db.Group("x.id").Select("x.id,x.patient_id,x.item_id,x.item_name,x.inspect_value,x.inspect_date,s.name,s.dialysis_no,r.range_max,r.range_min,d.sort").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.id = x.item_id").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
|
|
1697
|
+
|
|
1698
|
+ return inspection, err
|
|
1699
|
+}
|