瀏覽代碼

历史排班

28169 1 月之前
父節點
當前提交
85f6077b59

+ 7 - 7
controllers/base_api_controller.go 查看文件

@@ -73,7 +73,7 @@ func (this *BaseAuthAPIController) Prepare() {
73 73
 		var userAdmin models.AdminUser
74 74
 		userAdmin.Id = 16919
75 75
 		userAdmin.Mobile = "15717313968"
76
-		userAdmin.Id = 10579 //4,809
76
+		userAdmin.Id = 10599 //4,809
77 77
 		userAdmin.Mobile = "12222222222"
78 78
 		userAdmin.IsSuperAdmin = true
79 79
 		userAdmin.Status = 1
@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 11
84
-		subscibe.OrgId = 10344 //机构id 10344
84
+		subscibe.OrgId = 10598 //机构id 10344
85 85
 		subscibe.PeriodStart = 1547447814
86 86
 		subscibe.PeriodEnd = 1550039814
87 87
 		subscibe.State = 1
@@ -91,8 +91,8 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
95
-		adminUserInfo.CurrentAppId = 14655 //4
94
+		adminUserInfo.CurrentOrgId = 10598 //机构id小英9675或4
95
+		adminUserInfo.CurrentAppId = 3467  //4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
98 98
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 11
329
-		subscibe.OrgId = 10344 //机构id小英10344或4
329
+		subscibe.OrgId = 10598 //机构id小英10344或4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -336,8 +336,8 @@ func (this *BaseServeAPIController) Prepare() {
336 336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337 337
 		subscibes[4] = &subscibe
338 338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
340
-		adminUserInfo.CurrentAppId = 14655 //4
339
+		adminUserInfo.CurrentOrgId = 10598 //机构id小英9675或4
340
+		adminUserInfo.CurrentAppId = 3467  //4
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes
343 343
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 23 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -606,6 +606,7 @@ func (this *DialysisAPIController) DialysisRecord() {
606 606
 	lastAssesmentBeforDialysis, _ := service.GetLastAssessmentBeforDialysis(patientID, adminInfo.Org.Id)
607 607
 
608 608
 	dryWeightList, _ := service.GetPatientDryList(patientID, adminInfo.Org.Id)
609
+
609 610
 	returnData := map[string]interface{}{
610 611
 		"patient":                        patient,
611 612
 		"schedual":                       schedual,
@@ -2610,6 +2611,10 @@ func (c *DialysisAPIController) Finish() {
2610 2611
 			tempassessmentAfterDislysis.ActualUltrafiltration = 0
2611 2612
 		}
2612 2613
 
2614
+		if adminUserInfo.Org.Id == 10612 {
2615
+			tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume / 1000
2616
+		}
2617
+
2613 2618
 	}
2614 2619
 
2615 2620
 	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 {
@@ -10572,6 +10577,24 @@ func (c *DialysisAPIController) MobileCoverSch() {
10572 10577
 	id_one, _ := c.GetInt64("id_one")
10573 10578
 	id_two, _ := c.GetInt64("id_two")
10574 10579
 	sch, _ := service.GetScheduleTen(c.GetMobileAdminUserInfo().Org.Id, id_one)
10580
+	//针对凤凰医院
10581
+	if c.GetMobileAdminUserInfo().Org.Id == 10579 || c.GetMobileAdminUserInfo().Org.Id == 10344 || c.GetMobileAdminUserInfo().Org.Id == 10206 {
10582
+		advice, _ := service.GetDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10583
+		if len(advice) > 0 {
10584
+			service.UpdateAdviceObj(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10585
+		}
10586
+	}
10587
+
10588
+	if c.GetMobileAdminUserInfo().Org.Id == 10206 || c.GetMobileAdminUserInfo().Org.Id == 10344 {
10589
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10590
+		project, _ := service.GetHisPrescriptionProjectList(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10591
+		if len(hisAdvice) > 0 {
10592
+			service.UpdateHisAdviceObj(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10593
+		}
10594
+		if len(project) > 0 {
10595
+			service.UpdateProjectObj(sch.PatientId, sch.ScheduleDate, c.GetMobileAdminUserInfo().Org.Id)
10596
+		}
10597
+	}
10575 10598
 	sch_two, _ := service.GetScheduleTen(c.GetMobileAdminUserInfo().Org.Id, id_two)
10576 10599
 
10577 10600
 	order, _ := service.GetOneDialysisOrderOne(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)

+ 161 - 2
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go 查看文件

@@ -522,10 +522,148 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
522 522
 func (this *StaffScheduleApiController) DeleteSchedule() {
523 523
 	id, _ := this.GetInt64("id")
524 524
 	org_id := this.GetMobileAdminUserInfo().Org.Id
525
-	err := service.DeleteSchedule(id)
526 525
 
526
+	schedule, _ := service.GetScheduleNight(org_id, id)
527
+
528
+	//如果使用的是保存出库功能
529
+	drugOutConfig, _ := service.FindDrugOutConfigById(org_id)
530
+	//退库
531
+	if drugOutConfig.IsOpen == 1 {
532
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, org_id)
533
+		for _, item := range hisAdvice {
534
+			creater := this.GetMobileAdminUserInfo().AdminUser.Id
535
+			err := service.DrugAutoAddCancelInfo(item, creater)
536
+			if err != nil {
537
+				err = fmt.Errorf("!:%v", err)
538
+				return
539
+			}
540
+		}
541
+		//查询是否有出库记录
542
+		service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, org_id)
543
+	}
544
+
545
+	//查询该患者当天是否开耗材
546
+	list, _ := service.GetPatientGoodCountToday(schedule.PatientId, schedule.ScheduleDate, org_id)
547
+	if len(list) > 0 {
548
+
549
+		operation_time := time.Now().Unix()
550
+		creater := this.GetMobileAdminUserInfo().AdminUser.Id
551
+		//创建退库单
552
+		timeStr := time.Now().Format("2006-01-02")
553
+		timeArr := strings.Split(timeStr, "-")
554
+		total, _ := service.FindAllCancelStockTotal(org_id)
555
+		total = total + 1
556
+		orderNumber := "CKTKD" + strconv.FormatInt(org_id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
557
+		houseConfig, _ := service.GetAllStoreHouseConfig(org_id)
558
+		cancelStock := models.CancelStock{
559
+			OrderNumber:  orderNumber,
560
+			OperaTime:    operation_time,
561
+			OrgId:        org_id,
562
+			Creater:      creater,
563
+			Ctime:        time.Now().Unix(),
564
+			Status:       1,
565
+			ReturnTime:   schedule.ScheduleDate,
566
+			Type:         1,
567
+			StorehouseId: houseConfig.StorehouseOutInfo,
568
+			IsCheck:      1,
569
+		}
570
+		_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(schedule.ScheduleDate, org_id)
571
+		if msgerrkonde == gorm.ErrRecordNotFound {
572
+			service.AddSigleCancelStock(&cancelStock)
573
+		}
574
+		cancel, _ := service.GetLastCancelStockById(org_id)
575
+		//进行退库操作
576
+		for _, item := range list {
577
+			good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
578
+			manufacturer, _ := service.GetManufactureById(item.Manufacturer)
579
+			deaerler, _ := service.GetDealerById(item.Dealer)
580
+			//回退库存
581
+			service.UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
582
+			goodList, _ := service.GetSumGoodList(org_id, houseConfig.StorehouseOutInfo, item.GoodId)
583
+			var flush_count int64
584
+			for _, it := range goodList {
585
+				flush_count += it.StockCount
586
+			}
587
+			cancelStockInfo := models.CancelStockInfo{
588
+				GoodId:          item.GoodId,
589
+				CancelStockId:   cancel.ID,
590
+				GoodTypeId:      good.GoodTypeId,
591
+				Count:           item.Count,
592
+				Price:           item.Price,
593
+				Total:           0,
594
+				ProductDate:     item.ProductDate,
595
+				ExpiryDate:      item.ExpiryDate,
596
+				Ctime:           time.Now().Unix(),
597
+				Status:          1,
598
+				OrgId:           org_id,
599
+				OrderNumber:     cancel.OrderNumber,
600
+				Type:            0,
601
+				Dealer:          deaerler.DealerName,
602
+				Manufacturer:    manufacturer.ManufacturerName,
603
+				Number:          item.Number,
604
+				RegisterAccount: "",
605
+				Remark:          "",
606
+				WarehouseInfoId: item.WarehouseInfotId,
607
+				PatientId:       item.PatientId,
608
+				RecordDate:      item.SysRecordTime,
609
+				StorehouseId:    houseConfig.StorehouseOutInfo,
610
+				IsCheck:         1,
611
+			}
612
+
613
+			service.CreateCancelStockInfoOne(&cancelStockInfo)
614
+
615
+			cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
616
+
617
+			flow := models.VmStockFlow{
618
+				WarehousingId:           item.WarehouseInfotId,
619
+				GoodId:                  item.GoodId,
620
+				Number:                  item.Number,
621
+				LicenseNumber:           item.LicenseNumber,
622
+				Count:                   item.Count,
623
+				UserOrgId:               org_id,
624
+				PatientId:               item.PatientId,
625
+				SystemTime:              item.SysRecordTime,
626
+				ConsumableType:          7,
627
+				IsSys:                   0,
628
+				WarehousingOrder:        "",
629
+				WarehouseOutId:          item.WarehouseOutId,
630
+				WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
631
+				IsEdit:                  0,
632
+				CancelStockId:           cancel.ID,
633
+				CancelOrderNumber:       cancel.OrderNumber,
634
+				Manufacturer:            manufacturer.ID,
635
+				Dealer:                  0,
636
+				Creator:                 org_id,
637
+				UpdateCreator:           0,
638
+				Status:                  1,
639
+				Ctime:                   time.Now().Unix(),
640
+				Mtime:                   0,
641
+				Price:                   item.Price,
642
+				WarehousingDetailId:     item.WarehouseInfotId,
643
+				WarehouseOutDetailId:    item.ID,
644
+				CancelOutDetailId:       cancelInfo.ID,
645
+				ProductDate:             item.ProductDate,
646
+				ExpireDate:              item.ExpiryDate,
647
+				StorehouseId:            houseConfig.StorehouseOutInfo,
648
+				OverCount:               flush_count,
649
+			}
650
+			service.CreateStockFlowOne(flow)
651
+
652
+			//退库数量增加
653
+			service.UpdateSumAddCancelCount(org_id, item.GoodId, houseConfig.StorehouseOutInfo, item.Count)
654
+			//出库数量减少
655
+			service.UpdateSumCount(org_id, houseConfig.StorehouseOutInfo, item.GoodId, item.Count)
656
+
657
+			//更新库存
658
+			service.UpdateSumGood(org_id, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
659
+
660
+			//更新基础库库存
661
+			service.UpdateGoodInfoSumCountSix(item.GoodId, flush_count, org_id)
662
+		}
663
+	}
664
+
665
+	err := service.DeleteSchedule(id)
527 666
 	if err == nil {
528
-		schedule, _ := service.GetScheduleNight(org_id, id)
529 667
 
530 668
 		//记录日志
531 669
 		byterequest, _ := json.Marshal(schedule)
@@ -1253,6 +1391,27 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
1253 1391
 		}
1254 1392
 		service.UpdateRepeatSchStatus(org_id, schedule_date)
1255 1393
 		service.CreateScheduleLog(scheduleLog)
1394
+
1395
+		scheduleToday, _ := service.GetPatientScheduleToday(schedule.PatientId, schedule.ScheduleDate, schedule.UserOrgId)
1396
+
1397
+		//针对凤凰医院
1398
+		if org_id == 10579 || org_id == 10344 || org_id == 10206 {
1399
+			advice, _ := service.GetDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1400
+			if len(advice) > 0 {
1401
+				service.UpdateAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1402
+			}
1403
+		}
1404
+
1405
+		if org_id == 10206 || org_id == 10344 {
1406
+			hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1407
+			project, _ := service.GetHisPrescriptionProjectList(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1408
+			if len(hisAdvice) > 0 {
1409
+				service.UpdateHisAdviceObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1410
+			}
1411
+			if len(project) > 0 {
1412
+				service.UpdateProjectObj(scheduleToday.PatientId, scheduleToday.ScheduleDate, org_id)
1413
+			}
1414
+		}
1256 1415
 		if err == nil {
1257 1416
 			c.ServeSuccessJSON(map[string]interface{}{
1258 1417
 				"msg": "ok",

+ 175 - 17
controllers/schedule_api_controller.go 查看文件

@@ -97,6 +97,25 @@ func (c *ScheduleApiController) CoverSch() {
97 97
 	id_one, _ := c.GetInt64("id_one")
98 98
 	id_two, _ := c.GetInt64("id_two")
99 99
 	sch, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_one)
100
+	orgId := c.GetAdminUserInfo().CurrentOrgId
101
+	//针对凤凰医院
102
+	if orgId == 10579 || orgId == 10344 || orgId == 10206 {
103
+		advice, _ := service.GetDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
104
+		if len(advice) > 0 {
105
+			service.UpdateAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
106
+		}
107
+	}
108
+
109
+	if orgId == 10206 || orgId == 10344 {
110
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
111
+		project, _ := service.GetHisPrescriptionProjectList(sch.PatientId, sch.ScheduleDate, orgId)
112
+		if len(hisAdvice) > 0 {
113
+			service.UpdateHisAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
114
+		}
115
+		if len(project) > 0 {
116
+			service.UpdateProjectObj(sch.PatientId, sch.ScheduleDate, orgId)
117
+		}
118
+	}
100 119
 	sch_two, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_two)
101 120
 	//order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
102 121
 	//if order.ID > 0 {
@@ -714,6 +733,24 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
714 733
 					}
715 734
 
716 735
 					schedule.Status = 0
736
+					//针对凤凰医院
737
+					if adminInfo.CurrentOrgId == 10579 || adminInfo.CurrentOrgId == 10344 || adminInfo.CurrentOrgId == 10206 {
738
+						advice, _ := service.GetDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
739
+						if len(advice) > 0 {
740
+							service.UpdateAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
741
+						}
742
+					}
743
+
744
+					if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
745
+						hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
746
+						project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
747
+						if len(hisAdvice) > 0 {
748
+							service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
749
+						}
750
+						if len(project) > 0 {
751
+							service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
752
+						}
753
+					}
717 754
 					service.SaveSch(&schedule)
718 755
 				}
719 756
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
@@ -1985,6 +2022,144 @@ func (c *ScheduleApiController) DeleteSchedule() {
1985 2022
 
1986 2023
 	schedule.Status = 0
1987 2024
 	schedule.UpdatedTime = time.Now().Unix()
2025
+
2026
+	//如果使用的是保存出库功能
2027
+	drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
2028
+	//退库
2029
+	if drugOutConfig.IsOpen == 1 {
2030
+		hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2031
+		for _, item := range hisAdvice {
2032
+			creater := adminINfo.AdminUser.Id
2033
+			err = service.DrugAutoAddCancelInfo(item, creater)
2034
+			if err != nil {
2035
+				err = fmt.Errorf("!:%v", err)
2036
+				return
2037
+			}
2038
+		}
2039
+		//查询是否有出库记录
2040
+		service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2041
+	}
2042
+
2043
+	//查询该患者当天是否开耗材
2044
+	list, _ := service.GetPatientGoodCountToday(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2045
+	if len(list) > 0 {
2046
+
2047
+		operation_time := time.Now().Unix()
2048
+		creater := c.GetAdminUserInfo().AdminUser.Id
2049
+		//创建退库单
2050
+		timeStr := time.Now().Format("2006-01-02")
2051
+		timeArr := strings.Split(timeStr, "-")
2052
+		total, _ := service.FindAllCancelStockTotal(c.GetAdminUserInfo().CurrentOrgId)
2053
+		total = total + 1
2054
+		orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
2055
+		houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
2056
+		cancelStock := models.CancelStock{
2057
+			OrderNumber:  orderNumber,
2058
+			OperaTime:    operation_time,
2059
+			OrgId:        c.GetAdminUserInfo().CurrentOrgId,
2060
+			Creater:      creater,
2061
+			Ctime:        time.Now().Unix(),
2062
+			Status:       1,
2063
+			ReturnTime:   schedule.ScheduleDate,
2064
+			Type:         1,
2065
+			StorehouseId: houseConfig.StorehouseOutInfo,
2066
+			IsCheck:      1,
2067
+		}
2068
+		_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(schedule.ScheduleDate, c.GetAdminUserInfo().CurrentOrgId)
2069
+		if msgerrkonde == gorm.ErrRecordNotFound {
2070
+			service.AddSigleCancelStock(&cancelStock)
2071
+		}
2072
+		cancel, _ := service.GetLastCancelStockById(c.GetAdminUserInfo().CurrentOrgId)
2073
+		//进行退库操作
2074
+		for _, item := range list {
2075
+			good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
2076
+			manufacturer, _ := service.GetManufactureById(item.Manufacturer)
2077
+			deaerler, _ := service.GetDealerById(item.Dealer)
2078
+			//回退库存
2079
+			service.UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
2080
+			goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId)
2081
+			var flush_count int64
2082
+			for _, it := range goodList {
2083
+				flush_count += it.StockCount
2084
+			}
2085
+			cancelStockInfo := models.CancelStockInfo{
2086
+				GoodId:          item.GoodId,
2087
+				CancelStockId:   cancel.ID,
2088
+				GoodTypeId:      good.GoodTypeId,
2089
+				Count:           item.Count,
2090
+				Price:           item.Price,
2091
+				Total:           0,
2092
+				ProductDate:     item.ProductDate,
2093
+				ExpiryDate:      item.ExpiryDate,
2094
+				Ctime:           time.Now().Unix(),
2095
+				Status:          1,
2096
+				OrgId:           c.GetAdminUserInfo().CurrentOrgId,
2097
+				OrderNumber:     cancel.OrderNumber,
2098
+				Type:            0,
2099
+				Dealer:          deaerler.DealerName,
2100
+				Manufacturer:    manufacturer.ManufacturerName,
2101
+				Number:          item.Number,
2102
+				RegisterAccount: "",
2103
+				Remark:          "",
2104
+				WarehouseInfoId: item.WarehouseInfotId,
2105
+				PatientId:       item.PatientId,
2106
+				RecordDate:      item.SysRecordTime,
2107
+				StorehouseId:    houseConfig.StorehouseOutInfo,
2108
+				IsCheck:         1,
2109
+			}
2110
+
2111
+			service.CreateCancelStockInfoOne(&cancelStockInfo)
2112
+
2113
+			cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
2114
+
2115
+			flow := models.VmStockFlow{
2116
+				WarehousingId:           item.WarehouseInfotId,
2117
+				GoodId:                  item.GoodId,
2118
+				Number:                  item.Number,
2119
+				LicenseNumber:           item.LicenseNumber,
2120
+				Count:                   item.Count,
2121
+				UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
2122
+				PatientId:               item.PatientId,
2123
+				SystemTime:              item.SysRecordTime,
2124
+				ConsumableType:          7,
2125
+				IsSys:                   0,
2126
+				WarehousingOrder:        "",
2127
+				WarehouseOutId:          item.WarehouseOutId,
2128
+				WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
2129
+				IsEdit:                  0,
2130
+				CancelStockId:           cancel.ID,
2131
+				CancelOrderNumber:       cancel.OrderNumber,
2132
+				Manufacturer:            manufacturer.ID,
2133
+				Dealer:                  0,
2134
+				Creator:                 c.GetAdminUserInfo().CurrentOrgId,
2135
+				UpdateCreator:           0,
2136
+				Status:                  1,
2137
+				Ctime:                   time.Now().Unix(),
2138
+				Mtime:                   0,
2139
+				Price:                   item.Price,
2140
+				WarehousingDetailId:     item.WarehouseInfotId,
2141
+				WarehouseOutDetailId:    item.ID,
2142
+				CancelOutDetailId:       cancelInfo.ID,
2143
+				ProductDate:             item.ProductDate,
2144
+				ExpireDate:              item.ExpiryDate,
2145
+				StorehouseId:            houseConfig.StorehouseOutInfo,
2146
+				OverCount:               flush_count,
2147
+			}
2148
+			service.CreateStockFlowOne(flow)
2149
+
2150
+			//退库数量增加
2151
+			service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.GoodId, houseConfig.StorehouseOutInfo, item.Count)
2152
+			//出库数量减少
2153
+			service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, item.Count)
2154
+
2155
+			//更新库存
2156
+			service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
2157
+
2158
+			//更新基础库库存
2159
+			service.UpdateGoodInfoSumCountSix(item.GoodId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
2160
+		}
2161
+	}
2162
+
1988 2163
 	err = service.UpdateSchedule(schedule)
1989 2164
 
1990 2165
 	//记录日志
@@ -2023,23 +2198,6 @@ func (c *ScheduleApiController) DeleteSchedule() {
2023 2198
 		}
2024 2199
 	}
2025 2200
 
2026
-	//如果使用的是保存出库功能
2027
-	drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
2028
-	//退库
2029
-	if drugOutConfig.IsOpen == 1 {
2030
-		hisAdvice, _ := service.GetHisDoctorAdviceListTwentyOne(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2031
-		for _, item := range hisAdvice {
2032
-			creater := adminINfo.AdminUser.Id
2033
-			err = service.DrugAutoAddCancelInfo(item, creater)
2034
-			if err != nil {
2035
-				err = fmt.Errorf("!:%v", err)
2036
-				return
2037
-			}
2038
-		}
2039
-		//查询是否有出库记录
2040
-		service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
2041
-	}
2042
-
2043 2201
 	redis := service.RedisClient()
2044 2202
 
2045 2203
 	//处方

+ 6 - 0
service/patient_service.go 查看文件

@@ -1371,6 +1371,9 @@ func GetDoctorAdviceListOne(orgID, patientID, advice_type, stop, start, end int6
1371 1371
 	if advice_type == 1 && advice_type > 0 {
1372 1372
 		db = db.Where("x.advice_type = ?", advice_type)
1373 1373
 	}
1374
+	if advice_type == 2 && advice_type > 0 {
1375
+		db = db.Where("x.advice_type = ?", advice_type)
1376
+	}
1374 1377
 	if advice_type == 3 && advice_type > 0 {
1375 1378
 		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
1376 1379
 	}
@@ -2118,6 +2121,9 @@ func GetDoctorAdviceListThree(orgID, patientID, advice_type, stop, start, end in
2118 2121
 	if advice_type == 1 && advice_type > 0 {
2119 2122
 		db = db.Where("x.advice_type = ?", advice_type)
2120 2123
 	}
2124
+	if advice_type == 2 && advice_type > 0 {
2125
+		db = db.Where("x.advice_type = ?", advice_type)
2126
+	}
2121 2127
 	if advice_type == 3 && advice_type > 0 {
2122 2128
 		db = db.Where("x.advice_type = 2 or x.advice_type = 3")
2123 2129
 	}

+ 15 - 3
service/schedule_service.go 查看文件

@@ -1838,6 +1838,13 @@ func GetLastSchedule(patient_id int64, user_org_id int64) (models.XtSchedule, er
1838 1838
 	return schedule, err
1839 1839
 }
1840 1840
 
1841
+func GetPatientScheduleToday(patient_id int64, schedule_date int64, user_org_id int64) (models.XtSchedule, error) {
1842
+
1843
+	schedule := models.XtSchedule{}
1844
+	err = XTReadDB().Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status=0", patient_id, schedule_date, user_org_id).Find(&schedule).Error
1845
+	return schedule, err
1846
+}
1847
+
1841 1848
 func UpdateRepeatSchStatus(user_org_id int64, schedule_date int64) {
1842 1849
 	var schedules []models.XtSchedule
1843 1850
 	// Find duplicate records based on patient_id, schedule_date, and user_org_id
@@ -1849,9 +1856,8 @@ func UpdateRepeatSchStatus(user_org_id int64, schedule_date int64) {
1849 1856
 
1850 1857
 	for _, schedule := range schedules {
1851 1858
 		// Update records with status = 0 where id is less than max_id
1852
-		XTReadDB().Model(&models.XtSchedule{}).
1853
-			Where("patient_id = ? AND schedule_date = ? AND id < ?", schedule.PatientId, schedule.ScheduleDate, schedule.MaxId).
1854
-			Update("status", 0)
1859
+		XTReadDB().Model(&models.XtSchedule{}).Where("patient_id = ? AND schedule_date = ? AND id < ?", schedule.PatientId, schedule.ScheduleDate, schedule.MaxId).Update("status", 0)
1860
+
1855 1861
 	}
1856 1862
 
1857 1863
 }
@@ -1871,3 +1877,9 @@ func UpdateMobileSchedule(id_two int64, mode_id int64, bed_id int64, zone_id int
1871 1877
 
1872 1878
 	return err
1873 1879
 }
1880
+
1881
+func GetPatientGoodCountToday(patient_id int64, schedule_date int64, user_org_id int64) (list []*models.WarehouseOutInfo, err error) {
1882
+
1883
+	err = XTReadDB().Where("patient_id =? and record_time=? and use_org_id = ? and status=1", patient_id, schedule_date, user_org_id).Find(&list).Error
1884
+	return list, err
1885
+}