|
@@ -503,7 +503,8 @@ func GetLastNewSlowPatient(phone string, orgid int64) (*models.XtPatientsNew, er
|
503
|
503
|
func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int64, limit int64, page int64, orgID int64) (doctoradvice []*models.DoctorAdvices, total int64, err error) {
|
504
|
504
|
db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
505
|
505
|
table := UserReadDB().Table("sgj_user_admin_role as r")
|
506
|
|
- fmt.Print("table", table)
|
|
506
|
+ tabletwo := readDb.Table("xt_dialysis_prescription as s").Where("s.status = 1")
|
|
507
|
+ fmt.Print("table", table, tabletwo)
|
507
|
508
|
if orgID > 0 {
|
508
|
509
|
db = db.Where("x.user_org_id=?", orgID)
|
509
|
510
|
}
|
|
@@ -514,7 +515,10 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
|
514
|
515
|
db = db.Where("x.advice_type = ?", advice_type)
|
515
|
516
|
}
|
516
|
517
|
if advice_type == 3 {
|
517
|
|
- db = db.Where("x.advice_type <> 1")
|
|
518
|
+ db = db.Where("x.advice_type = 2 or x.advice_type = 3")
|
|
519
|
+ }
|
|
520
|
+ if advice_type == 4 {
|
|
521
|
+ db = db.Where("x.advice_type = ?", advice_type)
|
518
|
522
|
}
|
519
|
523
|
if start > 0 {
|
520
|
524
|
db = db.Where("x.start_time>=?", start)
|
|
@@ -523,7 +527,7 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
|
523
|
527
|
db = db.Where("x.start_time<=?", end)
|
524
|
528
|
}
|
525
|
529
|
//offset := (page - 1) * limit
|
526
|
|
- err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
|
|
530
|
+ err = db.Group("x.id").Count(&total).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name,s.dialyzer_perfusion_apparatus,s.anticoagulant,s.anticoagulant_shouji,s.anticoagulant_weichi,s.anticoagulant_zongliang, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Joins("left join xt_dialysis_prescription as s on s.patient_id = x.patient_id and s.record_date = x.advice_date and s.user_org_id = ?", orgID).Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
|
527
|
531
|
fmt.Print("err", err)
|
528
|
532
|
return
|
529
|
533
|
|
|
@@ -533,6 +537,8 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
|
533
|
537
|
db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
534
|
538
|
table := UserReadDB().Table("sgj_user_admin_role as r")
|
535
|
539
|
fmt.Println("table", table)
|
|
540
|
+ tabletwo := readDb.Table("xt_dialysis_prescription as s").Where("s.status = 1")
|
|
541
|
+ fmt.Print("table", table, tabletwo)
|
536
|
542
|
if orgID > 0 {
|
537
|
543
|
db = db.Where("x.user_org_id=?", orgID)
|
538
|
544
|
}
|
|
@@ -543,7 +549,10 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
|
543
|
549
|
db = db.Where("x.advice_type = ?", advice_type)
|
544
|
550
|
}
|
545
|
551
|
if advice_type == 3 {
|
546
|
|
- db = db.Where("x.advice_type <> 1")
|
|
552
|
+ db = db.Where("x.advice_type = 2 or x.advice_type = 3")
|
|
553
|
+ }
|
|
554
|
+ if advice_type == 4 {
|
|
555
|
+ db = db.Where("x.advice_type = ?", advice_type)
|
547
|
556
|
}
|
548
|
557
|
|
549
|
558
|
if start > 0 {
|
|
@@ -553,7 +562,7 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
|
553
|
562
|
db = db.Where("x.start_time<=?", end)
|
554
|
563
|
}
|
555
|
564
|
offset := (page - 1) * limit
|
556
|
|
- err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&doctoradvice).Error
|
|
565
|
+ err = db.Order("x.start_time desc").Group("x.start_time").Count(&total).Offset(offset).Limit(limit).Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.status, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.parent_id,r.user_name,s.dialyzer_perfusion_apparatus,s.anticoagulant,s.anticoagulant_shouji,s.anticoagulant_weichi,s.anticoagulant_zongliang, IF(x.parent_id > 0, x.parent_id, x.id) as advice_order").Joins("Left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Joins("left join xt_dialysis_prescription as s on s.patient_id = x.patient_id and s.record_date = x.advice_date and s.user_org_id = ?", orgID).Scan(&doctoradvice).Error
|
557
|
566
|
fmt.Print("错误是什么", err)
|
558
|
567
|
return
|
559
|
568
|
}
|