|
@@ -296,58 +296,67 @@ func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error
|
296
|
296
|
return patients, err
|
297
|
297
|
}
|
298
|
298
|
|
299
|
|
-func GetDialysisList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
|
300
|
|
- db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
|
301
|
|
- table := XTReadDB().Table("xt_patients as s")
|
302
|
|
- fmt.Println("table", table)
|
|
299
|
+func GetDialysisList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
|
|
300
|
+
|
|
301
|
+ db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
|
302
|
+ table := XTReadDB().Table("xt_schedule as s")
|
|
303
|
+ fmt.Println(table)
|
|
304
|
+ d := XTReadDB().Table("xt_patients as p")
|
|
305
|
+ fmt.Println(d)
|
303
|
306
|
if orgid > 0 {
|
304
|
|
- db = db.Where("p.user_org_id = ?", orgid)
|
|
307
|
+ db = db.Where("o.user_org_id = ?", orgid)
|
305
|
308
|
}
|
306
|
309
|
if startime > 0 {
|
307
|
|
- db = db.Where("p.record_date >= ?", startime)
|
|
310
|
+ db = db.Where("o.dialysis_date>=?", startime)
|
308
|
311
|
}
|
309
|
312
|
if endtime > 0 {
|
310
|
|
- db = db.Where("p.record_date <=?", endtime)
|
|
313
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
311
|
314
|
}
|
312
|
315
|
offset := (page - 1) * limit
|
313
|
|
- err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
|
314
|
|
- return prescription, total, err
|
|
316
|
+ err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").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 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
|
|
317
|
+ return order, total, err
|
|
318
|
+
|
315
|
319
|
}
|
316
|
320
|
|
317
|
|
-func GetAllDialysisList(startime int64, endtime int64, orgid int64) (prescription []*models.BloodDialysisPrescription, err error) {
|
|
321
|
+func GetAllDialysisList(startime int64, endtime int64, orgid int64) (order []*models.BloodDialysisOrder, err error) {
|
318
|
322
|
|
319
|
|
- db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
|
320
|
|
- table := XTReadDB().Table("xt_patients as s")
|
|
323
|
+ table := XTReadDB().Table("xt_schedule as s")
|
321
|
324
|
fmt.Println(table)
|
|
325
|
+ d := XTReadDB().Table("xt_patients as p")
|
|
326
|
+ fmt.Println(d)
|
|
327
|
+ db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
322
|
328
|
if orgid > 0 {
|
323
|
|
- db = db.Where("p.user_org_id = ?", orgid)
|
|
329
|
+ db = db.Where("o.user_org_id = ?", orgid)
|
324
|
330
|
}
|
325
|
331
|
if startime > 0 {
|
326
|
|
- db = db.Where("p.record_date >= ?", startime)
|
|
332
|
+ db = db.Where("o.dialysis_date>=?", startime)
|
327
|
333
|
}
|
328
|
334
|
if endtime > 0 {
|
329
|
|
- db = db.Where("p.record_date <=?", endtime)
|
|
335
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
330
|
336
|
}
|
331
|
|
- err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Scan(&prescription).Error
|
332
|
|
- return prescription, err
|
|
337
|
+ err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").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 ").Scan(&order).Error
|
|
338
|
+ return order, err
|
333
|
339
|
}
|
334
|
340
|
|
335
|
|
-func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
|
336
|
|
- db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
|
337
|
|
- table := XTReadDB().Table("xt_patients as s")
|
338
|
|
- fmt.Println("table", table)
|
|
341
|
+func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
|
|
342
|
+
|
|
343
|
+ table := XTReadDB().Table("xt_schedule as s")
|
|
344
|
+ fmt.Println(table)
|
|
345
|
+ d := XTReadDB().Table("xt_patients as p")
|
|
346
|
+ fmt.Println(d)
|
|
347
|
+ db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
339
|
348
|
if orgid > 0 {
|
340
|
|
- db = db.Where("p.user_org_id = ?", orgid)
|
|
349
|
+ db = db.Where("o.user_org_id = ?", orgid)
|
341
|
350
|
}
|
342
|
351
|
if startime > 0 {
|
343
|
|
- db = db.Where("p.record_date >= ?", startime)
|
|
352
|
+ db = db.Where("o.dialysis_date>=?", startime)
|
344
|
353
|
}
|
345
|
354
|
if endtime > 0 {
|
346
|
|
- db = db.Where("p.record_date <=?", endtime)
|
|
355
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
347
|
356
|
}
|
348
|
357
|
offset := (page - 1) * limit
|
349
|
|
- err = db.Group("p.patient_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
|
350
|
|
- return prescription, total, err
|
|
358
|
+ err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").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 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
|
|
359
|
+ return order, total, err
|
351
|
360
|
}
|
352
|
361
|
|
353
|
362
|
func GetLastSort(orgid int64) (models.XtQualityControlStandard, error) {
|
|
@@ -385,14 +394,17 @@ func GetDialysisDetailById(id int64, orgid int64, startime int64, endtime int64,
|
385
|
394
|
return prescription, total, err
|
386
|
395
|
}
|
387
|
396
|
|
388
|
|
-func GetPrescritionByName(orgid int64, keywords string, startime int64, endtime int64, limit int64, page int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
|
|
397
|
+func GetPrescritionByName(orgid int64, patient_id int64, startime int64, endtime int64, limit int64, page int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
|
389
|
398
|
|
390
|
399
|
db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
|
391
|
400
|
table := XTReadDB().Table("xt_patients as s")
|
392
|
401
|
fmt.Println(table)
|
393
|
|
- if len(keywords) > 0 {
|
394
|
|
- likeKey := "%" + keywords + "%"
|
395
|
|
- db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", likeKey, likeKey)
|
|
402
|
+ //if len(keywords) > 0 {
|
|
403
|
+ // likeKey := "%" + keywords + "%"
|
|
404
|
+ // db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", likeKey, likeKey)
|
|
405
|
+ //}
|
|
406
|
+ if patient_id > 0 {
|
|
407
|
+ db = db.Where("s.id = ?", patient_id)
|
396
|
408
|
}
|
397
|
409
|
if orgid > 0 {
|
398
|
410
|
db = db.Where("p.user_org_id = ?", orgid)
|
|
@@ -408,47 +420,87 @@ func GetPrescritionByName(orgid int64, keywords string, startime int64, endtime
|
408
|
420
|
return prescription, total, err
|
409
|
421
|
}
|
410
|
422
|
|
411
|
|
-func GetStatistics(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64, modeID int64) (dtd []*DialysisTotalDataStruct, ttd []*DialysisTotalDataStruct, total int64, err error) {
|
412
|
|
- db := readDb
|
413
|
|
- sql := "s.mode_id,from_unixtime(s.record_date, '%Y%m%d') as date, count(s.record_date) as number"
|
414
|
|
- datesql := "s.record_date as date"
|
415
|
|
- group := "from_unixtime(s.record_date, '%Y%m%d')"
|
416
|
|
- db = db.Table("xt_dialysis_prescription as s")
|
|
423
|
+func GetTreateInfo(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64) (blood []*models.TreatDialysisOrder, total int64, err error) {
|
|
424
|
+
|
|
425
|
+ db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
|
426
|
+ table := XTReadDB().Table("xt_schedule as s")
|
|
427
|
+ fmt.Println(table)
|
|
428
|
+ p := XTReadDB().Table("xt_patients as p")
|
|
429
|
+ fmt.Println(p)
|
|
430
|
+ sql := "from_unixtime(o.dialysis_date, '%Y%m%d') AS date"
|
|
431
|
+
|
417
|
432
|
if orgID > 0 {
|
418
|
|
- db = db.Where("s.user_org_id = ?", orgID)
|
419
|
|
- }
|
420
|
|
- if modeID > 0 {
|
421
|
|
- db = db.Where("s.mode_id=?", modeID)
|
|
433
|
+ db = db.Where("o.user_org_id = ?", orgID)
|
422
|
434
|
}
|
423
|
435
|
if startime > 0 {
|
424
|
|
- db = db.Where("s.record_date>=?", startime)
|
|
436
|
+ db = db.Where("o.dialysis_date >=?", startime)
|
425
|
437
|
}
|
426
|
438
|
if endtime > 0 {
|
427
|
|
- db = db.Where("s.record_date<=?", endtime)
|
|
439
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
|
440
|
+ }
|
|
441
|
+ if lapseto == 0 {
|
|
442
|
+ db = db.Where("p.lapseto = 1 or p.lapseto = 2")
|
428
|
443
|
}
|
429
|
|
- db = db.Where("s.status=1")
|
|
444
|
+ if lapseto > 0 {
|
|
445
|
+ db = db.Where("p.lapseto = ?", lapseto)
|
|
446
|
+ }
|
|
447
|
+ offset := (page - 1) * limit
|
|
448
|
+ err = db.Group("o.dialysis_date").Select(sql).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").Count(&total).Offset(offset).Limit(limit).Scan(&blood).Error
|
|
449
|
+ return blood, total, err
|
430
|
450
|
|
|
451
|
+}
|
|
452
|
+func GetTreatList(orgid int64, startime int64, endtime int64, lapseto int64) (ttd []*models.TreatTotalStruct, err error) {
|
|
453
|
+ db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
|
454
|
+ table := XTReadDB().Table("xt_schedule as s")
|
|
455
|
+ fmt.Println(table)
|
|
456
|
+ p := XTReadDB().Table("xt_patients as p")
|
|
457
|
+ fmt.Println(p)
|
|
458
|
+ if orgid > 0 {
|
|
459
|
+ db = db.Where("o.user_org_id = ?", orgid)
|
|
460
|
+ }
|
|
461
|
+ if startime > 0 {
|
|
462
|
+ db = db.Where("o.dialysis_date>=?", startime)
|
|
463
|
+ }
|
|
464
|
+ if endtime > 0 {
|
|
465
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
|
466
|
+ }
|
|
467
|
+ if lapseto == 0 {
|
|
468
|
+ db = db.Where("p.lapseto = 1 or p.lapseto = 2")
|
|
469
|
+ }
|
431
|
470
|
if lapseto > 0 {
|
432
|
|
- joinString := "JOIN xt_patients as p ON s.patient_id=p.id and p.lapseto=? and p.status=1"
|
433
|
|
- joinParams := make([]interface{}, 0)
|
434
|
|
- joinParams = append(joinParams, lapseto)
|
435
|
|
- if orgID > 0 {
|
436
|
|
- joinString += "AND p.user_org_id=?"
|
437
|
|
- joinParams = append(joinParams, orgID)
|
438
|
|
- }
|
|
471
|
+ db = db.Where("p.lapseto = ?", lapseto)
|
|
472
|
+ }
|
|
473
|
+ err = db.Select("s.mode_id, count(s.mode_id) as number").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").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
|
|
474
|
+ return ttd, err
|
|
475
|
+}
|
439
|
476
|
|
440
|
|
- db = db.Joins(joinString, joinParams...)
|
|
477
|
+func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dtd []*DialysisTotalDataStruct, ttd []*DialysisTotalDataStruct, err error) {
|
|
478
|
+ db := readDb
|
|
479
|
+ sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
|
|
480
|
+ datesql := " o.dialysis_date as date"
|
|
481
|
+ group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
|
|
482
|
+ db = db.Table(" xt_dialysis_order AS o").Joins("left join xt_schedule as s on o.patient_id = s.patient_id").Where("s.schedule_date = o.dialysis_date")
|
|
483
|
+ if orgID > 0 {
|
|
484
|
+ db = db.Where("o.user_org_id = ?", orgID)
|
|
485
|
+ }
|
|
486
|
+ if modeID > 0 {
|
|
487
|
+ db = db.Where("s.mode_id=?", modeID)
|
441
|
488
|
}
|
|
489
|
+ if startime > 0 {
|
|
490
|
+ db = db.Where("o.dialysis_date>=?", startime)
|
|
491
|
+ }
|
|
492
|
+ if endtime > 0 {
|
|
493
|
+ db = db.Where("o.dialysis_date<=?", endtime)
|
|
494
|
+ }
|
|
495
|
+ db = db.Where("o.status=1")
|
442
|
496
|
|
443
|
497
|
err = db.Select("s.mode_id, count(s.mode_id) as number").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
|
444
|
498
|
if err != nil {
|
445
|
499
|
return
|
446
|
500
|
}
|
447
|
501
|
|
448
|
|
- offset := (page - 1) * limit
|
449
|
|
-
|
450
|
502
|
var ds []*DialysisTotalDataStruct
|
451
|
|
- err = db.Select(datesql).Group(group).Count(&total).Order("date asc").Offset(offset).Limit(limit).Find(&ds).Error
|
|
503
|
+ err = db.Select(datesql).Group(group).Find(&ds).Error
|
452
|
504
|
if err != nil {
|
453
|
505
|
return
|
454
|
506
|
}
|
|
@@ -459,12 +511,13 @@ func GetStatistics(orgID int64, startime int64, endtime int64, lapseto int64, li
|
459
|
511
|
dates = append(dates, d.Date)
|
460
|
512
|
}
|
461
|
513
|
|
462
|
|
- db = db.Where("s.record_date IN (?)", dates)
|
|
514
|
+ db = db.Where("o.dialysis_date IN (?)", dates)
|
463
|
515
|
|
464
|
516
|
}
|
465
|
517
|
|
466
|
|
- err = db.Select(sql).Group(group + ", s.mode_id").Order("date asc, mode_id").Find(&dtd).Error
|
|
518
|
+ err = db.Select(sql).Group(group + ", s.mode_id").Order("date asc, s.mode_id").Find(&dtd).Error
|
467
|
519
|
return
|
|
520
|
+
|
468
|
521
|
}
|
469
|
522
|
|
470
|
523
|
func GetInspectionTotalCount(orgid int64) (configuration []*models.CheckConfiguration, err error) {
|
|
@@ -523,7 +576,7 @@ func GetInspectionDetailById(id int64, orgid int64, startime int64, endtime int6
|
523
|
576
|
return
|
524
|
577
|
}
|
525
|
578
|
|
526
|
|
-func GetSearchPatientInfo(orgid int64, keywords string, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
|
|
579
|
+func GetSearchPatientInfo(orgid int64, keywords int64, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
|
527
|
580
|
|
528
|
581
|
db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
|
529
|
582
|
table := XTReadDB().Table("xt_inspection_reference as r")
|
|
@@ -532,9 +585,12 @@ func GetSearchPatientInfo(orgid int64, keywords string, startime int64, endtime
|
532
|
585
|
fmt.Println(d)
|
533
|
586
|
p := XTReadDB().Table("xt_patients as p")
|
534
|
587
|
fmt.Println(p)
|
535
|
|
- if len(keywords) > 0 {
|
536
|
|
- likeKey := "%" + keywords + "%"
|
537
|
|
- db = db.Where("p.name LIKE ? OR p.dialysis_no LIKE ?", likeKey, likeKey)
|
|
588
|
+ //if len(keywords) > 0 {
|
|
589
|
+ // likeKey := "%" + keywords + "%"
|
|
590
|
+ // db = db.Where("p.name LIKE ? OR p.dialysis_no LIKE ?", likeKey, likeKey)
|
|
591
|
+ //}
|
|
592
|
+ if keywords > 0 {
|
|
593
|
+ db = db.Where("x.patient_id = ?", keywords)
|
538
|
594
|
}
|
539
|
595
|
if orgid > 0 {
|
540
|
596
|
db = db.Where("x.org_id = ?", orgid)
|
|
@@ -1603,9 +1659,9 @@ func GetPatientContor(lapstor, orgid int64, keywords string, startime int64, end
|
1603
|
1659
|
return inspection, err
|
1604
|
1660
|
}
|
1605
|
1661
|
|
1606
|
|
-func GetPatientNames(orgid int64, patientname string) (models.XtPatients, error) {
|
|
1662
|
+func GetPatientNames(orgid int64, patientid int64) (models.XtPatients, error) {
|
1607
|
1663
|
patients := models.XtPatients{}
|
1608
|
|
- err := readDb.Where("user_org_id = ? and (name=? or dialysis_no=?) and status = 1", orgid, patientname, patientname).Find(&patients).Error
|
|
1664
|
+ err := readDb.Where("user_org_id = ? and id = ? and status = 1", orgid, patientid).Find(&patients).Error
|
1609
|
1665
|
return patients, err
|
1610
|
1666
|
}
|
1611
|
1667
|
|