Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
f868677694

+ 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
 #

+ 44 - 5
controllers/his_api_controller.go View File

@@ -3034,6 +3034,7 @@ func (c *HisApiController) PostProjectInformation() {
3034 3034
 		project.Pinyin = pinyin
3035 3035
 
3036 3036
 		wubi := projectM["wubi"].(string)
3037
+		fmt.Println("五笔333333333333333333333333333333", wubi)
3037 3038
 		project.Wubi = wubi
3038 3039
 
3039 3040
 		statistical_classification := projectM["statistical_classification"].(string)
@@ -3086,7 +3087,7 @@ func (c *HisApiController) PostProjectInformation() {
3086 3087
 		project.IsRecord = is_record
3087 3088
 
3088 3089
 		medical_code := projectM["medical_code"].(string)
3089
-		project.Wubi = medical_code
3090
+		project.MedicalCode = medical_code
3090 3091
 
3091 3092
 		tube_color := projectM["tube_color"].(string)
3092 3093
 
@@ -3128,8 +3129,10 @@ func (c *HisApiController) PostProjectInformation() {
3128 3129
 
3129 3130
 		project.TubeColor = tube_color_id
3130 3131
 
3132
+		single_dose := projectM["single_dose"].(string)
3133
+		project.SingleDose = single_dose
3131 3134
 		execution_frequency := projectM["execution_frequency"].(string)
3132
-		project.Wubi = execution_frequency
3135
+		project.ExecutionFrequency = execution_frequency
3133 3136
 
3134 3137
 		delivery_way := projectM["delivery_way"].(string)
3135 3138
 		project.DeliveryWay = delivery_way
@@ -3141,7 +3144,7 @@ func (c *HisApiController) PostProjectInformation() {
3141 3144
 		project.Total = total
3142 3145
 
3143 3146
 		medical_status := int64(projectM["medical_status"].(float64))
3144
-		project.TubeColor = medical_status
3147
+		project.MedicalStatus = medical_status
3145 3148
 
3146 3149
 		category := int64(projectM["category"].(float64))
3147 3150
 		project.Category = category
@@ -3156,7 +3159,8 @@ func (c *HisApiController) PostProjectInformation() {
3156 3159
 		remark := projectM["remark"].(string)
3157 3160
 		project.Remark = remark
3158 3161
 
3159
-		record_date := c.GetString("record_date")
3162
+		record_date := projectM["record_date"].(string)
3163
+		fmt.Println("日期222222222", record_date)
3160 3164
 		timeLayout := "2006-01-02"
3161 3165
 		loc, _ := time.LoadLocation("Local")
3162 3166
 
@@ -3170,7 +3174,42 @@ func (c *HisApiController) PostProjectInformation() {
3170 3174
 	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
3171 3175
 	if len(projectList) > 0 {
3172 3176
 		for _, item := range projectList {
3173
-			service.CreateProjectInfomation(item, orgId)
3177
+			project := models.HisProject{
3178
+				ProjectName:                 item.ProjectName,
3179
+				Price:                       item.Price,
3180
+				Unit:                        item.Unit,
3181
+				CostClassify:                item.CostClassify,
3182
+				ExecutiveSection:            item.ExecutiveSection,
3183
+				MedicalCoverage:             item.MedicalCoverage,
3184
+				UserOrgId:                   orgId,
3185
+				Status:                      1,
3186
+				CreatedTime:                 time.Now().Unix(),
3187
+				Pinyin:                      item.Pinyin,
3188
+				Wubi:                        item.Wubi,
3189
+				StatisticalClassification:   item.StatisticalClassification,
3190
+				DiseaseDirectory:            item.DiseaseDirectory,
3191
+				IsRecord:                    item.IsRecord,
3192
+				MedicalCode:                 item.MedicalCode,
3193
+				TubeColor:                   item.TubeColor,
3194
+				SingleDose:                  item.SingleDose,
3195
+				DeliveryWay:                 item.DeliveryWay,
3196
+				NumberDays:                  item.NumberDays,
3197
+				Total:                       item.Total,
3198
+				Category:                    item.Category,
3199
+				MedicalStatus:               item.MedicalStatus,
3200
+				SpecailProject:              item.SpecailProject,
3201
+				RecordDate:                  item.RecordDate,
3202
+				Remark:                      item.Remark,
3203
+				SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
3204
+				ExecutionFrequency:          item.ExecutionFrequency,
3205
+			}
3206
+
3207
+			_, errcodeproject := service.GetProjectByNameIsExsit(item.ProjectName, orgId)
3208
+			if errcodeproject == gorm.ErrRecordNotFound {
3209
+				service.CreateProjectInfomation(&project)
3210
+			} else if errcodeproject == nil {
3211
+				service.UpdateProjectByName(&project, item.ProjectName, orgId)
3212
+			}
3174 3213
 
3175 3214
 			log := models.ExportLog{
3176 3215
 				LogType:    6,

+ 4 - 5
controllers/manager_center_api_controller.go View File

@@ -340,7 +340,6 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
340 340
 	//查询是否存在
341 341
 	_, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
342 342
 	if errOne == gorm.ErrRecordNotFound {
343
-		fmt.Println("进来了吗")
344 343
 		c.ServeSuccessJSON(map[string]interface{}{
345 344
 			"msg": "修改成功",
346 345
 		})
@@ -376,7 +375,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
376 375
 	_, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
377 376
 
378 377
 	if errThree == gorm.ErrRecordNotFound {
379
-		fmt.Println("进来了吗2")
378
+
380 379
 		c.ServeSuccessJSON(map[string]interface{}{
381 380
 			"msg": "修改成功",
382 381
 		})
@@ -398,7 +397,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
398 397
 
399 398
 	_, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
400 399
 	if errFour == gorm.ErrRecordNotFound {
401
-		fmt.Println("进来了吗3")
400
+
402 401
 		c.ServeSuccessJSON(map[string]interface{}{
403 402
 			"msg": "修改成功",
404 403
 		})
@@ -414,7 +413,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
414 413
 
415 414
 	_, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
416 415
 	if errFive == gorm.ErrRecordNotFound {
417
-		fmt.Println("进来了吗4")
416
+
418 417
 		c.ServeSuccessJSON(map[string]interface{}{
419 418
 			"msg": "修改成功",
420 419
 		})
@@ -1591,7 +1590,7 @@ func (c *ManagerCenterApiController) ModifyGoodInfo() {
1591 1590
 		ProductionType:              production_type,
1592 1591
 	}
1593 1592
 
1594
-	totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id)
1593
+	totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
1595 1594
 	if totals > 0 {
1596 1595
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1597 1596
 		return

+ 134 - 38
controllers/stock_in_api_controller.go View File

@@ -2284,15 +2284,11 @@ func (this *StockManagerApiController) AddGoodInformation() {
2284 2284
 			service.CreateExportErrLog(&err_log)
2285 2285
 			continue
2286 2286
 		}
2287
-		fmt.Println("33333333", unit_id)
2288
-		good.GoodUnit = unit_id
2289 2287
 
2290
-		if goodNameM["retail_price"] == nil || reflect.TypeOf(goodNameM["retail_price"]).String() != "float64" {
2291
-			utils.ErrorLog("retail_price")
2292
-			return
2293
-		}
2288
+		good.GoodUnit = unit_id
2294 2289
 
2295
-		retail_price := goodNameM["retail_price"].(float64)
2290
+		retail_prices := goodNameM["retail_price"].(string)
2291
+		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2296 2292
 		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2297 2293
 			err_log := models.ExportErrLog{
2298 2294
 				LogType:    5,
@@ -2333,7 +2329,7 @@ func (this *StockManagerApiController) AddGoodInformation() {
2333 2329
 
2334 2330
 		var dealer_id int64
2335 2331
 		dealerName := goodNameM["dealer"].(string)
2336
-
2332
+		fmt.Println("经销商33333333", dealerName)
2337 2333
 		dealer := models.Dealer{
2338 2334
 			OrgId:      orgId,
2339 2335
 			Status:     1,
@@ -2371,14 +2367,10 @@ func (this *StockManagerApiController) AddGoodInformation() {
2371 2367
 		}
2372 2368
 		wubi := goodNameM["wubi"].(string)
2373 2369
 
2374
-		good.Pinyin = wubi
2370
+		good.Wubi = wubi
2375 2371
 
2376
-		if goodNameM["buy_price"] == nil || reflect.TypeOf(goodNameM["buy_price"]).String() != "float64" {
2377
-			utils.ErrorLog("buy_price")
2378
-			return
2379
-		}
2380
-
2381
-		buy_price := goodNameM["buy_price"].(float64)
2372
+		buy_prices := goodNameM["buy_price"].(string)
2373
+		buy_price, _ := strconv.ParseFloat(buy_prices, 64)
2382 2374
 		good.BuyPrice = buy_price
2383 2375
 
2384 2376
 		if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
@@ -2474,7 +2466,11 @@ func (this *StockManagerApiController) AddGoodInformation() {
2474 2466
 		}
2475 2467
 
2476 2468
 		good.StatisticsCategory = statistic_id
2469
+
2470
+		special_medical := goodNameM["special_medical"].(string)
2471
+		good.SpecialMedical = special_medical
2477 2472
 		goods = append(goods, &good)
2473
+
2478 2474
 	}
2479 2475
 
2480 2476
 	export_time := time.Now().Unix()
@@ -2482,7 +2478,44 @@ func (this *StockManagerApiController) AddGoodInformation() {
2482 2478
 	if len(goods) > 0 {
2483 2479
 
2484 2480
 		for _, item := range goods {
2485
-			service.CreateGoodsInfomation(item, orgId)
2481
+
2482
+			goodInfo := models.GoodInfo{
2483
+				GoodName:          item.GoodName,
2484
+				SpecificationName: item.SpecificationName,
2485
+				GoodKind:          item.GoodKind,
2486
+				GoodTypeId:        item.GoodTypeId,
2487
+				Dealer:            item.Dealer,
2488
+				GoodUnit:          item.GoodUnit,
2489
+				IsRecord:          item.IsRecord,
2490
+				IsSpecialDiseases: item.IsSpecialDiseases,
2491
+				Manufacturer:      item.Manufacturer,
2492
+				Pinyin:            item.Pinyin,
2493
+
2494
+				ProductionType:              item.ProductionType,
2495
+				Remark:                      item.Remark,
2496
+				RetailPrice:                 item.RetailPrice,
2497
+				SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
2498
+				SpecialMedical:              item.SpecialMedical,
2499
+				Wubi:                        item.Wubi,
2500
+				StockWarnCount:              item.StockWarnCount,
2501
+				MedicalInsuranceLevel:       item.MedicalInsuranceLevel,
2502
+				OrgId:                       orgId,
2503
+				Status:                      1,
2504
+				Ctime:                       time.Now().Unix(),
2505
+				StatisticsCategory:          item.StatisticsCategory,
2506
+				GoodCode:                    item.GoodCode,
2507
+				BuyPrice:                    item.BuyPrice,
2508
+				MedicalInsuranceNumber:      item.MedicalInsuranceNumber,
2509
+			}
2510
+
2511
+			//查询同种耗材名称同种类型同种规格的耗材是否存在
2512
+			_, errcodegood := service.GetGoodsInformaitonIsExist(item.GoodName, item.GoodTypeId, item.SpecificationName, orgId)
2513
+
2514
+			if errcodegood == gorm.ErrRecordNotFound {
2515
+				service.CreateGoodsInfomation(&goodInfo)
2516
+			} else if errcodegood == nil {
2517
+				service.UpdateGoodsInformation(&goodInfo, item.GoodName, item.GoodTypeId, item.SpecificationName, orgId)
2518
+			}
2486 2519
 
2487 2520
 			log := models.ExportLog{
2488 2521
 				LogType:    5,
@@ -2572,19 +2605,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
2572 2605
 		}
2573 2606
 
2574 2607
 		drug_alias, _ := goodNameM["drug_alias"].(string)
2575
-		if len(drug_alias) == 0 { //名字为空则生成一条导入错误日志
2576
-			err_log := models.ExportErrLog{
2577
-				LogType:    4,
2578
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2579
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的药品别名不能为空",
2580
-				Status:     1,
2581
-				CreateTime: time.Now().Unix(),
2582
-				UpdateTime: time.Now().Unix(),
2583
-				ExportTime: time.Now().Unix(),
2584
-			}
2585
-			service.CreateExportErrLog(&err_log)
2586
-			continue
2587
-		}
2588 2608
 
2589 2609
 		drug.DrugAlias = drug_alias
2590 2610
 
@@ -2693,7 +2713,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2693 2713
 		drug.DrugOriginPlace = drug_origin_place
2694 2714
 
2695 2715
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2696
-
2716
+		fmt.Println("药品剂型2222222222", drug_dosage_form)
2697 2717
 		if len(drug_dosage_form) == 0 {
2698 2718
 			err_log := models.ExportErrLog{
2699 2719
 				LogType:    4,
@@ -2738,10 +2758,11 @@ func (this *StockManagerApiController) AddDrugInformation() {
2738 2758
 
2739 2759
 		drugDosageList, _ := service.GetParentDataConfig(drugDosageconfig.ID, orgId)
2740 2760
 		for _, it := range drugDosageList {
2741
-			if drug_dosage == it.Name {
2742
-				drug_dosage_form_id = int64(it.ID)
2761
+			if drug_dosage_form == it.Name {
2762
+				drug_dosage_form_id = int64(it.Value)
2743 2763
 			}
2744 2764
 		}
2765
+		fmt.Println("hhhhhhh66666666666666", drug_dosage_form_id)
2745 2766
 		drug.DrugDosageForm = drug_dosage_form_id
2746 2767
 
2747 2768
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
@@ -2882,7 +2903,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2882 2903
 		drug.LastPrice = last_price
2883 2904
 
2884 2905
 		drug_classify := goodNameM["drug_classify"].(string)
2885
-		fmt.Println("drug_classify22222222222222222", drug_classify)
2906
+
2886 2907
 		if len(drug_classify) == 0 { //名字为空则生成一条导入错误日志
2887 2908
 			err_log := models.ExportErrLog{
2888 2909
 				LogType:    4,
@@ -2929,12 +2950,11 @@ func (this *StockManagerApiController) AddDrugInformation() {
2929 2950
 		drugClassList, _ := service.GetParentDataConfig(drugClassifyConfig.ID, orgId)
2930 2951
 		for _, it := range drugClassList {
2931 2952
 			if drug_classify == it.Name {
2932
-				fmt.Println("88888888888888888", it.Name)
2933
-				fmt.Println("hhhhhhhhhhhh", drug_classify)
2934 2953
 				drug_classify_id = int64(it.Value)
2935 2954
 			}
2936 2955
 		}
2937
-		drug.DrugCategory = drug_classify_id
2956
+
2957
+		drug.DrugClassify = strconv.FormatInt(drug_classify_id, 10)
2938 2958
 
2939 2959
 		manufacturer := goodNameM["manufacturer"].(string)
2940 2960
 		if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
@@ -3102,7 +3122,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
3102 3122
 		social_security_directory_code := goodNameM["social_security_directory_code"].(string)
3103 3123
 		drug.SocialSecurityDirectoryCode = social_security_directory_code
3104 3124
 		record_date := goodNameM["record_date"].(string)
3105
-		fmt.Println("日期2222222222", record_date)
3125
+
3106 3126
 		timeLayout := "2006-01-02"
3107 3127
 		loc, _ := time.LoadLocation("Local")
3108 3128
 
@@ -3196,9 +3216,82 @@ func (this *StockManagerApiController) AddDrugInformation() {
3196 3216
 				drug_category_id = int64(it.Value)
3197 3217
 			}
3198 3218
 		}
3199
-		fmt.Println("666666666666666666666", drug_category_id)
3219
+
3200 3220
 		drug.DrugCategory = drug_category_id
3201 3221
 
3222
+		drug_dose := goodNameM["drug_dose"].(string)
3223
+
3224
+		if len(drug_dose) == 0 {
3225
+			err_log := models.ExportErrLog{
3226
+				LogType:    4,
3227
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3228
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3229
+				Status:     1,
3230
+				CreateTime: time.Now().Unix(),
3231
+				UpdateTime: time.Now().Unix(),
3232
+				ExportTime: time.Now().Unix(),
3233
+			}
3234
+			service.CreateExportErrLog(&err_log)
3235
+			continue
3236
+		}
3237
+		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3238
+		drug.DrugDose = drugDoses
3239
+
3240
+		var units = "单位"
3241
+		var unit_id int64
3242
+		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3243
+
3244
+		if len(drugDoseUnit) == 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
+
3258
+		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3259
+		if len(drugDoseUnit) != 0 {
3260
+			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3261
+			if errcodedataconfig == gorm.ErrRecordNotFound {
3262
+				dataconfig := models.Dataconfig{
3263
+					ParentId:       dataConfig.ID,
3264
+					Module:         "hemodialysis",
3265
+					OrgId:          orgId,
3266
+					Name:           drugDoseUnit,
3267
+					FieldName:      "",
3268
+					Value:          index + 50,
3269
+					CreatedTime:    "",
3270
+					UpdatedTime:    "",
3271
+					CreateUserId:   adminUser.AdminUser.Id,
3272
+					Status:         1,
3273
+					Remark:         "",
3274
+					DeleteIdSystem: 0,
3275
+					Title:          "",
3276
+					Content:        "",
3277
+					Order:          0,
3278
+					Code:           "",
3279
+					FieldType:      0,
3280
+				}
3281
+				service.CreateDataConfig(&dataconfig)
3282
+			}
3283
+		}
3284
+		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3285
+		for _, it := range list {
3286
+			if drugDoseUnit == it.Name {
3287
+				unit_id = int64(it.Value)
3288
+			}
3289
+		}
3290
+		drug.DrugDoseUnit = unit_id
3291
+
3292
+		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3293
+
3294
+		drug.LmtUsedFlag = lmt_used_flags
3202 3295
 		drugList = append(drugList, &drug)
3203 3296
 	}
3204 3297
 
@@ -3248,6 +3341,9 @@ func (this *StockManagerApiController) AddDrugInformation() {
3248 3341
 				DrugStatus:                  item.DrugStatus,
3249 3342
 				LimitRemark:                 item.LimitRemark,
3250 3343
 				DrugCategory:                item.DrugCategory,
3344
+				DrugDose:                    item.DrugDose,
3345
+				DrugDoseUnit:                item.DrugDoseUnit,
3346
+				LmtUsedFlag:                 item.LmtUsedFlag,
3251 3347
 			}
3252 3348
 
3253 3349
 			//查询同种药品同种规格是否存在

+ 1 - 0
models/drug.go View File

@@ -58,6 +58,7 @@ type BaseDrugLib struct {
58 58
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
59 59
 	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
60 60
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
61
+	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
61 62
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
62 63
 }
63 64
 

+ 83 - 62
service/stock_service.go View File

@@ -1978,8 +1978,8 @@ func FindGoodInfoByNameTwo(name string, org_id int64, good_type_id int64, good_n
1978 1978
 	return
1979 1979
 }
1980 1980
 
1981
-func FindGoodInfoByNameOne(name string, org_id int64, good_type_id int64, id int64) (total int64) {
1982
-	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and id <> ? ", org_id, name, good_type_id, id).Count(&total)
1981
+func FindGoodInfoByNameOne(name string, org_id int64, good_type_id int64, id int64, goodname string) (total int64) {
1982
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and id <> ? and good_name = ? ", org_id, name, good_type_id, id, goodname).Count(&total)
1983 1983
 	return
1984 1984
 }
1985 1985
 
@@ -2244,34 +2244,32 @@ func UpdatedManufactur(manufacturer *models.Manufacturer, orgid int64) error {
2244 2244
 	return err
2245 2245
 }
2246 2246
 
2247
-func CreateGoodsInfomation(info *models.GoodInfo, orgid int64) error {
2248
-
2249
-	goodInfo := models.GoodInfo{
2250
-		GoodName:                    info.GoodName,
2251
-		SpecificationName:           info.SpecificationName,
2252
-		GoodKind:                    info.GoodKind,
2253
-		GoodTypeId:                  info.GoodTypeId,
2254
-		Dealer:                      info.Dealer,
2255
-		GoodUnit:                    info.GoodUnit,
2256
-		IsRecord:                    info.IsRecord,
2257
-		IsSpecialDiseases:           info.IsSpecialDiseases,
2258
-		Manufacturer:                info.Manufacturer,
2259
-		Pinyin:                      info.Pinyin,
2260
-		ProductionType:              info.ProductionType,
2261
-		Remark:                      info.Remark,
2262
-		RetailPrice:                 info.RetailPrice,
2263
-		SocialSecurityDirectoryCode: info.SocialSecurityDirectoryCode,
2264
-		SpecialMedical:              info.SpecialMedical,
2265
-		Wubi:                        info.Wubi,
2266
-		StockWarnCount:              info.StockWarnCount,
2267
-		MedicalInsuranceLevel:       info.MedicalInsuranceLevel,
2268
-		OrgId:                       orgid,
2269
-		Status:                      1,
2270
-		Ctime:                       time.Now().Unix(),
2271
-		StatisticsCategory:          info.StatisticsCategory,
2272
-		GoodCode:                    info.GoodCode,
2273
-	}
2274
-	err := XTWriteDB().Create(&goodInfo).Error
2247
+func GetGoodsInformaitonIsExist(goodName string, goodType int64, specificationName string, orgid int64) (*models.GoodInfo, error) {
2248
+
2249
+	var good models.GoodInfo
2250
+	var err error
2251
+	err = XTReadDB().Model(&good).Where("good_name = ? and good_type_id = ? and specification_name = ? and org_id = ? and status = 1", goodName, goodType, specificationName, orgid).Find(&good).Error
2252
+	if err == gorm.ErrRecordNotFound {
2253
+		return nil, err
2254
+	}
2255
+
2256
+	if err != nil {
2257
+		return nil, err
2258
+	}
2259
+
2260
+	return &good, nil
2261
+
2262
+}
2263
+
2264
+func CreateGoodsInfomation(info *models.GoodInfo) error {
2265
+
2266
+	err := XTWriteDB().Create(&info).Error
2267
+	return err
2268
+}
2269
+
2270
+func UpdateGoodsInformation(info *models.GoodInfo, goodName string, goodType int64, specificationName string, orgid int64) error {
2271
+
2272
+	err := XTWriteDB().Model(&info).Where("good_name = ? and good_type_id = ? and specification_name = ? and org_id = ? and status = 1", goodName, goodType, specificationName, orgid).Updates(map[string]interface{}{"good_name": info.GoodName, "good_type_id": info.GoodTypeId, "medical_insurance_level": info.MedicalInsuranceLevel, "good_kind": info.GoodKind, "specification_name": info.SpecificationName, "manufacturer": info.Manufacturer, "good_unit": info.GoodUnit, "retail_price": info.RetailPrice, "stock_warn_count": info.StockWarnCount, "dealer": info.Dealer, "pinyin": info.Pinyin, "wubi": info.Wubi, "buy_price": info.BuyPrice, "medical_insurance_number": info.MedicalInsuranceNumber, "is_special_diseases": info.IsSpecialDiseases, "is_record": info.IsRecord, "statistics_category": info.StatisticsCategory, "good_status": info.GoodStatus, "social_security_directory_code": info.SocialSecurityDirectoryCode, "production_type": info.ProductionType, "special_medical": info.SpecialMedical, "remark": info.Remark}).Error
2275 2273
 	return err
2276 2274
 }
2277 2275
 
@@ -2308,44 +2306,35 @@ func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2308 2306
 
2309 2307
 func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
2310 2308
 
2311
-	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}).Error
2309
+	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
2312 2310
 	return err
2313 2311
 }
2314 2312
 
2315
-func CreateProjectInfomation(info *models.HisProject, orgid int64) error {
2316
-
2317
-	project := models.HisProject{
2318
-		ProjectName:                 info.ProjectName,
2319
-		Price:                       info.Price,
2320
-		Unit:                        info.Unit,
2321
-		CostClassify:                info.CostClassify,
2322
-		ExecutiveSection:            info.ExecutiveSection,
2323
-		MedicalCoverage:             info.MedicalCoverage,
2324
-		UserOrgId:                   orgid,
2325
-		Status:                      1,
2326
-		CreatedTime:                 time.Now().Unix(),
2327
-		Pinyin:                      info.Pinyin,
2328
-		Wubi:                        info.Wubi,
2329
-		StatisticalClassification:   info.StatisticalClassification,
2330
-		DiseaseDirectory:            info.DiseaseDirectory,
2331
-		IsRecord:                    info.IsRecord,
2332
-		MedicalCode:                 info.MedicalCode,
2333
-		TubeColor:                   info.TubeColor,
2334
-		SingleDose:                  info.SingleDose,
2335
-		DeliveryWay:                 info.DeliveryWay,
2336
-		NumberDays:                  info.NumberDays,
2337
-		Total:                       info.Total,
2338
-		Category:                    info.Category,
2339
-		MedicalStatus:               info.MedicalStatus,
2340
-		SpecailProject:              info.SpecailProject,
2341
-		RecordDate:                  info.RecordDate,
2342
-		Remark:                      info.Remark,
2343
-		SocialSecurityDirectoryCode: info.SocialSecurityDirectoryCode,
2344
-	}
2345
-	err := XTWriteDB().Create(&project).Error
2313
+func GetProjectByNameIsExsit(projectName string, orgid int64) (*models.HisProject, error) {
2314
+
2315
+	var projoect models.HisProject
2316
+	var err error
2317
+	err = XTReadDB().Model(&projoect).Where("project_name = ? and user_org_id = ? and status =1", projectName, orgid).Find(&projoect).Error
2318
+	if err == gorm.ErrRecordNotFound {
2319
+		return nil, err
2320
+	}
2321
+	if err != nil {
2322
+		return nil, err
2323
+	}
2324
+	return &projoect, nil
2325
+}
2326
+
2327
+func CreateProjectInfomation(info *models.HisProject) error {
2328
+
2329
+	err := XTWriteDB().Create(&info).Error
2346 2330
 	return err
2347 2331
 }
2348 2332
 
2333
+func UpdateProjectByName(project *models.HisProject, projectName string, orgid int64) error {
2334
+
2335
+	err := XTWriteDB().Model(&project).Where("project_name = ? and user_org_id = ? and status = 1", projectName, orgid).Updates(map[string]interface{}{"project_name": project.ProjectName, "price": project.Price, "unit": project.Unit, "cost_classify": project.CostClassify, "executive_section": project.ExecutiveSection, "medical_coverage": project.MedicalCoverage, "pinyin": project.Pinyin, "wubi": project.Wubi, "statistical_classification": project.StatisticalClassification, "disease_directory": project.DiseaseDirectory, "is_record": project.IsRecord, "medical_code": project.MedicalCode, "tube_color": project.TubeColor, "single_dose": project.SingleDose, "delivery_way": project.DeliveryWay, "execution_frequency": project.ExecutionFrequency, "number_days": project.NumberDays, "total": project.Total, "medical_status": project.MedicalStatus, "category": project.Category, "specail_project": project.SpecailProject, "social_security_directory_code": project.SocialSecurityDirectoryCode, "record_date": project.RecordDate, "remark": project.Remark}).Error
2336
+	return err
2337
+}
2349 2338
 func GetWareOutInfoById(warehouseoutid int64, orgid int64) (warehouseinfo []*models.WarehouseOutInfo, err error) {
2350 2339
 
2351 2340
 	err = XTReadDB().Model(&warehouseinfo).Where("warehouse_out_id = ? and org_id = ? and status= 1 and is_sys = 0", warehouseoutid, orgid).Find(&warehouseinfo).Error
@@ -2470,3 +2459,35 @@ func GetDepartMentByName(name string, orgid int64) (*models.XtHisDepartment, err
2470 2459
 	}
2471 2460
 	return &department, nil
2472 2461
 }
2462
+
2463
+func GetDataConfigIsExist(orgid int64, name string) (models.Dataconfig, error) {
2464
+	dataconfig := models.Dataconfig{}
2465
+	err := XTReadDB().Model(&dataconfig).Where("org_id = ? and name = ? and status = 1", orgid, name).Find(&dataconfig).Error
2466
+	return dataconfig, err
2467
+}
2468
+
2469
+func GetChildeConfigIsExist(parentid int64, name string, orgid int64) (*models.Dataconfig, error) {
2470
+
2471
+	var dataconfig models.Dataconfig
2472
+	var err error
2473
+	err = XTReadDB().Model(&dataconfig).Where("parent_id = ? and (org_id = ? or org_id = 0) and name = ? and status = 1", parentid, orgid, name).Find(&dataconfig).Error
2474
+	if err == gorm.ErrRecordNotFound {
2475
+		return nil, err
2476
+	}
2477
+	if err != nil {
2478
+		return nil, err
2479
+	}
2480
+	return &dataconfig, nil
2481
+}
2482
+
2483
+func CreateDataConfig(dataconfig *models.Dataconfig) error {
2484
+
2485
+	err := XTWriteDB().Create(&dataconfig).Error
2486
+	return err
2487
+}
2488
+
2489
+func FindAllDataConfigList(orgid int64, parentId int64) (dataconfig []*models.Dataconfig, err error) {
2490
+
2491
+	err = XTReadDB().Model(&dataconfig).Where("(org_id = ? or org_id = 0) and parent_id = ? and status = 1", orgid, parentId).Find(&dataconfig).Error
2492
+	return dataconfig, err
2493
+}