|
@@ -455,28 +455,32 @@ func GetLastNewSlowPatient(phone string, orgid int64) (*models.XtPatientsNew, er
|
455
|
455
|
return &patientnew, nil
|
456
|
456
|
}
|
457
|
457
|
|
458
|
|
-func GetNewDoctorAdvice(patientid int64, doctype int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (doctoradvice []*models.DoctorAdvices, total int64, err error) {
|
459
|
|
- db := XTReadDB().Table("xt_doctor_advice as x").Where("x.status = 1")
|
460
|
|
- if orgId > 0 {
|
461
|
|
- db = db.Where("x.user_org_id = ?", orgId)
|
|
458
|
+func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int64, limit int64, page int64, orgID int64) (doctoradvice []*models.DoctorAdvices, total int64, err error) {
|
|
459
|
+ db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
|
460
|
+ table := UserReadDB().Table("sgj_user_admin_role as r")
|
|
461
|
+ fmt.Print("table", table)
|
|
462
|
+ if orgID > 0 {
|
|
463
|
+ db = db.Where("x.user_org_id=?", orgID)
|
462
|
464
|
}
|
463
|
|
-
|
464
|
|
- if patientid > 0 {
|
465
|
|
- db = db.Where("x.patient_id = ?", patientid)
|
|
465
|
+ if patientID > 0 {
|
|
466
|
+ db = db.Where("x.patient_id = ?", patientID)
|
466
|
467
|
}
|
467
|
|
- if startime != 0 {
|
468
|
|
- db = db.Where("x.record_date>= ?", startime)
|
|
468
|
+ if advice_type > 0 {
|
|
469
|
+ db = db.Where("x.advice_type = ?", advice_type)
|
|
470
|
+ } else if advice_type == 0 {
|
|
471
|
+ db = db.Where("x.advice_type in (?)", []int{1, 3})
|
469
|
472
|
}
|
470
|
|
- if endtime != 0 {
|
471
|
|
- db = db.Where("x.record_date<=?", endtime)
|
|
473
|
+ if start != 0 {
|
|
474
|
+ db = db.Where("x.start_time>=?", start)
|
472
|
475
|
}
|
473
|
|
-
|
474
|
|
- if doctype > 0 {
|
475
|
|
- db = db.Where("x.advice_type = ?", doctype)
|
|
476
|
+ if end != 0 {
|
|
477
|
+ db = db.Where("start_time<=?", end)
|
476
|
478
|
}
|
477
|
479
|
offset := (page - 1) * limit
|
478
|
|
- err = db.Count(&total).Order("x.record_date desc").Offset(offset).Limit(limit).Group("x.id").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.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,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&doctoradvice).Error
|
|
480
|
+ 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").Offset(offset).Limit(limit).Order("start_time desc, groupno desc, advice_order desc, id asc").Scan(&doctoradvice).Error
|
|
481
|
+ fmt.Print("err", err)
|
479
|
482
|
return
|
|
483
|
+
|
480
|
484
|
}
|
481
|
485
|
|
482
|
486
|
func GetDryWeight(patientid int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (dryWeight []*models.XtPatientDryweight, total int64, err error) {
|