Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
854ec63a69

+ 1 - 1
conf/app.conf View File

@@ -1,6 +1,6 @@
1 1
 appname = 血透
2 2
 httpport = 9531
3
-runmode = prod
3
+runmode = dev
4 4
 
5 5
 #
6 6
 copyrequestbody = true

+ 1 - 1
controllers/dialysis_record_api_controller.go View File

@@ -761,7 +761,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
761 761
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
762 762
 
763 763
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
764
-				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 {
764
+				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 36 {
765 765
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
766 766
 				}
767 767
 				// 只针对方济医院

+ 1 - 3
controllers/drug_stock_api_contorller.go View File

@@ -488,7 +488,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
488 488
 		Manufacturer:     manufacturer_id,
489 489
 	}
490 490
 
491
-	service.EditDrugWarehousing(warehousing)
491
+	service.EditDrugWarehousingOne(warehousing, id)
492 492
 
493 493
 	dataBody := make(map[string]interface{}, 0)
494 494
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
@@ -541,8 +541,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
541 541
 				var productDates int64
542 542
 				var expiryDates int64
543 543
 
544
-				fmt.Println()
545
-
546 544
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
547 545
 					expiryDates = 0
548 546
 				} else {

+ 243 - 25
controllers/his_api_controller.go View File

@@ -2806,7 +2806,8 @@ func (c *HisApiController) GetPutOnRecordList() {
2806 2806
 //}
2807 2807
 
2808 2808
 func (c *HisApiController) PostProjectInformation() {
2809
-
2809
+	adminUser := c.GetAdminUserInfo()
2810
+	orgId := adminUser.CurrentOrgId
2810 2811
 	dataBody := make(map[string]interface{}, 0)
2811 2812
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
2812 2813
 	if err != nil {
@@ -2817,7 +2818,7 @@ func (c *HisApiController) PostProjectInformation() {
2817 2818
 	var projectList []*models.HisProject
2818 2819
 	var total_goods []interface{}
2819 2820
 	tempProjects := dataBody["projects"].([]interface{})
2820
-
2821
+	fmt.Println("666666666666", tempProjects)
2821 2822
 	total_goods = tempProjects
2822 2823
 	for index, projectMap := range tempProjects {
2823 2824
 
@@ -2846,8 +2847,9 @@ func (c *HisApiController) PostProjectInformation() {
2846 2847
 
2847 2848
 		project.ProjectName = project_name
2848 2849
 
2849
-		price := projectM["price"].(float64)
2850
+		prices := projectM["price"].(string)
2850 2851
 
2852
+		price, _ := strconv.ParseFloat(prices, 64)
2851 2853
 		if price <= 0 { //名字为空则生成一条导入错误日志
2852 2854
 			err_log := models.ExportErrLog{
2853 2855
 				LogType:    6,
@@ -2874,7 +2876,7 @@ func (c *HisApiController) PostProjectInformation() {
2874 2876
 			err_log := models.ExportErrLog{
2875 2877
 				LogType:    6,
2876 2878
 				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2877
-				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空",
2879
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空或内容与系统不匹配",
2878 2880
 				Status:     1,
2879 2881
 				CreateTime: time.Now().Unix(),
2880 2882
 				UpdateTime: time.Now().Unix(),
@@ -2885,17 +2887,12 @@ func (c *HisApiController) PostProjectInformation() {
2885 2887
 		}
2886 2888
 		project.Unit = unit
2887 2889
 
2888
-		if projectM["cost_classify_id"] == nil || reflect.TypeOf(projectM["cost_classify_id"]).String() != "float64" {
2889
-			utils.ErrorLog("cost_classify_id")
2890
-			return
2891
-		}
2892
-
2893
-		cost_classify_id := int64(projectM["cost_classify_id"].(float64))
2894
-		if cost_classify_id <= 0 { //名字为空则生成一条导入错误日志
2890
+		cost_classify := projectM["cost_classify"].(string)
2891
+		if len(cost_classify) == 0 { //名字为空则生成一条导入错误日志
2895 2892
 			err_log := models.ExportErrLog{
2896 2893
 				LogType:    6,
2897 2894
 				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2898
-				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
2895
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空或内容与系统不匹配",
2899 2896
 				Status:     1,
2900 2897
 				CreateTime: time.Now().Unix(),
2901 2898
 				UpdateTime: time.Now().Unix(),
@@ -2904,13 +2901,51 @@ func (c *HisApiController) PostProjectInformation() {
2904 2901
 			service.CreateExportErrLog(&err_log)
2905 2902
 			continue
2906 2903
 		}
2904
+		var costClassify = "费用类别"
2905
+		var cost_classify_id int64
2906
+
2907
+		costClassifyConfig, _ := service.GetDrugDataConfig(0, costClassify)
2908
+
2909
+		if len(cost_classify) != 0 {
2910
+			_, errcode := service.IsExistDicConfig(costClassifyConfig.ID, cost_classify, orgId)
2911
+			if errcode == gorm.ErrRecordNotFound {
2912
+				dataconfig := models.DictDataconfig{
2913
+					ParentId:       costClassifyConfig.ID,
2914
+					Module:         "system",
2915
+					OrgId:          orgId,
2916
+					Name:           cost_classify,
2917
+					FieldName:      "",
2918
+					Value:          index + 50,
2919
+					CreatedTime:    "",
2920
+					UpdatedTime:    "",
2921
+					CreateUserId:   adminUser.AdminUser.Id,
2922
+					Status:         1,
2923
+					Remark:         "",
2924
+					DeleteIdSystem: 0,
2925
+					Title:          "",
2926
+					Content:        "",
2927
+					Order:          0,
2928
+					Code:           "",
2929
+				}
2930
+				service.CreatedDicConfig(&dataconfig)
2931
+			}
2932
+		}
2933
+
2934
+		costClassList, _ := service.GetParentDataConfig(costClassifyConfig.ID, orgId)
2935
+
2936
+		for _, it := range costClassList {
2937
+			if cost_classify == it.Name {
2938
+				cost_classify_id = int64(it.Value)
2939
+			}
2940
+		}
2907 2941
 		project.CostClassify = cost_classify_id
2908
-		executive_section_id := int64(projectM["executive_section_id"].(float64))
2909
-		if executive_section_id <= 0 { //名字为空则生成一条导入错误日志
2942
+
2943
+		executive_section := projectM["executive_section"].(string)
2944
+		if len(executive_section) == 0 { //名字为空则生成一条导入错误日志
2910 2945
 			err_log := models.ExportErrLog{
2911 2946
 				LogType:    6,
2912 2947
 				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2913
-				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
2948
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空或内容与系统不匹配",
2914 2949
 				Status:     1,
2915 2950
 				CreateTime: time.Now().Unix(),
2916 2951
 				UpdateTime: time.Now().Unix(),
@@ -2920,15 +2955,31 @@ func (c *HisApiController) PostProjectInformation() {
2920 2955
 			continue
2921 2956
 		}
2922 2957
 
2923
-		project.ExecutiveSection = executive_section_id
2924
-
2925
-		if projectM["medical_insurance_level_id"] == nil || reflect.TypeOf(projectM["medical_insurance_level_id"]).String() != "float64" {
2926
-			utils.ErrorLog("medical_insurance_level_id")
2927
-			return
2958
+		if len(executive_section) != 0 {
2959
+			//查找科室是否有内容
2960
+			_, errcodedepart := service.GetDepartMentByName(executive_section, orgId)
2961
+			if errcodedepart == gorm.ErrRecordNotFound {
2962
+				department := models.XtHisDepartment{
2963
+					Name:        executive_section,
2964
+					Status:      1,
2965
+					UserOrgId:   adminUser.CurrentOrgId,
2966
+					CreatedTime: time.Now().Unix(),
2967
+				}
2968
+				service.CreateDePartment(&department)
2969
+			}
2970
+		}
2971
+		var executive_section_id int64
2972
+		departMentList, _ := service.GetAllDepartMent(orgId)
2973
+		for _, it := range departMentList {
2974
+			if executive_section == it.Name {
2975
+				executive_section_id = it.ID
2976
+			}
2928 2977
 		}
2978
+		project.ExecutiveSection = executive_section_id
2929 2979
 
2930
-		medical_insurance_level_id := int64(projectM["medical_insurance_level_id"].(float64))
2931
-		if executive_section_id <= 0 { //名字为空则生成一条导入错误日志
2980
+		medical_coverage := projectM["medical_coverage"].(string)
2981
+		fmt.Println("3333333333333", medical_coverage)
2982
+		if len(medical_coverage) == 0 { //名字为空则生成一条导入错误日志
2932 2983
 			err_log := models.ExportErrLog{
2933 2984
 				LogType:    6,
2934 2985
 				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
@@ -2942,13 +2993,180 @@ func (c *HisApiController) PostProjectInformation() {
2942 2993
 			continue
2943 2994
 		}
2944 2995
 
2945
-		project.MedicalCoverage = medical_insurance_level_id
2996
+		var medicalCoverage = "医保等级"
2997
+		var medical_coverage_id int64
2998
+
2999
+		medicalCoverageConfig, _ := service.GetDrugDataConfig(0, medicalCoverage)
3000
+		if len(medical_coverage) != 0 {
3001
+
3002
+			_, errormedicalcoverage := service.IsExistDicConfig(medicalCoverageConfig.ID, medical_coverage, orgId)
3003
+			if errormedicalcoverage == gorm.ErrRecordNotFound {
3004
+				dataconfig := models.DictDataconfig{
3005
+					ParentId:       medicalCoverageConfig.ID,
3006
+					Module:         "system",
3007
+					OrgId:          orgId,
3008
+					Name:           medical_coverage,
3009
+					FieldName:      "",
3010
+					Value:          index + 50,
3011
+					CreatedTime:    "",
3012
+					UpdatedTime:    "",
3013
+					CreateUserId:   adminUser.AdminUser.Id,
3014
+					Status:         1,
3015
+					Remark:         "",
3016
+					DeleteIdSystem: 0,
3017
+					Title:          "",
3018
+					Content:        "",
3019
+					Order:          0,
3020
+					Code:           "",
3021
+				}
3022
+				service.CreatedDicConfig(&dataconfig)
3023
+			}
3024
+		}
3025
+		medicalCoverageList, _ := service.GetParentDataConfig(medicalCoverageConfig.ID, orgId)
3026
+		for _, it := range medicalCoverageList {
3027
+			if medical_coverage == it.Name {
3028
+				medical_coverage_id = int64(it.Value)
3029
+			}
3030
+		}
3031
+		project.MedicalCoverage = medical_coverage_id
3032
+
3033
+		pinyin := projectM["pinyin"].(string)
3034
+		project.Pinyin = pinyin
3035
+
3036
+		wubi := projectM["wubi"].(string)
3037
+		project.Wubi = wubi
3038
+
3039
+		statistical_classification := projectM["statistical_classification"].(string)
3040
+
3041
+		var statisticalClassification = "统计分类"
3042
+		var statistical_classification_id int64
3043
+		classiFication, _ := service.GetDrugDataConfig(0, statisticalClassification)
3044
+		if len(statistical_classification) != 0 {
3045
+
3046
+			_, classificationerrcodes := service.IsExistDicConfig(classiFication.ID, statistical_classification, orgId)
3047
+
3048
+			if classificationerrcodes == gorm.ErrRecordNotFound {
3049
+				dataconfig := models.DictDataconfig{
3050
+					ParentId:       classiFication.ID,
3051
+					Module:         "system",
3052
+					OrgId:          orgId,
3053
+					Name:           statistical_classification,
3054
+					FieldName:      "",
3055
+					Value:          index + 50,
3056
+					CreatedTime:    "",
3057
+					UpdatedTime:    "",
3058
+					CreateUserId:   adminUser.AdminUser.Id,
3059
+					Status:         1,
3060
+					Remark:         "",
3061
+					DeleteIdSystem: 0,
3062
+					Title:          "",
3063
+					Content:        "",
3064
+					Order:          0,
3065
+					Code:           "",
3066
+				}
3067
+				service.CreatedDicConfig(&dataconfig)
3068
+			}
2946 3069
 
3070
+		}
3071
+		classiFicationList, _ := service.GetParentDataConfig(classiFication.ID, orgId)
3072
+
3073
+		for _, it := range classiFicationList {
3074
+			if statistical_classification == it.Name {
3075
+
3076
+				statistical_classification_id = int64(it.Value)
3077
+			}
3078
+		}
3079
+
3080
+		project.StatisticalClassification = statistical_classification_id
3081
+
3082
+		disease_directory := int64(projectM["disease_directory"].(float64))
3083
+		project.DiseaseDirectory = disease_directory
3084
+
3085
+		is_record := int64(projectM["is_record"].(float64))
3086
+		project.IsRecord = is_record
3087
+
3088
+		medical_code := projectM["medical_code"].(string)
3089
+		project.Wubi = medical_code
3090
+
3091
+		tube_color := projectM["tube_color"].(string)
3092
+
3093
+		var tubeColor = "试管颜色"
3094
+		var tube_color_id int64
3095
+		tubeColorConfig, _ := service.GetDrugDataConfig(0, tubeColor)
3096
+		if len(tube_color) != 0 {
3097
+			_, errcodetube := service.IsExistDicConfig(tubeColorConfig.ID, tube_color, orgId)
3098
+			if errcodetube == gorm.ErrRecordNotFound {
3099
+				dataconfig := models.DictDataconfig{
3100
+					ParentId:       tubeColorConfig.ID,
3101
+					Module:         "system",
3102
+					OrgId:          orgId,
3103
+					Name:           tube_color,
3104
+					FieldName:      "",
3105
+					Value:          index + 50,
3106
+					CreatedTime:    "",
3107
+					UpdatedTime:    "",
3108
+					CreateUserId:   adminUser.AdminUser.Id,
3109
+					Status:         1,
3110
+					Remark:         "",
3111
+					DeleteIdSystem: 0,
3112
+					Title:          "",
3113
+					Content:        "",
3114
+					Order:          0,
3115
+					Code:           "",
3116
+				}
3117
+				service.CreatedDicConfig(&dataconfig)
3118
+			}
3119
+
3120
+		}
3121
+
3122
+		tubeColorList, _ := service.GetParentDataConfig(tubeColorConfig.ID, orgId)
3123
+		for _, it := range tubeColorList {
3124
+			if tube_color == it.Name {
3125
+				tube_color_id = int64(it.Value)
3126
+			}
3127
+		}
3128
+
3129
+		project.TubeColor = tube_color_id
3130
+
3131
+		execution_frequency := projectM["execution_frequency"].(string)
3132
+		project.Wubi = execution_frequency
3133
+
3134
+		delivery_way := projectM["delivery_way"].(string)
3135
+		project.DeliveryWay = delivery_way
3136
+
3137
+		number_days := projectM["number_days"].(string)
3138
+		project.NumberDays = number_days
3139
+
3140
+		total := projectM["total"].(string)
3141
+		project.Total = total
3142
+
3143
+		medical_status := int64(projectM["medical_status"].(float64))
3144
+		project.TubeColor = medical_status
3145
+
3146
+		category := int64(projectM["category"].(float64))
3147
+		project.Category = category
3148
+
3149
+		specail_project := int64(projectM["specail_project"].(float64))
3150
+		project.SpecailProject = specail_project
3151
+
3152
+		social_security_directory_code := projectM["social_security_directory_code"].(string)
3153
+		fmt.Println("社保目录编码22222222222", social_security_directory_code)
3154
+		project.SocialSecurityDirectoryCode = social_security_directory_code
3155
+
3156
+		remark := projectM["remark"].(string)
3157
+		project.Remark = remark
3158
+
3159
+		record_date := c.GetString("record_date")
3160
+		timeLayout := "2006-01-02"
3161
+		loc, _ := time.LoadLocation("Local")
3162
+
3163
+		theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
3164
+		project.RecordDate = theTime.Unix()
2947 3165
 		projectList = append(projectList, &project)
2948 3166
 	}
2949
-	adminUser := c.GetAdminUserInfo()
2950
-	orgId := adminUser.CurrentOrgId
3167
+
2951 3168
 	export_time := time.Now().Unix()
3169
+
2952 3170
 	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
2953 3171
 	if len(projectList) > 0 {
2954 3172
 		for _, item := range projectList {

+ 1 - 1
controllers/manager_center_api_controller.go View File

@@ -1441,7 +1441,7 @@ func (c *ManagerCenterApiController) CreateGoodInfo() {
1441 1441
 	special_medical := c.GetString("special_medical")
1442 1442
 	adminUserInfo := c.GetAdminUserInfo()
1443 1443
 
1444
-	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId, good_id)
1444
+	totals := service.FindGoodInfoByNameTwo(specification_name, adminUserInfo.CurrentOrgId, good_id, good_name)
1445 1445
 	if totals > 0 {
1446 1446
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1447 1447
 		return

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -335,7 +335,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
335 335
 
336 336
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
337 337
 
338
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 {
338
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 {
339 339
 		dewater_amount = dewater_amount * 1000
340 340
 	}
341 341
 

+ 2 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -2285,7 +2285,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2285 2285
 				record.UltrafiltrationRate = ultrafiltration_rate
2286 2286
 			}
2287 2287
 
2288
-			if template.TemplateId == 32 || template.TemplateId == 34 {
2288
+			if template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 {
2289 2289
 
2290 2290
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1)
2291 2291
 				record.UltrafiltrationRate = ultrafiltration_rate
@@ -2313,7 +2313,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2313 2313
 		}
2314 2314
 	}
2315 2315
 
2316
-	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 { //adminInfo.Org.Id == 9538
2316
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 { //adminInfo.Org.Id == 9538
2317 2317
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2318 2318
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2319 2319
 			record.UltrafiltrationVolume = ultrafiltration_volume

+ 154 - 103
controllers/schedule_api_controller.go View File

@@ -2011,112 +2011,163 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2011 2011
 	//获取本周患者排班
2012 2012
 	schedules, _ := service.GetWeekSchedules(orgId, start_time, end_time)
2013 2013
 
2014
-	//查询复制中的排班日期是否存在
2015
-	_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
2016
-
2017
-	if errcode == gorm.ErrRecordNotFound {
2018
-		//如果没有直接新增
2019
-
2020
-		for _, item := range schedules {
2021
-			//fmt.Println(item.StartTime+604800)
2022
-			//礼拜1
2023
-			if item.ScheduleWeek == 1 {
2024
-				item.ScheduleDate = copy_startime
2025
-			}
2026
-			if item.ScheduleWeek == 2 {
2027
-				item.ScheduleDate = copy_startime + 86400
2028
-			}
2029
-			if item.ScheduleWeek == 3 {
2030
-				item.ScheduleDate = copy_startime + 172800
2031
-			}
2032
-			if item.ScheduleWeek == 4 {
2033
-				item.ScheduleDate = copy_startime + 259200
2034
-			}
2035
-			if item.ScheduleWeek == 5 {
2036
-				item.ScheduleDate = copy_startime + 345600
2037
-			}
2038
-
2039
-			if item.ScheduleWeek == 6 {
2040
-				item.ScheduleDate = copy_startime + 432000
2041
-			}
2042
-			//礼拜天
2043
-			if item.ScheduleWeek == 0 {
2044
-				item.ScheduleDate = copy_endtime
2045
-			}
2046
-			schedule := models.XtSchedule{
2047
-				UserOrgId:    item.UserOrgId,
2048
-				PartitionId:  item.PartitionId,
2049
-				BedId:        item.BedId,
2050
-				PatientId:    item.PatientId,
2051
-				ScheduleDate: item.ScheduleDate,
2052
-				ScheduleType: item.ScheduleType,
2053
-				ScheduleWeek: item.ScheduleWeek,
2054
-				ModeId:       item.ModeId,
2055
-				Status:       1,
2056
-				CreatedTime:  time.Now().Unix(),
2057
-			}
2058
-
2059
-			err := service.AddPatientSchedule(&schedule)
2060
-			if err != nil {
2061
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2062
-				return
2063
-			}
2064
-			this.ServeSuccessJSON(map[string]interface{}{
2065
-				"schedule": schedule,
2066
-			})
2014
+	//先清除复制周的排班
2015
+	errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2016
+	fmt.Println(errcode)
2017
+	for _, item := range schedules {
2018
+		//fmt.Println(item.StartTime+604800)
2019
+		//礼拜1
2020
+		if item.ScheduleWeek == 1 {
2021
+			item.ScheduleDate = copy_startime
2022
+		}
2023
+		if item.ScheduleWeek == 2 {
2024
+			item.ScheduleDate = copy_startime + 86400
2025
+		}
2026
+		if item.ScheduleWeek == 3 {
2027
+			item.ScheduleDate = copy_startime + 172800
2028
+		}
2029
+		if item.ScheduleWeek == 4 {
2030
+			item.ScheduleDate = copy_startime + 259200
2031
+		}
2032
+		if item.ScheduleWeek == 5 {
2033
+			item.ScheduleDate = copy_startime + 345600
2067 2034
 		}
2068
-	} else if errcode == nil {
2069
-
2070
-		//先清除复制周的排班
2071
-		errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2072
-		fmt.Println(errcode)
2073
-		for _, item := range schedules {
2074
-			//fmt.Println(item.StartTime+604800)
2075
-			//礼拜1
2076
-			if item.ScheduleWeek == 1 {
2077
-				item.ScheduleDate = copy_startime
2078
-			}
2079
-			if item.ScheduleWeek == 2 {
2080
-				item.ScheduleDate = copy_startime + 86400
2081
-			}
2082
-			if item.ScheduleWeek == 3 {
2083
-				item.ScheduleDate = copy_startime + 172800
2084
-			}
2085
-			if item.ScheduleWeek == 4 {
2086
-				item.ScheduleDate = copy_startime + 259200
2087
-			}
2088
-			if item.ScheduleWeek == 5 {
2089
-				item.ScheduleDate = copy_startime + 345600
2090
-			}
2091 2035
 
2092
-			if item.ScheduleWeek == 6 {
2093
-				item.ScheduleDate = copy_startime + 432000
2094
-			}
2095
-			//礼拜天
2096
-			if item.ScheduleWeek == 0 {
2097
-				item.ScheduleDate = copy_endtime
2098
-			}
2099
-			schedule := models.XtSchedule{
2100
-				UserOrgId:    item.UserOrgId,
2101
-				PartitionId:  item.PartitionId,
2102
-				BedId:        item.BedId,
2103
-				PatientId:    item.PatientId,
2104
-				ScheduleDate: item.ScheduleDate,
2105
-				ScheduleType: item.ScheduleType,
2106
-				ScheduleWeek: item.ScheduleWeek,
2107
-				ModeId:       item.ModeId,
2108
-				Status:       1,
2109
-				CreatedTime:  time.Now().Unix(),
2110
-			}
2036
+		if item.ScheduleWeek == 6 {
2037
+			item.ScheduleDate = copy_startime + 432000
2038
+		}
2039
+		//礼拜天
2040
+		if item.ScheduleWeek == 0 {
2041
+			item.ScheduleDate = copy_endtime
2042
+		}
2043
+		schedule := models.XtSchedule{
2044
+			UserOrgId:    item.UserOrgId,
2045
+			PartitionId:  item.PartitionId,
2046
+			BedId:        item.BedId,
2047
+			PatientId:    item.PatientId,
2048
+			ScheduleDate: item.ScheduleDate,
2049
+			ScheduleType: item.ScheduleType,
2050
+			ScheduleWeek: item.ScheduleWeek,
2051
+			ModeId:       item.ModeId,
2052
+			Status:       1,
2053
+			CreatedTime:  time.Now().Unix(),
2054
+		}
2111 2055
 
2112
-			err := service.AddPatientSchedule(&schedule)
2113
-			if err != nil {
2114
-				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2115
-				return
2116
-			}
2117
-			this.ServeSuccessJSON(map[string]interface{}{
2118
-				"schedule": schedule,
2119
-			})
2056
+		err := service.AddPatientSchedule(&schedule)
2057
+		if err != nil {
2058
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2059
+			return
2120 2060
 		}
2061
+		this.ServeSuccessJSON(map[string]interface{}{
2062
+			"schedule": schedule,
2063
+		})
2121 2064
 	}
2065
+	//查询复制中的排班日期是否存在
2066
+	//_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
2067
+	//
2068
+	//if errcode == gorm.ErrRecordNotFound {
2069
+	//	//如果没有直接新增
2070
+	//
2071
+	//	for _, item := range schedules {
2072
+	//		//fmt.Println(item.StartTime+604800)
2073
+	//		//礼拜1
2074
+	//		if item.ScheduleWeek == 1 {
2075
+	//			item.ScheduleDate = copy_startime
2076
+	//		}
2077
+	//		if item.ScheduleWeek == 2 {
2078
+	//			item.ScheduleDate = copy_startime + 86400
2079
+	//		}
2080
+	//		if item.ScheduleWeek == 3 {
2081
+	//			item.ScheduleDate = copy_startime + 172800
2082
+	//		}
2083
+	//		if item.ScheduleWeek == 4 {
2084
+	//			item.ScheduleDate = copy_startime + 259200
2085
+	//		}
2086
+	//		if item.ScheduleWeek == 5 {
2087
+	//			item.ScheduleDate = copy_startime + 345600
2088
+	//		}
2089
+	//
2090
+	//		if item.ScheduleWeek == 6 {
2091
+	//			item.ScheduleDate = copy_startime + 432000
2092
+	//		}
2093
+	//		//礼拜天
2094
+	//		if item.ScheduleWeek == 0 {
2095
+	//			item.ScheduleDate = copy_endtime
2096
+	//		}
2097
+	//		schedule := models.XtSchedule{
2098
+	//			UserOrgId:    item.UserOrgId,
2099
+	//			PartitionId:  item.PartitionId,
2100
+	//			BedId:        item.BedId,
2101
+	//			PatientId:    item.PatientId,
2102
+	//			ScheduleDate: item.ScheduleDate,
2103
+	//			ScheduleType: item.ScheduleType,
2104
+	//			ScheduleWeek: item.ScheduleWeek,
2105
+	//			ModeId:       item.ModeId,
2106
+	//			Status:       1,
2107
+	//			CreatedTime:  time.Now().Unix(),
2108
+	//		}
2109
+	//
2110
+	//		err := service.AddPatientSchedule(&schedule)
2111
+	//		if err != nil {
2112
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2113
+	//			return
2114
+	//		}
2115
+	//		this.ServeSuccessJSON(map[string]interface{}{
2116
+	//			"schedule": schedule,
2117
+	//		})
2118
+	//	}
2119
+	//} else if errcode == nil {
2120
+	//
2121
+	//	//先清除复制周的排班
2122
+	//	errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
2123
+	//	fmt.Println(errcode)
2124
+	//	for _, item := range schedules {
2125
+	//		//fmt.Println(item.StartTime+604800)
2126
+	//		//礼拜1
2127
+	//		if item.ScheduleWeek == 1 {
2128
+	//			item.ScheduleDate = copy_startime
2129
+	//		}
2130
+	//		if item.ScheduleWeek == 2 {
2131
+	//			item.ScheduleDate = copy_startime + 86400
2132
+	//		}
2133
+	//		if item.ScheduleWeek == 3 {
2134
+	//			item.ScheduleDate = copy_startime + 172800
2135
+	//		}
2136
+	//		if item.ScheduleWeek == 4 {
2137
+	//			item.ScheduleDate = copy_startime + 259200
2138
+	//		}
2139
+	//		if item.ScheduleWeek == 5 {
2140
+	//			item.ScheduleDate = copy_startime + 345600
2141
+	//		}
2142
+	//
2143
+	//		if item.ScheduleWeek == 6 {
2144
+	//			item.ScheduleDate = copy_startime + 432000
2145
+	//		}
2146
+	//		//礼拜天
2147
+	//		if item.ScheduleWeek == 0 {
2148
+	//			item.ScheduleDate = copy_endtime
2149
+	//		}
2150
+	//		schedule := models.XtSchedule{
2151
+	//			UserOrgId:    item.UserOrgId,
2152
+	//			PartitionId:  item.PartitionId,
2153
+	//			BedId:        item.BedId,
2154
+	//			PatientId:    item.PatientId,
2155
+	//			ScheduleDate: item.ScheduleDate,
2156
+	//			ScheduleType: item.ScheduleType,
2157
+	//			ScheduleWeek: item.ScheduleWeek,
2158
+	//			ModeId:       item.ModeId,
2159
+	//			Status:       1,
2160
+	//			CreatedTime:  time.Now().Unix(),
2161
+	//		}
2162
+	//
2163
+	//		err := service.AddPatientSchedule(&schedule)
2164
+	//		if err != nil {
2165
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2166
+	//			return
2167
+	//		}
2168
+	//		this.ServeSuccessJSON(map[string]interface{}{
2169
+	//			"schedule": schedule,
2170
+	//		})
2171
+	//	}
2172
+	//}
2122 2173
 }

File diff suppressed because it is too large
+ 703 - 108
controllers/stock_in_api_controller.go


+ 1 - 0
models/drug.go View File

@@ -57,6 +57,7 @@ type BaseDrugLib struct {
57 57
 	DrugRemark                  string  `gorm:"column:drug_remark" json:"drug_remark" form:"drug_remark"`
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
+	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
60 61
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
61 62
 }
62 63
 

+ 38 - 28
models/his_models.go View File

@@ -365,34 +365,44 @@ func (HisPrescription) TableName() string {
365 365
 }
366 366
 
367 367
 type HisProject struct {
368
-	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
369
-	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
370
-	Pinyin                    string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
371
-	Wubi                      string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
372
-	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
373
-	Unit                      string  `gorm:"column:unit" json:"unit" form:"unit"`
374
-	CostClassify              int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
375
-	ExecutiveSection          int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
376
-	MedicalCoverage           int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
377
-	StatisticalClassification int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
378
-	DiseaseDirectory          int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
379
-	IsRecord                  int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
380
-	MedicalCode               string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
381
-	TubeColor                 int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
382
-	MedicalStatus             int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
383
-	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
384
-	Sign                      int64   `gorm:"column:sign" json:"sign" form:"sign"`
385
-	DefaultNumber             string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
386
-	IsDefault                 int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
387
-	IsCharge                  int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
388
-	IsEstimate                int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
389
-	IsWorkload                int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
390
-	Sort                      string  `gorm:"column:sort" json:"sort" form:"sort"`
391
-	DoctorAdvice              int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
392
-	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
393
-	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
394
-	CreatedTime               int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
395
-	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
368
+	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
369
+	ProjectName                 string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
370
+	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
371
+	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
372
+	Price                       float64 `gorm:"column:price" json:"price" form:"price"`
373
+	Unit                        string  `gorm:"column:unit" json:"unit" form:"unit"`
374
+	CostClassify                int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
375
+	ExecutiveSection            int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
376
+	MedicalCoverage             int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
377
+	StatisticalClassification   int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
378
+	DiseaseDirectory            int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
379
+	IsRecord                    int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
380
+	MedicalCode                 string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
381
+	TubeColor                   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
382
+	MedicalStatus               int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
383
+	Remark                      string  `gorm:"column:remark" json:"remark" form:"remark"`
384
+	Sign                        int64   `gorm:"column:sign" json:"sign" form:"sign"`
385
+	DefaultNumber               string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
386
+	IsDefault                   int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
387
+	IsCharge                    int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
388
+	IsEstimate                  int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
389
+	IsWorkload                  int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
390
+	Sort                        string  `gorm:"column:sort" json:"sort" form:"sort"`
391
+	DoctorAdvice                int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
392
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
393
+	Status                      int64   `gorm:"column:status" json:"status" form:"status"`
394
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
395
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
396
+	DeliveryWay                 string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
397
+	NumberDays                  string  `gorm:"column:number_days" json:"number_days" form:"number_days"`
398
+	Total                       string  `gorm:"column:total" json:"total" form:"total"`
399
+	Category                    int64   `gorm:"column:category" json:"category" form:"category"`
400
+	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
401
+	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
402
+	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
403
+	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
404
+	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
405
+	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
396 406
 }
397 407
 
398 408
 func (HisProject) TableName() string {

+ 3 - 2
service/schedule_service.go View File

@@ -738,8 +738,9 @@ func GetLastWeekSchedule(orgid int64, startime int64, endtime int64) (*models.Xt
738 738
 	return &schedule, nil
739 739
 }
740 740
 func AddPatientSchedule(schedule *models.XtSchedule) error {
741
-
742
-	err := XTWriteDB().Create(&schedule).Error
741
+	utx := XTWriteDB().Begin()
742
+	err := utx.Create(&schedule).Error
743
+	utx.Commit()
743 744
 	return err
744 745
 }
745 746
 

+ 205 - 37
service/stock_service.go View File

@@ -1973,6 +1973,11 @@ func FindGoodInfoByName(name string, org_id int64, good_type_id int64) (total in
1973 1973
 	return
1974 1974
 }
1975 1975
 
1976
+func FindGoodInfoByNameTwo(name string, org_id int64, good_type_id int64, good_name string) (total int64) {
1977
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? and good_name = ?", org_id, name, good_type_id, good_name).Count(&total)
1978
+	return
1979
+}
1980
+
1976 1981
 func FindGoodInfoByNameOne(name string, org_id int64, good_type_id int64, id int64) (total int64) {
1977 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)
1978 1983
 	return
@@ -2227,14 +2232,44 @@ func GetManufacturerName(orgid int64, name string) (*models.Manufacturer, error)
2227 2232
 	return &manufacturer, nil
2228 2233
 }
2229 2234
 
2235
+func CreateManufacturer(manufacturer *models.Manufacturer) error {
2236
+
2237
+	err := XTWriteDB().Create(manufacturer).Error
2238
+	return err
2239
+}
2240
+
2241
+func UpdatedManufactur(manufacturer *models.Manufacturer, orgid int64) error {
2242
+
2243
+	err := XTWriteDB().Model(&manufacturer).Where("org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"manufacturer_name": manufacturer.ManufacturerName}).Error
2244
+	return err
2245
+}
2246
+
2230 2247
 func CreateGoodsInfomation(info *models.GoodInfo, orgid int64) error {
2231 2248
 
2232 2249
 	goodInfo := models.GoodInfo{
2233
-		GoodName:              info.GoodName,
2234
-		MedicalInsuranceLevel: info.MedicalInsuranceLevel,
2235
-		OrgId:                 orgid,
2236
-		Status:                1,
2237
-		Ctime:                 time.Now().Unix(),
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,
2238 2273
 	}
2239 2274
 	err := XTWriteDB().Create(&goodInfo).Error
2240 2275
 	return err
@@ -2253,45 +2288,59 @@ func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error)
2253 2288
 	return goodInfo, err
2254 2289
 }
2255 2290
 
2256
-func CreateDrugsInfomation(info *models.BaseDrugLib, orgid int64) error {
2257
-
2258
-	goodInfo := models.BaseDrugLib{
2259
-		DrugName:              info.DrugName,
2260
-		DrugAlias:             info.DrugAlias,
2261
-		DrugSpec:              info.DrugSpec,
2262
-		DrugType:              info.DrugType,
2263
-		DrugStockLimit:        info.DrugStockLimit,
2264
-		DrugOriginPlace:       info.DrugOriginPlace,
2265
-		DrugDosageForm:        info.DrugDosageForm,
2266
-		MedicalInsuranceLevel: info.MedicalInsuranceLevel,
2267
-		MaxUnit:               info.MaxUnit,
2268
-		MinUnit:               info.MinUnit,
2269
-		UnitMatrixing:         info.UnitMatrixing,
2270
-		RetailPrice:           info.RetailPrice,
2271
-		LastPrice:             info.LastPrice,
2272
-		DrugClassify:          info.DrugClassify,
2273
-		Manufacturer:          info.Manufacturer,
2274
-		Dealer:                info.Dealer,
2275
-		OrgId:                 orgid,
2276
-		Status:                1,
2277
-		Ctime:                 time.Now().Unix(),
2291
+func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.BaseDrugLib, error) {
2292
+	var drug models.BaseDrugLib
2293
+	var err error
2294
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and status =1", drugname, drugdesc).Find(&drug).Error
2295
+	if err == gorm.ErrRecordNotFound {
2296
+		return nil, err
2278 2297
 	}
2279
-	err := XTWriteDB().Create(&goodInfo).Error
2298
+	if err != nil {
2299
+		return nil, err
2300
+	}
2301
+	return &drug, nil
2302
+}
2303
+
2304
+func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2305
+	err := XTWriteDB().Create(&info).Error
2306
+	return err
2307
+}
2308
+
2309
+func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
2310
+
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
2280 2312
 	return err
2281 2313
 }
2282 2314
 
2283 2315
 func CreateProjectInfomation(info *models.HisProject, orgid int64) error {
2284 2316
 
2285 2317
 	project := models.HisProject{
2286
-		ProjectName:      info.ProjectName,
2287
-		Price:            info.Price,
2288
-		Unit:             info.Unit,
2289
-		CostClassify:     info.CostClassify,
2290
-		ExecutiveSection: info.ExecutiveSection,
2291
-		MedicalCoverage:  info.MedicalCoverage,
2292
-		UserOrgId:        orgid,
2293
-		Status:           1,
2294
-		CreatedTime:      time.Now().Unix(),
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,
2295 2344
 	}
2296 2345
 	err := XTWriteDB().Create(&project).Error
2297 2346
 	return err
@@ -2302,3 +2351,122 @@ func GetWareOutInfoById(warehouseoutid int64, orgid int64) (warehouseinfo []*mod
2302 2351
 	err = XTReadDB().Model(&warehouseinfo).Where("warehouse_out_id = ? and org_id = ? and status= 1 and is_sys = 0", warehouseoutid, orgid).Find(&warehouseinfo).Error
2303 2352
 	return warehouseinfo, err
2304 2353
 }
2354
+
2355
+func EditDrugWarehousingOne(warehouse models.DrugWarehouse, id int64) {
2356
+	err = readDb.Model(&models.DrugWarehouse{}).Where("warehousing_order = ? AND status = 1 and id = ?", warehouse.WarehousingOrder, id).Update(map[string]interface{}{"mtime": time.Now().Unix(), "warehousing_time": warehouse.WarehousingTime, "modifier": warehouse.Modifier, "dealer": warehouse.Dealer, "manufacturer": warehouse.Manufacturer}).Error
2357
+
2358
+}
2359
+
2360
+func GetAllManufacturerList(orgid int64) (list []*models.Manufacturer, err error) {
2361
+
2362
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
2363
+	return list, err
2364
+}
2365
+
2366
+func GetAllDealerList(orgid int64) (list []*models.Dealer, err error) {
2367
+
2368
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
2369
+	return list, err
2370
+}
2371
+func GetDealerByName(orgid int64, name string) (*models.Dealer, error) {
2372
+	var dealer models.Dealer
2373
+	var err error
2374
+	err = XTReadDB().Model(&dealer).Where("org_id = ? and dealer_name = ? and status = 1", orgid, name).Find(&dealer).Error
2375
+	if err == gorm.ErrRecordNotFound {
2376
+		return nil, err
2377
+	}
2378
+	if err != nil {
2379
+		return nil, err
2380
+	}
2381
+	return &dealer, nil
2382
+}
2383
+
2384
+func CreateDealer(dealer *models.Dealer) error {
2385
+
2386
+	err := XTWriteDB().Create(&dealer).Error
2387
+	return err
2388
+}
2389
+
2390
+func UpdateDealer(dealer *models.Dealer, orgid int64) error {
2391
+
2392
+	err := XTWriteDB().Model(&dealer).Where("org_id = ? and status  =1", orgid).Updates(map[string]interface{}{"dealer_name": dealer.DealerName}).Error
2393
+	return err
2394
+}
2395
+
2396
+func GetDrugDataConfig(orgid int64, name string) (models.DictDataconfig, error) {
2397
+	dataconfig := models.DictDataconfig{}
2398
+	err := XTReadDB().Where("org_id = ? and name = ?", orgid, name).Find(&dataconfig).Error
2399
+	return dataconfig, err
2400
+}
2401
+
2402
+func GetParentDataConfig(parentid int64, orgid int64) (dataconfig []*models.DictDataconfig, err error) {
2403
+
2404
+	err = XTReadDB().Where("parent_id = ?  and status =1 and (org_id = ? or org_id = 0)", parentid, orgid).Find(&dataconfig).Error
2405
+	return dataconfig, err
2406
+}
2407
+
2408
+func IsExistDicConfig(parentid int64, goodKind string, orgid int64) (*models.DictDataconfig, error) {
2409
+
2410
+	var dataconfig models.DictDataconfig
2411
+	var err error
2412
+	err = XTReadDB().Where("parent_id = ? and status = 1 and name = ? and (org_id = ? or org_id = 0)", parentid, goodKind, orgid).Find(&dataconfig).Error
2413
+	if err == gorm.ErrRecordNotFound {
2414
+		return nil, err
2415
+	}
2416
+	if err != nil {
2417
+		return nil, err
2418
+	}
2419
+	return &dataconfig, nil
2420
+}
2421
+
2422
+func CreatedDicConfig(dataconfig *models.DictDataconfig) error {
2423
+
2424
+	err := XTWriteDB().Create(&dataconfig).Error
2425
+	return err
2426
+}
2427
+
2428
+func UpdatedDicConfig(parentid int64, dataconfig *models.DictDataconfig, orgid int64, goodKind string) error {
2429
+
2430
+	err := XTWriteDB().Model(&dataconfig).Where("parent_id = ? and org_id = ? and name = ?", parentid, orgid, goodKind).Updates(map[string]interface{}{"name": dataconfig.Name}).Error
2431
+	return err
2432
+}
2433
+
2434
+func GetGoodType(goodName string, orgid int64) (*models.GoodsType, error) {
2435
+
2436
+	var goodType models.GoodsType
2437
+	var err error
2438
+	err = XTReadDB().Where("type_name =? and org_id = ? and status = 1", goodName, orgid).Find(&goodType).Error
2439
+	if err == gorm.ErrRecordNotFound {
2440
+		return nil, err
2441
+	}
2442
+	if err != nil {
2443
+		return nil, err
2444
+	}
2445
+	return &goodType, nil
2446
+}
2447
+
2448
+func CreatedGoodType(goodsType *models.GoodsType) error {
2449
+
2450
+	err := XTWriteDB().Create(&goodsType).Error
2451
+	return err
2452
+}
2453
+
2454
+func GetAllGoodType(orgid int64) (goodsType []*models.GoodsType, err error) {
2455
+
2456
+	err = XTReadDB().Model(&goodsType).Where("org_id = ? and status = 1", orgid).Find(&goodsType).Error
2457
+	return goodsType, err
2458
+}
2459
+
2460
+func GetDepartMentByName(name string, orgid int64) (*models.XtHisDepartment, error) {
2461
+
2462
+	var department models.XtHisDepartment
2463
+	var err error
2464
+	err = XTReadDB().Where("name= ? and user_org_id = ? and status = 1", name, orgid).Find(&department).Error
2465
+	if err == gorm.ErrRecordNotFound {
2466
+		return nil, err
2467
+	}
2468
+	if err != nil {
2469
+		return nil, err
2470
+	}
2471
+	return &department, nil
2472
+}