|
@@ -683,7 +683,6 @@ func FindDoctorAdviceByGroupNo(orgID, groupNo int64) (advice models.DoctorAdvice
|
683
|
683
|
}
|
684
|
684
|
func GetDoctorAdviceList(orgID, patientID, advice_type, stop, start, end int64, keywords string) (advices []*models.DoctorAdvices, total int64, err error) {
|
685
|
685
|
|
686
|
|
- fmt.Println("advicetype-----", advice_type)
|
687
|
686
|
db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
688
|
687
|
table := UserReadDB().Table("sgj_user_admin_role as r")
|
689
|
688
|
fmt.Print("table", table)
|
|
@@ -693,11 +692,44 @@ func GetDoctorAdviceList(orgID, patientID, advice_type, stop, start, end int64,
|
693
|
692
|
if patientID > 0 {
|
694
|
693
|
db = db.Where("x.patient_id = ?", patientID)
|
695
|
694
|
}
|
696
|
|
-
|
697
|
|
-
|
698
|
|
-
|
699
|
|
-
|
700
|
|
-
|
|
695
|
+ if advice_type > 0 {
|
|
696
|
+ db = db.Where("x.advice_type = ?", advice_type)
|
|
697
|
+ } else if advice_type == 0 {
|
|
698
|
+ db = db.Where("x.advice_type in (?)", []int{1, 3})
|
|
699
|
+ }
|
|
700
|
+
|
|
701
|
+ if stop == 1 {
|
|
702
|
+ db = db.Where("(x.stop_state=? or x.execution_state=?)", stop, stop)
|
|
703
|
+ } else if stop == 2 {
|
|
704
|
+ db = db.Where("x.stop_state=? and x.execution_state=?", stop, stop)
|
|
705
|
+ }
|
|
706
|
+
|
|
707
|
+ if start != 0 {
|
|
708
|
+ db = db.Where("x.start_time>=?", start)
|
|
709
|
+ }
|
|
710
|
+ if end != 0 {
|
|
711
|
+ db = db.Where("start_time<=?", end)
|
|
712
|
+ }
|
|
713
|
+ if len(keywords) > 0 {
|
|
714
|
+ likeKey := "%" + keywords + "%"
|
|
715
|
+ db = db.Where("x.advice_name LIKE ?", likeKey)
|
|
716
|
+ }
|
|
717
|
+ 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(&advices).Error
|
|
718
|
+ fmt.Print("err", err)
|
|
719
|
+ return
|
|
720
|
+}
|
|
721
|
+
|
|
722
|
+func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int64, keywords string) (advices []*models.DoctorAdvices, total int64, err error) {
|
|
723
|
+
|
|
724
|
+ db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
|
725
|
+ table := UserReadDB().Table("sgj_user_admin_role as r")
|
|
726
|
+ fmt.Print("table", table)
|
|
727
|
+ if orgID > 0 {
|
|
728
|
+ db = db.Where("x.user_org_id=?", orgID)
|
|
729
|
+ }
|
|
730
|
+ if patientID > 0 {
|
|
731
|
+ db = db.Where("x.patient_id = ?", patientID)
|
|
732
|
+ }
|
701
|
733
|
if advice_type == 1 && advice_type > 0 {
|
702
|
734
|
db = db.Where("x.advice_type = ?", advice_type)
|
703
|
735
|
}
|
|
@@ -724,6 +756,48 @@ func GetDoctorAdviceList(orgID, patientID, advice_type, stop, start, end int64,
|
724
|
756
|
fmt.Print("err", err)
|
725
|
757
|
return
|
726
|
758
|
}
|
|
759
|
+
|
|
760
|
+func GetDoctorAdviceListTwo(orgID int64, patientID int64, advice_type int64, stop int64, start int64, end int64, keywords string, limit int64, page int64) (advices []*models.DoctorAdvices, total int64, err error) {
|
|
761
|
+
|
|
762
|
+ db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
|
763
|
+ table := UserReadDB().Table("sgj_user_admin_role as r")
|
|
764
|
+ fmt.Println(table)
|
|
765
|
+ if orgID > 0 {
|
|
766
|
+ db = db.Where("x.user_org_id=?", orgID)
|
|
767
|
+ }
|
|
768
|
+ if patientID > 0 {
|
|
769
|
+ db = db.Where("x.patient_id = ?", patientID)
|
|
770
|
+ }
|
|
771
|
+ if advice_type == 1 {
|
|
772
|
+ db = db.Where("x.advice_type = ?", advice_type)
|
|
773
|
+ }
|
|
774
|
+ if advice_type == 3 {
|
|
775
|
+ db = db.Where("x.advice_type <> 1")
|
|
776
|
+ }
|
|
777
|
+
|
|
778
|
+ if stop == 1 {
|
|
779
|
+ db = db.Where("(x.stop_state=? or x.execution_state=?)", stop, stop)
|
|
780
|
+ } else if stop == 2 {
|
|
781
|
+ db = db.Where("x.stop_state=? and x.execution_state=?", stop, stop)
|
|
782
|
+ }
|
|
783
|
+
|
|
784
|
+ if start != 0 {
|
|
785
|
+ db = db.Where("x.start_time>=?", start)
|
|
786
|
+ }
|
|
787
|
+ if end != 0 {
|
|
788
|
+ db = db.Where("start_time<=?", end)
|
|
789
|
+ }
|
|
790
|
+ if len(keywords) > 0 {
|
|
791
|
+ likeKey := "%" + keywords + "%"
|
|
792
|
+ db = db.Where("x.advice_name LIKE ?", likeKey)
|
|
793
|
+ }
|
|
794
|
+ offset := (page - 1) * limit
|
|
795
|
+ 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(&advices).Error
|
|
796
|
+ fmt.Print("错误是什么", err)
|
|
797
|
+ return
|
|
798
|
+
|
|
799
|
+}
|
|
800
|
+
|
727
|
801
|
func GetDoctorAdvicePageList(orgID, patientID, advice_type, stop, start, end int64, keywords string, page, limit int64) (advices []*models.DoctorAdvice, total int64, err error) {
|
728
|
802
|
|
729
|
803
|
offset := (page - 1) * limit
|