|
@@ -495,7 +495,7 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
|
495
|
495
|
db = db.Where("x.start_time>=?", start)
|
496
|
496
|
}
|
497
|
497
|
if end > 0 {
|
498
|
|
- db = db.Where("start_time<=?", end)
|
|
498
|
+ db = db.Where("x.start_time<=?", end)
|
499
|
499
|
}
|
500
|
500
|
//offset := (page - 1) * limit
|
501
|
501
|
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
|
|
@@ -505,6 +505,7 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
|
505
|
505
|
}
|
506
|
506
|
|
507
|
507
|
func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end int64, limit int64, page int64, orgID int64) (doctoradvice []*models.DoctorAdvice, total int64, err error) {
|
|
508
|
+ fmt.Println("advicetype------------------------------", advice_type)
|
508
|
509
|
db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
509
|
510
|
table := UserReadDB().Table("sgj_user_admin_role as r")
|
510
|
511
|
fmt.Println("table", table)
|
|
@@ -523,10 +524,10 @@ func GetNewDoctorAdviceOne(patientID int64, advice_type int64, start int64, end
|
523
|
524
|
db = db.Where("x.start_time>=?", start)
|
524
|
525
|
}
|
525
|
526
|
if end > 0 {
|
526
|
|
- db = db.Where("start_time<=?", end)
|
|
527
|
+ db = db.Where("x.start_time<=?", end)
|
527
|
528
|
}
|
528
|
529
|
offset := (page - 1) * limit
|
529
|
|
- err = db.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").Order("x.start_time desc").Scan(&doctoradvice).Error
|
|
530
|
+ 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
|
530
|
531
|
fmt.Print("错误是什么", err)
|
531
|
532
|
return
|
532
|
533
|
}
|
|
@@ -881,14 +882,14 @@ func GetAllDoctorTwo(orgid int64, appid int64) (appRole []*models.SgjUserAdminRo
|
881
|
882
|
func GetDoctorAdviceDetail(id int64, orgid int64) (advices []*models.DoctorAdvices, err error) {
|
882
|
883
|
|
883
|
884
|
db := XTReadDB().Table("xt_doctor_advice as x")
|
884
|
|
- err = db.Order("x.id desc").Select("x.id,x.user_org_id,x.patient_id,x.advice_type,x.advice_date,x.start_time,x.advice_name,x.advice_desc,x.reminder_date,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.record_date,x.dialysis_order_id,x.check_time,x.check_state,x.drug_spec,x.drug_spec_unit,x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.template_id,x.modifier,s.name").Joins("left join xt_patients as s on s.id=x.patient_id").Where("x.groupno = ? and x.status = 1 and x.user_org_id = ?", id, orgid).Scan(&advices).Error
|
|
885
|
+ err = db.Order("x.id desc").Select("x.id,x.user_org_id,x.patient_id,x.advice_type,x.advice_date,x.start_time,x.advice_name,x.advice_desc,x.reminder_date,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.record_date,x.dialysis_order_id,x.check_time,x.check_state,x.drug_spec,x.drug_spec_unit,x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,x.template_id,x.modifier,s.name").Joins("left join xt_patients as s on s.id=x.patient_id").Where("x.start_time = ? and x.status = 1 and x.user_org_id = ?", id, orgid).Scan(&advices).Error
|
885
|
886
|
|
886
|
887
|
return advices, err
|
887
|
888
|
}
|
888
|
889
|
|
889
|
890
|
func DeleteManagement(groupid int64, orgid int64) error {
|
890
|
891
|
|
891
|
|
- err := XTWriteDB().Model(models.DoctorAdvice{}).Where("groupno=? and user_org_id = ?", groupid, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
|
|
892
|
+ err := XTWriteDB().Model(models.DoctorAdvice{}).Where("start_time =? and user_org_id = ?", groupid, orgid).Update(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()}).Error
|
892
|
893
|
return err
|
893
|
894
|
}
|
894
|
895
|
|
|
@@ -1264,3 +1265,9 @@ func UpdatedBed(id int64, number *models.DeviceNumber) error {
|
1264
|
1265
|
err = XTWriteDB().Model(&number).Where("id=?", id).Update(map[string]interface{}{"number": number.Number, "zone_id": number.ZoneID, "group_id": number.GroupID, "mtime": time.Now().Unix()}).Error
|
1265
|
1266
|
return err
|
1266
|
1267
|
}
|
|
1268
|
+
|
|
1269
|
+func CreateLoginLod(log *models.SgjUserAdminLoginLog) error {
|
|
1270
|
+
|
|
1271
|
+ err := UserWriteDB().Model(&log).Create(&log).Error
|
|
1272
|
+ return err
|
|
1273
|
+}
|