|
@@ -13,9 +13,9 @@ func GetInspectionMajor(orgid int64) (inspection []*models.XtInspectionReference
|
13
|
13
|
return inspection, err
|
14
|
14
|
}
|
15
|
15
|
|
16
|
|
-func GetInspectionMinor(projectid int64) (inspection []*models.XtInspectionReference, err error) {
|
|
16
|
+func GetInspectionMinor(projectid int64, orgid int64) (inspection []*models.XtInspectionReference, err error) {
|
17
|
17
|
|
18
|
|
- err = XTReadDB().Model(&inspection).Where("project_id = ? and status = 1", projectid).Find(&inspection).Error
|
|
18
|
+ err = XTReadDB().Model(&inspection).Where("project_id = ? and status = 1 and org_id = ?", projectid, orgid).Find(&inspection).Error
|
19
|
19
|
return inspection, err
|
20
|
20
|
}
|
21
|
21
|
|
|
@@ -160,14 +160,19 @@ func DeleteCheck(id int64) error {
|
160
|
160
|
return err
|
161
|
161
|
}
|
162
|
162
|
|
163
|
|
-func GetDialysiTotal(startime int64, endtime int64, orgid int64) (prescription []*models.DialysisPrescription, total int64, err error) {
|
164
|
|
- err = XTReadDB().Model(&prescription).Where("record_date >= ? and record_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&prescription).Error
|
165
|
|
- return prescription, total, err
|
|
163
|
+func GetDialysiTotal(startime int64, endtime int64, orgid int64) (order []*models.DialysisOrder, total int64, err error) {
|
|
164
|
+ err = XTReadDB().Model(&order).Where("dialysis_date >= ? and dialysis_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&order).Error
|
|
165
|
+ return order, total, err
|
|
166
|
+
|
166
|
167
|
}
|
167
|
168
|
|
168
|
169
|
func GetDialysisCountMode(starttime int64, endtime int64, orgid int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
|
169
|
|
- err = readDb.Table("xt_dialysis_prescription as p").Where("p.record_date>= ? and p.record_date<=? and p.user_org_id=?", starttime, endtime, orgid).Select("p.mode_id,count(p.mode_id) as count").Group("p.mode_id").Scan(&counts).Error
|
|
170
|
+ //err = readDb.Table("xt_dialysis_prescription as p").Where("p.record_date>= ? and p.record_date<=? and p.user_org_id=?", starttime, endtime, orgid).Select("p.mode_id,count(p.mode_id) as count").Group("p.mode_id").Scan(&counts).Error
|
|
171
|
+ //return counts, err
|
|
172
|
+
|
|
173
|
+ err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
|
170
|
174
|
return counts, err
|
|
175
|
+
|
171
|
176
|
}
|
172
|
177
|
|
173
|
178
|
func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*models.PatientLapseto, total int64, err error) {
|
|
@@ -179,10 +184,18 @@ func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*mod
|
179
|
184
|
return counts, total, err
|
180
|
185
|
}
|
181
|
186
|
|
182
|
|
-func GetTotalRollOutPatients(orgid int64) (patients []*models.XtPatients, total int64, err error) {
|
|
187
|
+func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
|
183
|
188
|
|
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
|
|
189
|
+ db := XTReadDB().Table("x.patients as x")
|
|
190
|
+ 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
|
|
191
|
+ return patients, err
|
|
192
|
+}
|
|
193
|
+
|
|
194
|
+func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
|
|
195
|
+
|
|
196
|
+ db := XTReadDB().Table("x.patients as x")
|
|
197
|
+ 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
|
|
198
|
+ return patients, err
|
186
|
199
|
}
|
187
|
200
|
|
188
|
201
|
func GetPatientTotalCount(orgID int64) (total int64) {
|
|
@@ -217,9 +230,9 @@ func GetManPatientTotal(orgid int64) (patients []*models.XtPatients, total int64
|
217
|
230
|
// return counts, err
|
218
|
231
|
//}
|
219
|
232
|
|
220
|
|
-func GetPatientInfectiousCount(orgid int64) (counts []*models.PatientContagionsCountStruct, err error) {
|
|
233
|
+func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64) (counts []*models.PatientContagionsCountStruct, err error) {
|
221
|
234
|
|
222
|
|
- err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.is_infectious = 2", orgid).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
|
|
235
|
+ err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.is_infectious = 2 and s.created_time>=? and s.created_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
|
223
|
236
|
return counts, err
|
224
|
237
|
}
|
225
|
238
|
|
|
@@ -234,12 +247,11 @@ func GetTotalAgeCount(orgid int64) (counts []*models.PatientAgeCountStruct, err
|
234
|
247
|
readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
|
235
|
248
|
SELECT
|
236
|
249
|
CASE
|
237
|
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=20 THEN '20'
|
238
|
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>20 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=40 THEN '40'
|
239
|
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>40 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=60 THEN '60'
|
240
|
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>60 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=80 THEN '80'
|
241
|
|
- WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>80 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<=150 THEN '150'
|
242
|
|
- ELSE '-1'
|
|
250
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
|
|
251
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=40 THEN '40'
|
|
252
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=60 THEN '60'
|
|
253
|
+ WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
|
|
254
|
+ ELSE '150'
|
243
|
255
|
END
|
244
|
256
|
AS nnd FROM xt_patients as s where s.user_org_id=? and s.status=1
|
245
|
257
|
)a GROUP BY nnd`, orgid).Scan(&counts)
|
|
@@ -312,6 +324,19 @@ func GetDialysisAgeData(orgID int64) (counts []*models.DialysisAgePieDataStruct,
|
312
|
324
|
err = readDb.Raw(countSQL, countParams...).Scan(&counts).Error
|
313
|
325
|
return
|
314
|
326
|
|
|
327
|
+ //readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
|
|
328
|
+ // SELECT
|
|
329
|
+ // CASE
|
|
330
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0
|
|
331
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '0~12' WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12
|
|
332
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '12~36' WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36
|
|
333
|
+ // WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '36~60' WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60
|
|
334
|
+ // ELSE '150'
|
|
335
|
+ // END
|
|
336
|
+ // AS nnd FROM xt_patients as p where p.user_org_id=? and p.status=1
|
|
337
|
+ // )a GROUP BY nnd`, orgID).Scan(&counts)
|
|
338
|
+ //return
|
|
339
|
+
|
315
|
340
|
}
|
316
|
341
|
|
317
|
342
|
func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error) {
|
|
@@ -767,8 +792,11 @@ func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto in
|
767
|
792
|
if endtime > 0 {
|
768
|
793
|
db = db.Where("x.inspect_date <=?", endtime)
|
769
|
794
|
}
|
|
795
|
+ if lapseto == 0 {
|
|
796
|
+ db = db.Where("s.lapseto = 1 or s.lapseto = 2")
|
|
797
|
+ }
|
770
|
798
|
if lapseto > 0 {
|
771
|
|
- d = d.Where("s.lapseto = ?", lapseto)
|
|
799
|
+ db = db.Where("s.lapseto = ?", lapseto)
|
772
|
800
|
}
|
773
|
801
|
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
|
802
|
return inspection, err
|
|
@@ -1301,7 +1329,7 @@ func GetMonthProjectList(orgid int64, lapseto int64, modetype int64, januaryStar
|
1301
|
1329
|
}
|
1302
|
1330
|
|
1303
|
1331
|
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
|
|
-
|
|
1332
|
+ fmt.Println("lapseto=======", lapseto)
|
1305
|
1333
|
if lapseto == 0 {
|
1306
|
1334
|
d := XTReadDB().Table("xt_patients as s")
|
1307
|
1335
|
fmt.Println("d", d)
|
|
@@ -1445,79 +1473,78 @@ func GetMonthProjectListTwo(orgid int64, lapseto int64, modetype int64, januaryS
|
1445
|
1473
|
}
|
1446
|
1474
|
countSQL += ")a GROUP BY nnd"
|
1447
|
1475
|
err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
|
1476
|
+ }
|
1448
|
1477
|
|
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)
|
|
1478
|
+ if lapseto == 2 {
|
|
1479
|
+ d := XTReadDB().Table("xt_patients as s")
|
|
1480
|
+ fmt.Println("d", d)
|
|
1481
|
+ db := readDb.Table("xt_inspection as x ").Where("x.status=1")
|
|
1482
|
+ table := XTReadDB().Table("xt_inspection_reference as r")
|
|
1483
|
+ fmt.Println(table)
|
|
1484
|
+ countSQL := "SELECT nnd AS 'total',COUNT(*) AS 'count' FROM(" +
|
|
1485
|
+ "SELECT " +
|
|
1486
|
+ "CASE " +
|
|
1487
|
+ " 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 '一月'" +
|
|
1488
|
+ " 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 '二月'" +
|
|
1489
|
+ " 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 '三月'" +
|
|
1490
|
+ " 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 '四月'" +
|
|
1491
|
+ " 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 '五月'" +
|
|
1492
|
+ " 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 '六月'" +
|
|
1493
|
+ " 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 '七月'" +
|
|
1494
|
+ " 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 '八月'" +
|
|
1495
|
+ " 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 '九月'" +
|
|
1496
|
+ " 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 '十月'" +
|
|
1497
|
+ " 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 '十一月'" +
|
|
1498
|
+ " 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 '十二月'" +
|
|
1499
|
+ " ELSE '其他'" +
|
|
1500
|
+ "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)"
|
|
1501
|
+ countParams := make([]interface{}, 0)
|
|
1502
|
+ countParams = append(countParams, januaryStartStrUnix)
|
|
1503
|
+ countParams = append(countParams, januaryEndStrUnix)
|
|
1504
|
+ countParams = append(countParams, febStartStrStrUnix)
|
|
1505
|
+ countParams = append(countParams, febEndStrUnix)
|
|
1506
|
+ countParams = append(countParams, marchStartStrUnix)
|
|
1507
|
+ countParams = append(countParams, marchEndStrUnix)
|
|
1508
|
+ countParams = append(countParams, aprStartStrUnix)
|
|
1509
|
+ countParams = append(countParams, aprEndStrsUnix)
|
|
1510
|
+ countParams = append(countParams, mayStartStrUnix)
|
|
1511
|
+ countParams = append(countParams, mayEndStrsUnix)
|
|
1512
|
+ countParams = append(countParams, junStartStrUnix)
|
|
1513
|
+ countParams = append(countParams, junEndStrsUnix)
|
|
1514
|
+ countParams = append(countParams, julStartStrUnix)
|
|
1515
|
+ countParams = append(countParams, julEndStrsUnix)
|
|
1516
|
+ countParams = append(countParams, augStartStrUnix)
|
|
1517
|
+ countParams = append(countParams, augEndStrsUnix)
|
|
1518
|
+ countParams = append(countParams, sepStartStrUnix)
|
|
1519
|
+ countParams = append(countParams, sepEndStrsUnix)
|
|
1520
|
+ countParams = append(countParams, octStartStrUnix)
|
|
1521
|
+ countParams = append(countParams, octEndStrsUnix)
|
|
1522
|
+ countParams = append(countParams, novStartStrUnix)
|
|
1523
|
+ countParams = append(countParams, novEndStrsUnix)
|
|
1524
|
+ countParams = append(countParams, decStartStrUnix)
|
|
1525
|
+ countParams = append(countParams, decEndStrsUnix)
|
|
1526
|
+ if orgid > 0 {
|
|
1527
|
+ db = db.Where("x.org_id=?", orgid)
|
|
1528
|
+ countSQL += " AND x.org_id=?"
|
|
1529
|
+ countParams = append(countParams, orgid)
|
|
1530
|
+ }
|
|
1531
|
+ if modetype > 0 {
|
|
1532
|
+ db = db.Where("x.item_id = ?", modetype)
|
|
1533
|
+ countSQL += " AND x.item_id=?"
|
|
1534
|
+ countParams = append(countParams, modetype)
|
|
1535
|
+ }
|
|
1536
|
+ if januaryStartStrUnix > 0 {
|
|
1537
|
+ db = db.Where("x.inspect_date >= ?", januaryStartStrUnix)
|
|
1538
|
+ countSQL += " AND x.inspect_date >=?"
|
1474
|
1539
|
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)
|
|
1540
|
+ }
|
|
1541
|
+ if decEndStrsUnix > 0 {
|
|
1542
|
+ db = db.Where("x.inspect_date <= ?", decEndStrsUnix)
|
|
1543
|
+ countSQL += " AND x.inspect_date <=?"
|
1497
|
1544
|
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
|
1545
|
}
|
|
1546
|
+ countSQL += ")a GROUP BY nnd"
|
|
1547
|
+ err = readDb.Raw(countSQL, countParams...).Scan(&inspection).Error
|
1521
|
1548
|
}
|
1522
|
1549
|
return
|
1523
|
1550
|
}
|
|
@@ -1536,6 +1563,12 @@ func GetPatientsControl(orgid int64, lapstor int64, startime int64, endtime int6
|
1536
|
1563
|
if lapstor == 0 {
|
1537
|
1564
|
table = table.Where("s.lapseto = 1 or s.lapseto = 2")
|
1538
|
1565
|
}
|
|
1566
|
+ if lapstor == 1 {
|
|
1567
|
+ db = db.Where("s.lapseto = 1")
|
|
1568
|
+ }
|
|
1569
|
+ if lapstor == 2 {
|
|
1570
|
+ db = db.Where("s.lapseto = 2")
|
|
1571
|
+ }
|
1539
|
1572
|
if startime > 0 {
|
1540
|
1573
|
db = db.Where("x.inspect_date >=?", startime)
|
1541
|
1574
|
}
|
|
@@ -1555,6 +1588,45 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
|
1555
|
1588
|
fmt.Println(table)
|
1556
|
1589
|
d := readDb.Table(" xt_inspection_reference as r")
|
1557
|
1590
|
fmt.Println(d)
|
|
1591
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
1592
|
+ fmt.Println("d2", d2)
|
|
1593
|
+ if orgid > 0 {
|
|
1594
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
1595
|
+ }
|
|
1596
|
+ if lapstor == 0 {
|
|
1597
|
+ table = table.Where("s.lapseto = 1 or s.lapseto = 2")
|
|
1598
|
+ }
|
|
1599
|
+
|
|
1600
|
+ if lapstor == 1 {
|
|
1601
|
+ table = table.Where("s.lapseto = 1")
|
|
1602
|
+ }
|
|
1603
|
+ if lapstor == 2 {
|
|
1604
|
+ table = table.Where("s.lapseto = 2")
|
|
1605
|
+ }
|
|
1606
|
+ if startime > 0 {
|
|
1607
|
+ db = db.Where("x.inspect_date >=?", startime)
|
|
1608
|
+ }
|
|
1609
|
+ if endtime > 0 {
|
|
1610
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
1611
|
+ }
|
|
1612
|
+ 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
|
|
1613
|
+
|
|
1614
|
+ return inspection, err
|
|
1615
|
+}
|
|
1616
|
+
|
|
1617
|
+func GetPatientContor(lapstor, orgid int64, keywords string, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
|
|
1618
|
+
|
|
1619
|
+ db := readDb.Table("xt_inspection as x").Where("x.status =1")
|
|
1620
|
+ table := readDb.Table("xt_patients as s")
|
|
1621
|
+ fmt.Println(table)
|
|
1622
|
+ d := readDb.Table(" xt_inspection_reference as r")
|
|
1623
|
+ fmt.Println(d)
|
|
1624
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
1625
|
+ fmt.Println("d2", d2)
|
|
1626
|
+
|
|
1627
|
+ if len(keywords) > 0 {
|
|
1628
|
+ db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", keywords, keywords)
|
|
1629
|
+ }
|
1558
|
1630
|
|
1559
|
1631
|
if orgid > 0 {
|
1560
|
1632
|
db = db.Where("x.org_id = ?", orgid)
|
|
@@ -1562,13 +1634,83 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
|
1562
|
1634
|
if lapstor == 0 {
|
1563
|
1635
|
table = table.Where("s.lapseto = 1 or s.lapseto = 2")
|
1564
|
1636
|
}
|
|
1637
|
+
|
|
1638
|
+ if lapstor == 1 {
|
|
1639
|
+ table = table.Where("s.lapseto = 1")
|
|
1640
|
+ }
|
|
1641
|
+ if lapstor == 2 {
|
|
1642
|
+ table = table.Where("s.lapseto = 2")
|
|
1643
|
+ }
|
|
1644
|
+ if startime > 0 {
|
|
1645
|
+ db = db.Where("x.inspect_date >=?", startime)
|
|
1646
|
+ }
|
|
1647
|
+ if endtime > 0 {
|
|
1648
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
1649
|
+ }
|
|
1650
|
+ 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
|
|
1651
|
+
|
|
1652
|
+ return inspection, err
|
|
1653
|
+}
|
|
1654
|
+
|
|
1655
|
+func GetPatientNames(orgid int64, patientname string) (models.XtPatients, error) {
|
|
1656
|
+ patients := models.XtPatients{}
|
|
1657
|
+ err := readDb.Where("user_org_id = ? and (name=? or dialysis_no=?) and status = 1", orgid, patientname, patientname).Find(&patients).Error
|
|
1658
|
+ return patients, err
|
|
1659
|
+}
|
|
1660
|
+
|
|
1661
|
+func GetQualityControlById(orgid int64, patientid int64, startime int64, endtime int64, itemid int64) (inspection []*models.PatientInspectionCount, err error) {
|
|
1662
|
+
|
|
1663
|
+ db := readDb.Table("xt_inspection as x").Where("x.status =1")
|
|
1664
|
+ table := readDb.Table("xt_patients as s")
|
|
1665
|
+ fmt.Println(table)
|
|
1666
|
+ d := readDb.Table(" xt_inspection_reference as r")
|
|
1667
|
+ fmt.Println(d)
|
|
1668
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
1669
|
+ fmt.Println("d2", d2)
|
|
1670
|
+
|
|
1671
|
+ if orgid > 0 {
|
|
1672
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
1673
|
+ }
|
|
1674
|
+ if patientid > 0 {
|
|
1675
|
+ db = db.Where("x.patient_id = ?", patientid)
|
|
1676
|
+ }
|
|
1677
|
+
|
|
1678
|
+ if startime > 0 {
|
|
1679
|
+ db = db.Where("x.inspect_date >=?", startime)
|
|
1680
|
+ }
|
|
1681
|
+ if endtime > 0 {
|
|
1682
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
1683
|
+ }
|
|
1684
|
+ if itemid > 0 {
|
|
1685
|
+ db = db.Where("x.item_id = ?", itemid)
|
|
1686
|
+ }
|
|
1687
|
+ 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,r.unit").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
|
|
1688
|
+
|
|
1689
|
+ return inspection, err
|
|
1690
|
+}
|
|
1691
|
+
|
|
1692
|
+func GetLastPatientsControlTwo(orgid int64, patientid int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
|
|
1693
|
+
|
|
1694
|
+ db := readDb.Table("xt_inspection as x").Where("x.status =1")
|
|
1695
|
+ table := readDb.Table("xt_patients as s")
|
|
1696
|
+ fmt.Println(table)
|
|
1697
|
+ d := readDb.Table(" xt_inspection_reference as r")
|
|
1698
|
+ fmt.Println(d)
|
|
1699
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
1700
|
+ fmt.Println("d2", d2)
|
|
1701
|
+ if orgid > 0 {
|
|
1702
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
1703
|
+ }
|
|
1704
|
+ if patientid > 0 {
|
|
1705
|
+ db = db.Where("x.patient_id = ?", patientid)
|
|
1706
|
+ }
|
1565
|
1707
|
if startime > 0 {
|
1566
|
1708
|
db = db.Where("x.inspect_date >=?", startime)
|
1567
|
1709
|
}
|
1568
|
1710
|
if endtime > 0 {
|
1569
|
1711
|
db = db.Where("x.inspect_date <=?", endtime)
|
1570
|
1712
|
}
|
1571
|
|
- err = db.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").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").Order("x.inspect_date desc").Scan(&inspection).Error
|
|
1713
|
+ 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
|
1572
|
1714
|
|
1573
|
1715
|
return inspection, err
|
1574
|
1716
|
}
|