Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 1 year ago
parent
commit
dbc1c18fe3

BIN
XT_New.exe View File


+ 4 - 2
controllers/doctors_api_controller.go View File

@@ -103,8 +103,9 @@ func (c *DoctorsApiController) ScheduleAdvices() {
103 103
 	config, _ := service.GetHisDoctorConfig(orgID)
104 104
 	project_config, _ := service.GetHisProjectConfig(orgID)
105 105
 
106
+	var keyword string
106 107
 	if config.IsOpen == 0 || config.IsOpen == 2 {
107
-		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
108
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency, keyword)
108 109
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
109 110
 		if err != nil {
110 111
 			c.ErrorLog("获取排班信息失败:%v", err)
@@ -1393,6 +1394,7 @@ func (c *DoctorsApiController) GetScheduleAdvicesList() {
1393 1394
 	excution_way, _ := c.GetInt64("excution_way")
1394 1395
 	cost_type, _ := c.GetInt64("cost_type")
1395 1396
 	execution_frequency := c.GetString("execution_frequency")
1397
+	keyword := c.GetString("keyword")
1396 1398
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
1397 1399
 		adviceType = 0
1398 1400
 	}
@@ -1415,7 +1417,7 @@ func (c *DoctorsApiController) GetScheduleAdvicesList() {
1415 1417
 	project_config, _ := service.GetHisProjectConfig(orgID)
1416 1418
 
1417 1419
 	if config.IsOpen == 0 || config.IsOpen == 2 {
1418
-		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
1420
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency, keyword)
1419 1421
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1420 1422
 		if err != nil {
1421 1423
 			c.ErrorLog("获取排班信息失败:%v", err)

+ 118 - 123
controllers/drug_stock_api_contorller.go View File

@@ -3552,128 +3552,127 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3552 3552
 
3553 3553
 	checker := c.GetAdminUserInfo().AdminUser.Id
3554 3554
 	//更改核对状态
3555
-	err := service.CheckWarehousingInfo(warehousing_id, orgId, checker)
3555
+	service.CheckWarehousingInfo(warehousing_id, orgId, checker)
3556 3556
 
3557
-	if err == nil {
3558
-		list, _ := service.GetWarehousingInfoByList(warehousing_id, orgId)
3559
-		for _, item := range list {
3560
-			medical, _ := service.GetBaseDrugMedical(item.DrugId)
3561
-			if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3562
-				//新增库存
3563
-				service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
3557
+	list, _ := service.GetWarehousingInfoByList(warehousing_id, orgId)
3558
+	for _, item := range list {
3559
+		medical, _ := service.GetBaseDrugMedical(item.DrugId)
3560
+		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3561
+			//新增库存
3562
+			service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
3564 3563
 
3565
-			}
3566
-			if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3567
-				//新增库存
3568
-				service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
3564
+		}
3565
+		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3566
+			//新增库存
3567
+			service.AddDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID)
3569 3568
 
3570
-			}
3569
+		}
3571 3570
 
3572
-			if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3571
+		if item.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3573 3572
 
3574
-				//新增库存
3575
-				service.AddDrugWarehouseStockMinNumber(item.WarehousingCount, item.ID)
3573
+			//新增库存
3574
+			service.AddDrugWarehouseStockMinNumber(item.WarehousingCount, item.ID)
3576 3575
 
3577
-			}
3576
+		}
3578 3577
 
3579
-			Creator := c.GetAdminUserInfo().AdminUser.Id
3578
+		Creator := c.GetAdminUserInfo().AdminUser.Id
3580 3579
 
3581
-			//查询默认仓库
3580
+		//查询默认仓库
3582 3581
 
3583
-			//查询默认仓库剩余多少库存
3584
-			list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3585
-			var sum_count int64
3586
-			var sum_in_count int64
3587
-			for _, it := range list {
3588
-				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3589
-				if it.MaxUnit == baseDrug.MaxUnit {
3590
-					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3591
-					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3592
-				}
3593
-				sum_count += it.StockMaxNumber + it.StockMinNumber
3594
-				sum_in_count += it.WarehousingCount
3595
-			}
3596
-			flow := &models.DrugFlow{
3597
-				WarehousingId:           0,
3598
-				DrugId:                  item.DrugId,
3599
-				Number:                  item.Number,
3600
-				BatchNumber:             item.BatchNumber,
3601
-				Count:                   item.WarehousingCount,
3602
-				UserOrgId:               item.OrgId,
3603
-				PatientId:               0,
3604
-				SystemTime:              time.Now().Unix(),
3605
-				ConsumableType:          1,
3606
-				IsSys:                   0,
3607
-				WarehousingOrder:        item.WarehousingOrder,
3608
-				WarehouseOutId:          0,
3609
-				WarehouseOutOrderNumber: "",
3610
-				IsEdit:                  0,
3611
-				CancelStockId:           0,
3612
-				CancelOrderNumber:       "",
3613
-				Manufacturer:            0,
3614
-				Dealer:                  0,
3615
-				Creator:                 Creator,
3616
-				UpdateCreator:           Creator,
3617
-				Status:                  1,
3618
-				Ctime:                   item.Ctime,
3619
-				Mtime:                   0,
3620
-				Price:                   item.Price,
3621
-				WarehousingDetailId:     item.ID,
3622
-				WarehouseOutDetailId:    0,
3623
-				CancelOutDetailId:       0,
3624
-				ExpireDate:              item.ExpiryDate,
3625
-				ProductDate:             item.ProductDate,
3626
-				MaxUnit:                 item.MaxUnit,
3627
-				MinUnit:                 item.MinUnit,
3628
-				StorehouseId:            item.StorehouseId,
3629
-				OverCount:               sum_count,
3630
-			}
3631
-			service.CreateDrugFlowTwo(flow)
3632
-			//更新基础库剩余库存
3633
-			service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3634
-
3635
-			drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3636
-			var total_count int64 // 入库总数量
3637
-			var over_count int64  //剩余库存
3638
-			for _, it := range drugInfolist {
3639
-				baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3640
-				if it.MaxUnit == baseDrug.MaxUnit {
3641
-					it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3642
-					it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3643
-				}
3644
-			}
3645
-			for _, it := range drugInfolist {
3646
-				total_count += it.WarehousingCount
3647
-				over_count += it.StockMaxNumber + it.StockMinNumber
3582
+		//查询默认仓库剩余多少库存
3583
+		list, _ := service.GetDrugSumCountByStorehouseId(houseConfig.DrugStorehouseOut, item.OrgId, item.DrugId)
3584
+		var sum_count int64
3585
+		var sum_in_count int64
3586
+		for _, it := range list {
3587
+			baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3588
+			if it.MaxUnit == baseDrug.MaxUnit {
3589
+				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3590
+				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3648 3591
 			}
3649
-			//查询该仓库是否有默认数据
3650
-			_, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
3651
-			if errcode == gorm.ErrRecordNotFound {
3652
-				drugStock := models.XtDrugStockCount{
3653
-					UserOrgId:      item.OrgId,
3654
-					StorehouseId:   item.StorehouseId,
3655
-					SumInCount:     total_count,
3656
-					SumOutCount:    0,
3657
-					SumCancelCount: 0,
3658
-					DrugId:         item.DrugId,
3659
-					Ctime:          time.Now().Unix(),
3660
-					Mtime:          0,
3661
-					Status:         1,
3662
-					FlushCount:     over_count,
3663
-					SumActOutCount: 0,
3664
-				}
3665
-				service.CreateDrugStockSum(drugStock)
3592
+			sum_count += it.StockMaxNumber + it.StockMinNumber
3593
+			sum_in_count += it.WarehousingCount
3594
+		}
3595
+		flow := &models.DrugFlow{
3596
+			WarehousingId:           0,
3597
+			DrugId:                  item.DrugId,
3598
+			Number:                  item.Number,
3599
+			BatchNumber:             item.BatchNumber,
3600
+			Count:                   item.WarehousingCount,
3601
+			UserOrgId:               item.OrgId,
3602
+			PatientId:               0,
3603
+			SystemTime:              time.Now().Unix(),
3604
+			ConsumableType:          1,
3605
+			IsSys:                   0,
3606
+			WarehousingOrder:        item.WarehousingOrder,
3607
+			WarehouseOutId:          0,
3608
+			WarehouseOutOrderNumber: "",
3609
+			IsEdit:                  0,
3610
+			CancelStockId:           0,
3611
+			CancelOrderNumber:       "",
3612
+			Manufacturer:            0,
3613
+			Dealer:                  0,
3614
+			Creator:                 Creator,
3615
+			UpdateCreator:           Creator,
3616
+			Status:                  1,
3617
+			Ctime:                   item.Ctime,
3618
+			Mtime:                   0,
3619
+			Price:                   item.Price,
3620
+			WarehousingDetailId:     item.ID,
3621
+			WarehouseOutDetailId:    0,
3622
+			CancelOutDetailId:       0,
3623
+			ExpireDate:              item.ExpiryDate,
3624
+			ProductDate:             item.ProductDate,
3625
+			MaxUnit:                 item.MaxUnit,
3626
+			MinUnit:                 item.MinUnit,
3627
+			StorehouseId:            item.StorehouseId,
3628
+			OverCount:               sum_count,
3629
+		}
3630
+		service.CreateDrugFlowTwo(flow)
3631
+		//更新基础库剩余库存
3632
+		service.UpdateMedicalSumCount(item.DrugId, sum_count, sum_in_count, item.OrgId)
3666 3633
 
3667
-			} else if errcode == nil {
3668
-				service.UpdateDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count)
3634
+		drugInfolist, _ := service.GetDrugSumCountByStorehouseId(item.StorehouseId, item.OrgId, item.DrugId)
3635
+		var total_count int64 // 入库总数量
3636
+		var over_count int64  //剩余库存
3637
+		for _, it := range drugInfolist {
3638
+			baseDrug, _ := service.GetBaseDrugMedical(it.DrugId)
3639
+			if it.MaxUnit == baseDrug.MaxUnit {
3640
+				it.WarehousingCount = it.WarehousingCount * baseDrug.MinNumber
3641
+				it.StockMaxNumber = it.StockMaxNumber * baseDrug.MinNumber
3642
+			}
3643
+		}
3644
+		for _, it := range drugInfolist {
3645
+			total_count += it.WarehousingCount
3646
+			over_count += it.StockMaxNumber + it.StockMinNumber
3647
+		}
3648
+		//查询该仓库是否有默认数据
3649
+		_, errcode := service.GetDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId)
3650
+		if errcode == gorm.ErrRecordNotFound {
3651
+			drugStock := models.XtDrugStockCount{
3652
+				UserOrgId:      item.OrgId,
3653
+				StorehouseId:   item.StorehouseId,
3654
+				SumInCount:     total_count,
3655
+				SumOutCount:    0,
3656
+				SumCancelCount: 0,
3657
+				DrugId:         item.DrugId,
3658
+				Ctime:          time.Now().Unix(),
3659
+				Mtime:          0,
3660
+				Status:         1,
3661
+				FlushCount:     over_count,
3662
+				SumActOutCount: 0,
3669 3663
 			}
3664
+			service.CreateDrugStockSum(drugStock)
3670 3665
 
3666
+		} else if errcode == nil {
3667
+			service.UpdateDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count)
3671 3668
 		}
3672 3669
 
3673
-		c.ServeSuccessJSON(map[string]interface{}{
3674
-			"list": list,
3675
-		})
3676 3670
 	}
3671
+
3672
+	c.ServeSuccessJSON(map[string]interface{}{
3673
+		"list": list,
3674
+	})
3675
+
3677 3676
 }
3678 3677
 
3679 3678
 func (c *StockDrugApiController) ReturnCheckWarehouseingInfo() {
@@ -3820,11 +3819,7 @@ func (c *StockDrugApiController) CheckDrugOut() {
3820 3819
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3821 3820
 		////出库数量累加
3822 3821
 		var out_count_one int64
3823
-		//fmt.Println("it.count", it.CountUnit)
3824
-		//fmt.Println("MaxUnit", medical.MaxUnit)
3825
-		//fmt.Println("MinUnit", medical.MinUnit)
3826
-		//fmt.Println("count", it.Count)
3827
-		//fmt.Println("number", medical.MinNumber)
3822
+
3828 3823
 		if it.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3829 3824
 			out_count_one = it.Count * medical.MinNumber
3830 3825
 		}
@@ -3836,10 +3831,8 @@ func (c *StockDrugApiController) CheckDrugOut() {
3836 3831
 		if it.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3837 3832
 			out_count_one = it.Count
3838 3833
 		}
3839
-		//fmt.Println("countone3232232323323232332332wo", out_count_one)
3840
-		//增加出库数量
3834
+
3841 3835
 		service.AddDrugCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, out_count_one)
3842
-		//fmt.Println("countunit23322332232323", it.CountUnit)
3843 3836
 
3844 3837
 	}
3845 3838
 	warehousingOutInfoListThree, _ := service.GetDrugWarehouseOutListById(warehouse_out_id, orgId)
@@ -3847,7 +3840,7 @@ func (c *StockDrugApiController) CheckDrugOut() {
3847 3840
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3848 3841
 		drup, _ := service.FindBaseDrugLibRecord(it.OrgId, it.DrugId)
3849 3842
 		//出库逻辑
3850
-		service.AutoDrugDeliverInfoFourtyOne(orgId, it.Count, &drugWarehouseOut, &drup, it)
3843
+		service.AutoDrugDeliverInfoFourtyOne(orgId, it.Count, &drugWarehouseOut, &drup, it, it.CountUnit)
3851 3844
 
3852 3845
 		//查询剩余库存
3853 3846
 		stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, it.OrgId, it.DrugId)
@@ -3861,13 +3854,6 @@ func (c *StockDrugApiController) CheckDrugOut() {
3861 3854
 		//更新基础库库存
3862 3855
 		service.UpdateBaseDrugSumTwo(it.DrugId, sum_count, it.OrgId)
3863 3856
 
3864
-		//查询该药品剩余库存
3865
-		//infolist, _ := service.FindDrugWarehouseInfoFlushCountByStorehouse(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut)
3866
-		//var over_count int64
3867
-		//for _, its := range infolist {
3868
-		//  over_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3869
-		//}
3870
-		//更新剩余库存
3871 3857
 		service.UpdateDrugStockCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
3872 3858
 
3873 3859
 	}
@@ -3996,8 +3982,17 @@ func (c *StockDrugApiController) ToReturnCheck() {
3996 3982
 		infolist, _ := service.FindDrugWarehouseInfoFlushCountByStorehouse(item.DrugId, item.OrgId, storeHouseConfig.DrugStorehouseOut)
3997 3983
 		var over_count int64
3998 3984
 		for _, its := range infolist {
3999
-			over_count += its.StockMaxNumber*medical.MinNumber + its.StockMinNumber
3985
+			baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
3986
+			fmt.Println("ITS", its.MaxUnit)
3987
+			fmt.Println("itwowoowow", baseDrug.MaxUnit)
3988
+			if its.MaxUnit == baseDrug.MaxUnit {
3989
+				its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
3990
+			}
3991
+			fmt.Println("its.StockMaxNumber", its.StockMaxNumber)
3992
+			fmt.Println("its.StockMinNumber", its.StockMinNumber)
3993
+			over_count += its.StockMaxNumber + its.StockMinNumber
4000 3994
 		}
3995
+		fmt.Println("over_coutnwowowowowo", over_count)
4001 3996
 		service.UpdateDrugStockCount(item.DrugId, item.OrgId, storeHouseConfig.DrugStorehouseOut, over_count)
4002 3997
 
4003 3998
 	}

File diff suppressed because it is too large
+ 826 - 766
controllers/his_api_controller.go


+ 3 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -1265,6 +1265,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1265 1265
 		})
1266 1266
 		return
1267 1267
 	} else if origin == 2 {
1268
+		fmt.Println("缉拿咯喔我我哦我我")
1268 1269
 		adminInfo := c.GetMobileAdminUserInfo()
1269 1270
 		creater := c.GetMobileAdminUserInfo().AdminUser.Id
1270 1271
 		var ids []string
@@ -1659,6 +1660,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1659 1660
 				}
1660 1661
 
1661 1662
 				//
1663
+				fmt.Println("config.IsOpen", config.IsOpen)
1664
+				fmt.Println("config.IsOpen", item.UserOrgId)
1662 1665
 				if config.IsOpen == 1 && item.UserOrgId == 10028 {
1663 1666
 
1664 1667
 					service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)

+ 6 - 7
controllers/pharmacy_controller.go View File

@@ -90,7 +90,7 @@ func (this *PharmacyController) TodayNumber() {
90 90
 		etime = stime + 86399
91 91
 	}
92 92
 
93
-	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 {
93
+	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10480 {
94 94
 		//查询表里当天的数据
95 95
 		var wtotal int
96 96
 		wtotal, err = service.GetTodayPharmacy(stime, etime, orgid, 1)
@@ -118,7 +118,7 @@ func (this *PharmacyController) TodayNumber() {
118 118
 		return
119 119
 	}
120 120
 
121
-	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 {
121
+	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10480 {
122 122
 		var wtotal int
123 123
 		var itotal int
124 124
 		//查找出库数量
@@ -169,7 +169,7 @@ func (this *PharmacyController) IssuedDrug() {
169 169
 		etime = stime + 86399
170 170
 	}
171 171
 
172
-	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 || orgid == 10375 {
172
+	if orgid == 10164 || orgid == 3877 || orgid == 10188 || orgid == 10217 || orgid == 9671 || orgid == 10387 || orgid == 10375 || orgid == 10480 || orgid == 10344 {
173 173
 
174 174
 		//获取排班班次
175 175
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
@@ -193,7 +193,7 @@ func (this *PharmacyController) IssuedDrug() {
193 193
 		})
194 194
 	}
195 195
 
196
-	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10375 {
196
+	if orgid != 10164 && orgid == 3877 && orgid != 10188 && orgid != 10217 && orgid != 9671 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid == 10344 {
197 197
 		//查询表里当天的数据
198 198
 		var flist []*models.TmpPatient
199 199
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
@@ -249,7 +249,7 @@ func (this *PharmacyController) WaitingDrug() {
249 249
 		etime = stime + 86399
250 250
 	}
251 251
 
252
-	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 && orgid != 10375 {
252
+	if orgid != 9671 && orgid != 10188 && orgid != 10217 && orgid != 3877 && orgid != 10164 && orgid != 10387 && orgid != 10375 && orgid != 10480 && orgid != 10344 {
253 253
 		//查询表里当天的数据
254 254
 		var flist []*models.TmpPatient
255 255
 		flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
@@ -273,11 +273,10 @@ func (this *PharmacyController) WaitingDrug() {
273 273
 	}
274 274
 
275 275
 	//当天已发药的人数
276
-	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 || orgid == 10375 {
276
+	if orgid == 9671 || orgid == 10188 || orgid == 10217 || orgid == 3877 || orgid == 10164 || orgid == 10387 || orgid == 10375 || orgid == 10480 || orgid == 10344 {
277 277
 
278 278
 		//获取排班班次
279 279
 		schedule, _ := service.GetSchedulePatientId(stime, etime, orgid, shift, partition)
280
-		fmt.Println("schedule--------", schedule)
281 280
 		var ids []int64
282 281
 		for _, item := range schedule {
283 282
 			ids = append(ids, item.PatientId)

+ 0 - 1
controllers/schedule_api_controller.go View File

@@ -4223,7 +4223,6 @@ func (this *ScheduleApiController) GetBloodScheduleList() {
4223 4223
 
4224 4224
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4225 4225
 
4226
-	fmt.Println("weekt_ywppwepwpwwep", week_type)
4227 4226
 	if week_type > 0 {
4228 4227
 		list, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone)
4229 4228
 		for _, item := range list {

+ 152 - 8
controllers/sign_api_controller.go View File

@@ -8,6 +8,7 @@ import (
8 8
 	"fmt"
9 9
 	"github.com/astaxie/beego"
10 10
 	"github.com/jung-kurt/gofpdf"
11
+	"github.com/mozillazg/go-pinyin"
11 12
 	"io/ioutil"
12 13
 	"time"
13 14
 )
@@ -657,14 +658,155 @@ func (this *SignApiController) GetEnterPriseDetail() {
657 658
 
658 659
 func (this *SignApiController) UploadPrintOrder() {
659 660
 
660
-	dataBody := make(map[string]interface{}, 0)
661
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
662
-	fmt.Println("err", err)
663
-	name := dataBody["name"].(string)
661
+	list, _ := service.GetAllPatientNew(10188)
662
+	for _, item := range list {
663
+
664
+		hans := item.Name // 要转换的汉字字符串
665
+		// 创建一个拼音转换器
666
+		p := pinyin.NewArgs()
667
+
668
+		// 将汉字转为拼音
669
+		pinyinSlice := pinyin.Pinyin(hans, p)
670
+
671
+		// 输出拼音
672
+		fmt.Println("Pinyin:", pinyinSlice)
673
+
674
+		// 获取首字母
675
+		firstLetter := ""
676
+		for _, py := range pinyinSlice {
677
+			if len(py) > 0 {
678
+				firstLetter += string(py[0][0])
679
+			}
680
+		}
681
+
682
+		item.FirstLetter = firstLetter
683
+		service.UpdatePatientNew(item.ID, item.FirstLetter)
684
+		// 输出首字母
685
+		//fmt.Println("First Letter:", firstLetter)
686
+	}
687
+
688
+	//pdfg, _ := wkhtml.NewPDFGenerator()
689
+	//
690
+	//htmlStr := `<html><body><h1 style="color:red;">This is an html
691
+	// from pdf to test color<h1><img src="http://api.qrserver.com/v1/create-qr-
692
+	//code/?data=HelloWorld"   ></img></body></html>`
693
+	//
694
+	//pdfg.AddPage(wkhtml.NewPageReader(strings.NewReader(htmlStr)))
695
+	//
696
+	//// Create PDF document in internal buffer
697
+	//err = pdfg.Create()
698
+	//
699
+	////Your Pdf Name
700
+	//err = pdfg.WriteFile("./Your_pdfname.pdf")
701
+
702
+	//dataBody := make(map[string]interface{}, 0)
703
+	//err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
704
+	//fmt.Println(err)
705
+	//name := dataBody["name"].(string)
706
+	//fmt.Println(name)
707
+	//sign := service.CreateNewUploadPact(name)
708
+	//fmt.Println("sign")
709
+	//information, pdfBase64 := service.SavePdfInformation(name)
710
+
711
+	pdf := gofpdf.New("P", "mm", "A4", "")
712
+	pdf.AddPage()
713
+	pdf.Text(5, 10, "血液净化治疗记录单")
714
+	//wd := pdf.GetStringWidth(titleStr) + 6
715
+	//fmt.Println("wd", wd)
716
+	//pdf.SetY(0.6)            //先要设置 Y,然后再设置 X。否则,会导致 X 失效
717
+	//pdf.SetX((210 - wd) / 2) //水平居中的算法
718
+	//pdf.AddUTF8Font("simkai", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
719
+	//pdf.SetFont("simkai", "", 20)
720
+
721
+	//将字体加载进来
722
+	//AddUTF8Font("给字体起个别名", "", "fontPath")
723
+	pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
724
+	pdf.SetFont("simfang", "", 20)
725
+	var title = "血液透析(滤过)记录表单"
726
+	//表格居中显示
727
+	pdf.Text(70, 10, title)
728
+	wd := pdf.GetStringWidth(title) + 100
729
+	fmt.Println("wd", wd)
730
+	pdf.SetY(100)            //先要设置 Y,然后再设置 X。否则,会导致 X 失效
731
+	pdf.SetX((210 - wd) / 2) //水平居中的算法
732
+	//pdf.SetLineWidth(0)
733
+
734
+	//pdf.Line(10, 30, 585, 30)
735
+	//pdf.Ln(1)
736
+	//pdf.Write(10, "\n")
737
+	var numuber = "100000"
738
+	//表格居中显示
739
+	pdf.SetFont("", "", 14) // 设置加粗字体和字号
740
+	pdf.Text(10, 20, "病历号:"+numuber)
741
+	pdf.SetFont("", "", 14) // 设置加粗字体和字号
742
+	pdf.Text(60, 20, "姓名:")
743
+	pdf.SetFont("", "", 14) // 设置正常字体和字号
744
+	pdf.Text(90, 20, "性别:")
745
+	pdf.SetFont("", "", 14) // 设置正常字体和字号
746
+	pdf.Text(120, 20, "年龄:")
747
+	pdf.SetFont("", "", 14) // 设置正常字体和字号
748
+	pdf.Text(150, 20, "透析次数:")
749
+	pdf.SetFont("", "", 14) // 设置正常字体和字号
750
+
751
+	//表格居中显示
752
+	pdf.SetFont("", "", 14) // 设置加粗字体和字号
753
+	pdf.Text(10, 30, "入科方式:"+numuber)
754
+	pdf.SetFont("", "", 14) // 设置加粗字体和字号
755
+	pdf.Text(60, 30, "诊断:")
756
+
757
+	//param1: 单元格的宽,为0时表示一行,单位根据new()里面设置的来
758
+	//param2: 单元格的高,不能为0,单位根据new()里面设置的来
759
+	//param3: 单元格内容
760
+	//param4: 边框样式,一个空字符串表示无边框,“1”表示全边框,一个或多个“L”,“T”,“R”和“B”分别表示边界左,上,右,下
761
+	//param5: 表示调用后当前位置的位置。可能的值为0,接着当前行继续,1换行,2目前没有试过
762
+	//param6: 字体的位置,水平对齐包括"L", “C"或"R”(左,中,右)。垂直对齐由包含控制"T", “M”, “B"或"A”(上,中,下,基线),可以组合,比如说LT,CM等等
763
+	//param7: 是否填充单元格,需要调用SetFillColor()方法.默认false
764
+	//param8: 内部超链接,没用过
765
+	//param9: 超链接,没用过
766
+	pdf.AddUTF8Font("simfang", "", "D:/go/src/pkg/mod/github.com/jung-kurt/gofpdf@v1.16.2/font/simfang.ttf")
767
+	pdf.SetFont("simfang", "", 14)  // 设置字体、字号
768
+	pdf.SetFillColor(200, 200, 200) // 设置填充颜色
769
+
770
+	// 设置起始位置
771
+	var x = 10.0
772
+	var y = 40.0
773
+	// 创建8行2列的表格
774
+
775
+	for j := 0; j < 1; j++ {
776
+		//cellText := fmt.Sprintf("行%d列%d", i+1, j+1)                 // 填充每个单元格的内容
777
+		pdf.SetXY(x, y)                                         // 设置当前位置
778
+		pdf.CellFormat(15, 15, "时间", "1", 0, "C", false, 0, "") // 使用CellFormat()方法创建表格单元格
779
+		pdf.CellFormat(20, 15, "血压(mmHg)", "1", 0, "CM", false, 0, "")
780
+		pdf.CellFormat(20, 15, "脉搏(次/分)", "1", 0, "CM", false, 0, "")
781
+		pdf.CellFormat(20, 15, "呼吸(次/分)", "1", 0, "CM", false, 0, "")
782
+		pdf.CellFormat(20, 15, "血流量(ml/min)", "1", 0, "CM", false, 0, "")
783
+		pdf.CellFormat(20, 15, "静脉压(mmHg)", "1", 0, "CM", false, 0, "")
784
+		pdf.CellFormat(20, 15, "跨膜压(mmHg)", "1", 0, "CM", false, 0, "")
785
+		pdf.CellFormat(20, 15, "透析液温(℃)", "1", 0, "CM", false, 0, "")
786
+		pdf.CellFormat(20, 15, "钠浓度(mmol/L)", "1", 0, "CM", false, 0, "")
787
+		pdf.CellFormat(20, 15, "超滤量(ml) ", "1", 0, "CM", false, 0, "")
788
+		pdf.CellFormat(35, 15, "病情变化及处理", "1", 0, "CM", false, 0, "")
789
+
790
+		y += 15 // 下一行起始位置的y坐标增加60(单元格高度)
791
+	}
792
+	x += 200.0 // 下一列起始位置的x坐标增加190(单元格宽度)
793
+	y = 10.0   // 行起始位置的y坐标重置为10
794
+
795
+	//设置表格单元格大小,
796
+	//pdf.CellFormat(180, 15, "李王", "1", 0, "LM", false, 0, "")
797
+
798
+	pdf.Ln(2)
799
+	//pdf.Ln(2) 行距2mm
800
+
801
+	if err := pdf.OutputFileAndClose("6.pdf"); err != nil {
802
+		panic(err.Error())
803
+	}
664 804
 
665
-	sign := service.CreateNewUploadPact(name)
666 805
 	this.ServeSuccessJSON(map[string]interface{}{
667
-		"sign": sign,
806
+		//"sign":      information,
807
+		//"pdfBase64": pdfBase64,
808
+		//"name": name,
809
+
668 810
 	})
669 811
 
670 812
 }
@@ -715,7 +857,8 @@ func (this *SignApiController) CreateSdkSendInformation() {
715 857
 
716 858
 func (this *SignApiController) SavePdfInformation() {
717 859
 
718
-	information, pdfBase64 := service.SavePdfInformation()
860
+	var name string
861
+	information, pdfBase64 := service.SavePdfInformation(name)
719 862
 	informationOne := service.ToCheckInformation(pdfBase64)
720 863
 
721 864
 	maprequest := make(map[string]interface{})
@@ -973,7 +1116,8 @@ func (this *SignApiController) SavePdfInformation() {
973 1116
 
974 1117
 func (this *SignApiController) ToCheckInformation() {
975 1118
 
976
-	information, pdfBase64 := service.SavePdfInformation()
1119
+	var name string
1120
+	information, pdfBase64 := service.SavePdfInformation(name)
977 1121
 	informationOne := service.ToCheckInformation(pdfBase64)
978 1122
 
979 1123
 	this.ServeSuccessJSON(map[string]interface{}{

+ 1 - 1
controllers/stock_in_api_controller.go View File

@@ -7108,7 +7108,7 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7108 7108
 		}
7109 7109
 		service.CreateGoodErrcode(goodErrcode)
7110 7110
 	}
7111
-	//查询已审核的单据
7111
+	//查询已保存的单据
7112 7112
 	warehousingOutInfo, erroce := service.GetWarehouseOutById(id, orgId)
7113 7113
 	if erroce != nil {
7114 7114
 		goodErrcode := models.XtGoodErrcode{

+ 1 - 0
models/monitor_models.go View File

@@ -132,6 +132,7 @@ type MonitorPatients struct {
132 132
 	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
133 133
 	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
134 134
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
135
+	FirstLetter                  string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
135 136
 }
136 137
 
137 138
 func (MonitorPatients) TableName() string {

+ 5 - 0
models/patient_models.go View File

@@ -25,6 +25,7 @@ type MSchedualPatientList struct {
25 25
 	TrobleShoot        int64  `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
26 26
 	SchRemark          string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
27 27
 	ScheduleRemark     string `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
28
+	FirstLetter        string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
28 29
 }
29 30
 
30 31
 func (MSchedualPatientList) TableName() string {
@@ -832,6 +833,7 @@ type XtPatientsNew struct {
832 833
 	InfectiousRemark             string  `gorm:"column:infectious_remark" json:"infectious_remark" form:"infectious_remark"`
833 834
 	AllergicHistory              string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
834 835
 	PatientAddress               string  `gorm:"column:patient_address" json:"patient_address" form:"patient_address"`
836
+	FirstLetter                  string  `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
835 837
 }
836 838
 
837 839
 func (XtPatientsNew) TableName() string {
@@ -1808,6 +1810,9 @@ type NewDialysisPrescription struct {
1808 1810
 	AdminUserId                int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
1809 1811
 	DialysisRemark             string  `gorm:"column:dialysis_remark" json:"dialysis_remark" form:"dialysis_remark"`
1810 1812
 	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
1813
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
1814
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
1815
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
1811 1816
 }
1812 1817
 
1813 1818
 func (NewDialysisPrescription) TableName() string {

+ 4 - 3
models/schedule_models.go View File

@@ -312,9 +312,10 @@ func (BloodPatientDialysisPrescription) TableName() string {
312 312
 }
313 313
 
314 314
 type VmBloodPatients struct {
315
-	ID    int64  `gorm:"column:id" json:"id" form:"id"`
316
-	BedId int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
317
-	Name  string `gorm:"column:name" json:"name" form:"name"`
315
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
316
+	BedId       int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
317
+	Name        string `gorm:"column:name" json:"name" form:"name"`
318
+	FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
318 319
 }
319 320
 
320 321
 func (VmBloodPatients) TableName() string {

+ 1 - 2
service/manage_center_service.go View File

@@ -2,7 +2,6 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
-	"fmt"
6 5
 	"github.com/jinzhu/gorm"
7 6
 	"strconv"
8 7
 	"strings"
@@ -450,7 +449,7 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
450 449
 		for _, its := range list {
451 450
 			//查询该批次病人该药品出库数据
452 451
 			infos, _ := GetDrugAutoWarehouseOutTen(advice.PatientId, advice.AdviceDate, advice.DrugId, advice.ID, its.WarehouseInfoId)
453
-			fmt.Println("info2332323232332233223wo", infos.Count)
452
+
454 453
 			//查询该药品出库批次总入库数量
455 454
 			druginfo, _ := GetDrugInfoSix(its.WarehouseInfoId, infos.OrgId)
456 455
 

+ 1 - 1
service/manage_service.go View File

@@ -1818,7 +1818,7 @@ func GetObjectDisInfectionLongTime(user_org_id int64) (list []*models.XtNewObjec
1818 1818
 
1819 1819
 func GetDialysisOrderPatient(org_id int64) (order []*models.XtDialysisOrder, err error) {
1820 1820
 
1821
-	err = XTReadDB().Where("user_org_id = ? and dialysis_date>=? and dialysis_date<=? and status =1", org_id, 1667232000, 1669737600).Find(&order).Error
1821
+	err = XTReadDB().Where("user_org_id = ? and dialysis_date>=? and dialysis_date<=? and status =1", org_id, 1669824000, 1672416000).Find(&order).Error
1822 1822
 
1823 1823
 	return order, err
1824 1824
 }

+ 423 - 108
service/mobile_dialysis_service.go View File

@@ -4519,10 +4519,13 @@ func GetFistMonitorSix(orgid int64, patient_id int64, dialysis_date int64) (reco
4519 4519
 	return record, err
4520 4520
 }
4521 4521
 
4522
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64, cost_type int64, execution_frequency string) ([]*MScheduleDoctorAdviceVM, error) {
4522
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64, cost_type int64, execution_frequency string, keyword string) ([]*MScheduleDoctorAdviceVM, error) {
4523 4523
 
4524 4524
 	var vms []*MScheduleDoctorAdviceVM
4525
+
4526
+	keyword = "%" + keyword + "%"
4525 4527
 	adviceWhere := ""
4528
+
4526 4529
 	adviceCondition := []interface{}{}
4527 4530
 	if adviceType == 0 {
4528 4531
 		if patientType == 0 {
@@ -4530,20 +4533,47 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4530 4533
 				if execution_state > 0 {
4531 4534
 					if cost_type > 0 {
4532 4535
 						if len(execution_frequency) > 0 {
4533
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and execution_frequency = ?"
4534
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency)
4536
+							if len(keyword) > 0 {
4537
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and execution_frequency = ? and advice_name like ?"
4538
+
4539
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency, keyword)
4540
+							} else {
4541
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and execution_frequency = ?"
4542
+
4543
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency)
4544
+							}
4545
+
4535 4546
 						} else {
4536
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ?"
4537
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type)
4547
+
4548
+							if len(keyword) > 0 {
4549
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and advice_name like ?"
4550
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, keyword)
4551
+							} else {
4552
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ?"
4553
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type)
4554
+							}
4555
+
4538 4556
 						}
4539 4557
 
4540 4558
 					} else {
4541 4559
 						if len(execution_frequency) > 0 {
4542
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and  execution_frequency = ?"
4543
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency)
4560
+							if len(keyword) > 0 {
4561
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and  execution_frequency = ? and advice_name like ?"
4562
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency, keyword)
4563
+							} else {
4564
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and  execution_frequency = ?"
4565
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency)
4566
+							}
4567
+
4544 4568
 						} else {
4545
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
4546
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4569
+							if len(keyword) > 0 {
4570
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and advice_name like ?"
4571
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, keyword)
4572
+							} else {
4573
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
4574
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4575
+							}
4576
+
4547 4577
 						}
4548 4578
 
4549 4579
 					}
@@ -4563,8 +4593,14 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4563 4593
 							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_frequency = ?"
4564 4594
 							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_frequency)
4565 4595
 						} else {
4566
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
4567
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4596
+							if len(keyword) > 0 {
4597
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ? and advice_name like ?"
4598
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, keyword)
4599
+							} else {
4600
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
4601
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4602
+							}
4603
+
4568 4604
 						}
4569 4605
 
4570 4606
 					}
@@ -4575,20 +4611,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4575 4611
 				if execution_state > 0 {
4576 4612
 					if cost_type > 0 {
4577 4613
 						if len(execution_frequency) > 0 {
4578
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and is_settle = ? and execution_frequency = ?"
4579
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, execution_frequency)
4614
+							if len(keyword) > 0 {
4615
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and is_settle = ? and execution_frequency = ? and advice_name like ?"
4616
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, execution_frequency, keyword)
4617
+							} else {
4618
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and is_settle = ? and execution_frequency = ?"
4619
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, execution_frequency)
4620
+							}
4621
+
4580 4622
 						} else {
4581
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and is_settle = ?"
4582
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type)
4623
+							if len(keyword) > 0 {
4624
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and is_settle = ? and advice_name like ?"
4625
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, keyword)
4626
+							} else {
4627
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and is_settle = ?"
4628
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type)
4629
+							}
4630
+
4583 4631
 						}
4584 4632
 
4585 4633
 					} else {
4586 4634
 						if len(execution_frequency) > 0 {
4587
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and execution_frequency = ?"
4588
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, execution_frequency)
4635
+							if len(keyword) > 0 {
4636
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and execution_frequency = ? and advice_name like ?"
4637
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, execution_frequency, keyword)
4638
+							} else {
4639
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and execution_frequency = ?"
4640
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, execution_frequency)
4641
+							}
4642
+
4589 4643
 						} else {
4590
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ?"
4591
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4644
+							if len(keyword) > 0 {
4645
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ? and advice_name like ?"
4646
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, keyword)
4647
+							} else {
4648
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_state= ?"
4649
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
4650
+							}
4651
+
4592 4652
 						}
4593 4653
 
4594 4654
 					}
@@ -4596,20 +4656,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4596 4656
 				} else {
4597 4657
 					if cost_type > 0 {
4598 4658
 						if len(execution_frequency) > 0 {
4599
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and is_settle = ? and execution_frequency = ?"
4600
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, execution_frequency)
4659
+							if len(keyword) > 0 {
4660
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and is_settle = ? and execution_frequency = ? and advice_name like ?"
4661
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, execution_frequency, keyword)
4662
+							} else {
4663
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and is_settle = ? and execution_frequency = ?"
4664
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, execution_frequency)
4665
+							}
4666
+
4601 4667
 						} else {
4602
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and is_settle = ?"
4603
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type)
4668
+							if len(keyword) > 0 {
4669
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and is_settle = ? and advice_name like ?"
4670
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, keyword)
4671
+							} else {
4672
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and is_settle = ?"
4673
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type)
4674
+							}
4675
+
4604 4676
 						}
4605 4677
 
4606 4678
 					} else {
4607 4679
 						if len(execution_frequency) > 0 {
4608
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_frequency = ?"
4609
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_frequency)
4680
+							if len(keyword) > 0 {
4681
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_frequency = ? and advice_name like ?"
4682
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_frequency, keyword)
4683
+							} else {
4684
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and execution_frequency = ?"
4685
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_frequency)
4686
+							}
4687
+
4610 4688
 						} else {
4611
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
4612
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4689
+							if len(keyword) > 0 {
4690
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and advice_name like ?"
4691
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, keyword)
4692
+							} else {
4693
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
4694
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
4695
+							}
4696
+
4613 4697
 						}
4614 4698
 
4615 4699
 					}
@@ -4623,20 +4707,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4623 4707
 				if execution_state > 0 {
4624 4708
 					if cost_type > 0 {
4625 4709
 						if len(execution_frequency) > 0 {
4626
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and execution_frequency = ?"
4627
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, cost_type, execution_frequency)
4710
+							if len(keyword) > 0 {
4711
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and execution_frequency = ? and advice_name like ?"
4712
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, cost_type, execution_frequency, keyword)
4713
+							} else {
4714
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and execution_frequency = ?"
4715
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, cost_type, execution_frequency)
4716
+							}
4717
+
4628 4718
 						} else {
4629
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ?"
4630
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, cost_type)
4719
+							if len(keyword) > 0 {
4720
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ? and advice_name like ?"
4721
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, cost_type, keyword)
4722
+							} else {
4723
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and is_settle = ?"
4724
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, cost_type)
4725
+							}
4726
+
4631 4727
 						}
4632 4728
 
4633 4729
 					} else {
4634 4730
 						if len(execution_frequency) > 0 {
4635
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and execution_frequency = ?"
4636
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, execution_frequency)
4731
+							if len(keyword) > 0 {
4732
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and execution_frequency = ? and advice_name like ?"
4733
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, execution_frequency, keyword)
4734
+							} else {
4735
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and execution_frequency = ?"
4736
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, execution_frequency)
4737
+							}
4738
+
4637 4739
 						} else {
4638
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
4639
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
4740
+							if len(keyword) > 0 {
4741
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ? and advice_name like ?"
4742
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state, keyword)
4743
+							} else {
4744
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_state= ?"
4745
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_state)
4746
+							}
4747
+
4640 4748
 						}
4641 4749
 
4642 4750
 					}
@@ -4644,20 +4752,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4644 4752
 				} else {
4645 4753
 					if cost_type > 0 {
4646 4754
 						if len(execution_frequency) > 0 {
4647
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and is_settle=? and execution_frequency = ?"
4648
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, cost_type, execution_frequency)
4755
+							if len(keyword) > 0 {
4756
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and is_settle=? and execution_frequency = ? and advice_name like ?"
4757
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, cost_type, execution_frequency, keyword)
4758
+							} else {
4759
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and is_settle=? and execution_frequency = ?"
4760
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, cost_type, execution_frequency)
4761
+							}
4762
+
4649 4763
 						} else {
4650
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and is_settle=?"
4651
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, cost_type)
4764
+							if len(keyword) > 0 {
4765
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and is_settle=? and advice_name like ?"
4766
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, cost_type, keyword)
4767
+							} else {
4768
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and is_settle=?"
4769
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, cost_type)
4770
+							}
4771
+
4652 4772
 						}
4653 4773
 
4654 4774
 					} else {
4655 4775
 						if len(execution_frequency) > 0 {
4656
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_frequency = ?"
4657
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_frequency)
4776
+							if len(keyword) > 0 {
4777
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_frequency = ? and advice_name like ?"
4778
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_frequency, keyword)
4779
+							} else {
4780
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and execution_frequency = ?"
4781
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, execution_frequency)
4782
+							}
4783
+
4658 4784
 						} else {
4659
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
4660
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
4785
+							if len(keyword) > 0 {
4786
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ? and advice_name like ?"
4787
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id, keyword)
4788
+							} else {
4789
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
4790
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
4791
+							}
4792
+
4661 4793
 						}
4662 4794
 
4663 4795
 					}
@@ -4668,20 +4800,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4668 4800
 				if execution_state > 0 {
4669 4801
 					if cost_type > 0 {
4670 4802
 						if len(execution_frequency) > 0 {
4671
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and execution_frequency = ?"
4672
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, cost_type, execution_frequency)
4803
+							if len(keyword) > 0 {
4804
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and execution_frequency = ? and advice_name like ?"
4805
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, cost_type, execution_frequency, keyword)
4806
+							} else {
4807
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and execution_frequency = ?"
4808
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, cost_type, execution_frequency)
4809
+							}
4810
+
4673 4811
 						} else {
4674
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=?"
4675
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, cost_type)
4812
+							if len(keyword) > 0 {
4813
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and advice_name like ?"
4814
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, cost_type, keyword)
4815
+							} else {
4816
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=?"
4817
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, cost_type)
4818
+							}
4819
+
4676 4820
 						}
4677 4821
 
4678 4822
 					} else {
4679 4823
 						if len(execution_frequency) > 0 {
4680
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and execution_frequency = ?"
4681
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, execution_frequency)
4824
+							if len(keyword) > 0 {
4825
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and execution_frequency = ? and advice_name like ?"
4826
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, execution_frequency, keyword)
4827
+							} else {
4828
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and execution_frequency = ?"
4829
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, execution_frequency)
4830
+							}
4831
+
4682 4832
 						} else {
4683
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
4684
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
4833
+							if len(keyword) > 0 {
4834
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and advice_name like ?"
4835
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state, keyword)
4836
+							} else {
4837
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
4838
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_state)
4839
+							}
4840
+
4685 4841
 						}
4686 4842
 
4687 4843
 					}
@@ -4689,20 +4845,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4689 4845
 				} else {
4690 4846
 					if cost_type > 0 {
4691 4847
 						if len(execution_frequency) > 0 {
4692
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and  is_settle=? and execution_frequency = ?"
4693
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, cost_type, execution_frequency)
4848
+							if len(keyword) > 0 {
4849
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and  is_settle=? and execution_frequency = ? and advice_name like ?"
4850
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, cost_type, execution_frequency, keyword)
4851
+							} else {
4852
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and  is_settle=? and execution_frequency = ?"
4853
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, cost_type, execution_frequency)
4854
+							}
4855
+
4694 4856
 						} else {
4695
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and  is_settle=?"
4696
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, cost_type)
4857
+							if len(keyword) > 0 {
4858
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and  is_settle=? and advice_name like ?"
4859
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, cost_type, keyword)
4860
+							} else {
4861
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and  is_settle=?"
4862
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, cost_type)
4863
+							}
4864
+
4697 4865
 						}
4698 4866
 
4699 4867
 					} else {
4700 4868
 						if len(execution_frequency) > 0 {
4701
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_frequency = ?"
4702
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_frequency)
4869
+							if len(keyword) > 0 {
4870
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_frequency = ? and advice_name like ?"
4871
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_frequency, keyword)
4872
+							} else {
4873
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and execution_frequency = ?"
4874
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, execution_frequency)
4875
+							}
4876
+
4703 4877
 						} else {
4704
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
4705
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
4878
+							if len(keyword) > 0 {
4879
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and advice_name like ?"
4880
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, keyword)
4881
+							} else {
4882
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
4883
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
4884
+							}
4885
+
4706 4886
 						}
4707 4887
 
4708 4888
 					}
@@ -4716,20 +4896,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4716 4896
 				if execution_state > 0 {
4717 4897
 					if cost_type > 0 {
4718 4898
 						if len(execution_frequency) > 0 {
4719
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and is_settle=? and execution_frequency = ?"
4720
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency)
4899
+							if len(keyword) > 0 {
4900
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and is_settle=? and execution_frequency = ? and advice_name like ?"
4901
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency, keyword)
4902
+							} else {
4903
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and is_settle=? and execution_frequency = ?"
4904
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency)
4905
+							}
4906
+
4721 4907
 						} else {
4722
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and is_settle=?"
4723
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type)
4908
+							if len(keyword) > 0 {
4909
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and is_settle=? and advice_name like ?"
4910
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, keyword)
4911
+							} else {
4912
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and is_settle=?"
4913
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type)
4914
+							}
4915
+
4724 4916
 						}
4725 4917
 
4726 4918
 					} else {
4727 4919
 						if len(execution_frequency) > 0 {
4728
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ?and execution_frequency = ?"
4729
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency)
4920
+							if len(keyword) > 0 {
4921
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ?and execution_frequency = ? and advice_name like ?"
4922
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency, keyword)
4923
+							} else {
4924
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ?and execution_frequency = ?"
4925
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency)
4926
+							}
4927
+
4730 4928
 						} else {
4731
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ?"
4732
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4929
+							if len(keyword) > 0 {
4930
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ? and advice_name like ?"
4931
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, keyword)
4932
+							} else {
4933
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and execution_state = ?"
4934
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
4935
+							}
4936
+
4733 4937
 						}
4734 4938
 
4735 4939
 					}
@@ -4737,20 +4941,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4737 4941
 				} else {
4738 4942
 					if cost_type > 0 {
4739 4943
 						if len(execution_frequency) > 0 {
4740
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and is_settle=? and execution_frequency = ?"
4741
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, execution_frequency)
4944
+							if len(keyword) > 0 {
4945
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and is_settle=? and execution_frequency = ? and advice_name like ?"
4946
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, execution_frequency, keyword)
4947
+							} else {
4948
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and is_settle=? and execution_frequency = ?"
4949
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, execution_frequency)
4950
+							}
4951
+
4742 4952
 						} else {
4743
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and is_settle=?"
4744
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type)
4953
+							if len(keyword) > 0 {
4954
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and is_settle=? and advice_name like ?"
4955
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, keyword)
4956
+							} else {
4957
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and is_settle=?"
4958
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type)
4959
+							}
4960
+
4745 4961
 						}
4746 4962
 
4747 4963
 					} else {
4748 4964
 						if len(execution_frequency) > 0 {
4749
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)and execution_frequency = ?"
4750
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_frequency)
4965
+							if len(keyword) > 0 {
4966
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)and execution_frequency = ? and advice_name like ?"
4967
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_frequency, keyword)
4968
+							} else {
4969
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)and execution_frequency = ?"
4970
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_frequency)
4971
+							}
4972
+
4751 4973
 						} else {
4752
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
4753
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4974
+							if len(keyword) > 0 {
4975
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?) and advice_name like ?"
4976
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, keyword)
4977
+							} else {
4978
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
4979
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
4980
+							}
4981
+
4754 4982
 						}
4755 4983
 
4756 4984
 					}
@@ -4761,20 +4989,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4761 4989
 				if execution_state > 0 {
4762 4990
 					if cost_type > 0 {
4763 4991
 						if len(execution_frequency) > 0 {
4764
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and execution_frequency = ?"
4765
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, execution_frequency)
4992
+							if len(keyword) > 0 {
4993
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and execution_frequency = ? and advice_name like ?"
4994
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, execution_frequency, keyword)
4995
+							} else {
4996
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and execution_frequency = ?"
4997
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, execution_frequency)
4998
+							}
4999
+
4766 5000
 						} else {
4767
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=?"
4768
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type)
5001
+							if len(keyword) > 0 {
5002
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=? and advice_name like ?"
5003
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type, keyword)
5004
+							} else {
5005
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and is_settle=?"
5006
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, cost_type)
5007
+							}
5008
+
4769 5009
 						}
4770 5010
 
4771 5011
 					} else {
4772 5012
 						if len(execution_frequency) > 0 {
4773
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and execution_frequency = ?"
4774
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, execution_frequency)
5013
+							if len(keyword) > 0 {
5014
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and execution_frequency = ? and advice_name like ?"
5015
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, execution_frequency, keyword)
5016
+							} else {
5017
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and execution_frequency = ?"
5018
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, execution_frequency)
5019
+							}
5020
+
4775 5021
 						} else {
4776
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
4777
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
5022
+							if len(keyword) > 0 {
5023
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ? and advice_name like ?"
5024
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state, keyword)
5025
+							} else {
5026
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_state = ?"
5027
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_state)
5028
+							}
5029
+
4778 5030
 						}
4779 5031
 
4780 5032
 					}
@@ -4782,20 +5034,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4782 5034
 				} else {
4783 5035
 					if cost_type > 0 {
4784 5036
 						if len(execution_frequency) > 0 {
4785
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = ? and execution_frequency = ?"
4786
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, execution_frequency)
5037
+							if len(keyword) > 0 {
5038
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = ? and execution_frequency = ? and advice_name like ?"
5039
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, execution_frequency, keyword)
5040
+							} else {
5041
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = ? and execution_frequency = ?"
5042
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, execution_frequency)
5043
+							}
5044
+
4787 5045
 						} else {
4788
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = ?"
4789
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type)
5046
+							if len(keyword) > 0 {
5047
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = ? and advice_name like ?"
5048
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type, keyword)
5049
+							} else {
5050
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and is_settle = ?"
5051
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, cost_type)
5052
+							}
5053
+
4790 5054
 						}
4791 5055
 
4792 5056
 					} else {
4793 5057
 						if len(execution_frequency) > 0 {
4794
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_frequency = ?"
4795
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_frequency)
5058
+							if len(keyword) > 0 {
5059
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_frequency = ? and advice_name like ?"
5060
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_frequency, keyword)
5061
+							} else {
5062
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and execution_frequency = ?"
5063
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, execution_frequency)
5064
+							}
5065
+
4796 5066
 						} else {
4797
-							adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
4798
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
5067
+							if len(keyword) > 0 {
5068
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1) and advice_name like ?"
5069
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, keyword)
5070
+							} else {
5071
+								adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
5072
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
5073
+							}
5074
+
4799 5075
 						}
4800 5076
 
4801 5077
 					}
@@ -4812,20 +5088,44 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4812 5088
 				if execution_state > 0 {
4813 5089
 					if cost_type > 0 {
4814 5090
 						if len(execution_frequency) > 0 {
4815
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and is_settle = ? and execution_frequency = ?"
4816
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency)
5091
+							if len(keyword) > 0 {
5092
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and is_settle = ? and execution_frequency = ? and advice_name like ?"
5093
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency, keyword)
5094
+							} else {
5095
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and is_settle = ? and execution_frequency = ?"
5096
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, execution_frequency)
5097
+							}
5098
+
4817 5099
 						} else {
4818
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and is_settle = ?"
4819
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type)
5100
+							if len(keyword) > 0 {
5101
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and is_settle = ? and advice_name like ?"
5102
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type, keyword)
5103
+							} else {
5104
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and is_settle = ?"
5105
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, cost_type)
5106
+							}
5107
+
4820 5108
 						}
4821 5109
 
4822 5110
 					} else {
4823 5111
 						if len(execution_frequency) > 0 {
4824
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and execution_frequency = ?"
4825
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency)
5112
+							if len(keyword) > 0 {
5113
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and execution_frequency = ? and advice_name like ?"
5114
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency, keyword)
5115
+							} else {
5116
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and execution_frequency = ?"
5117
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, execution_frequency)
5118
+							}
5119
+
4826 5120
 						} else {
4827
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ?"
4828
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
5121
+							if len(keyword) > 0 {
5122
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ? and advice_name like ?"
5123
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state, keyword)
5124
+							} else {
5125
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_state = ?"
5126
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_state)
5127
+							}
5128
+
4829 5129
 						}
4830 5130
 
4831 5131
 					}
@@ -4833,20 +5133,35 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
4833 5133
 				} else {
4834 5134
 					if cost_type > 0 {
4835 5135
 						if len(execution_frequency) > 0 {
4836
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and is_settle = ? and execution_frequency = ?"
4837
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, execution_frequency)
5136
+							if len(keyword) > 0 {
5137
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and is_settle = ? and execution_frequency = ? and advice_name like ?"
5138
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, execution_frequency, keyword)
5139
+							} else {
5140
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and is_settle = ? and execution_frequency = ?"
5141
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, execution_frequency)
5142
+							}
5143
+
4838 5144
 						} else {
4839
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and is_settle = ? "
4840
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type)
5145
+							if len(keyword) > 0 {
5146
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and is_settle = ? and advice_name like ? "
5147
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type, keyword)
5148
+							} else {
5149
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and is_settle = ? "
5150
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, cost_type)
5151
+							}
5152
+
4841 5153
 						}
4842 5154
 
4843 5155
 					} else {
4844 5156
 						if len(execution_frequency) > 0 {
4845
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? and execution_frequency = ?"
4846
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, execution_frequency)
4847
-						} else {
4848
-							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
4849
-							adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
5157
+							if len(keyword) > 0 {
5158
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ?  and advice_name like ?"
5159
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id, keyword)
5160
+							} else {
5161
+								adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
5162
+								adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
5163
+							}
5164
+
4850 5165
 						}
4851 5166
 
4852 5167
 					}

+ 41 - 7
service/new_warehouse_service.go View File

@@ -596,6 +596,23 @@ func AddDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count in
596 596
 	return err
597 597
 }
598 598
 
599
+func FindOverCount(drug_id int64, org_id int64, storehouse_id int64) (models.XtDrugStockCount, error) {
600
+
601
+	stockCount := models.XtDrugStockCount{}
602
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and storehouse_id=?", drug_id, org_id, storehouse_id).Find(&stockCount).Error
603
+	return stockCount, err
604
+}
605
+
606
+func UpdateActOut(id int64, sum_in_count int64, flush_count int64, sum_cancel_count int64) error {
607
+
608
+	var sum_out_count int64
609
+	sum_out_count = sum_in_count - flush_count
610
+	var sum_act_out_count int64
611
+	sum_act_out_count = sum_out_count + sum_cancel_count
612
+	err := XTWriteDB().Model(&models.XtDrugStockCount{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"sum_out_count": sum_out_count, "sum_act_out_count": sum_act_out_count}).Error
613
+	return err
614
+}
615
+
599 616
 func ReduceDrugCount(drug_id int64, org_id int64, storehouse_id int64, out_count int64) error {
600 617
 	ut := XTWriteDB().Begin()
601 618
 	err := ut.Model(&models.XtDrugStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and drug_id = ?", storehouse_id, org_id, drug_id).UpdateColumn("sum_out_count", gorm.Expr("sum_out_count - ?", out_count)).Error
@@ -1390,8 +1407,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1390 1407
 
1391 1408
 	}
1392 1409
 
1393
-	fmt.Println("库存数量2嚄噢嚄噢噢哦哦嚄噢嚄o", stock_number)
1394
-	fmt.Println("出库数咯哦我我我我嚄嚄嚄嚄", deliver_number)
1395 1410
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1396 1411
 	if stock_number >= deliver_number {
1397 1412
 
@@ -1554,7 +1569,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1554 1569
 
1555 1570
 			//查询今日该药品该患者是否有出库数据
1556 1571
 			lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
1557
-			fmt.Println("以色列---------------------------------------", lastDrugOutInfo.ID)
1572
+
1558 1573
 			if lastDrugOutInfo.ID == 0 {
1559 1574
 				errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1560 1575
 				if errOne != nil {
@@ -1575,7 +1590,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1575 1590
 				}
1576 1591
 			}
1577 1592
 			if lastDrugOutInfo.ID > 0 {
1578
-				fmt.Println("wowowowowowwwwwwwwwwwwwwwwwwwwwwwww")
1593
+
1579 1594
 				//删除在新增
1580 1595
 				UpdateDrugWarehouseOutInfoTen(lastDrugOutInfo.PatientId, lastDrugOutInfo.SysRecordTime, advice.ID)
1581 1596
 
@@ -1603,6 +1618,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1603 1618
 		fmt.Println("退款数来的发阿道夫", cancel_count)
1604 1619
 
1605 1620
 		fmt.Println("查收嗖嗖嗖哦", deliver_number_one-(out_count-cancel_count))
1621
+
1606 1622
 		if deliver_number_one-(out_count-cancel_count) >= 0 {
1607 1623
 			if (deliver_number_one - out_count - cancel_count) != 0 {
1608 1624
 
@@ -1638,7 +1654,24 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1638 1654
 						AdviceId:                advice.ID,
1639 1655
 					}
1640 1656
 
1641
-					AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1657
+					errThreeThrtiy := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1658
+
1659
+					if errThreeThrtiy != nil {
1660
+						drugError := models.XtDrugError{
1661
+							UserOrgId:             orgID,
1662
+							DrugId:                advice.DrugId,
1663
+							RecordDate:            advice.AdviceDate,
1664
+							PatientId:             advice.PatientId,
1665
+							Remark:                "插入数据报错",
1666
+							Status:                1,
1667
+							Ctime:                 time.Now().Unix(),
1668
+							Mtime:                 0,
1669
+							SumCount:              0,
1670
+							Prescribingnumber:     advice.PrescribingNumber,
1671
+							PrescribingNumberUnit: advice.PrescribingNumberUnit,
1672
+						}
1673
+						CreateDrugError(drugError)
1674
+					}
1642 1675
 
1643 1676
 				}
1644 1677
 				lastDrugOutInfo, _ := GetNewDrugWarehouseOutInfoSix(advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId, advice.ID, warehouse.ID)
@@ -1693,6 +1726,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1693 1726
 					}
1694 1727
 					CreateDrugError(drugError)
1695 1728
 				}
1729
+
1696 1730
 				//出库数量相加
1697 1731
 				errThreeTys := AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
1698 1732
 
@@ -2160,8 +2194,6 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2160 2194
 			cancel_count += item.Count
2161 2195
 		}
2162 2196
 
2163
-		fmt.Println("deliver_nbumbwowowoowowow", deliver_number)
2164
-		fmt.Println("out_coutnwoowowowowowow", out_count)
2165 2197
 		//如果本次出库数据大于历史出库数据 新增1条流水
2166 2198
 		if deliver_number > (out_count - cancel_count) {
2167 2199
 
@@ -2200,6 +2232,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2200 2232
 			CreateDrugFlowOne(drugflow)
2201 2233
 			//出库数量相加
2202 2234
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
2235
+
2203 2236
 		}
2204 2237
 
2205 2238
 		if deliver_number < (out_count - cancel_count) {
@@ -3271,6 +3304,7 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
3271 3304
 			CreateDrugFlowOne(drugflow)
3272 3305
 			//出库数量相加
3273 3306
 			AddDrugCount(advice.DrugId, orgID, storeConfig.DrugStorehouseOut, drugflow.Count)
3307
+
3274 3308
 		}
3275 3309
 
3276 3310
 		if deliver_number < (out_count - cancel_count) {

+ 1 - 1
service/patientmanage_service.go View File

@@ -777,7 +777,7 @@ func SearchallPatient(keyword string, orgid int64) (patients []*models.XtPatient
777 777
 	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
778 778
 	if len(keyword) > 0 {
779 779
 		likeKey := "%" + keyword + "%"
780
-		db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ?", likeKey, likeKey)
780
+		db = db.Where("x.name LIKE ? OR x.dialysis_no LIKE ? OR x.first_letter=?", likeKey, likeKey, likeKey)
781 781
 	}
782 782
 	if orgid > 0 {
783 783
 		db = db.Where("x.user_org_id = ?", orgid)

+ 51 - 26
service/sign_service.go View File

@@ -10,8 +10,10 @@ import (
10 10
 	"encoding/json"
11 11
 	"fmt"
12 12
 	"github.com/astaxie/beego"
13
+	"github.com/jung-kurt/gofpdf"
13 14
 	"io/ioutil"
14 15
 	"net/http"
16
+	"path"
15 17
 )
16 18
 
17 19
 func GetSignNameByPhone(phoneOne string) string {
@@ -1657,7 +1659,7 @@ func CreateSdkSendInformation() (string, string) {
1657 1659
 	return str, orderId
1658 1660
 }
1659 1661
 
1660
-func SavePdfInformation() (string, string) {
1662
+func SavePdfInformation(name string) (string, string) {
1661 1663
 
1662 1664
 	var url string
1663 1665
 
@@ -1671,19 +1673,20 @@ func SavePdfInformation() (string, string) {
1671 1673
 
1672 1674
 	maprequest["signTitle"] = "举报合同"
1673 1675
 
1674
-	//file := "C:/Users/28169/Desktop/2.pdf"
1675
-	file := "/swspan/gopath/src/XT_New/static/6.pdf"
1676
-
1677
-	fileBytes, _ := ioutil.ReadFile(file) // 读取file
1676
+	//file := "C:/Users/28169/Desktop/9.pdf"
1677
+	//file := "/swspan/gopath/src/XT_New/static/16.pdf"
1678
+	//fileBytes, _ := ioutil.ReadFile(file) // 读取file
1679
+	//
1680
+	//contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
1678 1681
 
1679
-	contractBase64 := base64.StdEncoding.EncodeToString(fileBytes) // 加密成base64字符串
1682
+	//fmt.Println("contractBase64", contractBase64)
1680 1683
 
1681 1684
 	//文件获取方式
1682
-	maprequest["fileType"] = 1
1685
+	maprequest["fileType"] = 3
1683 1686
 
1684
-	maprequest["pdfBase64"] = contractBase64
1687
+	//maprequest["pdfBase64"] = name
1685 1688
 	//合同内容
1686
-	maprequest["fileContent"] = contractBase64
1689
+	maprequest["fileContent"] = "https://kuyi.shengws.com/20.pdf"
1687 1690
 
1688 1691
 	//签署用户人ID
1689 1692
 	maprequest["userId"] = "JMO9U8JH4TN8E3QOI0GUVUF2"
@@ -1712,46 +1715,44 @@ func SavePdfInformation() (string, string) {
1712 1715
 	//预冲者样式
1713 1716
 	inputArrOne := make(map[string]interface{})
1714 1717
 	inputArrOne["sealName"] = "1"
1715
-	inputArrOne["keyword"] = "杨姣"
1718
+	inputArrOne["keyword"] = "穿刺者"
1716 1719
 	inputArrOne["pages"] = "0"
1717 1720
 	inputArrOne["offsetX"] = "50"
1718 1721
 	inputArrOne["offsetY"] = "0"
1719 1722
 
1720 1723
 	keywordSignControls = append(keywordSignControls, inputArrOne)
1721
-
1722
-	//穿刺者样式
1724
+	stepStamper["keywordSignControls"] = keywordSignControls
1725
+	//医生签名
1723 1726
 	//inputArr := make(map[string]interface{})
1724 1727
 	//inputArr["sealName"] = "2"
1725
-	//inputArr["keyword"] = "治疗护士"
1728
+	//inputArr["keyword"] = "医生签名"
1726 1729
 	//inputArr["pages"] = "1"
1727 1730
 	//inputArr["offsetX"] = "100"
1728 1731
 	//inputArr["offsetY"] = "0"
1729 1732
 	//
1730 1733
 	//keywordSignControls = append(keywordSignControls, inputArr)
1731 1734
 	//
1732
-	////上机者
1735
+	//上机者
1733 1736
 	//inputArrSix := make(map[string]interface{})
1734 1737
 	//inputArrSix["sealName"] = "3"
1735
-	//inputArrSix["keyword"] = "核对护士"
1738
+	//inputArrSix["keyword"] = "护士签名"
1736 1739
 	//inputArrSix["pages"] = "1"
1737 1740
 	//inputArrSix["offsetX"] = "100"
1738 1741
 	//inputArrSix["offsetY"] = "0"
1739 1742
 	//
1740 1743
 	//keywordSignControls = append(keywordSignControls, inputArrSix)
1741
-	//
1742 1744
 
1743 1745
 	////医生签名
1744 1746
 	//inputArrSeven := make(map[string]interface{})
1745 1747
 	//inputArrSeven["sealName"] = "4"
1746
-	//inputArrSeven["keyword"] = "医生签名"
1748
+	//inputArrSeven["keyword"] = "核对护士签名"
1747 1749
 	//inputArrSeven["pages"] = "1"
1748 1750
 	//inputArrSeven["offsetX"] = "100"
1749 1751
 	//inputArrSeven["offsetY"] = "0"
1750 1752
 	//
1751 1753
 	//keywordSignControls = append(keywordSignControls, inputArrSeven)
1752
-	//
1754
+
1753 1755
 	//stepStamper["keywordSignControls"] = keywordSignControls
1754
-	stepStamper["keywordSignControls"] = keywordSignControls
1755 1756
 	//
1756 1757
 
1757 1758
 	//crossSignControls := make([]map[string]interface{}, 0)
@@ -1766,17 +1767,16 @@ func SavePdfInformation() (string, string) {
1766 1767
 	//stepStamper["crossSignControls"] = crossSignControls
1767 1768
 	//
1768 1769
 	//xySignControls := make([]map[string]interface{}, 0)
1769
-	//
1770 1770
 	//inputArrThree := make(map[string]interface{})
1771 1771
 	//inputArrThree["sealName"] = "1"
1772
-	//inputArrThree["positionX"] = "100"
1773
-	//inputArrThree["positionY"] = "0"
1772
+	//inputArrThree["positionX"] = "200"
1773
+	//inputArrThree["positionY"] = "100"
1774 1774
 	//inputArrThree["pages"] = "0"
1775 1775
 	//
1776 1776
 	//xySignControls = append(xySignControls, inputArrThree)
1777
-	//
1777
+	////
1778 1778
 	//stepStamper["xySignControls"] = xySignControls
1779
-
1779
+	//
1780 1780
 	maprequest["stepStamper"] = stepStamper
1781 1781
 
1782 1782
 	seals := make([]map[string]interface{}, 0)
@@ -1794,7 +1794,7 @@ func SavePdfInformation() (string, string) {
1794 1794
 
1795 1795
 	sealTextsList := make(map[string]interface{})
1796 1796
 	sealTextsList["text"] = "2023年8月8日"
1797
-	sealTextsList["fontSize"] = "100"
1797
+	sealTextsList["fontSize"] = "12"
1798 1798
 	sealTextsList["fontColor"] = "#333333"
1799 1799
 	sealTextsList["isTextArea"] = true
1800 1800
 	sealTextsList["textAlign"] = 0
@@ -1941,7 +1941,7 @@ func SavePdfInformation() (string, string) {
1941 1941
 
1942 1942
 	}
1943 1943
 	str := string(respBytes)
1944
-
1944
+	fmt.Println("报错提示", str)
1945 1945
 	var respJSON map[string]interface{}
1946 1946
 	if err := json.Unmarshal([]byte(string(respBytes)), &respJSON); err != nil {
1947 1947
 		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
@@ -2037,3 +2037,28 @@ func UpdatePersionEnterPrise(id int64, userId string) error {
2037 2037
 	err := XTWriteDB().Model(&models.XtDevicePersonEnterprise{}).Where("id=? and status =1", id).Updates(map[string]interface{}{"user_id": userId}).Error
2038 2038
 	return err
2039 2039
 }
2040
+
2041
+func SingleImg2Pdf(pathStr string) {
2042
+	pdf := gofpdf.New("P", "mm", "A4", "")
2043
+	pdf.AddPage()
2044
+	pdf.SetFont("Arial", "", 11)
2045
+	pdf.Image(pathStr, 10, 10, pdf.GetPageSizeStr("A4").Wd-20, 0, false, "", 0, "")
2046
+	// pdf.Text(50, 20, "logo.png")
2047
+	fileNameAll := path.Base(pathStr)
2048
+	fileSuffix := path.Ext(pathStr)
2049
+	fileStr := fmt.Sprintf("./pdfs/%s.pdf", fileNameAll[0:len(fileNameAll)-len(fileSuffix)])
2050
+	err := pdf.OutputFileAndClose(fileStr)
2051
+	fmt.Println(err)
2052
+}
2053
+
2054
+func GetAllPatientNew(org_id int64) (new []*models.XtPatientsNew, err error) {
2055
+
2056
+	err = XTReadDB().Where("user_org_id = ? and status=1", org_id).Find(&new).Error
2057
+	return new, err
2058
+}
2059
+
2060
+func UpdatePatientNew(id int64, firstleterr string) error {
2061
+
2062
+	err := XTWriteDB().Model(models.XtPatientsNew{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"first_letter": firstleterr}).Error
2063
+	return err
2064
+}

+ 11 - 7
service/stock_service.go View File

@@ -3259,13 +3259,17 @@ func UpdateStockOut(warehouseinfoid int64, info models.WarehousingInfo) error {
3259 3259
 }
3260 3260
 
3261 3261
 func AddSigleDrugWarehouseOutInfo(info *models.DrugWarehouseOutInfo) error {
3262
-	ut := writeDb.Begin()
3263
-	err := ut.Create(&info).Error
3264
-	if err != nil {
3265
-		ut.Rollback()
3266
-		return err
3267
-	}
3268
-	ut.Commit()
3262
+	//ut := writeDb.Begin()
3263
+	//err := ut.Create(&info).Error
3264
+	//if err != nil {
3265
+	//	ut.Rollback()
3266
+	//	return err
3267
+	//}
3268
+	//ut.Commit()
3269
+	//return err
3270
+
3271
+	err := writeDb.Create(&info).Error
3272
+
3269 3273
 	return err
3270 3274
 }
3271 3275
 

+ 73 - 48
service/warhouse_service.go View File

@@ -5756,70 +5756,86 @@ func ConsumablesDeliveryThirty(orgID int64, record_time int64, goods *models.War
5756 5756
 			}
5757 5757
 			CreateGoodErrcode(goodErrcode)
5758 5758
 		}
5759
-	}
5760
-
5761
-	goods.Count = deliver_number - stock_number
5762
-	ConsumablesDeliveryThirty(orgID, record_time, goods, warehouseOut, count, creator)
5763 5759
 
5760
+		goods.Count = deliver_number - stock_number
5761
+		ConsumablesDeliveryThirty(orgID, record_time, goods, warehouseOut, count, creator)
5762
+	}
5764 5763
 	return nil
5765 5764
 }
5766 5765
 
5767 5766
 // 药品手动出库 递归方式
5768
-func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DrugWarehouseOutInfo) (err error) {
5767
+func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DrugWarehouseOutInfo, unit string) (err error) {
5769 5768
 
5770 5769
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
5771 5770
 	var deliver_number int64 = 0
5771
+
5772 5772
 	var stock_number int64 = 0
5773
-	var retail_price float64
5773
+
5774
+	var drug_price float64
5774 5775
 	if advice.CountUnit == drup.MaxUnit {
5775 5776
 		deliver_number = prescribingNumber * drup.MinNumber
5776
-		formatInt := strconv.FormatInt(prescribingNumber, 10)
5777
-		floatcount, _ := strconv.ParseFloat(formatInt, 64)
5778
-		retail_price = floatcount * advice.Price
5777
+
5779 5778
 	} else {
5780 5779
 		deliver_number = prescribingNumber
5781
-		formatInt := strconv.FormatInt(prescribingNumber, 10)
5782
-		floatcount, _ := strconv.ParseFloat(formatInt, 64)
5783
-		retail_price = floatcount * advice.Price
5780
+
5781
+	}
5782
+	if advice.CountUnit == drup.MaxUnit {
5783
+		drug_price = drup.RetailPrice
5784 5784
 	}
5785
+	fmt.Println(drug_price)
5785 5786
 
5786
-	lastWarehouse, _ := FindLastDrugWarehousingInfoByID(advice.DrugId, warehouseout.StorehouseId)
5787
-	if lastWarehouse.StockMinNumber >= drup.MinNumber {
5788
-		var stockMax int64
5789
-		var stockMin int64
5790
-		stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
5791
-		stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
5792
-		//fmt.Println("stockmax", stockMax)
5793
-		//fmt.Println("stockMin", stockMin)
5794
-		ChangeMaxNumber(lastWarehouse.ID, stockMax)
5795
-		UpdateMinNumber(lastWarehouse.ID, stockMin)
5787
+	if advice.CountUnit == drup.MinUnit {
5788
+		drug_price = drup.MinPrice
5796 5789
 	}
5797 5790
 
5798
-	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId, warehouseout.StorehouseId)
5791
+	if advice.CountUnit != drup.MaxUnit || advice.CountUnit != drup.MinUnit {
5792
+		drug_price = drup.RetailPrice
5793
+	}
5799 5794
 
5800
-	if err != nil {
5795
+	// 根据先进先出原则,查询最先入库的批次,进行出库
5796
+	// 如果没有对应的库存,则报错
5797
+	lastWarehouse, _ := FindLastDrugWarehousingInfoByID(advice.DrugId, advice.StorehouseId)
5798
+
5799
+	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
5800
+		if lastWarehouse.StockMinNumber >= drup.MinNumber {
5801
+			var stockMax int64
5802
+			var stockMin int64
5803
+			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
5804
+			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
5805
+
5806
+			ChangeMaxNumber(lastWarehouse.ID, stockMax)
5807
+			UpdateMinNumber(lastWarehouse.ID, stockMin)
5808
+
5809
+		}
5810
+	}
5811
+
5812
+	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
5813
+
5814
+		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
5815
+		ChangeMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber)
5801 5816
 
5802
-		return err
5803 5817
 	}
5804 5818
 
5819
+	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId, advice.StorehouseId)
5820
+
5805 5821
 	// 将该批次的剩余库存数量转换为拆零数量
5806 5822
 	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
5823
+
5807 5824
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
5825
+
5808 5826
 	}
5809 5827
 	if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
5828
+
5810 5829
 		stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
5830
+
5811 5831
 	}
5812 5832
 	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
5833
+
5813 5834
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
5814
-	}
5815 5835
 
5816
-	fmt.Println("stock_number", stock_number)
5817
-	fmt.Println("deliver_number", deliver_number)
5818
-	// 当库存数量大于或等于出库数量的话,则正常出库该批次
5836
+	}
5819 5837
 	if stock_number >= deliver_number {
5820 5838
 
5821
-		// 出库完成后,要减去对应批次的库存数量
5822
-		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
5823 5839
 		var maxNumber int64 = 0
5824 5840
 		var minNumber int64 = 0
5825 5841
 
@@ -5837,12 +5853,16 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
5837 5853
 		}
5838 5854
 
5839 5855
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
5856
+			//fmt.Println("金1")
5840 5857
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
5841 5858
 		}
5859
+
5842 5860
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
5861
+			//fmt.Println("金2")
5843 5862
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
5844 5863
 		}
5845 5864
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
5865
+			//fmt.Println("金3")
5846 5866
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
5847 5867
 		}
5848 5868
 
@@ -5855,37 +5875,42 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
5855 5875
 
5856 5876
 		warehouse.Mtime = time.Now().Unix()
5857 5877
 
5878
+		//fmt.Println("stockmin", warehouse.StockMinNumber)
5879
+		//fmt.Println("minnubmerr", minNumber)
5858 5880
 		if warehouse.StockMinNumber < minNumber {
5881
+			//fmt.Println("金4")
5859 5882
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
5860 5883
 			if warehouse.MaxUnit != warehouse.MinUnit {
5861 5884
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
5862 5885
 			}
5863
-
5886
+			if minNumber == 2 && warehouse.MaxUnit == warehouse.MinUnit && warehouse.StockMinNumber == 0 {
5887
+				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
5888
+			}
5864 5889
 		} else {
5865
-			//fmt.Println("maxNumber23323323332322323w9", maxNumber)
5866
-			//fmt.Println("maxNumber23323323332322323w9", minNumber)
5890
+			//fmt.Println("金5")
5867 5891
 			if minNumber > 0 {
5868
-				if minNumber == 1 && maxNumber == 1 && drup.MaxUnit != drup.MinUnit {
5869
-					warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5870
-				} else {
5871
-					if (warehouse.StockMinNumber - minNumber) >= 0 {
5872
-						warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
5873
-					}
5874
-
5892
+				if (warehouse.StockMinNumber - minNumber) >= 0 {
5893
+					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
5875 5894
 				}
5895
+
5876 5896
 			}
5877 5897
 
5878
-			if minNumber == 0 && maxNumber != 1 {
5898
+			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
5899
+				//fmt.Println("6")
5879 5900
 				if warehouse.StockMinNumber > 0 {
5880
-					if (warehouse.StockMinNumber - deliver_number) >= 0 {
5901
+					if warehouse.StockMinNumber-deliver_number >= 0 {
5881 5902
 						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5882 5903
 					}
5904
+
5883 5905
 				}
5906
+
5884 5907
 			}
5908
+
5885 5909
 		}
5886 5910
 
5887
-		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit {
5911
+		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
5888 5912
 			if (warehouse.StockMinNumber - deliver_number) >= 0 {
5913
+				//fmt.Println("金7")
5889 5914
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
5890 5915
 			}
5891 5916
 
@@ -5947,7 +5972,7 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
5947 5972
 			StockCount:              advice.StockCount,
5948 5973
 			WarehousingDetailId:     warehouse.ID,
5949 5974
 			OverCount:               over_count,
5950
-			RetailPrice:             retail_price, //手动出库出库价格
5975
+			RetailPrice:             drug_price, //手动出库出库价格
5951 5976
 			WarehousingId:           warehouse.ID,
5952 5977
 			SystemTime:              advice.SysRecordTime,
5953 5978
 		}
@@ -5965,7 +5990,7 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
5965 5990
 	} else {
5966 5991
 		stock_number_int := strconv.FormatInt(stock_number, 10)
5967 5992
 		stock_number_int_count, _ := strconv.ParseFloat(stock_number_int, 64)
5968
-		retail_price = stock_number_int_count * advice.Price
5993
+		drug_price = stock_number_int_count * advice.Price
5969 5994
 		//扣减库存
5970 5995
 		warehouse.StockMaxNumber = 0
5971 5996
 		warehouse.StockMinNumber = 0
@@ -6015,7 +6040,7 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
6015 6040
 			LastPrice:               warehouse.Price,
6016 6041
 			StockCount:              advice.StockCount,
6017 6042
 			OverCount:               over_count,
6018
-			RetailPrice:             retail_price, //手动出库出库价格
6043
+			RetailPrice:             drug_price, //手动出库出库价格
6019 6044
 			WarehousingId:           warehouse.ID,
6020 6045
 			WarehousingDetailId:     warehouse.ID,
6021 6046
 			SystemTime:              advice.SysRecordTime,
@@ -6030,7 +6055,7 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
6030 6055
 
6031 6056
 		advice.CountUnit = drup.MinUnit
6032 6057
 
6033
-		AutoDrugDeliverInfoFourtyOne(orgID, prescribingNumber_two_temp, warehouseout, drup, advice)
6058
+		AutoDrugDeliverInfoFourtyOne(orgID, prescribingNumber_two_temp, warehouseout, drup, advice, unit)
6034 6059
 	}
6035 6060
 
6036 6061
 	return