|
@@ -304,6 +304,101 @@ func GetSchedualPatientsByKeywords(keywords string, org_id int64) (schedule []*m
|
304
|
304
|
|
305
|
305
|
}
|
306
|
306
|
|
|
307
|
+func GetWeekDayScheduleTwo(orgID int64, scheduleDate int64, scheduleDates *time.Time, weektime int64) (schedules []*models.WeekSchedule, err error) {
|
|
308
|
+ db := readDb.Table("xt_schedule as s ").Where("s.status =1")
|
|
309
|
+ if orgID > 0 {
|
|
310
|
+ db = db.Where("s.user_org_id = ?", orgID)
|
|
311
|
+ }
|
|
312
|
+ if scheduleDate > 0 {
|
|
313
|
+ db = db.Where("s.schedule_date = ?", scheduleDate)
|
|
314
|
+
|
|
315
|
+ }
|
|
316
|
+ if weektime > 0 {
|
|
317
|
+ db = db.Where("s.schedule_type = ?", weektime)
|
|
318
|
+ }
|
|
319
|
+ err = db.
|
|
320
|
+ Preload("DeviceZone", "status = 1 ").
|
|
321
|
+ Preload("DeviceNumber", "status = 1 ").
|
|
322
|
+ Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
|
|
323
|
+ return db.Where("status = 1").Order("id asc")
|
|
324
|
+ }).
|
|
325
|
+ Joins("JOIN xt_patients as p ON p.id = s.patient_id").
|
|
326
|
+ Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
|
|
327
|
+ Order("s.partition_id asc").
|
|
328
|
+ Find(&schedules).Error
|
|
329
|
+
|
|
330
|
+ for _, item := range schedules {
|
|
331
|
+ _, config := FindDoctorAdviceRecordByOrgId(item.UserOrgId)
|
|
332
|
+ if config.IsOpenRemind > 0 {
|
|
333
|
+ //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
|
|
334
|
+ var advice_three []*models.DoctorAdvice
|
|
335
|
+ advices, _ := GetLastLongAdviceByGroupNoOther(item.UserOrgId, item.PatientId)
|
|
336
|
+ advices_two, _ := GetLastLongAdviceByGroupNoThreeOther(item.UserOrgId, item.PatientId)
|
|
337
|
+ for _, advice := range advices {
|
|
338
|
+ advice.IsCheck = 1
|
|
339
|
+ if advice.FrequencyType == 3 {
|
|
340
|
+ week := int(scheduleDates.Weekday())
|
|
341
|
+ fmt.Println(advice.WeekDay)
|
|
342
|
+ switch week {
|
|
343
|
+ case 1:
|
|
344
|
+ if strings.Index(advice.WeekDay, "周一") > -1 {
|
|
345
|
+ advice_three = append(advice_three, advice)
|
|
346
|
+ }
|
|
347
|
+ break
|
|
348
|
+ case 2:
|
|
349
|
+ if strings.Index(advice.WeekDay, "周二") > -1 {
|
|
350
|
+ advice_three = append(advice_three, advice)
|
|
351
|
+ }
|
|
352
|
+ break
|
|
353
|
+ case 3:
|
|
354
|
+ if strings.Index(advice.WeekDay, "周三") > -1 {
|
|
355
|
+ advice_three = append(advice_three, advice)
|
|
356
|
+ }
|
|
357
|
+ break
|
|
358
|
+ case 4:
|
|
359
|
+ if strings.Index(advice.WeekDay, "周四") > -1 {
|
|
360
|
+ advice_three = append(advice_three, advice)
|
|
361
|
+ }
|
|
362
|
+ break
|
|
363
|
+ case 5:
|
|
364
|
+ if strings.Index(advice.WeekDay, "周五") > -1 {
|
|
365
|
+ advice_three = append(advice_three, advice)
|
|
366
|
+ }
|
|
367
|
+ break
|
|
368
|
+ case 6:
|
|
369
|
+ if strings.Index(advice.WeekDay, "周六") > -1 {
|
|
370
|
+ advice_three = append(advice_three, advice)
|
|
371
|
+ }
|
|
372
|
+ break
|
|
373
|
+ case 0:
|
|
374
|
+ if strings.Index(advice.WeekDay, "周日") > -1 {
|
|
375
|
+ advice_three = append(advice_three, advice)
|
|
376
|
+ }
|
|
377
|
+ break
|
|
378
|
+ }
|
|
379
|
+ } else if advice.FrequencyType == 1 {
|
|
380
|
+ advice_three = append(advice_three, advice)
|
|
381
|
+ }
|
|
382
|
+ }
|
|
383
|
+
|
|
384
|
+ for _, advice := range advices_two {
|
|
385
|
+ now := scheduleDates.Unix()
|
|
386
|
+ dayStr := strconv.FormatInt(advice.DayCount, 10)
|
|
387
|
+ dayStr2 := "-" + dayStr
|
|
388
|
+ count, _ := strconv.ParseInt(dayStr2, 10, 64)
|
|
389
|
+ oldTime := scheduleDates.AddDate(0, 0, int(count)).Unix()
|
|
390
|
+ advices, _ := FindAllDoctorAdviceByTimeOther(now, oldTime, item.PatientId, item.UserOrgId, advice.TemplateId)
|
|
391
|
+ if len(advices) == 0 {
|
|
392
|
+ advice_three = append(advice_three, advice)
|
|
393
|
+ }
|
|
394
|
+ }
|
|
395
|
+
|
|
396
|
+ item.DoctorAdvice = append(item.DoctorAdvice, advice_three...)
|
|
397
|
+ }
|
|
398
|
+ }
|
|
399
|
+ return
|
|
400
|
+}
|
|
401
|
+
|
307
|
402
|
func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Time) (schedules []*models.WeekSchedule, err error) {
|
308
|
403
|
|
309
|
404
|
err = readDb.
|