|
@@ -349,6 +349,24 @@ func (c *HisApiController) GetHisPatientList() {
|
349
|
349
|
})
|
350
|
350
|
}
|
351
|
351
|
|
|
352
|
+type CustomTemplate struct {
|
|
353
|
+ ID int64 `gorm:"column:id" json:"id" form:"id"`
|
|
354
|
+ UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
|
|
355
|
+ RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
|
|
356
|
+ PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
|
|
357
|
+ Status int64 `gorm:"column:status" json:"status" form:"status"`
|
|
358
|
+ Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
|
|
359
|
+ Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
|
|
360
|
+ Type int64 `gorm:"column:type" json:"type" form:"type"`
|
|
361
|
+ Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
|
|
362
|
+ Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
|
|
363
|
+ PType int64 `gorm:"column:p_type" json:"p_type" form:"p_type"`
|
|
364
|
+ PTemplateId int64 `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
|
|
365
|
+ HisPrescriptionAdviceTemplate []models.HisPrescriptionAdviceTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"advices"`
|
|
366
|
+ HisPrescriptionProjectTemplate []models.HisPrescriptionProjectTemplate `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
|
|
367
|
+ MedType string `gorm:"column:med_type" json:"med_type" form:"med_type"`
|
|
368
|
+}
|
|
369
|
+
|
352
|
370
|
func (c *HisApiController) GetHisPatientInfo() {
|
353
|
371
|
patient_id, _ := c.GetInt64("patient_id")
|
354
|
372
|
his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
@@ -384,7 +402,7 @@ func (c *HisApiController) GetHisPatientInfo() {
|
384
|
402
|
|
385
|
403
|
var prescriptions []*models.HisPrescription
|
386
|
404
|
var last_prescriptions []*models.HisPrescription
|
387
|
|
- var sch_prescriptions []*models.HisPrescriptionInfoTemplate
|
|
405
|
+ var sch_prescriptions []CustomTemplate
|
388
|
406
|
last_p_info, _ := service.FindLastPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
389
|
407
|
if p_type == 1 { //住院
|
390
|
408
|
prescriptions, _ = service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
|
|
@@ -396,10 +414,116 @@ func (c *HisApiController) GetHisPatientInfo() {
|
396
|
414
|
|
397
|
415
|
sch, _ := service.GetPatientSch(patient_id, recordDateTime, admin.CurrentOrgId)
|
398
|
416
|
if sch.ID > 0 {
|
|
417
|
+ var week string
|
|
418
|
+ t := time.Now()
|
|
419
|
+ switch t.Weekday().String() {
|
|
420
|
+ case "Monday":
|
|
421
|
+ week = "周一"
|
|
422
|
+ break
|
|
423
|
+ case "Tuesday":
|
|
424
|
+ week = "周二"
|
|
425
|
+
|
|
426
|
+ break
|
|
427
|
+ case "Wednesday":
|
|
428
|
+ week = "周三"
|
|
429
|
+
|
|
430
|
+ break
|
|
431
|
+ case "Thursday":
|
|
432
|
+ week = "周四"
|
|
433
|
+
|
|
434
|
+ break
|
|
435
|
+ case "Friday":
|
|
436
|
+ week = "周五"
|
|
437
|
+
|
|
438
|
+ break
|
|
439
|
+ case "Saturday":
|
|
440
|
+ week = "周六"
|
|
441
|
+
|
|
442
|
+ break
|
|
443
|
+ case "Sunday":
|
|
444
|
+ week = "周日"
|
|
445
|
+
|
|
446
|
+ break
|
|
447
|
+
|
|
448
|
+ }
|
|
449
|
+
|
399
|
450
|
mode_template, _ := service.GetHisPrescriptionBySchMode(sch.ModeId, patient_id, admin.CurrentOrgId)
|
400
|
|
- sch_prescriptions, _ = service.GetHisPrescriptionTemplate(mode_template.ID, admin.CurrentOrgId)
|
|
451
|
+ temp_sch_prescriptions, _ := service.GetHisPrescriptionTemplate(mode_template.ID, admin.CurrentOrgId)
|
|
452
|
+
|
|
453
|
+ //根据推送频率组装新的数组
|
|
454
|
+ for _, item := range temp_sch_prescriptions {
|
|
455
|
+ var cus CustomTemplate
|
|
456
|
+ cus.ID = item.ID
|
|
457
|
+ cus.UserOrgId = item.UserOrgId
|
|
458
|
+ cus.PatientId = item.PatientId
|
|
459
|
+ cus.MedType = item.MedType
|
|
460
|
+ cus.RecordDate = item.RecordDate
|
|
461
|
+ cus.Type = item.Type
|
|
462
|
+ cus.PType = item.PType
|
|
463
|
+ for _, subItem := range item.HisPrescriptionAdviceTemplate {
|
|
464
|
+ if subItem.FrequencyType == 1 { //每次必推
|
|
465
|
+ cus.HisPrescriptionAdviceTemplate = append(cus.HisPrescriptionAdviceTemplate, subItem)
|
|
466
|
+ }
|
|
467
|
+
|
|
468
|
+ if subItem.FrequencyType == 3 && strings.Index(subItem.WeekDay, week) != -1 { //按照星期来推
|
|
469
|
+ cus.HisPrescriptionAdviceTemplate = append(cus.HisPrescriptionAdviceTemplate, subItem)
|
|
470
|
+ }
|
|
471
|
+
|
|
472
|
+ if subItem.FrequencyType == 2 { //按照天数频率
|
|
473
|
+ p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
|
|
474
|
+ now := p.Unix()
|
|
475
|
+ dayStr := strconv.FormatInt(subItem.DayCount, 10)
|
|
476
|
+ dayStr2 := "-" + dayStr
|
|
477
|
+ count, _ := strconv.ParseInt(dayStr2, 10, 64)
|
|
478
|
+ oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
|
|
479
|
+ advices, _ := service.FindAllHisDoctorAdviceByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.DrugId)
|
|
480
|
+ if len(advices) == 0 {
|
|
481
|
+ cus.HisPrescriptionAdviceTemplate = append(cus.HisPrescriptionAdviceTemplate, subItem)
|
|
482
|
+ }
|
|
483
|
+ }
|
|
484
|
+
|
|
485
|
+ }
|
401
|
486
|
|
|
487
|
+ for _, subItem := range item.HisPrescriptionProjectTemplate {
|
|
488
|
+
|
|
489
|
+ if subItem.FrequencyType == 1 {
|
|
490
|
+ cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
|
|
491
|
+ }
|
|
492
|
+
|
|
493
|
+ if subItem.FrequencyType == 3 && strings.Index(subItem.WeekDay, week) != -1 {
|
|
494
|
+ cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
|
|
495
|
+ }
|
|
496
|
+
|
|
497
|
+ if subItem.FrequencyType == 2 {
|
|
498
|
+ p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
|
|
499
|
+ now := p.Unix()
|
|
500
|
+ dayStr := strconv.FormatInt(subItem.DayCount, 10)
|
|
501
|
+ dayStr2 := "-" + dayStr
|
|
502
|
+ count, _ := strconv.ParseInt(dayStr2, 10, 64)
|
|
503
|
+ oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
|
|
504
|
+ projects, _ := service.FindAllHisProjectByTime(now, oldTime, patient_id, c.GetAdminUserInfo().CurrentOrgId, subItem.ProjectId)
|
|
505
|
+ if len(projects) == 0 {
|
|
506
|
+ cus.HisPrescriptionProjectTemplate = append(cus.HisPrescriptionProjectTemplate, subItem)
|
|
507
|
+ }
|
|
508
|
+ }
|
|
509
|
+
|
|
510
|
+ }
|
|
511
|
+
|
|
512
|
+ sch_prescriptions = append(sch_prescriptions, cus)
|
|
513
|
+
|
|
514
|
+ }
|
|
515
|
+
|
|
516
|
+ for _, item := range sch_prescriptions {
|
|
517
|
+ if len(item.HisPrescriptionProjectTemplate) == 0 {
|
|
518
|
+ item.HisPrescriptionProjectTemplate = make([]models.HisPrescriptionProjectTemplate, 0)
|
|
519
|
+ }
|
|
520
|
+ if len(item.HisPrescriptionAdviceTemplate) == 0 {
|
|
521
|
+ item.HisPrescriptionAdviceTemplate = make([]models.HisPrescriptionAdviceTemplate, 0)
|
|
522
|
+ }
|
|
523
|
+
|
|
524
|
+ }
|
402
|
525
|
}
|
|
526
|
+
|
403
|
527
|
//prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
|
404
|
528
|
//monthPrescriptions, _ := service.GetMonthHisPrescriptionTwo(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
|
405
|
529
|
case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|