|
@@ -504,39 +504,31 @@ func GetNewDoctorAdvice(patientID int64, advice_type int64, start int64, end int
|
504
|
504
|
|
505
|
505
|
}
|
506
|
506
|
|
507
|
|
-func GetNewDoctorAdviceOne(patientID int64, page int64, orgID int64) (doctoradvice []*models.DoctorAdvice, total int64, date int64, err error) {
|
508
|
|
-
|
509
|
|
- var advicesCount models.UserDoctorAdvicesCount
|
510
|
|
-
|
511
|
|
- err = XTReadDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and status =1", patientID, orgID).Select("count(distinct record_date) as count,patient_id").Scan(&advicesCount).Error
|
512
|
|
-
|
513
|
|
- if err != nil {
|
514
|
|
- return
|
|
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
|
+ db := readDb.Table("xt_doctor_advice as x").Where("x.status = 1")
|
|
509
|
+ table := UserReadDB().Table("sgj_user_admin_role as r")
|
|
510
|
+ fmt.Println("table", table)
|
|
511
|
+ if orgID > 0 {
|
|
512
|
+ db = db.Where("x.user_org_id=?", orgID)
|
515
|
513
|
}
|
516
|
|
- total = advicesCount.Count
|
517
|
|
- if total == 0 || page > total {
|
518
|
|
- return
|
|
514
|
+ if patientID > 0 {
|
|
515
|
+ db = db.Where("x.patient_id = ?", patientID)
|
519
|
516
|
}
|
520
|
|
-
|
521
|
|
- var Id models.AdviceDate
|
522
|
|
-
|
523
|
|
- err = XTReadDB().Model(models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and status = 1", patientID, orgID).Select("record_date").Group("record_date").Order("created_time desc").Offset(page - 1).Limit(10).Scan(&Id).Error
|
524
|
|
- if err != nil {
|
525
|
|
- return
|
|
517
|
+ if advice_type > 0 {
|
|
518
|
+ db = db.Where("x.advice_type = ?", advice_type)
|
|
519
|
+ } else if advice_type == 0 {
|
|
520
|
+ db = db.Where("x.advice_type in (?)", []int{1, 3})
|
526
|
521
|
}
|
527
|
|
-
|
528
|
|
- if Id.RecordDate == 0 {
|
529
|
|
- return
|
|
522
|
+ if start > 0 {
|
|
523
|
+ db = db.Where("x.start_time>=?", start)
|
530
|
524
|
}
|
531
|
|
-
|
532
|
|
- date = Id.RecordDate
|
533
|
|
- fmt.Println("结构是==============", Id.RecordDate)
|
534
|
|
- doctoradvice, err = GetAdvices(orgID, patientID, Id.RecordDate)
|
535
|
|
- if err != nil {
|
536
|
|
- return
|
|
525
|
+ if end > 0 {
|
|
526
|
+ db = db.Where("start_time<=?", end)
|
537
|
527
|
}
|
|
528
|
+ 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("start_time desc").Scan(&doctoradvice).Error
|
|
530
|
+ fmt.Print("错误是什么东西", err)
|
538
|
531
|
return
|
539
|
|
-
|
540
|
532
|
}
|
541
|
533
|
|
542
|
534
|
func GetDryWeight(patientid int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (dryWeight []*models.XtPatientDryweight, total int64, err error) {
|
|
@@ -1064,7 +1056,7 @@ func GetAllZone(orgid int64, page int64, limit int64) (zone []*models.DeviceZone
|
1064
|
1056
|
db = db.Where("x.org_id = ?", orgid)
|
1065
|
1057
|
}
|
1066
|
1058
|
offset := (page - 1) * limit
|
1067
|
|
- err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.type,n.number").Joins("left join xt_device_number as n on n.zone_id = x.id").Scan(&zone).Error
|
|
1059
|
+ err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.type,n.number").Joins("left join xt_device_number as n on n.zone_id = x.id AND n.status = 1").Scan(&zone).Error
|
1068
|
1060
|
return zone, total, err
|
1069
|
1061
|
}
|
1070
|
1062
|
|
|
@@ -1087,7 +1079,7 @@ func GetAllGroup(orgid int64, page int64, limit int64) (group []*models.DeviceGr
|
1087
|
1079
|
db = db.Where("x.org_id = ?", orgid)
|
1088
|
1080
|
}
|
1089
|
1081
|
offset := (page - 1) * limit
|
1090
|
|
- err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.status,x.ctime,x.mtime,n.number").Joins("left join xt_device_number as n on n.group_id = x.id").Scan(&group).Error
|
|
1082
|
+ err = db.Group("x.id").Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.name,x.status,x.ctime,x.mtime,n.number").Joins("left join xt_device_number as n on n.group_id = x.id And n.status = 1").Scan(&group).Error
|
1091
|
1083
|
return group, total, err
|
1092
|
1084
|
}
|
1093
|
1085
|
|
|
@@ -1121,7 +1113,7 @@ func GetAllNumber(page int64, limit int64, orgid int64) (number []*models.Device
|
1121
|
1113
|
db = db.Where("x.org_id = ?", orgid)
|
1122
|
1114
|
}
|
1123
|
1115
|
offset := (page - 1) * limit
|
1124
|
|
- err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime desc").Select("x.id,x.org_id,x.number,x.group_id,x.zone_id,x.status").Find(&number).Error
|
|
1116
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Order("x.ctime asc").Select("x.id,x.org_id,x.number,x.group_id,x.zone_id,x.status").Find(&number).Error
|
1125
|
1117
|
|
1126
|
1118
|
return number, total, err
|
1127
|
1119
|
}
|
|
@@ -1178,3 +1170,47 @@ func GetOrgInformation(id int64) (models.SgjUserOrg, error) {
|
1178
|
1170
|
err := UserReadDB().Where("id=? and status = 1", id).Find(&org).Error
|
1179
|
1171
|
return org, err
|
1180
|
1172
|
}
|
|
1173
|
+
|
|
1174
|
+func GetShortName(orgtype int64) (models.SgjUserOrgType, error) {
|
|
1175
|
+
|
|
1176
|
+ orgType := models.SgjUserOrgType{}
|
|
1177
|
+ err := UserReadDB().Model(&orgType).Where("id=? and status = 1", orgtype).Find(&orgType).Error
|
|
1178
|
+ return orgType, err
|
|
1179
|
+}
|
|
1180
|
+
|
|
1181
|
+func GetTypeName(id int64) (models.SgjUserOrgType, error) {
|
|
1182
|
+ orgType := models.SgjUserOrgType{}
|
|
1183
|
+ err := UserReadDB().Model(&orgType).Where("id=? and status = 1", id).Find(&orgType).Error
|
|
1184
|
+ return orgType, err
|
|
1185
|
+}
|
|
1186
|
+
|
|
1187
|
+func GetOrgProvince(id int64) (models.SgjUserDistrict, error) {
|
|
1188
|
+
|
|
1189
|
+ district := models.SgjUserDistrict{}
|
|
1190
|
+ err := UserReadDB().Model(&district).Where("id=?", id).Find(&district).Error
|
|
1191
|
+ return district, err
|
|
1192
|
+}
|
|
1193
|
+
|
|
1194
|
+func GetAllOrgType() (orgType []*models.SgjUserOrgType, err error) {
|
|
1195
|
+
|
|
1196
|
+ err = UserReadDB().Model(&models.SgjUserOrgType{}).Where("status= ? AND id = ? OR id = ? OR id = ? OR id = ? OR id = ? OR id = ?", 1, 1, 7, 12, 16, 21, 26).Find(&orgType).Error
|
|
1197
|
+ return
|
|
1198
|
+}
|
|
1199
|
+
|
|
1200
|
+func UpdateOrg(id int64, org models.SgjUserOrg) error {
|
|
1201
|
+
|
|
1202
|
+ err := UserWriteDB().Model(&org).Where("id = ?", id).Update(map[string]interface{}{"org_name": org.OrgName, "org_short_name": org.OrgShortName, "province": org.Province, "city": org.City, "district": org.District, "address": org.Address, "org_type": org.OrgType, "telephone": org.Telephone, "contact_name": org.ContactName, "mtime": time.Now().Unix()}).Error
|
|
1203
|
+ return err
|
|
1204
|
+}
|
|
1205
|
+
|
|
1206
|
+func GetMyInfoName(id int64) (models.SgjUserAdminRole, error) {
|
|
1207
|
+ role := models.SgjUserAdminRole{}
|
|
1208
|
+ err := UserReadDB().Model(&role).Where("id=? and status = 1", id).Find(&role).Error
|
|
1209
|
+ return role, err
|
|
1210
|
+}
|
|
1211
|
+
|
|
1212
|
+func GetAdminName(id int64) (models.AdminUser, error) {
|
|
1213
|
+ user := models.AdminUser{}
|
|
1214
|
+ err := UserReadDB().Model(&user).Where("id=? and status =1", id).Find(&user).Error
|
|
1215
|
+ return user, err
|
|
1216
|
+}
|