Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
059bb3f8c3

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #

+ 13 - 15
controllers/drug_stock_api_contorller.go View File

@@ -136,27 +136,25 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
136 136
 
137 137
 				warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
138 138
 
139
-				if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
140
-					utils.ErrorLog("price")
139
+				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
140
+					utils.ErrorLog("last_price")
141 141
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
142 142
 					return
143 143
 				}
144
-				price, _ := strconv.ParseFloat(items["price"].(string), 64)
145
-				total := float64(warehousing_count) * price
144
+				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
145
+				total := float64(warehousing_count) * last_price
146 146
 
147
-				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
-					utils.ErrorLog("retail_price")
149
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
-					return
151
-				}
152
-				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
-				retail_price_total := float64(warehousing_count) * retail_price
147
+				//if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
+				//	utils.ErrorLog("retail_price")
149
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
+				//	return
151
+				//}
152
+				//retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
+				retail_price_total := float64(warehousing_count) * last_price
154 154
 
155 155
 				var productDates int64
156 156
 				var expiryDates int64
157 157
 
158
-				fmt.Println()
159
-
160 158
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
161 159
 					expiryDates = 0
162 160
 				} else {
@@ -207,7 +205,7 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
207 205
 					ProductDate:      productDates,
208 206
 					ExpiryDate:       expiryDates,
209 207
 					WarehousingCount: warehousing_count,
210
-					Price:            price,
208
+					Price:            last_price,
211 209
 					TotalPrice:       total,
212 210
 					Status:           1,
213 211
 					Ctime:            ctime,
@@ -216,7 +214,7 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
216 214
 					Type:             types,
217 215
 					Manufacturer:     manufacturer_id,
218 216
 					Dealer:           dealer_id,
219
-					RetailPrice:      retail_price,
217
+					//RetailPrice:      retail_price,
220 218
 					RetailTotalPrice: retail_price_total,
221 219
 				}
222 220
 				warehousingInfo = append(warehousingInfo, warehouseInfo)

+ 55 - 2
controllers/manager_center_api_controller.go View File

@@ -78,6 +78,8 @@ func ManagerCenterRegistRouters() {
78 78
 	beego.Router("/api/diagnose/list", &ManagerCenterApiController{}, "get:GetDiagnoseList")
79 79
 	beego.Router("/api/diagnose/delete", &ManagerCenterApiController{}, "post:DeleteDiagnose")
80 80
 	beego.Router("/api/diagnose/get", &ManagerCenterApiController{}, "get:GetDiagnose")
81
+	beego.Router("/api/drug/getalldruglist", &ManagerCenterApiController{}, "get:GetAllDrugList")
82
+	beego.Router("/api/drug/postsearchdruglist", &ManagerCenterApiController{}, "get:GetSearchDrugList")
81 83
 
82 84
 }
83 85
 
@@ -134,6 +136,11 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
134 136
 	loc, _ := time.LoadLocation("Local")
135 137
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
136 138
 	drug_remark := c.GetString("drug_remark")
139
+	dosage := c.GetString("dosage")
140
+	unval := c.GetString("unval")
141
+	packing_unit := c.GetString("packing_unit")
142
+	packing_price, _ := c.GetFloat("packing_price")
143
+	drug_day := c.GetString("drug_day")
137 144
 	adminInfo := c.GetAdminUserInfo()
138 145
 
139 146
 	drugLib := &models.BaseDrugLib{
@@ -190,6 +197,11 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
190 197
 		SocialSecurityDirectoryCode: social_security_directory_code,
191 198
 		RecordDate:                  theTime.Unix(),
192 199
 		DrugRemark:                  drug_remark,
200
+		Dosage:                      dosage,
201
+		Unval:                       unval,
202
+		PackingUnit:                 packing_unit,
203
+		PackingPrice:                packing_price,
204
+		DrugDay:                     drug_day,
193 205
 	}
194 206
 
195 207
 	total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
@@ -197,7 +209,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
197 209
 	drug_code = "54000000" + drug_code
198 210
 	drugLib.DrugCode = drug_code
199 211
 
200
-	count := service.FindBaseDrugLibRecordCount(drugLib)
212
+	count := service.FindBaseDrugLibRecordCountOne(drugLib)
201 213
 
202 214
 	if count == 0 {
203 215
 		err := service.CreateBaseDrugLib(drugLib)
@@ -274,6 +286,11 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
274 286
 	loc, _ := time.LoadLocation("Local")
275 287
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
276 288
 	drug_remark := c.GetString("drug_remark")
289
+	dosage := c.GetString("dosage")
290
+	unval := c.GetString("unval")
291
+	packing_unit := c.GetString("packing_unit")
292
+	packing_price, _ := c.GetFloat("packing_price")
293
+	drug_day := c.GetString("drug_day")
277 294
 	adminInfo := c.GetAdminUserInfo()
278 295
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
279 296
 
@@ -333,6 +350,11 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
333 350
 		SocialSecurityDirectoryCode: social_security_directory_code,
334 351
 		RecordDate:                  theTime.Unix(),
335 352
 		DrugRemark:                  drug_remark,
353
+		Dosage:                      dosage,
354
+		Unval:                       unval,
355
+		PackingPrice:                packing_price,
356
+		PackingUnit:                 packing_unit,
357
+		DrugDay:                     drug_day,
336 358
 	}
337 359
 
338 360
 	err := service.UpdateBaseDrugLib(drugLib)
@@ -355,7 +377,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
355 377
 	//查询是否存在
356 378
 	_, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
357 379
 	if errTwo == gorm.ErrRecordNotFound {
358
-		fmt.Println("进来了吗1")
380
+
359 381
 		c.ServeSuccessJSON(map[string]interface{}{
360 382
 			"msg": "修改成功",
361 383
 		})
@@ -2129,3 +2151,34 @@ func (c *ManagerCenterApiController) GetDiagnose() {
2129 2151
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2130 2152
 	}
2131 2153
 }
2154
+
2155
+func (c *ManagerCenterApiController) GetAllDrugList() {
2156
+
2157
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2158
+
2159
+	list, err := service.GetAllDrugList(orgId)
2160
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2161
+	if err == nil {
2162
+		c.ServeSuccessJSON(map[string]interface{}{
2163
+			"list":             list,
2164
+			"manufacturerList": manufacturerList,
2165
+		})
2166
+	} else {
2167
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2168
+	}
2169
+}
2170
+
2171
+func (c *ManagerCenterApiController) GetSearchDrugList() {
2172
+	keyword := c.GetString("keyword")
2173
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2174
+	list, err := service.GetSearchDrugList(keyword, orgId)
2175
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2176
+	if err == nil {
2177
+		c.ServeSuccessJSON(map[string]interface{}{
2178
+			"list":             list,
2179
+			"manufacturerList": manufacturerList,
2180
+		})
2181
+	} else {
2182
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2183
+	}
2184
+}

+ 268 - 163
controllers/stock_in_api_controller.go View File

@@ -2607,21 +2607,85 @@ func (this *StockManagerApiController) AddDrugInformation() {
2607 2607
 
2608 2608
 		drug.DrugName = drug_name
2609 2609
 
2610
-		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
2611
-			utils.ErrorLog("drug_alias")
2610
+		if goodNameM["unval"] == nil || reflect.TypeOf(goodNameM["unval"]).String() != "string" {
2611
+			utils.ErrorLog("unval")
2612 2612
 			return
2613 2613
 		}
2614 2614
 
2615
-		drug_alias, _ := goodNameM["drug_alias"].(string)
2615
+		unval, _ := goodNameM["unval"].(string)
2616
+		if len(drug_name) == 0 { //名字为空则生成一条导入错误日志
2617
+			err_log := models.ExportErrLog{
2618
+				LogType:    4,
2619
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2620
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零不能为空",
2621
+				Status:     1,
2622
+				CreateTime: time.Now().Unix(),
2623
+				UpdateTime: time.Now().Unix(),
2624
+				ExportTime: time.Now().Unix(),
2625
+			}
2626
+			service.CreateExportErrLog(&err_log)
2627
+			continue
2628
+		}
2616 2629
 
2617
-		drug.DrugAlias = drug_alias
2630
+		drug.Unval = unval
2631
+
2632
+		min_unit := goodNameM["min_unit"].(string)
2633
+		if len(min_unit) == 0 { //名字为空则生成一条导入错误日志
2634
+			err_log := models.ExportErrLog{
2635
+				LogType:    4,
2636
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2637
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零单位不能为空",
2638
+				Status:     1,
2639
+				CreateTime: time.Now().Unix(),
2640
+				UpdateTime: time.Now().Unix(),
2641
+				ExportTime: time.Now().Unix(),
2642
+			}
2643
+			service.CreateExportErrLog(&err_log)
2644
+			continue
2645
+		}
2646
+
2647
+		drug.MinUnit = min_unit
2648
+
2649
+		dosage, _ := goodNameM["dosage"].(string)
2650
+		if len(dosage) == 0 { //名字为空则生成一条导入错误日志
2651
+			err_log := models.ExportErrLog{
2652
+				LogType:    4,
2653
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2654
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
2655
+				Status:     1,
2656
+				CreateTime: time.Now().Unix(),
2657
+				UpdateTime: time.Now().Unix(),
2658
+				ExportTime: time.Now().Unix(),
2659
+			}
2660
+			service.CreateExportErrLog(&err_log)
2661
+			continue
2662
+		}
2663
+
2664
+		drug.Dosage = dosage
2665
+
2666
+		max_unit_id := goodNameM["max_unit"].(string)
2667
+		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2668
+			err_log := models.ExportErrLog{
2669
+				LogType:    4,
2670
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2671
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量单位不能为空",
2672
+				Status:     1,
2673
+				CreateTime: time.Now().Unix(),
2674
+				UpdateTime: time.Now().Unix(),
2675
+				ExportTime: time.Now().Unix(),
2676
+			}
2677
+			service.CreateExportErrLog(&err_log)
2678
+			continue
2679
+		}
2618 2680
 
2619
-		drug_spec, _ := goodNameM["drug_spec"].(string)
2620
-		if len(drug_spec) == 0 { //名字为空则生成一条导入错误日志
2681
+		drug.MaxUnit = max_unit_id
2682
+
2683
+		packing_unit := goodNameM["packing_unit"].(string)
2684
+		if len(packing_unit) == 0 { //名字为空则生成一条导入错误日志
2621 2685
 			err_log := models.ExportErrLog{
2622 2686
 				LogType:    4,
2623 2687
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2624
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的药品规格不能为空",
2688
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的包装单位不能为空",
2625 2689
 				Status:     1,
2626 2690
 				CreateTime: time.Now().Unix(),
2627 2691
 				UpdateTime: time.Now().Unix(),
@@ -2631,7 +2695,58 @@ func (this *StockManagerApiController) AddDrugInformation() {
2631 2695
 			continue
2632 2696
 		}
2633 2697
 
2634
-		drug.DrugSpec = drug_spec
2698
+		drug.PackingUnit = packing_unit
2699
+
2700
+		delivery_way := goodNameM["delivery_way"].(string)
2701
+		if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
2702
+			err_log := models.ExportErrLog{
2703
+				LogType:    4,
2704
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2705
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
2706
+				Status:     1,
2707
+				CreateTime: time.Now().Unix(),
2708
+				UpdateTime: time.Now().Unix(),
2709
+				ExportTime: time.Now().Unix(),
2710
+			}
2711
+			service.CreateExportErrLog(&err_log)
2712
+			continue
2713
+		}
2714
+
2715
+		drug.DeliveryWay = delivery_way
2716
+
2717
+		execution_frequency := goodNameM["execution_frequency"].(string)
2718
+		if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
2719
+			err_log := models.ExportErrLog{
2720
+				LogType:    4,
2721
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2722
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
2723
+				Status:     1,
2724
+				CreateTime: time.Now().Unix(),
2725
+				UpdateTime: time.Now().Unix(),
2726
+				ExportTime: time.Now().Unix(),
2727
+			}
2728
+			service.CreateExportErrLog(&err_log)
2729
+			continue
2730
+		}
2731
+
2732
+		drug.ExecutionFrequency = execution_frequency
2733
+
2734
+		drug_day := goodNameM["drug_day"].(string)
2735
+		if len(drug_day) == 0 { //名字为空则生成一条导入错误日志
2736
+			err_log := models.ExportErrLog{
2737
+				LogType:    4,
2738
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2739
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
2740
+				Status:     1,
2741
+				CreateTime: time.Now().Unix(),
2742
+				UpdateTime: time.Now().Unix(),
2743
+				ExportTime: time.Now().Unix(),
2744
+			}
2745
+			service.CreateExportErrLog(&err_log)
2746
+			continue
2747
+		}
2748
+
2749
+		drug.DrugDay = drug_day
2635 2750
 
2636 2751
 		drug_type := goodNameM["drug_type"].(string)
2637 2752
 		if len(drug_type) == 0 { //名字为空则生成一条导入错误日志
@@ -2828,12 +2943,12 @@ func (this *StockManagerApiController) AddDrugInformation() {
2828 2943
 		}
2829 2944
 		drug.MedicalInsuranceLevel = medical_insurance_level_id
2830 2945
 
2831
-		max_unit_id := goodNameM["max_unit"].(string)
2946
+		unit_matrixing := goodNameM["unit_matrixing"].(string)
2832 2947
 		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2833 2948
 			err_log := models.ExportErrLog{
2834 2949
 				LogType:    4,
2835 2950
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2836
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的最大不能为空",
2951
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
2837 2952
 				Status:     1,
2838 2953
 				CreateTime: time.Now().Unix(),
2839 2954
 				UpdateTime: time.Now().Unix(),
@@ -2843,14 +2958,15 @@ func (this *StockManagerApiController) AddDrugInformation() {
2843 2958
 			continue
2844 2959
 		}
2845 2960
 
2846
-		drug.MaxUnit = max_unit_id
2961
+		drug.UnitMatrixing = unit_matrixing
2962
+		retail_prices := goodNameM["retail_price"].(string)
2963
+		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2847 2964
 
2848
-		min_unit := goodNameM["min_unit"].(string)
2849
-		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2965
+		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2850 2966
 			err_log := models.ExportErrLog{
2851 2967
 				LogType:    4,
2852 2968
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2853
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的最小单位不能为空",
2969
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零售价不能为空",
2854 2970
 				Status:     1,
2855 2971
 				CreateTime: time.Now().Unix(),
2856 2972
 				UpdateTime: time.Now().Unix(),
@@ -2860,32 +2976,16 @@ func (this *StockManagerApiController) AddDrugInformation() {
2860 2976
 			continue
2861 2977
 		}
2862 2978
 
2863
-		drug.MinUnit = min_unit
2864
-
2865
-		unit_matrixing := goodNameM["unit_matrixing"].(string)
2866
-		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2867
-			err_log := models.ExportErrLog{
2868
-				LogType:    4,
2869
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2870
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
2871
-				Status:     1,
2872
-				CreateTime: time.Now().Unix(),
2873
-				UpdateTime: time.Now().Unix(),
2874
-				ExportTime: time.Now().Unix(),
2875
-			}
2876
-			service.CreateExportErrLog(&err_log)
2877
-			continue
2878
-		}
2979
+		drug.RetailPrice = retail_price
2879 2980
 
2880
-		drug.UnitMatrixing = unit_matrixing
2881
-		retail_prices := goodNameM["retail_price"].(string)
2882
-		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2981
+		packing_prices := goodNameM["packing_price"].(string)
2982
+		packing_price, _ := strconv.ParseFloat(packing_prices, 64)
2883 2983
 
2884
-		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2984
+		if packing_price <= 0 { //名字为空则生成一条导入错误日志
2885 2985
 			err_log := models.ExportErrLog{
2886 2986
 				LogType:    4,
2887 2987
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2888
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的零售价不能为空",
2988
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的包装零售价不能为空",
2889 2989
 				Status:     1,
2890 2990
 				CreateTime: time.Now().Unix(),
2891 2991
 				UpdateTime: time.Now().Unix(),
@@ -2903,7 +3003,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2903 3003
 			err_log := models.ExportErrLog{
2904 3004
 				LogType:    4,
2905 3005
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2906
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的上次进价不能为空",
3006
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的进价不能为空",
2907 3007
 				Status:     1,
2908 3008
 				CreateTime: time.Now().Unix(),
2909 3009
 				UpdateTime: time.Now().Unix(),
@@ -2968,6 +3068,77 @@ func (this *StockManagerApiController) AddDrugInformation() {
2968 3068
 			}
2969 3069
 		}
2970 3070
 
3071
+		drug_dose := goodNameM["drug_dose"].(string)
3072
+
3073
+		if len(drug_dose) == 0 {
3074
+			err_log := models.ExportErrLog{
3075
+				LogType:    4,
3076
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3077
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量不能为空",
3078
+				Status:     1,
3079
+				CreateTime: time.Now().Unix(),
3080
+				UpdateTime: time.Now().Unix(),
3081
+				ExportTime: time.Now().Unix(),
3082
+			}
3083
+			service.CreateExportErrLog(&err_log)
3084
+			continue
3085
+		}
3086
+		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3087
+		drug.DrugDose = drugDoses
3088
+
3089
+		var units = "单位"
3090
+		var unit_id int64
3091
+		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3092
+
3093
+		if len(drugDoseUnit) == 0 {
3094
+			err_log := models.ExportErrLog{
3095
+				LogType:    4,
3096
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3097
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量单位不能为空",
3098
+				Status:     1,
3099
+				CreateTime: time.Now().Unix(),
3100
+				UpdateTime: time.Now().Unix(),
3101
+				ExportTime: time.Now().Unix(),
3102
+			}
3103
+			service.CreateExportErrLog(&err_log)
3104
+			continue
3105
+		}
3106
+
3107
+		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3108
+		if len(drugDoseUnit) != 0 {
3109
+			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3110
+			if errcodedataconfig == gorm.ErrRecordNotFound {
3111
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3112
+				dataconfig := models.Dataconfig{
3113
+					ParentId:       dataConfig.ID,
3114
+					Module:         "hemodialysis",
3115
+					OrgId:          orgId,
3116
+					Name:           drugDoseUnit,
3117
+					FieldName:      "",
3118
+					Value:          childConfig.Value + 1,
3119
+					CreatedTime:    "",
3120
+					UpdatedTime:    "",
3121
+					CreateUserId:   adminUser.AdminUser.Id,
3122
+					Status:         1,
3123
+					Remark:         "",
3124
+					DeleteIdSystem: 0,
3125
+					Title:          "",
3126
+					Content:        "",
3127
+					Order:          0,
3128
+					Code:           "",
3129
+					FieldType:      0,
3130
+				}
3131
+				service.CreateDataConfig(&dataconfig)
3132
+			}
3133
+		}
3134
+		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3135
+		for _, it := range list {
3136
+			if drugDoseUnit == it.Name {
3137
+				unit_id = int64(it.Value)
3138
+			}
3139
+		}
3140
+		drug.DrugDoseUnit = unit_id
3141
+
2971 3142
 		drug.DrugClassify = strconv.FormatInt(drug_classify_id, 10)
2972 3143
 
2973 3144
 		manufacturer := goodNameM["manufacturer"].(string)
@@ -3033,14 +3204,61 @@ func (this *StockManagerApiController) AddDrugInformation() {
3033 3204
 		}
3034 3205
 		drug.Dealer = dealer_id
3035 3206
 
3036
-		pinyin := goodNameM["pinyin"].(string)
3207
+		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3037 3208
 
3038
-		drug.Pinyin = pinyin
3039
-		wubi := goodNameM["wubi"].(string)
3040
-		drug.Wubi = wubi
3209
+		drug.LmtUsedFlag = lmt_used_flags
3210
+
3211
+		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
3212
+			utils.ErrorLog("drug_alias")
3213
+			return
3214
+		}
3041 3215
 
3042
-		drug_alias_pinyin := goodNameM["drug_alias_pinyin"].(string)
3043
-		drug.DrugAliasPinyin = drug_alias_pinyin
3216
+		drug_alias, _ := goodNameM["drug_alias"].(string)
3217
+
3218
+		drug.DrugAlias = drug_alias
3219
+
3220
+		drug_category := goodNameM["drug_category"].(string)
3221
+
3222
+		var drugCategory = "药品类别"
3223
+		var drug_category_id int64
3224
+
3225
+		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3226
+
3227
+		if len(drug_category) != 0 {
3228
+			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3229
+			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3230
+				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3231
+				dataconfig := models.DictDataconfig{
3232
+					ParentId:       drugCategoryConfig.ID,
3233
+					Module:         "system",
3234
+					OrgId:          orgId,
3235
+					Name:           drug_category,
3236
+					FieldName:      "",
3237
+					Value:          drugCategoryConfigSix.Value + 1,
3238
+					CreatedTime:    "",
3239
+					UpdatedTime:    "",
3240
+					CreateUserId:   adminUser.AdminUser.Id,
3241
+					Status:         1,
3242
+					Remark:         "",
3243
+					DeleteIdSystem: 0,
3244
+					Title:          "",
3245
+					Content:        "",
3246
+					Order:          0,
3247
+					Code:           "",
3248
+				}
3249
+				service.CreatedDicConfig(&dataconfig)
3250
+			}
3251
+		}
3252
+
3253
+		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
3254
+		fmt.Println("drugCategoryList", drugCategoryList)
3255
+		for _, it := range drugCategoryList {
3256
+			if drug_category == it.Name {
3257
+				drug_category_id = int64(it.Value)
3258
+			}
3259
+		}
3260
+
3261
+		drug.DrugCategory = drug_category_id
3044 3262
 
3045 3263
 		statistics_category := goodNameM["statistics_category"].(string)
3046 3264
 
@@ -3153,9 +3371,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
3153 3371
 		limit_remark := goodNameM["limit_remark"].(string)
3154 3372
 		drug.LimitRemark = limit_remark
3155 3373
 
3156
-		drug_alias_wubi := goodNameM["drug_alias_wubi"].(string)
3157
-		drug.DrugAliasWubi = drug_alias_wubi
3158
-
3159 3374
 		drug_control := goodNameM["drug_control"].(string)
3160 3375
 
3161 3376
 		var drugControl = "开药控制"
@@ -3196,123 +3411,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
3196 3411
 		}
3197 3412
 		drug.DrugControl = drug_control_id
3198 3413
 
3199
-		drug_category := goodNameM["drug_category"].(string)
3200
-
3201
-		var drugCategory = "药品类别"
3202
-		var drug_category_id int64
3203
-
3204
-		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3205
-
3206
-		if len(drug_category) != 0 {
3207
-			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3208
-			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3209
-				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3210
-				dataconfig := models.DictDataconfig{
3211
-					ParentId:       drugCategoryConfig.ID,
3212
-					Module:         "system",
3213
-					OrgId:          orgId,
3214
-					Name:           drug_category,
3215
-					FieldName:      "",
3216
-					Value:          drugCategoryConfigSix.Value + 1,
3217
-					CreatedTime:    "",
3218
-					UpdatedTime:    "",
3219
-					CreateUserId:   adminUser.AdminUser.Id,
3220
-					Status:         1,
3221
-					Remark:         "",
3222
-					DeleteIdSystem: 0,
3223
-					Title:          "",
3224
-					Content:        "",
3225
-					Order:          0,
3226
-					Code:           "",
3227
-				}
3228
-				service.CreatedDicConfig(&dataconfig)
3229
-			}
3230
-		}
3231
-
3232
-		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
3233
-		fmt.Println("drugCategoryList", drugCategoryList)
3234
-		for _, it := range drugCategoryList {
3235
-			if drug_category == it.Name {
3236
-				drug_category_id = int64(it.Value)
3237
-			}
3238
-		}
3239
-
3240
-		drug.DrugCategory = drug_category_id
3241
-
3242
-		drug_dose := goodNameM["drug_dose"].(string)
3243
-
3244
-		if len(drug_dose) == 0 {
3245
-			err_log := models.ExportErrLog{
3246
-				LogType:    4,
3247
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3248
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3249
-				Status:     1,
3250
-				CreateTime: time.Now().Unix(),
3251
-				UpdateTime: time.Now().Unix(),
3252
-				ExportTime: time.Now().Unix(),
3253
-			}
3254
-			service.CreateExportErrLog(&err_log)
3255
-			continue
3256
-		}
3257
-		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3258
-		drug.DrugDose = drugDoses
3259
-
3260
-		var units = "单位"
3261
-		var unit_id int64
3262
-		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3263
-
3264
-		if len(drugDoseUnit) == 0 {
3265
-			err_log := models.ExportErrLog{
3266
-				LogType:    4,
3267
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3268
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3269
-				Status:     1,
3270
-				CreateTime: time.Now().Unix(),
3271
-				UpdateTime: time.Now().Unix(),
3272
-				ExportTime: time.Now().Unix(),
3273
-			}
3274
-			service.CreateExportErrLog(&err_log)
3275
-			continue
3276
-		}
3277
-
3278
-		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3279
-		if len(drugDoseUnit) != 0 {
3280
-			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3281
-			if errcodedataconfig == gorm.ErrRecordNotFound {
3282
-				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3283
-				dataconfig := models.Dataconfig{
3284
-					ParentId:       dataConfig.ID,
3285
-					Module:         "hemodialysis",
3286
-					OrgId:          orgId,
3287
-					Name:           drugDoseUnit,
3288
-					FieldName:      "",
3289
-					Value:          childConfig.Value + 1,
3290
-					CreatedTime:    "",
3291
-					UpdatedTime:    "",
3292
-					CreateUserId:   adminUser.AdminUser.Id,
3293
-					Status:         1,
3294
-					Remark:         "",
3295
-					DeleteIdSystem: 0,
3296
-					Title:          "",
3297
-					Content:        "",
3298
-					Order:          0,
3299
-					Code:           "",
3300
-					FieldType:      0,
3301
-				}
3302
-				service.CreateDataConfig(&dataconfig)
3303
-			}
3304
-		}
3305
-		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3306
-		for _, it := range list {
3307
-			if drugDoseUnit == it.Name {
3308
-				unit_id = int64(it.Value)
3309
-			}
3310
-		}
3311
-		drug.DrugDoseUnit = unit_id
3312
-
3313
-		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3314
-
3315
-		drug.LmtUsedFlag = lmt_used_flags
3316 3414
 		drugList = append(drugList, &drug)
3317 3415
 	}
3318 3416
 
@@ -3365,10 +3463,17 @@ func (this *StockManagerApiController) AddDrugInformation() {
3365 3463
 				DrugDose:                    item.DrugDose,
3366 3464
 				DrugDoseUnit:                item.DrugDoseUnit,
3367 3465
 				LmtUsedFlag:                 item.LmtUsedFlag,
3466
+				Dosage:                      item.Dosage,
3467
+				Unval:                       item.Unval,
3468
+				PackingUnit:                 item.PackingUnit,
3469
+				PackingPrice:                item.PackingPrice,
3470
+				DrugDay:                     item.DrugDay,
3471
+				DeliveryWay:                 item.DeliveryWay,
3472
+				ExecutionFrequency:          item.ExecutionFrequency,
3368 3473
 			}
3369 3474
 
3370 3475
 			//查询同种药品同种规格是否存在
3371
-			_, drugerror := service.IsExistDrugByName(item.DrugName, item.DrugSpec, orgId)
3476
+			_, drugerror := service.IsExistDrugByNameOne(item.DrugName, item.Dosage, item.MaxUnit, item.Unval, item.MinUnit, item.PackingUnit, orgId)
3372 3477
 
3373 3478
 			if drugerror == gorm.ErrRecordNotFound {
3374 3479
 				service.CreateDrugsInfomation(&goodInfo)

+ 5 - 0
models/drug.go View File

@@ -60,6 +60,11 @@ type BaseDrugLib struct {
60 60
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
61 61
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
62 62
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
63
+	Dosage       string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
64
+	Unval        string  `gorm:"column:unval" json:"unval" form:"unval"`
65
+	PackingUnit  string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
66
+	PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
67
+	DrugDay      string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
63 68
 }
64 69
 
65 70
 func (BaseDrugLib) TableName() string {

+ 11 - 0
service/manage_center_service.go View File

@@ -158,6 +158,11 @@ func FindBaseDrugLibRecordCount(lib *models.BaseDrugLib) (count int64) {
158 158
 	return
159 159
 }
160 160
 
161
+func FindBaseDrugLibRecordCountOne(lib *models.BaseDrugLib) (count int64) {
162
+	readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_name = ? and dosage = ? and max_unit = ? and unval = ? and min_unit = ? and packing_unit = ? and manufacturer = ? and status = 1", lib.OrgId, lib.DrugName, lib.Dosage, lib.MaxUnit, lib.Unval, lib.MinUnit, lib.PackingUnit, lib.Manufacturer).Count(&count)
163
+	return
164
+}
165
+
161 166
 func FindAllDrugLibRecordTotal(org_id int64) (count int64) {
162 167
 	readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND status = 1", org_id).Count(&count)
163 168
 	return
@@ -357,3 +362,9 @@ func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
357 362
 	err := readDb.Model(&models.DictDataconfig{}).Where(" (user_org_id = ? Or user_org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
358 363
 	return err, data.Code
359 364
 }
365
+
366
+func GetAllDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
367
+
368
+	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
369
+	return drug, err
370
+}

+ 44 - 14
service/stock_service.go View File

@@ -540,19 +540,24 @@ func (VMDrugWarehouseInfo) TableName() string {
540 540
 }
541 541
 
542 542
 type Drug struct {
543
-	ID              int64  `gorm:"column:id" json:"id" form:"id"`
544
-	DrugName        string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
545
-	DrugSpec        string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
546
-	DrugType        int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
547
-	DrugStockLimit  string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
548
-	DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
549
-	DrugDosageForm  int64  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
550
-	Manufacturer    int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
551
-	Status          int64  `gorm:"column:status" json:"status" form:"status"`
552
-	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
553
-	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
554
-	OrgId           int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
555
-	DrugCode        string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
543
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
544
+	DrugName        string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
545
+	DrugSpec        string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
546
+	DrugType        int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
547
+	DrugStockLimit  string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
548
+	DrugOriginPlace string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
549
+	DrugDosageForm  int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
550
+	Manufacturer    int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
551
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
552
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
553
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
554
+	OrgId           int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
555
+	DrugCode        string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
556
+	Dosage          string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
557
+	Unval           string  `gorm:"column:unval" json:"unval" form:"unval"`
558
+	PackingUnit     string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
559
+	PackingPrice    float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
560
+	DrugDay         string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
556 561
 }
557 562
 
558 563
 func (Drug) TableName() string {
@@ -2300,6 +2305,19 @@ func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.B
2300 2305
 	return &drug, nil
2301 2306
 }
2302 2307
 
2308
+func IsExistDrugByNameOne(drugname string, dosage string, maxunit string, unival string, minunit string, packtunit string, orgid int64) (*models.BaseDrugLib, error) {
2309
+	var drug models.BaseDrugLib
2310
+	var err error
2311
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and dosage = ?  and max_unit = ? and unval = ? and min_unit=? and packing_unit = ? and status =1 and org_id = ?", drugname, dosage, maxunit, unival, minunit, packtunit, orgid).Find(&drug).Error
2312
+	if err == gorm.ErrRecordNotFound {
2313
+		return nil, err
2314
+	}
2315
+	if err != nil {
2316
+		return nil, err
2317
+	}
2318
+	return &drug, nil
2319
+}
2320
+
2303 2321
 func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2304 2322
 	err := XTWriteDB().Create(&info).Error
2305 2323
 	return err
@@ -2307,7 +2325,7 @@ func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2307 2325
 
2308 2326
 func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
2309 2327
 
2310
-	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag}).Error
2328
+	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag, "delivery_way": drug.DeliveryWay, "execution_frequency": drug.ExecutionFrequency, "dosage": drug.Dosage, "unval": drug.Unval, "packing_unit": drug.PackingUnit, "packing_price": drug.PackingPrice, "drug_day": drug.DrugDay}).Error
2311 2329
 	return err
2312 2330
 }
2313 2331
 
@@ -2512,3 +2530,15 @@ func GetWarehouseOrderInfoList(orgid int64) (list []*models.WarehousingInfo, err
2512 2530
 	err = XTReadDB().Model(&list).Where("org_id = ? and status = 1", orgid).Order("id asc").Group("good_id").Find(&list).Error
2513 2531
 	return list, err
2514 2532
 }
2533
+
2534
+func GetSearchDrugList(keywords string, orgid int64) (drug []*models.BaseDrugLib, err error) {
2535
+
2536
+	db := XTReadDB().Model(&drug).Where("org_id=? and status=1 ", orgid)
2537
+	if len(keywords) > 0 {
2538
+		likekey := "%" + keywords + "%"
2539
+		err = db.Where("(drug_name LIKE ?)", likekey).Find(&drug).Error
2540
+	} else {
2541
+		err = db.Find(&drug).Error
2542
+	}
2543
+	return
2544
+}