瀏覽代碼

耗材参数

XMLWAN 4 年之前
父節點
當前提交
d8ede31bd2

+ 2 - 2
controllers/base_api_controller.go 查看文件

@@ -95,8 +95,8 @@ func (this *BaseAuthAPIController) Prepare() {
95 95
 		//adminUserInfo.Subscibes = subscibes
96 96
 		//this.SetSession("admin_user_info", &adminUserInfo)
97 97
 
98
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
99
-		//this.StopRun()
98
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
99
+		this.StopRun()
100 100
 
101 101
 	}
102 102
 

+ 19 - 17
controllers/dialysis_api_controller.go 查看文件

@@ -327,11 +327,11 @@ func (c *DialysisApiController) PostPrescription() {
327 327
 		PreImpulse:                 preImpules,
328 328
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
329 329
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
330
-		Blood:                    blood,
331
-		DialysisDialyszers:       dialysis_dialyszers,
332
-		DialysisIrrigation:       dialysis_irrigation,
333
-		AntioxidantCommodityName: antioxidant_commodity_name,
334
-		DisplaceSpeed:            displace_speed,
330
+		Blood:                      blood,
331
+		DialysisDialyszers:         dialysis_dialyszers,
332
+		DialysisIrrigation:         dialysis_irrigation,
333
+		AntioxidantCommodityName:   antioxidant_commodity_name,
334
+		DisplaceSpeed:              displace_speed,
335 335
 	}
336 336
 
337 337
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -656,11 +656,11 @@ func (c *DialysisApiController) PostSoulution() {
656 656
 
657 657
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
658 658
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
659
-		Blood:                    blood,
660
-		DialysisIrrigation:       dialysis_irrigation,
661
-		DialysisDialyszers:       dialysis_dialyszers,
662
-		AntioxidantCommodityName: antioxidant_commodity_name,
663
-		DisplaceSpeed:            displace_speed,
659
+		Blood:                     blood,
660
+		DialysisIrrigation:        dialysis_irrigation,
661
+		DialysisDialyszers:        dialysis_dialyszers,
662
+		AntioxidantCommodityName:  antioxidant_commodity_name,
663
+		DisplaceSpeed:             displace_speed,
664 664
 	}
665 665
 
666 666
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1100,7 +1100,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1100 1100
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1101 1101
 		return
1102 1102
 	}
1103
-	fmt.Println("丰管业配置", data.SealingFluidDispose)
1103
+
1104 1104
 	assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1105 1105
 	assessment.DialysisOrderId = data.DialysisOrderId
1106 1106
 	assessment.Evaluator = adminUserInfo.AdminUser.Id
@@ -1163,6 +1163,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1163 1163
 	assessment.DiastolicPressure = data.DiastolicPressure
1164 1164
 	assessment.AdditionalWeight = data.AdditionalWeight
1165 1165
 	assessment.OtherComplication = data.OtherComplication
1166
+	assessment.Ktv = data.Ktv
1166 1167
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1167 1168
 
1168 1169
 	if assessment.ID > 0 {
@@ -3010,12 +3011,13 @@ func (c *DialysisApiController) GetSchedule() {
3010 3011
 	schedual_type, _ := c.GetInt64("schedual_type")
3011 3012
 	adminUserInfo := c.GetAdminUserInfo()
3012 3013
 
3013
-	timeLayout := "2006-01-02 15:04:05"
3014
-
3015
-	date := time.Now().Format("2006-01-02") + " 00:00:00"
3016
-	loc, _ := time.LoadLocation("Local")
3017
-	theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3018
-	scheduleTime := theStartTime.Unix()
3014
+	//timeLayout := "2006-01-02 15:04:05"
3015
+	//
3016
+	//date := time.Now().Format("2006-01-02") + " 00:00:00"
3017
+	//loc, _ := time.LoadLocation("Local")
3018
+	//theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3019
+	//scheduleTime := theStartTime.Unix()
3020
+	scheduleTime, _ := c.GetInt64("record_date")
3019 3021
 
3020 3022
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
3021 3023
 

+ 1 - 0
controllers/dialysis_record_api_controller.go 查看文件

@@ -553,6 +553,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
553 553
 func (this *DialysisRecordAPIController) StartDialysis() {
554 554
 	patientID, _ := this.GetInt64("patient_id")
555 555
 	recordDateStr := this.GetString("date")
556
+	fmt.Println("上机日期222222222222222222222222", recordDateStr)
556 557
 	nurseID, _ := this.GetInt64("nurse")
557 558
 	punctureNurseId, _ := this.GetInt64("puncture_nurse")
558 559
 	startDateStr := this.GetString("start_time")

+ 22 - 1
controllers/gobal_config_api_controller.go 查看文件

@@ -84,7 +84,7 @@ func GobalConfigRegistRouters() {
84 84
 	beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
85 85
 	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
86 86
 	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
87
-
87
+	beego.Router("/api/drugstock/getdrugautomaticlist", &GobalConfigApiController{}, "Get:GetDrugAutoMaticList")
88 88
 }
89 89
 
90 90
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1700,3 +1700,24 @@ func (c *GobalConfigApiController) GetOrderConfig() {
1700 1700
 		"config": config,
1701 1701
 	})
1702 1702
 }
1703
+
1704
+func (c *GobalConfigApiController) GetDrugAutoMaticList() {
1705
+
1706
+	adminUserInfo := c.GetAdminUserInfo()
1707
+	orgId := adminUserInfo.CurrentOrgId
1708
+	warehous_out_id, _ := c.GetInt64("warehous_out_id")
1709
+	record_time, _ := c.GetInt64("record_time")
1710
+	warehouse_out_order_number := c.GetString("warehouse_out_order_number")
1711
+	drugConfig, _ := service.GetDrugStockConfig(orgId)
1712
+	list, err := service.GetDrugAutoMaticList(orgId, warehous_out_id, record_time, warehouse_out_order_number)
1713
+	drugList, err := service.GetAllBaseDrugList(orgId)
1714
+	if err != nil {
1715
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1716
+		return
1717
+	}
1718
+	c.ServeSuccessJSON(map[string]interface{}{
1719
+		"list":       list,
1720
+		"drugConfig": drugConfig,
1721
+		"drugList":   drugList,
1722
+	})
1723
+}

+ 21 - 13
controllers/his_api_controller.go 查看文件

@@ -414,6 +414,7 @@ func (c *HisApiController) CreateHisPrescription() {
414 414
 					utils.ErrorLog("pre_time")
415 415
 				}
416 416
 				preTime, _ := items["pre_time"].(string)
417
+
417 418
 				timeLayout := "2006-01-02"
418 419
 				loc, _ := time.LoadLocation("Local")
419 420
 				theTime2, err := time.ParseInLocation(timeLayout+" 15:04", preTime, loc)
@@ -442,6 +443,7 @@ func (c *HisApiController) CreateHisPrescription() {
442 443
 					PrescriptionNumber: hpInfo.PrescriptionNumber,
443 444
 					PreTime:            pTime,
444 445
 				}
446
+
445 447
 				service.SaveHisPrescription(prescription)
446 448
 
447 449
 				//更改患者挂号状态
@@ -465,17 +467,19 @@ func (c *HisApiController) CreateHisPrescription() {
465 467
 							s.Status = 1
466 468
 							s.UserOrgId = adminInfo.CurrentOrgId
467 469
 							s.RecordDate = recordDateTime
468
-							s.StartTime = prescription.PreTime
469 470
 							s.Groupno = groupNo
470 471
 							s.CreatedTime = ctime
471 472
 							s.UpdatedTime = mtime
472 473
 							s.PatientId = patient_id
473 474
 							s.HisPatientId = his_patient_id
475
+							s.StartTime = pTime
474 476
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
475 477
 							if errcode > 0 {
476 478
 								c.ServeFailJSONWithSGJErrorCode(errcode)
477 479
 								return
478 480
 							}
481
+
482
+							s.StartTime = pTime
479 483
 							service.CreateHisDoctorAdvice(&s)
480 484
 							var randNum int
481 485
 							randNum = rand.Intn(10000) + 1000
@@ -2818,7 +2822,7 @@ func (c *HisApiController) PostProjectInformation() {
2818 2822
 	var projectList []*models.HisProject
2819 2823
 	var total_goods []interface{}
2820 2824
 	tempProjects := dataBody["projects"].([]interface{})
2821
-	fmt.Println("666666666666", tempProjects)
2825
+
2822 2826
 	total_goods = tempProjects
2823 2827
 	for index, projectMap := range tempProjects {
2824 2828
 
@@ -2876,7 +2880,7 @@ func (c *HisApiController) PostProjectInformation() {
2876 2880
 			err_log := models.ExportErrLog{
2877 2881
 				LogType:    6,
2878 2882
 				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2879
-				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空或内容与系统不匹配",
2883
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的单位不能为空",
2880 2884
 				Status:     1,
2881 2885
 				CreateTime: time.Now().Unix(),
2882 2886
 				UpdateTime: time.Now().Unix(),
@@ -2892,7 +2896,7 @@ func (c *HisApiController) PostProjectInformation() {
2892 2896
 			err_log := models.ExportErrLog{
2893 2897
 				LogType:    6,
2894 2898
 				UserOrgId:  c.GetAdminUserInfo().CurrentOrgId,
2895
-				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空或内容与系统不匹配",
2899
+				ErrMsg:     "第" + strconv.Itoa(index+3) + "行" + "的费用类别不能为空",
2896 2900
 				Status:     1,
2897 2901
 				CreateTime: time.Now().Unix(),
2898 2902
 				UpdateTime: time.Now().Unix(),
@@ -2909,13 +2913,14 @@ func (c *HisApiController) PostProjectInformation() {
2909 2913
 		if len(cost_classify) != 0 {
2910 2914
 			_, errcode := service.IsExistDicConfig(costClassifyConfig.ID, cost_classify, orgId)
2911 2915
 			if errcode == gorm.ErrRecordNotFound {
2916
+				costConfig, _ := service.GetLastDicConfig(costClassifyConfig.ID, orgId)
2912 2917
 				dataconfig := models.DictDataconfig{
2913 2918
 					ParentId:       costClassifyConfig.ID,
2914 2919
 					Module:         "system",
2915 2920
 					OrgId:          orgId,
2916 2921
 					Name:           cost_classify,
2917 2922
 					FieldName:      "",
2918
-					Value:          index + 50,
2923
+					Value:          costConfig.Value + 1,
2919 2924
 					CreatedTime:    "",
2920 2925
 					UpdatedTime:    "",
2921 2926
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2978,7 +2983,7 @@ func (c *HisApiController) PostProjectInformation() {
2978 2983
 		project.ExecutiveSection = executive_section_id
2979 2984
 
2980 2985
 		medical_coverage := projectM["medical_coverage"].(string)
2981
-		fmt.Println("3333333333333", medical_coverage)
2986
+
2982 2987
 		if len(medical_coverage) == 0 { //名字为空则生成一条导入错误日志
2983 2988
 			err_log := models.ExportErrLog{
2984 2989
 				LogType:    6,
@@ -3001,13 +3006,14 @@ func (c *HisApiController) PostProjectInformation() {
3001 3006
 
3002 3007
 			_, errormedicalcoverage := service.IsExistDicConfig(medicalCoverageConfig.ID, medical_coverage, orgId)
3003 3008
 			if errormedicalcoverage == gorm.ErrRecordNotFound {
3009
+				medicalCoverageConfig, _ := service.GetLastDicConfig(medicalCoverageConfig.ID, orgId)
3004 3010
 				dataconfig := models.DictDataconfig{
3005 3011
 					ParentId:       medicalCoverageConfig.ID,
3006 3012
 					Module:         "system",
3007 3013
 					OrgId:          orgId,
3008 3014
 					Name:           medical_coverage,
3009 3015
 					FieldName:      "",
3010
-					Value:          index + 50,
3016
+					Value:          medicalCoverageConfig.Value + 1,
3011 3017
 					CreatedTime:    "",
3012 3018
 					UpdatedTime:    "",
3013 3019
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3034,7 +3040,7 @@ func (c *HisApiController) PostProjectInformation() {
3034 3040
 		project.Pinyin = pinyin
3035 3041
 
3036 3042
 		wubi := projectM["wubi"].(string)
3037
-		fmt.Println("五笔333333333333333333333333333333", wubi)
3043
+
3038 3044
 		project.Wubi = wubi
3039 3045
 
3040 3046
 		statistical_classification := projectM["statistical_classification"].(string)
@@ -3047,13 +3053,14 @@ func (c *HisApiController) PostProjectInformation() {
3047 3053
 			_, classificationerrcodes := service.IsExistDicConfig(classiFication.ID, statistical_classification, orgId)
3048 3054
 
3049 3055
 			if classificationerrcodes == gorm.ErrRecordNotFound {
3056
+				classiFicationConfig, _ := service.GetLastDicConfig(classiFication.ID, orgId)
3050 3057
 				dataconfig := models.DictDataconfig{
3051 3058
 					ParentId:       classiFication.ID,
3052 3059
 					Module:         "system",
3053 3060
 					OrgId:          orgId,
3054 3061
 					Name:           statistical_classification,
3055 3062
 					FieldName:      "",
3056
-					Value:          index + 50,
3063
+					Value:          classiFicationConfig.Value + 1,
3057 3064
 					CreatedTime:    "",
3058 3065
 					UpdatedTime:    "",
3059 3066
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3097,13 +3104,14 @@ func (c *HisApiController) PostProjectInformation() {
3097 3104
 		if len(tube_color) != 0 {
3098 3105
 			_, errcodetube := service.IsExistDicConfig(tubeColorConfig.ID, tube_color, orgId)
3099 3106
 			if errcodetube == gorm.ErrRecordNotFound {
3107
+				tubeConfig, _ := service.GetLastDicConfig(tubeColorConfig.ID, orgId)
3100 3108
 				dataconfig := models.DictDataconfig{
3101 3109
 					ParentId:       tubeColorConfig.ID,
3102 3110
 					Module:         "system",
3103 3111
 					OrgId:          orgId,
3104 3112
 					Name:           tube_color,
3105 3113
 					FieldName:      "",
3106
-					Value:          index + 50,
3114
+					Value:          tubeConfig.Value + 1,
3107 3115
 					CreatedTime:    "",
3108 3116
 					UpdatedTime:    "",
3109 3117
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3153,14 +3161,14 @@ func (c *HisApiController) PostProjectInformation() {
3153 3161
 		project.SpecailProject = specail_project
3154 3162
 
3155 3163
 		social_security_directory_code := projectM["social_security_directory_code"].(string)
3156
-		fmt.Println("社保目录编码22222222222", social_security_directory_code)
3164
+
3157 3165
 		project.SocialSecurityDirectoryCode = social_security_directory_code
3158 3166
 
3159 3167
 		remark := projectM["remark"].(string)
3160 3168
 		project.Remark = remark
3161 3169
 
3162 3170
 		record_date := projectM["record_date"].(string)
3163
-		fmt.Println("日期222222222", record_date)
3171
+
3164 3172
 		timeLayout := "2006-01-02"
3165 3173
 		loc, _ := time.LoadLocation("Local")
3166 3174
 
@@ -3171,7 +3179,7 @@ func (c *HisApiController) PostProjectInformation() {
3171 3179
 
3172 3180
 	export_time := time.Now().Unix()
3173 3181
 
3174
-	errLogs, _ := service.FindPatientExportLog(c.GetAdminUserInfo().CurrentOrgId, export_time)
3182
+	errLogs, _ := service.FindPatientExportLogThree(c.GetAdminUserInfo().CurrentOrgId, export_time)
3175 3183
 	if len(projectList) > 0 {
3176 3184
 		for _, item := range projectList {
3177 3185
 			project := models.HisProject{

+ 33 - 8
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -846,6 +846,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
846 846
 	supine_diastolic_blood_pressure := c.GetString("supine_diastolic_blood_pressure")
847 847
 	diastolic_pressure := c.GetString("diastolic_pressure")
848 848
 	other_complication := c.GetString("other_complication")
849
+	ktv := c.GetString("ktv")
849 850
 	if id <= 0 {
850 851
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
851 852
 		return
@@ -938,6 +939,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
938 939
 		SettingPressure:              setting_pressure,
939 940
 		DiastolicPressure:            diastolic_pressure,
940 941
 		OtherComplication:            other_complication,
942
+		Ktv:                          ktv,
941 943
 	}
942 944
 
943 945
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -3075,13 +3077,13 @@ func (c *DialysisAPIController) GetSchedule() {
3075 3077
 	schedual_type, _ := c.GetInt64("schedual_type")
3076 3078
 	adminUserInfo := c.GetMobileAdminUserInfo()
3077 3079
 
3078
-	timeLayout := "2006-01-02 15:04:05"
3079
-
3080
-	date := time.Now().Format("2006-01-02") + " 00:00:00"
3081
-	loc, _ := time.LoadLocation("Local")
3082
-	theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3083
-	scheduleTime := theStartTime.Unix()
3084
-
3080
+	//timeLayout := "2006-01-02 15:04:05"
3081
+	//
3082
+	//date := time.Now().Format("2006-01-02") + " 00:00:00"
3083
+	//loc, _ := time.LoadLocation("Local")
3084
+	//theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
3085
+	//scheduleTime := theStartTime.Unix()
3086
+	scheduleTime, _ := c.GetInt64("record_date")
3085 3087
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.Org.Id, scheduleTime, schedual_type)
3086 3088
 
3087 3089
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -3553,6 +3555,7 @@ func (c *DialysisAPIController) EditConsumables() {
3553 3555
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
3554 3556
 
3555 3557
 			goods, _ := dataBody["goods"].([]interface{})
3558
+			fmt.Println("goods2222222222222", goods)
3556 3559
 			if len(goods) > 0 {
3557 3560
 				for _, item := range goods {
3558 3561
 					items := item.(map[string]interface{})
@@ -3636,7 +3639,7 @@ func (c *DialysisAPIController) EditConsumables() {
3636 3639
 				}
3637 3640
 			}
3638 3641
 		}
3639
-
3642
+		fmt.Println("hhhhhhhhhhhhhhhhhhhh", beforePrepares)
3640 3643
 		//查询今日患者出库列表
3641 3644
 		consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
3642 3645
 
@@ -3696,6 +3699,7 @@ func (c *DialysisAPIController) EditConsumables() {
3696 3699
 
3697 3700
 		//查询是否有出库单
3698 3701
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
3702
+		fmt.Println("是否有出库单22222222222222222222222", err)
3699 3703
 		if err == gorm.ErrRecordNotFound {
3700 3704
 			//没有记录,则创建出库单
3701 3705
 			timeStr := time.Now().Format("2006-01-02")
@@ -3800,6 +3804,7 @@ func (c *DialysisAPIController) EditConsumables() {
3800 3804
 						if err == nil {
3801 3805
 
3802 3806
 							count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3807
+
3803 3808
 							if count == 0 {
3804 3809
 								details := &models.AutomaticReduceDetail{
3805 3810
 									WarehouseOutId:          warehouseOutInfo.ID,
@@ -3826,6 +3831,7 @@ func (c *DialysisAPIController) EditConsumables() {
3826 3831
 						}
3827 3832
 
3828 3833
 						count, _ := service.FindPatientAutomaticReduceRecord(adminInfo.Org.Id, record_time, item.GoodId, item.GoodTypeId, patient_id)
3834
+
3829 3835
 						if count == 0 {
3830 3836
 							details := &models.AutomaticReduceDetail{
3831 3837
 								WarehouseOutId:          outInfo.ID,
@@ -3842,6 +3848,7 @@ func (c *DialysisAPIController) EditConsumables() {
3842 3848
 							}
3843 3849
 							service.AddSigleAutoReduceRecordInfo(details)
3844 3850
 						} else if count == 1 {
3851
+							fmt.Println("llllllllllllllllllllll")
3845 3852
 							service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
3846 3853
 						}
3847 3854
 						//details := &models.AutomaticReduceDetail{
@@ -3864,7 +3871,9 @@ func (c *DialysisAPIController) EditConsumables() {
3864 3871
 			}
3865 3872
 
3866 3873
 			if len(beforePrepares) > 0 { //修改
3874
+
3867 3875
 				for _, consumable := range consumables_source {
3876
+
3868 3877
 					for _, before := range beforePrepares {
3869 3878
 
3870 3879
 						if consumable.GoodId == before.GoodId {
@@ -3874,6 +3883,7 @@ func (c *DialysisAPIController) EditConsumables() {
3874 3883
 								//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
3875 3884
 								//判断前端更改后的商品id的出库记录在数据库中是否存在
3876 3885
 								err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
3886
+								fmt.Println("err222222222222222222", err)
3877 3887
 								if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
3878 3888
 
3879 3889
 									warehouseOutInfo := &models.WarehouseOutInfo{
@@ -3895,6 +3905,7 @@ func (c *DialysisAPIController) EditConsumables() {
3895 3905
 									warehouseOutInfo.GoodId = before.GoodId
3896 3906
 									warehouseOutInfo.GoodTypeId = before.GoodTypeId
3897 3907
 									err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3908
+									fmt.Println("err2223444444444444444444", err)
3898 3909
 									if err == nil {
3899 3910
 										//可能存在商品使用人不存在的情况,需要先判断商品使用人是否存在
3900 3911
 										user, err := service.FindGoodUserById(before.GoodTypeId, before.GoodId, patient_id, adminInfo.Org.Id, record_time)
@@ -3953,6 +3964,7 @@ func (c *DialysisAPIController) EditConsumables() {
3953 3964
 												GoodTypeId:              consumable.GoodTypeId,
3954 3965
 												Count:                   before.Count,
3955 3966
 											}
3967
+
3956 3968
 											service.AddSigleAutoReduceRecordInfo(details)
3957 3969
 										} else if err == nil {
3958 3970
 											if user.ID > 0 {
@@ -3969,10 +3981,23 @@ func (c *DialysisAPIController) EditConsumables() {
3969 3981
 			}
3970 3982
 		}
3971 3983
 
3984
+		//更新自动出库的地方
3972 3985
 		var errs error
3973 3986
 		if len(beforePrepares) > 0 {
3987
+
3974 3988
 			for _, item := range beforePrepares {
3975 3989
 				errs = service.UpdateDialysisBeforePrepareTwo(item)
3990
+
3991
+				detail := models.AutomaticReduceDetail{
3992
+					PatientId:  item.PatientId,
3993
+					Status:     1,
3994
+					RecordTime: item.RecordDate,
3995
+					OrgId:      item.UserOrgId,
3996
+					GoodId:     item.GoodId,
3997
+					GoodTypeId: item.GoodTypeId,
3998
+					Count:      item.Count,
3999
+				}
4000
+				service.UpdateAutoReduceDetailSix(&detail)
3976 4001
 			}
3977 4002
 		}
3978 4003
 		if errs == nil {

+ 12 - 0
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

@@ -1242,6 +1242,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1242 1242
 func (c *PatientApiController) ModifyExecDoctorAdvice() {
1243 1243
 	execution_time := c.GetString("execution_time")
1244 1244
 	groupno, _ := c.GetInt64("groupno", -1)
1245
+
1245 1246
 	var ids []string
1246 1247
 	if groupno == 0 {
1247 1248
 		advice_ids := c.GetString("advice_id")
@@ -1312,10 +1313,21 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1312 1313
 	var err error
1313 1314
 	if groupno > 0 {
1314 1315
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1316
+
1315 1317
 	} else {
1316 1318
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1317 1319
 	}
1318 1320
 
1321
+	//判断是否开启his
1322
+	errs, config := service.FindXTHisRecordByOrgId(adminUserInfo.Org.Id)
1323
+	//如果开启去修改执行时间
1324
+	if config.IsOpen == 1 {
1325
+		advicesinfo := models.HisDoctorAdviceInfo{
1326
+			ExecutionTime: theTime.Unix(),
1327
+			UpdatedTime:   time.Now().Unix(),
1328
+		}
1329
+		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1330
+	}
1319 1331
 	if err != nil {
1320 1332
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1321 1333
 		return

+ 22 - 5
controllers/schedule_api_controller.go 查看文件

@@ -1317,13 +1317,30 @@ func (this *ScheduleApiController) ExportSchedule() {
1317 1317
 		errLogs, _ := service.FindSchedualExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
1318 1318
 
1319 1319
 		if len(schedules) > 0 {
1320
-			schedule_date := time.Now().Format("2006-01-02")
1321
-			date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1322
-			clear_schedule_date := date.Unix() //根据日期去清除,该日期未来的排班数据
1323
-			err := service.UpdateScheduleStatus(clear_schedule_date, this.GetAdminUserInfo().CurrentOrgId)
1320
+			//schedule_date := time.Now().Format("2006-01-02")
1321
+			//date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1322
+			//clear_schedule_date := date.Unix() //根据日期去清除,该日期未来的排班数据
1323
+			//err := service.UpdateScheduleStatus(clear_schedule_date, this.GetAdminUserInfo().CurrentOrgId)
1324 1324
 			if err == nil {
1325 1325
 				for _, item := range schedules {
1326
-					service.CreateSchedule(item)
1326
+					//查找当天日期是否存在
1327
+					_, errcode := service.GetTodayScheduleIsExist(item.PatientId, item.ScheduleDate, item.UserOrgId)
1328
+					if errcode == gorm.ErrRecordNotFound {
1329
+						service.CreateSchedule(item)
1330
+					} else if errcode == nil {
1331
+						schedule := models.XtSchedule{
1332
+							PartitionId:  item.PartitionId,
1333
+							BedId:        item.BedId,
1334
+							PatientId:    item.PatientId,
1335
+							ScheduleDate: item.ScheduleDate,
1336
+							ScheduleType: item.ScheduleType,
1337
+							ScheduleWeek: item.ScheduleWeek,
1338
+							ModeId:       item.ModeId,
1339
+							Status:       1,
1340
+						}
1341
+						service.UpdateScheduleByOrgId(item.PatientId, item.ScheduleDate, item.UserOrgId, &schedule)
1342
+					}
1343
+
1327 1344
 				}
1328 1345
 
1329 1346
 				log := models.ExportLog{

+ 126 - 46
controllers/stock_in_api_controller.go 查看文件

@@ -72,6 +72,8 @@ func StockManagerApiRegistRouters() {
72 72
 	beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
73 73
 
74 74
 	beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
75
+
76
+	beego.Router("/api/good/initializtion", &StockManagerApiController{}, "Get:GetInitializtion")
75 77
 }
76 78
 
77 79
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -2076,14 +2078,14 @@ func (this *StockManagerApiController) AddGoodInformation() {
2076 2078
 
2077 2079
 		if len(good_kind) != 0 {
2078 2080
 			_, errcodegoodkind := service.IsExistDicConfig(config.ID, good_kind, orgId)
2079
-
2081
+			lastConfig, _ := service.GetLastDicConfig(config.ID, orgId)
2080 2082
 			dataconfig := models.DictDataconfig{
2081 2083
 				ParentId:       config.ID,
2082 2084
 				Module:         "system",
2083 2085
 				OrgId:          orgId,
2084 2086
 				Name:           good_kind,
2085 2087
 				FieldName:      "",
2086
-				Value:          index + 50,
2088
+				Value:          lastConfig.Value + 1,
2087 2089
 				CreatedTime:    "",
2088 2090
 				UpdatedTime:    "",
2089 2091
 				CreateUserId:   adminUserInfo.AdminUser.Id,
@@ -2175,13 +2177,14 @@ func (this *StockManagerApiController) AddGoodInformation() {
2175 2177
 		if len(medical_insurance_level) != 0 {
2176 2178
 			_, errcodemedicalInsurance := service.IsExistDicConfig(medicalInsuranceDataConfig.ID, medical_insurance_level, orgId)
2177 2179
 			if errcodemedicalInsurance == gorm.ErrRecordNotFound {
2180
+				mediConfigOne, _ := service.GetLastDicConfig(medicalInsuranceDataConfig.ID, orgId)
2178 2181
 				dataconfig := models.DictDataconfig{
2179 2182
 					ParentId:       medicalInsuranceDataConfig.ID,
2180 2183
 					Module:         "system",
2181 2184
 					OrgId:          orgId,
2182 2185
 					Name:           medical_insurance_level,
2183 2186
 					FieldName:      "",
2184
-					Value:          index + 50,
2187
+					Value:          mediConfigOne.Value + 1,
2185 2188
 					CreatedTime:    "",
2186 2189
 					UpdatedTime:    "",
2187 2190
 					CreateUserId:   adminUserInfo.AdminUser.Id,
@@ -2329,7 +2332,8 @@ func (this *StockManagerApiController) AddGoodInformation() {
2329 2332
 
2330 2333
 		var dealer_id int64
2331 2334
 		dealerName := goodNameM["dealer"].(string)
2332
-		fmt.Println("经销商33333333", dealerName)
2335
+
2336
+		fmt.Println("经销商", dealerName)
2333 2337
 		dealer := models.Dealer{
2334 2338
 			OrgId:      orgId,
2335 2339
 			Status:     1,
@@ -2435,13 +2439,14 @@ func (this *StockManagerApiController) AddGoodInformation() {
2435 2439
 			_, errcodecagegory := service.IsExistDicConfig(drugDataConfig.ID, statistics_category, orgId)
2436 2440
 
2437 2441
 			if errcodecagegory == gorm.ErrRecordNotFound {
2442
+				dicConfigThree, _ := service.GetLastDicConfig(drugDataConfig.ID, orgId)
2438 2443
 				dataconfig := models.DictDataconfig{
2439 2444
 					ParentId:       drugDataConfig.ID,
2440 2445
 					Module:         "system",
2441 2446
 					OrgId:          orgId,
2442 2447
 					Name:           statistics_category,
2443 2448
 					FieldName:      "",
2444
-					Value:          index + 50,
2449
+					Value:          dicConfigThree.Value + 1,
2445 2450
 					CreatedTime:    "",
2446 2451
 					UpdatedTime:    "",
2447 2452
 					CreateUserId:   adminUserInfo.AdminUser.Id,
@@ -2474,23 +2479,23 @@ func (this *StockManagerApiController) AddGoodInformation() {
2474 2479
 	}
2475 2480
 
2476 2481
 	export_time := time.Now().Unix()
2477
-	errLogs, _ := service.FindPatientExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
2482
+	errLogs, _ := service.FindPatientExportLogTwo(this.GetAdminUserInfo().CurrentOrgId, export_time)
2478 2483
 	if len(goods) > 0 {
2479 2484
 
2480 2485
 		for _, item := range goods {
2481 2486
 
2482 2487
 			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
-
2488
+				GoodName:                    item.GoodName,
2489
+				SpecificationName:           item.SpecificationName,
2490
+				GoodKind:                    item.GoodKind,
2491
+				GoodTypeId:                  item.GoodTypeId,
2492
+				Dealer:                      item.Dealer,
2493
+				GoodUnit:                    item.GoodUnit,
2494
+				IsRecord:                    item.IsRecord,
2495
+				IsSpecialDiseases:           item.IsSpecialDiseases,
2496
+				Manufacturer:                item.Manufacturer,
2497
+				Pinyin:                      item.Pinyin,
2498
+				GoodStatus:                  item.GoodStatus,
2494 2499
 				ProductionType:              item.ProductionType,
2495 2500
 				Remark:                      item.Remark,
2496 2501
 				RetailPrice:                 item.RetailPrice,
@@ -2575,6 +2580,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2575 2580
 
2576 2581
 	total_goods = tempDrugs
2577 2582
 	for index, drugMap := range tempDrugs {
2583
+
2578 2584
 		goodNameM := drugMap.(map[string]interface{})
2579 2585
 		var drug models.BaseDrugLib
2580 2586
 		if goodNameM["drug_name"] == nil || reflect.TypeOf(goodNameM["drug_name"]).String() != "string" {
@@ -2644,16 +2650,19 @@ func (this *StockManagerApiController) AddDrugInformation() {
2644 2650
 		var drugType = "药品类型"
2645 2651
 
2646 2652
 		drugconfig, _ := service.GetDrugDataConfig(0, drugType)
2647
-		if len(drug_type) == 0 {
2648
-			_, errcodes := service.IsExistDicConfig(drugconfig.ParentId, drug_type, orgId)
2653
+		if len(drug_type) != 0 {
2654
+			_, errcodes := service.IsExistDicConfig(drugconfig.ID, drug_type, orgId)
2649 2655
 			if errcodes == gorm.ErrRecordNotFound {
2656
+				//获取该型号最后一条数据型号
2657
+				config, _ := service.GetLastDicConfig(drugconfig.ID, orgId)
2658
+
2650 2659
 				dataconfig := models.DictDataconfig{
2651 2660
 					ParentId:       drugconfig.ID,
2652 2661
 					Module:         "system",
2653 2662
 					OrgId:          orgId,
2654 2663
 					Name:           drug_type,
2655 2664
 					FieldName:      "",
2656
-					Value:          index + 50,
2665
+					Value:          config.Value + 1,
2657 2666
 					CreatedTime:    "",
2658 2667
 					UpdatedTime:    "",
2659 2668
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2713,7 +2722,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2713 2722
 		drug.DrugOriginPlace = drug_origin_place
2714 2723
 
2715 2724
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2716
-		fmt.Println("药品剂型2222222222", drug_dosage_form)
2725
+
2717 2726
 		if len(drug_dosage_form) == 0 {
2718 2727
 			err_log := models.ExportErrLog{
2719 2728
 				LogType:    4,
@@ -2734,13 +2743,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
2734 2743
 		if len(drug_dosage_form) != 0 {
2735 2744
 			_, errcodess := service.IsExistDicConfig(drugDosageconfig.ID, drug_dosage_form, orgId)
2736 2745
 			if errcodess == gorm.ErrRecordNotFound {
2746
+				configOne, _ := service.GetLastDicConfig(drugDosageconfig.ID, orgId)
2737 2747
 				dataconfig := models.DictDataconfig{
2738 2748
 					ParentId:       drugDosageconfig.ID,
2739 2749
 					Module:         "system",
2740 2750
 					OrgId:          orgId,
2741
-					Name:           drug_dosage,
2751
+					Name:           drug_dosage_form,
2742 2752
 					FieldName:      "",
2743
-					Value:          index + 50,
2753
+					Value:          configOne.Value + 1,
2744 2754
 					CreatedTime:    "",
2745 2755
 					UpdatedTime:    "",
2746 2756
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2762,12 +2772,12 @@ func (this *StockManagerApiController) AddDrugInformation() {
2762 2772
 				drug_dosage_form_id = int64(it.Value)
2763 2773
 			}
2764 2774
 		}
2765
-		fmt.Println("hhhhhhh66666666666666", drug_dosage_form_id)
2775
+
2766 2776
 		drug.DrugDosageForm = drug_dosage_form_id
2767 2777
 
2768 2778
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2769 2779
 		var medical_insurance_level_id int64
2770
-		if len(medical_insurance_level) <= 0 { //名字为空则生成一条导入错误日志
2780
+		if len(medical_insurance_level) == 0 { //名字为空则生成一条导入错误日志
2771 2781
 			err_log := models.ExportErrLog{
2772 2782
 				LogType:    4,
2773 2783
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
@@ -2785,13 +2795,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
2785 2795
 		if len(medical_insurance_level) != 0 {
2786 2796
 			_, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
2787 2797
 			if errcodemedical == gorm.ErrRecordNotFound {
2798
+				medConfig, _ := service.GetLastDicConfig(medicalInsuranceConfig.ID, orgId)
2788 2799
 				dataconfig := models.DictDataconfig{
2789 2800
 					ParentId:       medicalInsuranceConfig.ID,
2790 2801
 					Module:         "system",
2791 2802
 					OrgId:          orgId,
2792 2803
 					Name:           medical_insurance_level,
2793 2804
 					FieldName:      "",
2794
-					Value:          index + 50,
2805
+					Value:          medConfig.Value + 1,
2795 2806
 					CreatedTime:    "",
2796 2807
 					UpdatedTime:    "",
2797 2808
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2921,17 +2932,18 @@ func (this *StockManagerApiController) AddDrugInformation() {
2921 2932
 		var drugClassify = "药物分类"
2922 2933
 		var drug_classify_id int64
2923 2934
 		drugClassifyConfig, _ := service.GetDrugDataConfig(0, drugClassify)
2924
-		fmt.Println("9999999999999999999", drugClassifyConfig)
2935
+
2925 2936
 		if len(drug_classify) != 0 {
2926 2937
 			_, errcodesClass := service.IsExistDicConfig(drugClassifyConfig.ID, drug_classify, orgId)
2927 2938
 			if errcodesClass == gorm.ErrRecordNotFound {
2939
+				drugClassConfig, _ := service.GetLastDicConfig(drugClassifyConfig.ID, orgId)
2928 2940
 				dataconfig := models.DictDataconfig{
2929 2941
 					ParentId:       drugClassifyConfig.ID,
2930 2942
 					Module:         "system",
2931 2943
 					OrgId:          orgId,
2932 2944
 					Name:           drug_classify,
2933 2945
 					FieldName:      "",
2934
-					Value:          index + 50,
2946
+					Value:          drugClassConfig.Value + 1,
2935 2947
 					CreatedTime:    "",
2936 2948
 					UpdatedTime:    "",
2937 2949
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -2996,17 +3008,20 @@ func (this *StockManagerApiController) AddDrugInformation() {
2996 3008
 		drug.Manufacturer = manufacturer_id
2997 3009
 
2998 3010
 		dealer := goodNameM["dealer"].(string)
2999
-		_, errcodesdealer := service.GetDealerByName(orgId, dealer)
3000
-		if errcodesdealer == gorm.ErrRecordNotFound {
3001
-			dealerconfig := models.Dealer{
3002
-				DealerName: dealer,
3003
-				Status:     1,
3004
-				OrgId:      orgId,
3005
-				Ctime:      time.Now().Unix(),
3006
-				Creater:    adminUser.AdminUser.Id,
3011
+		if len(dealer) != 0 {
3012
+			_, errcodesdealer := service.GetDealerByName(orgId, dealer)
3013
+			if errcodesdealer == gorm.ErrRecordNotFound {
3014
+				dealerconfig := models.Dealer{
3015
+					DealerName: dealer,
3016
+					Status:     1,
3017
+					OrgId:      orgId,
3018
+					Ctime:      time.Now().Unix(),
3019
+					Creater:    adminUser.AdminUser.Id,
3020
+				}
3021
+				service.CreateDealer(&dealerconfig)
3007 3022
 			}
3008
-			service.CreateDealer(&dealerconfig)
3009 3023
 		}
3024
+
3010 3025
 		var dealer_id int64
3011 3026
 		dealerList, _ := service.GetAllDealerList(orgId)
3012 3027
 		for _, it := range dealerList {
@@ -3034,14 +3049,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3034 3049
 		if len(statistics_category) != 0 {
3035 3050
 			_, errcodestatistc := service.IsExistDicConfig(statistcConfig.ID, statistics_category, orgId)
3036 3051
 			if errcodestatistc == gorm.ErrRecordNotFound {
3037
-
3052
+				staConfig, _ := service.GetLastDicConfig(statistcConfig.ID, orgId)
3038 3053
 				dataconfig := models.DictDataconfig{
3039 3054
 					ParentId:       statistcConfig.ID,
3040 3055
 					Module:         "system",
3041 3056
 					OrgId:          orgId,
3042 3057
 					Name:           statistics_category,
3043 3058
 					FieldName:      "",
3044
-					Value:          index + 50,
3059
+					Value:          staConfig.Value + 1,
3045 3060
 					CreatedTime:    "",
3046 3061
 					UpdatedTime:    "",
3047 3062
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3081,13 +3096,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3081 3096
 		if len(pharmacology_category) != 0 {
3082 3097
 			_, errcodespharmacology := service.IsExistDicConfig(pharmacologyConfig.ID, pharmacology_category, orgId)
3083 3098
 			if errcodespharmacology == gorm.ErrRecordNotFound {
3099
+				dicConfig, _ := service.GetLastDicConfig(pharmacologyConfig.ID, orgId)
3084 3100
 				dataconfig := models.DictDataconfig{
3085 3101
 					ParentId:       pharmacologyConfig.ID,
3086 3102
 					Module:         "system",
3087 3103
 					OrgId:          orgId,
3088 3104
 					Name:           pharmacology_category,
3089 3105
 					FieldName:      "",
3090
-					Value:          index + 50,
3106
+					Value:          dicConfig.Value + 1,
3091 3107
 					CreatedTime:    "",
3092 3108
 					UpdatedTime:    "",
3093 3109
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3147,13 +3163,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3147 3163
 		if len(drug_control) != 0 {
3148 3164
 			_, errcodesdrugcontrol := service.IsExistDicConfig(drugContorlConfig.ID, drug_control, orgId)
3149 3165
 			if errcodesdrugcontrol == gorm.ErrRecordNotFound {
3166
+				drugContorlConfigOne, _ := service.GetLastDicConfig(drugContorlConfig.ID, orgId)
3150 3167
 				dataconfig := models.DictDataconfig{
3151 3168
 					ParentId:       drugContorlConfig.ID,
3152 3169
 					Module:         "system",
3153 3170
 					OrgId:          orgId,
3154 3171
 					Name:           drug_control,
3155 3172
 					FieldName:      "",
3156
-					Value:          index + 50,
3173
+					Value:          drugContorlConfigOne.Value + 1,
3157 3174
 					CreatedTime:    "",
3158 3175
 					UpdatedTime:    "",
3159 3176
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3183,17 +3200,18 @@ func (this *StockManagerApiController) AddDrugInformation() {
3183 3200
 		var drug_category_id int64
3184 3201
 
3185 3202
 		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3186
-		fmt.Println("33333drugCategoryConfig", drugCategoryConfig)
3203
+
3187 3204
 		if len(drug_category) != 0 {
3188 3205
 			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3189 3206
 			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3207
+				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3190 3208
 				dataconfig := models.DictDataconfig{
3191 3209
 					ParentId:       drugCategoryConfig.ID,
3192 3210
 					Module:         "system",
3193 3211
 					OrgId:          orgId,
3194 3212
 					Name:           drug_category,
3195 3213
 					FieldName:      "",
3196
-					Value:          index + 50,
3214
+					Value:          drugCategoryConfigSix.Value + 1,
3197 3215
 					CreatedTime:    "",
3198 3216
 					UpdatedTime:    "",
3199 3217
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3259,13 +3277,14 @@ func (this *StockManagerApiController) AddDrugInformation() {
3259 3277
 		if len(drugDoseUnit) != 0 {
3260 3278
 			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3261 3279
 			if errcodedataconfig == gorm.ErrRecordNotFound {
3280
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3262 3281
 				dataconfig := models.Dataconfig{
3263 3282
 					ParentId:       dataConfig.ID,
3264 3283
 					Module:         "hemodialysis",
3265 3284
 					OrgId:          orgId,
3266 3285
 					Name:           drugDoseUnit,
3267 3286
 					FieldName:      "",
3268
-					Value:          index + 50,
3287
+					Value:          childConfig.Value + 1,
3269 3288
 					CreatedTime:    "",
3270 3289
 					UpdatedTime:    "",
3271 3290
 					CreateUserId:   adminUser.AdminUser.Id,
@@ -3296,8 +3315,8 @@ func (this *StockManagerApiController) AddDrugInformation() {
3296 3315
 	}
3297 3316
 
3298 3317
 	export_time := time.Now().Unix()
3299
-	errLogs, _ := service.FindPatientExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
3300
-	fmt.Println("数组", drugList)
3318
+	errLogs, _ := service.FindPatientExportLogOne(this.GetAdminUserInfo().CurrentOrgId, export_time)
3319
+
3301 3320
 	if len(drugList) > 0 {
3302 3321
 		for _, item := range drugList {
3303 3322
 
@@ -3395,3 +3414,64 @@ func (this *StockManagerApiController) AddDrugInformation() {
3395 3414
 		})
3396 3415
 	}
3397 3416
 }
3417
+
3418
+func (this *StockManagerApiController) GetInitializtion() {
3419
+
3420
+	orgId := this.GetAdminUserInfo().CurrentOrgId
3421
+	var drugCategory = "药品类别"
3422
+	var drugType = "药品类型"
3423
+	var drugDosageForm = "药品剂型"
3424
+	var medicalInsuranceLevel = "医保等级"
3425
+	var drugControl = "开药控制"
3426
+	var drugClassify = "药物分类"
3427
+	var statisticsCategory = "统计分类"
3428
+	var pharmacologyCategory = "药理分类"
3429
+	var goodKind = "耗材种类"
3430
+	var tubeColor = "试管颜色"
3431
+	var costClassify = "费用类别"
3432
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
3433
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
3434
+
3435
+	drugCategoryParent, _ := service.GetDrugDataConfig(0, drugCategory)
3436
+	drugCategoryList, _ := service.GetParentDataConfig(drugCategoryParent.ID, orgId)
3437
+
3438
+	drugDosageFormParent, _ := service.GetDrugDataConfig(0, drugDosageForm)
3439
+	drugDosageFormList, _ := service.GetParentDataConfig(drugDosageFormParent.ID, orgId)
3440
+
3441
+	medicalInsuranceLevelParent, _ := service.GetDrugDataConfig(0, medicalInsuranceLevel)
3442
+	medicalInsuranceLevelList, _ := service.GetParentDataConfig(medicalInsuranceLevelParent.ID, orgId)
3443
+
3444
+	drugControlParent, _ := service.GetDrugDataConfig(0, drugControl)
3445
+	drugControlList, _ := service.GetParentDataConfig(drugControlParent.ID, orgId)
3446
+
3447
+	drugClassifyParent, _ := service.GetDrugDataConfig(0, drugClassify)
3448
+	drugClassifyList, _ := service.GetParentDataConfig(drugClassifyParent.ID, orgId)
3449
+
3450
+	statisticsCategoryParent, _ := service.GetDrugDataConfig(0, statisticsCategory)
3451
+	statisticsCategoryList, _ := service.GetParentDataConfig(statisticsCategoryParent.ID, orgId)
3452
+
3453
+	pharmacologyCategoryParent, _ := service.GetDrugDataConfig(0, pharmacologyCategory)
3454
+	pharmacologyCategoryList, _ := service.GetParentDataConfig(pharmacologyCategoryParent.ID, orgId)
3455
+
3456
+	goodKindParent, _ := service.GetDrugDataConfig(0, goodKind)
3457
+	goodKindList, _ := service.GetParentDataConfig(goodKindParent.ID, orgId)
3458
+
3459
+	tubeColorParent, _ := service.GetDrugDataConfig(0, tubeColor)
3460
+	tubeColorList, _ := service.GetParentDataConfig(tubeColorParent.ID, orgId)
3461
+
3462
+	costClassifyParent, _ := service.GetDrugDataConfig(0, costClassify)
3463
+	costClassifyList, _ := service.GetParentDataConfig(costClassifyParent.ID, orgId)
3464
+	this.ServeSuccessJSON(map[string]interface{}{
3465
+		"drugCategoryList":          drugCategoryList,
3466
+		"drugTypeList":              drugTypeList,
3467
+		"drugDosageFormList":        drugDosageFormList,
3468
+		"medicalInsuranceLevelList": medicalInsuranceLevelList,
3469
+		"drugControlList":           drugControlList,
3470
+		"drugClassifyList":          drugClassifyList,
3471
+		"statisticsCategoryList":    statisticsCategoryList,
3472
+		"pharmacologyCategoryList":  pharmacologyCategoryList,
3473
+		"goodKindList":              goodKindList,
3474
+		"tubeColorList":             tubeColorList,
3475
+		"costClassifyList":          costClassifyList,
3476
+	})
3477
+}

+ 1 - 0
models/dialysis.go 查看文件

@@ -585,6 +585,7 @@ type AssessmentAfterDislysis struct {
585 585
 	SupineDiastolicBloodPressure    string  `gorm:"column:supine_diastolic_blood_pressure" json:"supine_diastolic_blood_pressure" form:"supine_diastolic_blood_pressure"`
586 586
 	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
587 587
 	OtherComplication               string  `gorm:"column:other_complication" json:"other_complication" form:"other_complication"`
588
+	Ktv                             string  `gorm:"column:ktv" json:"ktv" form:"ktv"`
588 589
 }
589 590
 
590 591
 func (AssessmentAfterDislysis) TableName() string {

+ 10 - 0
models/drug_stock.go 查看文件

@@ -215,3 +215,13 @@ type DrugAutomaticReduceDetail struct {
215 215
 func (DrugAutomaticReduceDetail) TableName() string {
216 216
 	return "xt_drug_automatic_reduce_detail"
217 217
 }
218
+
219
+type VmDrugAutomaticReduceDetail struct {
220
+	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
221
+	WarehouseOutId          int64  `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
222
+	WarehouseOutOrderNumber string `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number" form:"warehouse_out_order_number"`
223
+	PatientId               int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
224
+	RecordTime              int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
225
+	DrugId                  int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
226
+	Total                   int64
227
+}

+ 26 - 3
service/dialysis_service.go 查看文件

@@ -1093,12 +1093,18 @@ func UpdateDialysisBeforePrepare(info *models.DialysisBeforePrepare) (err error)
1093 1093
 
1094 1094
 func UpdateDialysisBeforePrepareTwo(info *models.DialysisBeforePrepare) (err error) {
1095 1095
 	err = writeDb.Model(&models.DialysisBeforePrepare{}).
1096
-		Where("status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND user_org_id = ? AND record_date = ?", info.GoodId, info.GoodTypeId, info.PatientId, info.UserOrgId, info.RecordDate).
1097
-		Updates(map[string]interface{}{"count": info.Count, "updated_time": time.Now().Unix(), "modifier": info.Modifier, "commdity_code": info.CommdityCode}).Error
1096
+		Where("status = 1 and good_id = ? AND good_type_id = ? AND patient_id = ? AND user_org_id = ? AND record_date = ?", info.GoodId, info.GoodTypeId, info.PatientId, info.UserOrgId, info.RecordDate).
1097
+		Updates(map[string]interface{}{"count": info.Count, "updated_time": time.Now().Unix(), "modifier": info.Modifier, "commdity_code": info.CommdityCode, "status": 1}).Error
1098 1098
 
1099 1099
 	return err
1100 1100
 }
1101 1101
 
1102
+func UpdateAutoReduceDetailSix(detail *models.AutomaticReduceDetail) (err error) {
1103
+
1104
+	err = writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? and good_type_id = ? And patient_id = ? and org_id =?", detail.GoodId, detail.GoodTypeId, detail.PatientId, detail.OrgId).Updates(map[string]interface{}{"count": detail.Count, "mtime": detail.Mtime, "status": 1}).Error
1105
+	return err
1106
+}
1107
+
1102 1108
 func UpdateOrderCountSub(good_type_id int64, good_id int64, number string, org_id int64, count int64) {
1103 1109
 	writeDb.Model(&models.WarehouseOutInfo{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, number).UpdateColumn("count", gorm.Expr("count - ?", count))
1104 1110
 
@@ -1110,7 +1116,7 @@ func UpdateOrderCountAdd(good_type_id int64, good_id int64, number string, org_i
1110 1116
 }
1111 1117
 
1112 1118
 func UpdateUserInfoDetails(good_type_id int64, good_id int64, time int64, org_id int64, patient_id int64, count int64, out *models.WarehouseOutInfo) {
1113
-	writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND warehouse_out_order_number = ? AND patient_id = ?", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber, patient_id).Updates(map[string]interface{}{"count": count})
1119
+	writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND warehouse_out_order_number = ? AND patient_id = ?", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber, patient_id).Updates(map[string]interface{}{"count": count, "status": 1})
1114 1120
 	//writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND org_id = ? AND status = 1 AND is_sys = 1 AND warehouse_out_order_number = ? ", good_id, good_type_id, org_id, out.WarehouseOutOrderNumber).UpdateColumn("count", count)
1115 1121
 
1116 1122
 }
@@ -1173,3 +1179,20 @@ func CreateDialysisBeforePrepareOne(prepare *models.DialysisBeforePrepare) error
1173 1179
 	err := XTReadDB().Create(&prepare).Error
1174 1180
 	return err
1175 1181
 }
1182
+
1183
+func ModifyExceDoctorAdviceById(m *models.HisDoctorAdviceInfo, ids []string) (err error) {
1184
+
1185
+	ut := writeDb.Begin()
1186
+	err = ut.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1   AND id IN (?) AND execution_state = 1", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
1187
+	if err != nil {
1188
+		ut.Rollback()
1189
+		return
1190
+	}
1191
+	err = ut.Model(&models.HisDoctorAdviceInfo{}).Where("status = 1   AND parent_id IN (?) AND execution_state = 1 ", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
1192
+	if err != nil {
1193
+		ut.Rollback()
1194
+		return
1195
+	}
1196
+	ut.Commit()
1197
+	return err
1198
+}

+ 14 - 0
service/gobal_config_service.go 查看文件

@@ -459,3 +459,17 @@ func GetMonitorConfigById(orgid int64) (*models.XtMonitorConfig, error) {
459 459
 	}
460 460
 	return &config, nil
461 461
 }
462
+
463
+func GetDrugAutoMaticList(orgid int64, warehouse_out_id int64, record_time int64, warehouse_out_order_number string) (auto []*models.VmDrugAutomaticReduceDetail, err error) {
464
+
465
+	db := XTReadDB().Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
466
+	err = db.Select("x.org_id,x.warehouse_out_id,x.record_time,x.drug_id,sum(x.count) as total").Where("x.org_id = ?  and x.record_time = ? and x.status= 1 and x.warehouse_out_order_number = ?", orgid, record_time, warehouse_out_order_number).Group("x.drug_id").Scan(&auto).Error
467
+	return auto, err
468
+
469
+}
470
+
471
+func GetAllBaseDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
472
+
473
+	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
474
+	return drug, err
475
+}

+ 1 - 1
service/his_project_service.go 查看文件

@@ -47,7 +47,7 @@ func GetHisProjectList(orgid int64, limit int64, page int64, charge int64, start
47 47
 	if isMark > 0 {
48 48
 		db = db.Where("x.is_mark = ?", isMark)
49 49
 	}
50
-	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time,x.is_mark").Count(&total).Offset(offset).Limit(limit).Find(&hisproject).Error
50
+	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time,x.is_mark").Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&hisproject).Error
51 51
 	return hisproject, total, err
52 52
 }
53 53
 

+ 15 - 0
service/patient_service.go 查看文件

@@ -1394,6 +1394,21 @@ func FindPatientExportLog(org_id int64, export_time int64) (errLogs []*models.Ex
1394 1394
 	return
1395 1395
 }
1396 1396
 
1397
+func FindPatientExportLogOne(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
1398
+	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 4", org_id, export_time).Find(&errLogs).Error
1399
+	return
1400
+}
1401
+
1402
+func FindPatientExportLogTwo(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
1403
+	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 5", org_id, export_time).Find(&errLogs).Error
1404
+	return
1405
+}
1406
+
1407
+func FindPatientExportLogThree(org_id int64, export_time int64) (errLogs []*models.ExportErrLog, err error) {
1408
+	err = readDb.Model(&models.ExportErrLog{}).Where("user_org_id = ? AND export_time = ? AND log_type = 6", org_id, export_time).Find(&errLogs).Error
1409
+	return
1410
+}
1411
+
1397 1412
 func CreateExportLog(log *models.ExportLog) {
1398 1413
 	writeDb.Create(&log)
1399 1414
 }

+ 18 - 0
service/schedule_service.go 查看文件

@@ -133,6 +133,24 @@ func CreateSchedule(m *models.Schedule) error {
133 133
 	return writeDb.Model(&models.Schedule{}).Create(&m).Error
134 134
 }
135 135
 
136
+func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64) (*models.XtSchedule, error) {
137
+	var scheudle models.XtSchedule
138
+	var err error
139
+	err = XTReadDB().Model(&scheudle).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1", patientid, schedudate, orgid).Find(&scheudle).Error
140
+	if err == gorm.ErrRecordNotFound {
141
+		return nil, err
142
+	}
143
+	if err != nil {
144
+		return nil, err
145
+	}
146
+	return &scheudle, nil
147
+}
148
+
149
+func UpdateScheduleByOrgId(patientid int64, scheduledate int64, orgid int64, sch *models.XtSchedule) error {
150
+	err := XTWriteDB().Model(&sch).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1", patientid, scheduledate, orgid).Updates(map[string]interface{}{"partition_id": sch.PartitionId, "bed_id": sch.BedId, "schedule_type": sch.ScheduleType, "schedule_week": sch.ScheduleWeek, "mode_id": sch.ModeId, "updated_time": time.Now().Unix()}).Error
151
+	return err
152
+}
153
+
136 154
 func GetSchedule(orgID, id int64) (*models.Schedule, error) {
137 155
 	var schedule models.Schedule
138 156
 	var err error

+ 1 - 1
service/self_drug_service.go 查看文件

@@ -500,7 +500,7 @@ func CreateAotoMaticReduceDetail(detail *models.XtDrugAutomaticReduceDetail) err
500 500
 func GetDrugStockConfig(orgid int64) (models.XtDrugStockConfig, error) {
501 501
 
502 502
 	config := models.XtDrugStockConfig{}
503
-	err := XTReadDB().Model(&config).Where("org_id =? and status = 1", orgid).Find(&orgid).Error
503
+	err := XTReadDB().Model(&config).Where("org_id =? and status = 1", orgid).Find(&config).Error
504 504
 	return config, err
505 505
 }
506 506
 

+ 17 - 2
service/stock_service.go 查看文件

@@ -969,6 +969,7 @@ func FindAllDrugWarehouseOutList(orgId int64, page int64, limit int64, startTime
969 969
 		likeKey := "%" + keywords + "%"
970 970
 		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse_out.creater")
971 971
 		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_warehouse_out.manufacturer")
972
+
972 973
 		db = db.Where("xt_manufacturer.manufacturer_name LIKE ? OR sgj_user_admin_role.user_name LIKE ? OR xt_drug_warehouse_out.warehouse_out_order_number LIKE ?", likeKey, likeKey, likeKey).Group("xt_drug_warehouse_out.id")
973 974
 	}
974 975
 
@@ -2110,7 +2111,7 @@ func UpdateDrugStockOutInfoCount2(org_id int64, id int64, count int64) {
2110 2111
 
2111 2112
 func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
2112 2113
 
2113
-	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ? AND status = 1 AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ? AND count <> 0", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2114
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("org_id = ?AND status = 1  AND good_id = ? AND good_type_id = ? AND patient_id = ? AND record_time = ? AND count <> 0", org_id, good_id, good_type_id, patient_id, record_time).Count(&count).Error
2114 2115
 	return
2115 2116
 
2116 2117
 }
@@ -2289,7 +2290,7 @@ func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error)
2289 2290
 func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.BaseDrugLib, error) {
2290 2291
 	var drug models.BaseDrugLib
2291 2292
 	var err error
2292
-	err = XTReadDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and status =1", drugname, drugdesc).Find(&drug).Error
2293
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and status =1 and org_id = ?", drugname, drugdesc, orgid).Find(&drug).Error
2293 2294
 	if err == gorm.ErrRecordNotFound {
2294 2295
 		return nil, err
2295 2296
 	}
@@ -2408,6 +2409,13 @@ func IsExistDicConfig(parentid int64, goodKind string, orgid int64) (*models.Dic
2408 2409
 	return &dataconfig, nil
2409 2410
 }
2410 2411
 
2412
+func GetLastDicConfig(parentid int64, orgid int64) (models.DictDataconfig, error) {
2413
+
2414
+	dataconfig := models.DictDataconfig{}
2415
+	err := XTReadDB().Model(&dataconfig).Where("parent_id = ? and (org_id = ? or org_id = 0) and status = 1", parentid, orgid).Last(&dataconfig).Error
2416
+	return dataconfig, err
2417
+}
2418
+
2411 2419
 func CreatedDicConfig(dataconfig *models.DictDataconfig) error {
2412 2420
 
2413 2421
 	err := XTWriteDB().Create(&dataconfig).Error
@@ -2480,6 +2488,13 @@ func GetChildeConfigIsExist(parentid int64, name string, orgid int64) (*models.D
2480 2488
 	return &dataconfig, nil
2481 2489
 }
2482 2490
 
2491
+func GetLastChildeConfig(parentid int64, orgid int64) (models.Dataconfig, error) {
2492
+
2493
+	dataconfig := models.Dataconfig{}
2494
+	err := XTReadDB().Model(&dataconfig).Where("parent_id = ? and (org_id = ? or org_id = 0) and status =1", parentid, orgid).Last(&dataconfig).Error
2495
+	return dataconfig, err
2496
+}
2497
+
2483 2498
 func CreateDataConfig(dataconfig *models.Dataconfig) error {
2484 2499
 
2485 2500
 	err := XTWriteDB().Create(&dataconfig).Error