|
@@ -266,6 +266,52 @@ func GetDialysisParameterGoodList(orgID int64, schedule_type int64, partition_id
|
266
|
266
|
func SaveHisDialysis(orgid int64, ids []string) error {
|
267
|
267
|
|
268
|
268
|
goodsType := models.BloodGoodsType{}
|
269
|
|
- err := XTWriteDB().Where("org_id = ? and status = 1 and id in(?)", orgid, ids).Update(map[string]interface{}{"is_open": goodsType.IsOpen}).Error
|
|
269
|
+ err := XTWriteDB().Model(&goodsType).Where("org_id = ? and status = 1 and id in(?)", orgid, ids).Update(map[string]interface{}{"is_open": 1}).Error
|
|
270
|
+
|
|
271
|
+ err = XTWriteDB().Model(&goodsType).Where("org_id = ? and status = 1 and id not in(?)", orgid, ids).Update(map[string]interface{}{"is_open": 0}).Error
|
270
|
272
|
return err
|
271
|
273
|
}
|
|
274
|
+
|
|
275
|
+func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
|
|
276
|
+
|
|
277
|
+ db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
|
|
278
|
+ offset := (page - 1) * limit
|
|
279
|
+ if scheduleDate > 0 {
|
|
280
|
+ db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
|
|
281
|
+ }
|
|
282
|
+ if schedule_type > 0 {
|
|
283
|
+ db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
|
|
284
|
+ }
|
|
285
|
+ if partition_id > 0 {
|
|
286
|
+ db = db.Where("xt_schedule.partition_id = ?", partition_id)
|
|
287
|
+ }
|
|
288
|
+ if orgID > 0 {
|
|
289
|
+ db = db.Where("xt_schedule.user_org_id = ?", orgID)
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ if len(keywords) > 0 {
|
|
293
|
+ keywords = "%" + keywords + "%"
|
|
294
|
+ db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
295
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
296
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
297
|
+ Preload("HisPrescriptionInfoTemplate", func(db *gorm.DB) *gorm.DB {
|
|
298
|
+ return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
|
|
299
|
+ return db.Where("user_org_id = ? and status = 1 and type =3 ", orgID).Preload("GoodInfo", "org_id = ? and status = 1", orgID)
|
|
300
|
+ })
|
|
301
|
+ })
|
|
302
|
+ db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
|
|
303
|
+ err = db.Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
|
|
304
|
+ } else {
|
|
305
|
+ err = db.Count(&total).Offset(offset).Limit(limit).
|
|
306
|
+ Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
|
|
307
|
+ Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
|
|
308
|
+ Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
|
|
309
|
+ Preload("HisPrescriptionInfoTemplate", func(db *gorm.DB) *gorm.DB {
|
|
310
|
+ return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionProjectTemplate", func(db *gorm.DB) *gorm.DB {
|
|
311
|
+ return db.Where("user_org_id = ? and status = 1 and type =3 ", orgID).Preload("GoodInfo", "org_id = ? and status = 1", orgID)
|
|
312
|
+ })
|
|
313
|
+ }).Find(&schedule).Error
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+ return schedule, total, err
|
|
317
|
+}
|