|
@@ -59,7 +59,7 @@ func GetConfigurationlist(orgid int64, limit int64, page int64) (standard []*mod
|
59
|
59
|
table := XTReadDB().Table("xt_inspection_reference as s")
|
60
|
60
|
fmt.Println(table)
|
61
|
61
|
offset := (page - 1) * limit
|
62
|
|
- err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,s.unit,s.project_name,s.item_name").Count(&total).
|
|
62
|
+ err = db.Order("x.sort asc,x.created_time desc").Group("x.id").Select("x.id,x.inspection_major,x.inspection_minor,x.min_range,x.large_range,x.sort,x.user_org_id,x.range_value,x.range_type,s.unit,s.project_name,s.item_name").Count(&total).
|
63
|
63
|
Joins("left join xt_inspection_reference as s on s.id = x.inspection_minor").Offset(offset).Limit(limit).Scan(&standard).Error
|
64
|
64
|
return standard, total, err
|
65
|
65
|
}
|
|
@@ -301,7 +301,7 @@ func TotalDialysisCount(startime int64, endtime int64, orgid int64) (order []*mo
|
301
|
301
|
|
302
|
302
|
db := XTReadDB().Table("xt_dialysis_order as o")
|
303
|
303
|
|
304
|
|
- err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o where o.status = 1 and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ?", startime, endtime, orgid).Group("o.patient_id").Scan(&order).Error
|
|
304
|
+ err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o left join xt_schedule AS x ON x.patient_id = o.patient_id where o.status = 1 and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and x.schedule_date = o.dialysis_date and x.status = 1", startime, endtime, orgid).Group("o.patient_id").Scan(&order).Error
|
305
|
305
|
return order, err
|
306
|
306
|
}
|
307
|
307
|
|
|
@@ -584,7 +584,7 @@ func GetInspectionDetailById(id int64, orgid int64, startime int64, endtime int6
|
584
|
584
|
db = db.Where("x.inspect_date <=?", endtime)
|
585
|
585
|
}
|
586
|
586
|
|
587
|
|
- err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left join xt_inspection_reference as r on r.project_id = x.project_id").Group("project_id,patient_id").Scan(&projectCounts).Error
|
|
587
|
+ err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency,t.sort").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left join xt_inspection_reference as r on r.project_id = x.project_id").Group("project_id,patient_id").Scan(&projectCounts).Error
|
588
|
588
|
return
|
589
|
589
|
}
|
590
|
590
|
|
|
@@ -2332,7 +2332,7 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
|
2332
|
2332
|
d2 := readDb.Table("xt_quality_control_standard as d")
|
2333
|
2333
|
fmt.Println("d2", d2)
|
2334
|
2334
|
if orgid > 0 {
|
2335
|
|
- db = db.Where("x.org_id = ? and x.inspect_value <> 0", orgid)
|
|
2335
|
+ db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and x.inspect_type = 1", orgid)
|
2336
|
2336
|
}
|
2337
|
2337
|
if lapstor == 0 {
|
2338
|
2338
|
table = table.Where("s.lapseto = 1 or s.lapseto = 2")
|
|
@@ -2350,7 +2350,71 @@ func GetLastPatientsControl(orgid int64, lapstor int64, startime int64, endtime
|
2350
|
2350
|
if endtime > 0 {
|
2351
|
2351
|
db = db.Where("x.inspect_date <=?", endtime)
|
2352
|
2352
|
}
|
2353
|
|
- 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.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
|
|
2353
|
+ 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,d.min_range,d.large_range,d.range_value,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
|
|
2354
|
+
|
|
2355
|
+ return inspection, err
|
|
2356
|
+}
|
|
2357
|
+
|
|
2358
|
+func GetInfectiousPatientsControl(orgid int64, lapstor int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
|
|
2359
|
+ db := readDb.Table("xt_inspection as x").Where("x.status =1")
|
|
2360
|
+ table := readDb.Table("xt_patients as s")
|
|
2361
|
+ fmt.Println(table)
|
|
2362
|
+ d := readDb.Table(" xt_inspection_reference as r")
|
|
2363
|
+ fmt.Println(d)
|
|
2364
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
2365
|
+ fmt.Println("d2", d2)
|
|
2366
|
+ if orgid > 0 {
|
|
2367
|
+ db = db.Where("x.org_id = ? and x.inspect_value <> '' and x.inspect_type = 2", orgid)
|
|
2368
|
+ }
|
|
2369
|
+ if lapstor == 0 {
|
|
2370
|
+ table = table.Where("s.lapseto = 1 or s.lapseto = 2")
|
|
2371
|
+ }
|
|
2372
|
+
|
|
2373
|
+ if lapstor == 1 {
|
|
2374
|
+ table = table.Where("s.lapseto = 1")
|
|
2375
|
+ }
|
|
2376
|
+ if lapstor == 2 {
|
|
2377
|
+ table = table.Where("s.lapseto = 2")
|
|
2378
|
+ }
|
|
2379
|
+ if startime > 0 {
|
|
2380
|
+ db = db.Where("x.inspect_date >=?", startime)
|
|
2381
|
+ }
|
|
2382
|
+ if endtime > 0 {
|
|
2383
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
2384
|
+ }
|
|
2385
|
+ 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,d.min_range,d.large_range,d.range_value,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
|
|
2386
|
+
|
|
2387
|
+ return inspection, err
|
|
2388
|
+}
|
|
2389
|
+
|
|
2390
|
+func GetInfectiousControl(orgid int64, lapstor int64, startime int64, endtime int64) (inspection []*models.PatientInspectionCount, err error) {
|
|
2391
|
+ db := readDb.Table("xt_inspection as x").Where("x.status =1")
|
|
2392
|
+ table := readDb.Table("xt_patients as s")
|
|
2393
|
+ fmt.Println(table)
|
|
2394
|
+ d := readDb.Table(" xt_inspection_reference as r")
|
|
2395
|
+ fmt.Println(d)
|
|
2396
|
+ d2 := readDb.Table("xt_quality_control_standard as d")
|
|
2397
|
+ fmt.Println("d2", d2)
|
|
2398
|
+ if orgid > 0 {
|
|
2399
|
+ db = db.Where("x.org_id = ? and x.inspect_value <> '' and x.inspect_type = 2", orgid)
|
|
2400
|
+ }
|
|
2401
|
+ if lapstor == 0 {
|
|
2402
|
+ table = table.Where("s.lapseto = 1 or s.lapseto = 2")
|
|
2403
|
+ }
|
|
2404
|
+
|
|
2405
|
+ if lapstor == 1 {
|
|
2406
|
+ table = table.Where("s.lapseto = 1")
|
|
2407
|
+ }
|
|
2408
|
+ if lapstor == 2 {
|
|
2409
|
+ table = table.Where("s.lapseto = 2")
|
|
2410
|
+ }
|
|
2411
|
+ if startime > 0 {
|
|
2412
|
+ db = db.Where("x.inspect_date >=?", startime)
|
|
2413
|
+ }
|
|
2414
|
+ if endtime > 0 {
|
|
2415
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
2416
|
+ }
|
|
2417
|
+ 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,d.min_range,d.large_range,d.range_value,d.range_type").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join xt_inspection_reference as r on r.item_id = x.item_id AND r.org_id > 0 OR ( x.item_id = r.id AND r.org_id = 0)").Joins("left join xt_quality_control_standard as d on d.inspection_minor = x.item_id").Order("x.inspect_date desc").Scan(&inspection).Error
|
2354
|
2418
|
|
2355
|
2419
|
return inspection, err
|
2356
|
2420
|
}
|
|
@@ -2484,7 +2548,7 @@ func GetLastPatientsControlTwo(orgid int64, patientid int64, startime int64, end
|
2484
|
2548
|
if endtime > 0 {
|
2485
|
2549
|
db = db.Where("x.inspect_date <=?", endtime)
|
2486
|
2550
|
}
|
2487
|
|
- 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
|
|
2551
|
+ 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,d.large_range,d.min_range,d.range_type").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
|
2488
|
2552
|
|
2489
|
2553
|
return inspection, err
|
2490
|
2554
|
}
|