浏览代码

耗材参数

XMLWAN 4 年前
父节点
当前提交
f868677694

+ 1 - 1
conf/app.conf 查看文件

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

+ 44 - 5
controllers/his_api_controller.go 查看文件

3034
 		project.Pinyin = pinyin
3034
 		project.Pinyin = pinyin
3035
 
3035
 
3036
 		wubi := projectM["wubi"].(string)
3036
 		wubi := projectM["wubi"].(string)
3037
+		fmt.Println("五笔333333333333333333333333333333", wubi)
3037
 		project.Wubi = wubi
3038
 		project.Wubi = wubi
3038
 
3039
 
3039
 		statistical_classification := projectM["statistical_classification"].(string)
3040
 		statistical_classification := projectM["statistical_classification"].(string)
3086
 		project.IsRecord = is_record
3087
 		project.IsRecord = is_record
3087
 
3088
 
3088
 		medical_code := projectM["medical_code"].(string)
3089
 		medical_code := projectM["medical_code"].(string)
3089
-		project.Wubi = medical_code
3090
+		project.MedicalCode = medical_code
3090
 
3091
 
3091
 		tube_color := projectM["tube_color"].(string)
3092
 		tube_color := projectM["tube_color"].(string)
3092
 
3093
 
3128
 
3129
 
3129
 		project.TubeColor = tube_color_id
3130
 		project.TubeColor = tube_color_id
3130
 
3131
 
3132
+		single_dose := projectM["single_dose"].(string)
3133
+		project.SingleDose = single_dose
3131
 		execution_frequency := projectM["execution_frequency"].(string)
3134
 		execution_frequency := projectM["execution_frequency"].(string)
3132
-		project.Wubi = execution_frequency
3135
+		project.ExecutionFrequency = execution_frequency
3133
 
3136
 
3134
 		delivery_way := projectM["delivery_way"].(string)
3137
 		delivery_way := projectM["delivery_way"].(string)
3135
 		project.DeliveryWay = delivery_way
3138
 		project.DeliveryWay = delivery_way
3141
 		project.Total = total
3144
 		project.Total = total
3142
 
3145
 
3143
 		medical_status := int64(projectM["medical_status"].(float64))
3146
 		medical_status := int64(projectM["medical_status"].(float64))
3144
-		project.TubeColor = medical_status
3147
+		project.MedicalStatus = medical_status
3145
 
3148
 
3146
 		category := int64(projectM["category"].(float64))
3149
 		category := int64(projectM["category"].(float64))
3147
 		project.Category = category
3150
 		project.Category = category
3156
 		remark := projectM["remark"].(string)
3159
 		remark := projectM["remark"].(string)
3157
 		project.Remark = remark
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
 		timeLayout := "2006-01-02"
3164
 		timeLayout := "2006-01-02"
3161
 		loc, _ := time.LoadLocation("Local")
3165
 		loc, _ := time.LoadLocation("Local")
3162
 
3166
 
3170
 	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
3174
 	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
3171
 	if len(projectList) > 0 {
3175
 	if len(projectList) > 0 {
3172
 		for _, item := range projectList {
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
 			log := models.ExportLog{
3214
 			log := models.ExportLog{
3176
 				LogType:    6,
3215
 				LogType:    6,

+ 4 - 5
controllers/manager_center_api_controller.go 查看文件

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

+ 134 - 38
controllers/stock_in_api_controller.go 查看文件

2284
 			service.CreateExportErrLog(&err_log)
2284
 			service.CreateExportErrLog(&err_log)
2285
 			continue
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
 		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2292
 		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2297
 			err_log := models.ExportErrLog{
2293
 			err_log := models.ExportErrLog{
2298
 				LogType:    5,
2294
 				LogType:    5,
2333
 
2329
 
2334
 		var dealer_id int64
2330
 		var dealer_id int64
2335
 		dealerName := goodNameM["dealer"].(string)
2331
 		dealerName := goodNameM["dealer"].(string)
2336
-
2332
+		fmt.Println("经销商33333333", dealerName)
2337
 		dealer := models.Dealer{
2333
 		dealer := models.Dealer{
2338
 			OrgId:      orgId,
2334
 			OrgId:      orgId,
2339
 			Status:     1,
2335
 			Status:     1,
2371
 		}
2367
 		}
2372
 		wubi := goodNameM["wubi"].(string)
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
 		good.BuyPrice = buy_price
2374
 		good.BuyPrice = buy_price
2383
 
2375
 
2384
 		if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
2376
 		if goodNameM["social_security_directory_code"] == nil || reflect.TypeOf(goodNameM["social_security_directory_code"]).String() != "string" {
2474
 		}
2466
 		}
2475
 
2467
 
2476
 		good.StatisticsCategory = statistic_id
2468
 		good.StatisticsCategory = statistic_id
2469
+
2470
+		special_medical := goodNameM["special_medical"].(string)
2471
+		good.SpecialMedical = special_medical
2477
 		goods = append(goods, &good)
2472
 		goods = append(goods, &good)
2473
+
2478
 	}
2474
 	}
2479
 
2475
 
2480
 	export_time := time.Now().Unix()
2476
 	export_time := time.Now().Unix()
2482
 	if len(goods) > 0 {
2478
 	if len(goods) > 0 {
2483
 
2479
 
2484
 		for _, item := range goods {
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
 			log := models.ExportLog{
2520
 			log := models.ExportLog{
2488
 				LogType:    5,
2521
 				LogType:    5,
2572
 		}
2605
 		}
2573
 
2606
 
2574
 		drug_alias, _ := goodNameM["drug_alias"].(string)
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
 		drug.DrugAlias = drug_alias
2609
 		drug.DrugAlias = drug_alias
2590
 
2610
 
2693
 		drug.DrugOriginPlace = drug_origin_place
2713
 		drug.DrugOriginPlace = drug_origin_place
2694
 
2714
 
2695
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2715
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2696
-
2716
+		fmt.Println("药品剂型2222222222", drug_dosage_form)
2697
 		if len(drug_dosage_form) == 0 {
2717
 		if len(drug_dosage_form) == 0 {
2698
 			err_log := models.ExportErrLog{
2718
 			err_log := models.ExportErrLog{
2699
 				LogType:    4,
2719
 				LogType:    4,
2738
 
2758
 
2739
 		drugDosageList, _ := service.GetParentDataConfig(drugDosageconfig.ID, orgId)
2759
 		drugDosageList, _ := service.GetParentDataConfig(drugDosageconfig.ID, orgId)
2740
 		for _, it := range drugDosageList {
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
 		drug.DrugDosageForm = drug_dosage_form_id
2766
 		drug.DrugDosageForm = drug_dosage_form_id
2746
 
2767
 
2747
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2768
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2882
 		drug.LastPrice = last_price
2903
 		drug.LastPrice = last_price
2883
 
2904
 
2884
 		drug_classify := goodNameM["drug_classify"].(string)
2905
 		drug_classify := goodNameM["drug_classify"].(string)
2885
-		fmt.Println("drug_classify22222222222222222", drug_classify)
2906
+
2886
 		if len(drug_classify) == 0 { //名字为空则生成一条导入错误日志
2907
 		if len(drug_classify) == 0 { //名字为空则生成一条导入错误日志
2887
 			err_log := models.ExportErrLog{
2908
 			err_log := models.ExportErrLog{
2888
 				LogType:    4,
2909
 				LogType:    4,
2929
 		drugClassList, _ := service.GetParentDataConfig(drugClassifyConfig.ID, orgId)
2950
 		drugClassList, _ := service.GetParentDataConfig(drugClassifyConfig.ID, orgId)
2930
 		for _, it := range drugClassList {
2951
 		for _, it := range drugClassList {
2931
 			if drug_classify == it.Name {
2952
 			if drug_classify == it.Name {
2932
-				fmt.Println("88888888888888888", it.Name)
2933
-				fmt.Println("hhhhhhhhhhhh", drug_classify)
2934
 				drug_classify_id = int64(it.Value)
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
 		manufacturer := goodNameM["manufacturer"].(string)
2959
 		manufacturer := goodNameM["manufacturer"].(string)
2940
 		if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
2960
 		if len(manufacturer) == 0 { //名字为空则生成一条导入错误日志
3102
 		social_security_directory_code := goodNameM["social_security_directory_code"].(string)
3122
 		social_security_directory_code := goodNameM["social_security_directory_code"].(string)
3103
 		drug.SocialSecurityDirectoryCode = social_security_directory_code
3123
 		drug.SocialSecurityDirectoryCode = social_security_directory_code
3104
 		record_date := goodNameM["record_date"].(string)
3124
 		record_date := goodNameM["record_date"].(string)
3105
-		fmt.Println("日期2222222222", record_date)
3125
+
3106
 		timeLayout := "2006-01-02"
3126
 		timeLayout := "2006-01-02"
3107
 		loc, _ := time.LoadLocation("Local")
3127
 		loc, _ := time.LoadLocation("Local")
3108
 
3128
 
3196
 				drug_category_id = int64(it.Value)
3216
 				drug_category_id = int64(it.Value)
3197
 			}
3217
 			}
3198
 		}
3218
 		}
3199
-		fmt.Println("666666666666666666666", drug_category_id)
3219
+
3200
 		drug.DrugCategory = drug_category_id
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
 		drugList = append(drugList, &drug)
3295
 		drugList = append(drugList, &drug)
3203
 	}
3296
 	}
3204
 
3297
 
3248
 				DrugStatus:                  item.DrugStatus,
3341
 				DrugStatus:                  item.DrugStatus,
3249
 				LimitRemark:                 item.LimitRemark,
3342
 				LimitRemark:                 item.LimitRemark,
3250
 				DrugCategory:                item.DrugCategory,
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 查看文件

58
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
58
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
59
 	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
59
 	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
60
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
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
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
62
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
62
 }
63
 }
63
 
64
 

+ 83 - 62
service/stock_service.go 查看文件

1978
 	return
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
 	return
1983
 	return
1984
 }
1984
 }
1985
 
1985
 
2244
 	return err
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
 	return err
2273
 	return err
2276
 }
2274
 }
2277
 
2275
 
2308
 
2306
 
2309
 func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
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
 	return err
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
 	return err
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
 func GetWareOutInfoById(warehouseoutid int64, orgid int64) (warehouseinfo []*models.WarehouseOutInfo, err error) {
2338
 func GetWareOutInfoById(warehouseoutid int64, orgid int64) (warehouseinfo []*models.WarehouseOutInfo, err error) {
2350
 
2339
 
2351
 	err = XTReadDB().Model(&warehouseinfo).Where("warehouse_out_id = ? and org_id = ? and status= 1 and is_sys = 0", warehouseoutid, orgid).Find(&warehouseinfo).Error
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
 	}
2459
 	}
2471
 	return &department, nil
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
+}