XMLWAN 4 gadus atpakaļ
vecāks
revīzija
d8ede31bd2

+ 2 - 2
controllers/base_api_controller.go Parādīt failu

95
 		//adminUserInfo.Subscibes = subscibes
95
 		//adminUserInfo.Subscibes = subscibes
96
 		//this.SetSession("admin_user_info", &adminUserInfo)
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 Parādīt failu

327
 		PreImpulse:                 preImpules,
327
 		PreImpulse:                 preImpules,
328
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
328
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
329
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
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
 
656
 
657
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
657
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
658
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
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
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1100
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1101
 		return
1101
 		return
1102
 	}
1102
 	}
1103
-	fmt.Println("丰管业配置", data.SealingFluidDispose)
1103
+
1104
 	assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1104
 	assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1105
 	assessment.DialysisOrderId = data.DialysisOrderId
1105
 	assessment.DialysisOrderId = data.DialysisOrderId
1106
 	assessment.Evaluator = adminUserInfo.AdminUser.Id
1106
 	assessment.Evaluator = adminUserInfo.AdminUser.Id
1163
 	assessment.DiastolicPressure = data.DiastolicPressure
1163
 	assessment.DiastolicPressure = data.DiastolicPressure
1164
 	assessment.AdditionalWeight = data.AdditionalWeight
1164
 	assessment.AdditionalWeight = data.AdditionalWeight
1165
 	assessment.OtherComplication = data.OtherComplication
1165
 	assessment.OtherComplication = data.OtherComplication
1166
+	assessment.Ktv = data.Ktv
1166
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1167
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1167
 
1168
 
1168
 	if assessment.ID > 0 {
1169
 	if assessment.ID > 0 {
3010
 	schedual_type, _ := c.GetInt64("schedual_type")
3011
 	schedual_type, _ := c.GetInt64("schedual_type")
3011
 	adminUserInfo := c.GetAdminUserInfo()
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
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
3022
 	deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
3021
 
3023
 

+ 1 - 0
controllers/dialysis_record_api_controller.go Parādīt failu

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

+ 22 - 1
controllers/gobal_config_api_controller.go Parādīt failu

84
 	beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
84
 	beego.Router("/api/monitor/getmonitorconfig", &GobalConfigApiController{}, "Get:GetMonitorConfig")
85
 	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
85
 	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
86
 	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
86
 	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
87
-
87
+	beego.Router("/api/drugstock/getdrugautomaticlist", &GobalConfigApiController{}, "Get:GetDrugAutoMaticList")
88
 }
88
 }
89
 
89
 
90
 //provinces, _ := service.GetDistrictsByUpid(0)21
90
 //provinces, _ := service.GetDistrictsByUpid(0)21
1700
 		"config": config,
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 Parādīt failu

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

+ 33 - 8
controllers/mobile_api_controllers/dialysis_api_controller.go Parādīt failu

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

+ 12 - 0
controllers/mobile_api_controllers/patient_api_controller.go Parādīt failu

1242
 func (c *PatientApiController) ModifyExecDoctorAdvice() {
1242
 func (c *PatientApiController) ModifyExecDoctorAdvice() {
1243
 	execution_time := c.GetString("execution_time")
1243
 	execution_time := c.GetString("execution_time")
1244
 	groupno, _ := c.GetInt64("groupno", -1)
1244
 	groupno, _ := c.GetInt64("groupno", -1)
1245
+
1245
 	var ids []string
1246
 	var ids []string
1246
 	if groupno == 0 {
1247
 	if groupno == 0 {
1247
 		advice_ids := c.GetString("advice_id")
1248
 		advice_ids := c.GetString("advice_id")
1312
 	var err error
1313
 	var err error
1313
 	if groupno > 0 {
1314
 	if groupno > 0 {
1314
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1315
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1316
+
1315
 	} else {
1317
 	} else {
1316
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
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
 	if err != nil {
1331
 	if err != nil {
1320
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1332
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1321
 		return
1333
 		return

+ 22 - 5
controllers/schedule_api_controller.go Parādīt failu

1317
 		errLogs, _ := service.FindSchedualExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
1317
 		errLogs, _ := service.FindSchedualExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
1318
 
1318
 
1319
 		if len(schedules) > 0 {
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
 			if err == nil {
1324
 			if err == nil {
1325
 				for _, item := range schedules {
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
 				log := models.ExportLog{
1346
 				log := models.ExportLog{

+ 126 - 46
controllers/stock_in_api_controller.go Parādīt failu

72
 	beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
72
 	beego.Router("/api/good/postgoodinformation", &StockManagerApiController{}, "Post:AddGoodInformation")
73
 
73
 
74
 	beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
74
 	beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
75
+
76
+	beego.Router("/api/good/initializtion", &StockManagerApiController{}, "Get:GetInitializtion")
75
 }
77
 }
76
 
78
 
77
 func (c *StockManagerApiController) CreateWarehouse() {
79
 func (c *StockManagerApiController) CreateWarehouse() {
2076
 
2078
 
2077
 		if len(good_kind) != 0 {
2079
 		if len(good_kind) != 0 {
2078
 			_, errcodegoodkind := service.IsExistDicConfig(config.ID, good_kind, orgId)
2080
 			_, errcodegoodkind := service.IsExistDicConfig(config.ID, good_kind, orgId)
2079
-
2081
+			lastConfig, _ := service.GetLastDicConfig(config.ID, orgId)
2080
 			dataconfig := models.DictDataconfig{
2082
 			dataconfig := models.DictDataconfig{
2081
 				ParentId:       config.ID,
2083
 				ParentId:       config.ID,
2082
 				Module:         "system",
2084
 				Module:         "system",
2083
 				OrgId:          orgId,
2085
 				OrgId:          orgId,
2084
 				Name:           good_kind,
2086
 				Name:           good_kind,
2085
 				FieldName:      "",
2087
 				FieldName:      "",
2086
-				Value:          index + 50,
2088
+				Value:          lastConfig.Value + 1,
2087
 				CreatedTime:    "",
2089
 				CreatedTime:    "",
2088
 				UpdatedTime:    "",
2090
 				UpdatedTime:    "",
2089
 				CreateUserId:   adminUserInfo.AdminUser.Id,
2091
 				CreateUserId:   adminUserInfo.AdminUser.Id,
2175
 		if len(medical_insurance_level) != 0 {
2177
 		if len(medical_insurance_level) != 0 {
2176
 			_, errcodemedicalInsurance := service.IsExistDicConfig(medicalInsuranceDataConfig.ID, medical_insurance_level, orgId)
2178
 			_, errcodemedicalInsurance := service.IsExistDicConfig(medicalInsuranceDataConfig.ID, medical_insurance_level, orgId)
2177
 			if errcodemedicalInsurance == gorm.ErrRecordNotFound {
2179
 			if errcodemedicalInsurance == gorm.ErrRecordNotFound {
2180
+				mediConfigOne, _ := service.GetLastDicConfig(medicalInsuranceDataConfig.ID, orgId)
2178
 				dataconfig := models.DictDataconfig{
2181
 				dataconfig := models.DictDataconfig{
2179
 					ParentId:       medicalInsuranceDataConfig.ID,
2182
 					ParentId:       medicalInsuranceDataConfig.ID,
2180
 					Module:         "system",
2183
 					Module:         "system",
2181
 					OrgId:          orgId,
2184
 					OrgId:          orgId,
2182
 					Name:           medical_insurance_level,
2185
 					Name:           medical_insurance_level,
2183
 					FieldName:      "",
2186
 					FieldName:      "",
2184
-					Value:          index + 50,
2187
+					Value:          mediConfigOne.Value + 1,
2185
 					CreatedTime:    "",
2188
 					CreatedTime:    "",
2186
 					UpdatedTime:    "",
2189
 					UpdatedTime:    "",
2187
 					CreateUserId:   adminUserInfo.AdminUser.Id,
2190
 					CreateUserId:   adminUserInfo.AdminUser.Id,
2329
 
2332
 
2330
 		var dealer_id int64
2333
 		var dealer_id int64
2331
 		dealerName := goodNameM["dealer"].(string)
2334
 		dealerName := goodNameM["dealer"].(string)
2332
-		fmt.Println("经销商33333333", dealerName)
2335
+
2336
+		fmt.Println("经销商", dealerName)
2333
 		dealer := models.Dealer{
2337
 		dealer := models.Dealer{
2334
 			OrgId:      orgId,
2338
 			OrgId:      orgId,
2335
 			Status:     1,
2339
 			Status:     1,
2435
 			_, errcodecagegory := service.IsExistDicConfig(drugDataConfig.ID, statistics_category, orgId)
2439
 			_, errcodecagegory := service.IsExistDicConfig(drugDataConfig.ID, statistics_category, orgId)
2436
 
2440
 
2437
 			if errcodecagegory == gorm.ErrRecordNotFound {
2441
 			if errcodecagegory == gorm.ErrRecordNotFound {
2442
+				dicConfigThree, _ := service.GetLastDicConfig(drugDataConfig.ID, orgId)
2438
 				dataconfig := models.DictDataconfig{
2443
 				dataconfig := models.DictDataconfig{
2439
 					ParentId:       drugDataConfig.ID,
2444
 					ParentId:       drugDataConfig.ID,
2440
 					Module:         "system",
2445
 					Module:         "system",
2441
 					OrgId:          orgId,
2446
 					OrgId:          orgId,
2442
 					Name:           statistics_category,
2447
 					Name:           statistics_category,
2443
 					FieldName:      "",
2448
 					FieldName:      "",
2444
-					Value:          index + 50,
2449
+					Value:          dicConfigThree.Value + 1,
2445
 					CreatedTime:    "",
2450
 					CreatedTime:    "",
2446
 					UpdatedTime:    "",
2451
 					UpdatedTime:    "",
2447
 					CreateUserId:   adminUserInfo.AdminUser.Id,
2452
 					CreateUserId:   adminUserInfo.AdminUser.Id,
2474
 	}
2479
 	}
2475
 
2480
 
2476
 	export_time := time.Now().Unix()
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
 	if len(goods) > 0 {
2483
 	if len(goods) > 0 {
2479
 
2484
 
2480
 		for _, item := range goods {
2485
 		for _, item := range goods {
2481
 
2486
 
2482
 			goodInfo := models.GoodInfo{
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
 				ProductionType:              item.ProductionType,
2499
 				ProductionType:              item.ProductionType,
2495
 				Remark:                      item.Remark,
2500
 				Remark:                      item.Remark,
2496
 				RetailPrice:                 item.RetailPrice,
2501
 				RetailPrice:                 item.RetailPrice,
2575
 
2580
 
2576
 	total_goods = tempDrugs
2581
 	total_goods = tempDrugs
2577
 	for index, drugMap := range tempDrugs {
2582
 	for index, drugMap := range tempDrugs {
2583
+
2578
 		goodNameM := drugMap.(map[string]interface{})
2584
 		goodNameM := drugMap.(map[string]interface{})
2579
 		var drug models.BaseDrugLib
2585
 		var drug models.BaseDrugLib
2580
 		if goodNameM["drug_name"] == nil || reflect.TypeOf(goodNameM["drug_name"]).String() != "string" {
2586
 		if goodNameM["drug_name"] == nil || reflect.TypeOf(goodNameM["drug_name"]).String() != "string" {
2644
 		var drugType = "药品类型"
2650
 		var drugType = "药品类型"
2645
 
2651
 
2646
 		drugconfig, _ := service.GetDrugDataConfig(0, drugType)
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
 			if errcodes == gorm.ErrRecordNotFound {
2655
 			if errcodes == gorm.ErrRecordNotFound {
2656
+				//获取该型号最后一条数据型号
2657
+				config, _ := service.GetLastDicConfig(drugconfig.ID, orgId)
2658
+
2650
 				dataconfig := models.DictDataconfig{
2659
 				dataconfig := models.DictDataconfig{
2651
 					ParentId:       drugconfig.ID,
2660
 					ParentId:       drugconfig.ID,
2652
 					Module:         "system",
2661
 					Module:         "system",
2653
 					OrgId:          orgId,
2662
 					OrgId:          orgId,
2654
 					Name:           drug_type,
2663
 					Name:           drug_type,
2655
 					FieldName:      "",
2664
 					FieldName:      "",
2656
-					Value:          index + 50,
2665
+					Value:          config.Value + 1,
2657
 					CreatedTime:    "",
2666
 					CreatedTime:    "",
2658
 					UpdatedTime:    "",
2667
 					UpdatedTime:    "",
2659
 					CreateUserId:   adminUser.AdminUser.Id,
2668
 					CreateUserId:   adminUser.AdminUser.Id,
2713
 		drug.DrugOriginPlace = drug_origin_place
2722
 		drug.DrugOriginPlace = drug_origin_place
2714
 
2723
 
2715
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2724
 		drug_dosage_form := goodNameM["drug_dosage_form"].(string)
2716
-		fmt.Println("药品剂型2222222222", drug_dosage_form)
2725
+
2717
 		if len(drug_dosage_form) == 0 {
2726
 		if len(drug_dosage_form) == 0 {
2718
 			err_log := models.ExportErrLog{
2727
 			err_log := models.ExportErrLog{
2719
 				LogType:    4,
2728
 				LogType:    4,
2734
 		if len(drug_dosage_form) != 0 {
2743
 		if len(drug_dosage_form) != 0 {
2735
 			_, errcodess := service.IsExistDicConfig(drugDosageconfig.ID, drug_dosage_form, orgId)
2744
 			_, errcodess := service.IsExistDicConfig(drugDosageconfig.ID, drug_dosage_form, orgId)
2736
 			if errcodess == gorm.ErrRecordNotFound {
2745
 			if errcodess == gorm.ErrRecordNotFound {
2746
+				configOne, _ := service.GetLastDicConfig(drugDosageconfig.ID, orgId)
2737
 				dataconfig := models.DictDataconfig{
2747
 				dataconfig := models.DictDataconfig{
2738
 					ParentId:       drugDosageconfig.ID,
2748
 					ParentId:       drugDosageconfig.ID,
2739
 					Module:         "system",
2749
 					Module:         "system",
2740
 					OrgId:          orgId,
2750
 					OrgId:          orgId,
2741
-					Name:           drug_dosage,
2751
+					Name:           drug_dosage_form,
2742
 					FieldName:      "",
2752
 					FieldName:      "",
2743
-					Value:          index + 50,
2753
+					Value:          configOne.Value + 1,
2744
 					CreatedTime:    "",
2754
 					CreatedTime:    "",
2745
 					UpdatedTime:    "",
2755
 					UpdatedTime:    "",
2746
 					CreateUserId:   adminUser.AdminUser.Id,
2756
 					CreateUserId:   adminUser.AdminUser.Id,
2762
 				drug_dosage_form_id = int64(it.Value)
2772
 				drug_dosage_form_id = int64(it.Value)
2763
 			}
2773
 			}
2764
 		}
2774
 		}
2765
-		fmt.Println("hhhhhhh66666666666666", drug_dosage_form_id)
2775
+
2766
 		drug.DrugDosageForm = drug_dosage_form_id
2776
 		drug.DrugDosageForm = drug_dosage_form_id
2767
 
2777
 
2768
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2778
 		medical_insurance_level := goodNameM["medical_insurance_level"].(string)
2769
 		var medical_insurance_level_id int64
2779
 		var medical_insurance_level_id int64
2770
-		if len(medical_insurance_level) <= 0 { //名字为空则生成一条导入错误日志
2780
+		if len(medical_insurance_level) == 0 { //名字为空则生成一条导入错误日志
2771
 			err_log := models.ExportErrLog{
2781
 			err_log := models.ExportErrLog{
2772
 				LogType:    4,
2782
 				LogType:    4,
2773
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2783
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2785
 		if len(medical_insurance_level) != 0 {
2795
 		if len(medical_insurance_level) != 0 {
2786
 			_, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
2796
 			_, errcodemedical := service.IsExistDicConfig(medicalInsuranceConfig.ID, medical_insurance_level, orgId)
2787
 			if errcodemedical == gorm.ErrRecordNotFound {
2797
 			if errcodemedical == gorm.ErrRecordNotFound {
2798
+				medConfig, _ := service.GetLastDicConfig(medicalInsuranceConfig.ID, orgId)
2788
 				dataconfig := models.DictDataconfig{
2799
 				dataconfig := models.DictDataconfig{
2789
 					ParentId:       medicalInsuranceConfig.ID,
2800
 					ParentId:       medicalInsuranceConfig.ID,
2790
 					Module:         "system",
2801
 					Module:         "system",
2791
 					OrgId:          orgId,
2802
 					OrgId:          orgId,
2792
 					Name:           medical_insurance_level,
2803
 					Name:           medical_insurance_level,
2793
 					FieldName:      "",
2804
 					FieldName:      "",
2794
-					Value:          index + 50,
2805
+					Value:          medConfig.Value + 1,
2795
 					CreatedTime:    "",
2806
 					CreatedTime:    "",
2796
 					UpdatedTime:    "",
2807
 					UpdatedTime:    "",
2797
 					CreateUserId:   adminUser.AdminUser.Id,
2808
 					CreateUserId:   adminUser.AdminUser.Id,
2921
 		var drugClassify = "药物分类"
2932
 		var drugClassify = "药物分类"
2922
 		var drug_classify_id int64
2933
 		var drug_classify_id int64
2923
 		drugClassifyConfig, _ := service.GetDrugDataConfig(0, drugClassify)
2934
 		drugClassifyConfig, _ := service.GetDrugDataConfig(0, drugClassify)
2924
-		fmt.Println("9999999999999999999", drugClassifyConfig)
2935
+
2925
 		if len(drug_classify) != 0 {
2936
 		if len(drug_classify) != 0 {
2926
 			_, errcodesClass := service.IsExistDicConfig(drugClassifyConfig.ID, drug_classify, orgId)
2937
 			_, errcodesClass := service.IsExistDicConfig(drugClassifyConfig.ID, drug_classify, orgId)
2927
 			if errcodesClass == gorm.ErrRecordNotFound {
2938
 			if errcodesClass == gorm.ErrRecordNotFound {
2939
+				drugClassConfig, _ := service.GetLastDicConfig(drugClassifyConfig.ID, orgId)
2928
 				dataconfig := models.DictDataconfig{
2940
 				dataconfig := models.DictDataconfig{
2929
 					ParentId:       drugClassifyConfig.ID,
2941
 					ParentId:       drugClassifyConfig.ID,
2930
 					Module:         "system",
2942
 					Module:         "system",
2931
 					OrgId:          orgId,
2943
 					OrgId:          orgId,
2932
 					Name:           drug_classify,
2944
 					Name:           drug_classify,
2933
 					FieldName:      "",
2945
 					FieldName:      "",
2934
-					Value:          index + 50,
2946
+					Value:          drugClassConfig.Value + 1,
2935
 					CreatedTime:    "",
2947
 					CreatedTime:    "",
2936
 					UpdatedTime:    "",
2948
 					UpdatedTime:    "",
2937
 					CreateUserId:   adminUser.AdminUser.Id,
2949
 					CreateUserId:   adminUser.AdminUser.Id,
2996
 		drug.Manufacturer = manufacturer_id
3008
 		drug.Manufacturer = manufacturer_id
2997
 
3009
 
2998
 		dealer := goodNameM["dealer"].(string)
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
 		var dealer_id int64
3025
 		var dealer_id int64
3011
 		dealerList, _ := service.GetAllDealerList(orgId)
3026
 		dealerList, _ := service.GetAllDealerList(orgId)
3012
 		for _, it := range dealerList {
3027
 		for _, it := range dealerList {
3034
 		if len(statistics_category) != 0 {
3049
 		if len(statistics_category) != 0 {
3035
 			_, errcodestatistc := service.IsExistDicConfig(statistcConfig.ID, statistics_category, orgId)
3050
 			_, errcodestatistc := service.IsExistDicConfig(statistcConfig.ID, statistics_category, orgId)
3036
 			if errcodestatistc == gorm.ErrRecordNotFound {
3051
 			if errcodestatistc == gorm.ErrRecordNotFound {
3037
-
3052
+				staConfig, _ := service.GetLastDicConfig(statistcConfig.ID, orgId)
3038
 				dataconfig := models.DictDataconfig{
3053
 				dataconfig := models.DictDataconfig{
3039
 					ParentId:       statistcConfig.ID,
3054
 					ParentId:       statistcConfig.ID,
3040
 					Module:         "system",
3055
 					Module:         "system",
3041
 					OrgId:          orgId,
3056
 					OrgId:          orgId,
3042
 					Name:           statistics_category,
3057
 					Name:           statistics_category,
3043
 					FieldName:      "",
3058
 					FieldName:      "",
3044
-					Value:          index + 50,
3059
+					Value:          staConfig.Value + 1,
3045
 					CreatedTime:    "",
3060
 					CreatedTime:    "",
3046
 					UpdatedTime:    "",
3061
 					UpdatedTime:    "",
3047
 					CreateUserId:   adminUser.AdminUser.Id,
3062
 					CreateUserId:   adminUser.AdminUser.Id,
3081
 		if len(pharmacology_category) != 0 {
3096
 		if len(pharmacology_category) != 0 {
3082
 			_, errcodespharmacology := service.IsExistDicConfig(pharmacologyConfig.ID, pharmacology_category, orgId)
3097
 			_, errcodespharmacology := service.IsExistDicConfig(pharmacologyConfig.ID, pharmacology_category, orgId)
3083
 			if errcodespharmacology == gorm.ErrRecordNotFound {
3098
 			if errcodespharmacology == gorm.ErrRecordNotFound {
3099
+				dicConfig, _ := service.GetLastDicConfig(pharmacologyConfig.ID, orgId)
3084
 				dataconfig := models.DictDataconfig{
3100
 				dataconfig := models.DictDataconfig{
3085
 					ParentId:       pharmacologyConfig.ID,
3101
 					ParentId:       pharmacologyConfig.ID,
3086
 					Module:         "system",
3102
 					Module:         "system",
3087
 					OrgId:          orgId,
3103
 					OrgId:          orgId,
3088
 					Name:           pharmacology_category,
3104
 					Name:           pharmacology_category,
3089
 					FieldName:      "",
3105
 					FieldName:      "",
3090
-					Value:          index + 50,
3106
+					Value:          dicConfig.Value + 1,
3091
 					CreatedTime:    "",
3107
 					CreatedTime:    "",
3092
 					UpdatedTime:    "",
3108
 					UpdatedTime:    "",
3093
 					CreateUserId:   adminUser.AdminUser.Id,
3109
 					CreateUserId:   adminUser.AdminUser.Id,
3147
 		if len(drug_control) != 0 {
3163
 		if len(drug_control) != 0 {
3148
 			_, errcodesdrugcontrol := service.IsExistDicConfig(drugContorlConfig.ID, drug_control, orgId)
3164
 			_, errcodesdrugcontrol := service.IsExistDicConfig(drugContorlConfig.ID, drug_control, orgId)
3149
 			if errcodesdrugcontrol == gorm.ErrRecordNotFound {
3165
 			if errcodesdrugcontrol == gorm.ErrRecordNotFound {
3166
+				drugContorlConfigOne, _ := service.GetLastDicConfig(drugContorlConfig.ID, orgId)
3150
 				dataconfig := models.DictDataconfig{
3167
 				dataconfig := models.DictDataconfig{
3151
 					ParentId:       drugContorlConfig.ID,
3168
 					ParentId:       drugContorlConfig.ID,
3152
 					Module:         "system",
3169
 					Module:         "system",
3153
 					OrgId:          orgId,
3170
 					OrgId:          orgId,
3154
 					Name:           drug_control,
3171
 					Name:           drug_control,
3155
 					FieldName:      "",
3172
 					FieldName:      "",
3156
-					Value:          index + 50,
3173
+					Value:          drugContorlConfigOne.Value + 1,
3157
 					CreatedTime:    "",
3174
 					CreatedTime:    "",
3158
 					UpdatedTime:    "",
3175
 					UpdatedTime:    "",
3159
 					CreateUserId:   adminUser.AdminUser.Id,
3176
 					CreateUserId:   adminUser.AdminUser.Id,
3183
 		var drug_category_id int64
3200
 		var drug_category_id int64
3184
 
3201
 
3185
 		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3202
 		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3186
-		fmt.Println("33333drugCategoryConfig", drugCategoryConfig)
3203
+
3187
 		if len(drug_category) != 0 {
3204
 		if len(drug_category) != 0 {
3188
 			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3205
 			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3189
 			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3206
 			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3207
+				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3190
 				dataconfig := models.DictDataconfig{
3208
 				dataconfig := models.DictDataconfig{
3191
 					ParentId:       drugCategoryConfig.ID,
3209
 					ParentId:       drugCategoryConfig.ID,
3192
 					Module:         "system",
3210
 					Module:         "system",
3193
 					OrgId:          orgId,
3211
 					OrgId:          orgId,
3194
 					Name:           drug_category,
3212
 					Name:           drug_category,
3195
 					FieldName:      "",
3213
 					FieldName:      "",
3196
-					Value:          index + 50,
3214
+					Value:          drugCategoryConfigSix.Value + 1,
3197
 					CreatedTime:    "",
3215
 					CreatedTime:    "",
3198
 					UpdatedTime:    "",
3216
 					UpdatedTime:    "",
3199
 					CreateUserId:   adminUser.AdminUser.Id,
3217
 					CreateUserId:   adminUser.AdminUser.Id,
3259
 		if len(drugDoseUnit) != 0 {
3277
 		if len(drugDoseUnit) != 0 {
3260
 			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3278
 			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3261
 			if errcodedataconfig == gorm.ErrRecordNotFound {
3279
 			if errcodedataconfig == gorm.ErrRecordNotFound {
3280
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3262
 				dataconfig := models.Dataconfig{
3281
 				dataconfig := models.Dataconfig{
3263
 					ParentId:       dataConfig.ID,
3282
 					ParentId:       dataConfig.ID,
3264
 					Module:         "hemodialysis",
3283
 					Module:         "hemodialysis",
3265
 					OrgId:          orgId,
3284
 					OrgId:          orgId,
3266
 					Name:           drugDoseUnit,
3285
 					Name:           drugDoseUnit,
3267
 					FieldName:      "",
3286
 					FieldName:      "",
3268
-					Value:          index + 50,
3287
+					Value:          childConfig.Value + 1,
3269
 					CreatedTime:    "",
3288
 					CreatedTime:    "",
3270
 					UpdatedTime:    "",
3289
 					UpdatedTime:    "",
3271
 					CreateUserId:   adminUser.AdminUser.Id,
3290
 					CreateUserId:   adminUser.AdminUser.Id,
3296
 	}
3315
 	}
3297
 
3316
 
3298
 	export_time := time.Now().Unix()
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
 	if len(drugList) > 0 {
3320
 	if len(drugList) > 0 {
3302
 		for _, item := range drugList {
3321
 		for _, item := range drugList {
3303
 
3322
 
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 Parādīt failu

585
 	SupineDiastolicBloodPressure    string  `gorm:"column:supine_diastolic_blood_pressure" json:"supine_diastolic_blood_pressure" form:"supine_diastolic_blood_pressure"`
585
 	SupineDiastolicBloodPressure    string  `gorm:"column:supine_diastolic_blood_pressure" json:"supine_diastolic_blood_pressure" form:"supine_diastolic_blood_pressure"`
586
 	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
586
 	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
587
 	OtherComplication               string  `gorm:"column:other_complication" json:"other_complication" form:"other_complication"`
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
 func (AssessmentAfterDislysis) TableName() string {
591
 func (AssessmentAfterDislysis) TableName() string {

+ 10 - 0
models/drug_stock.go Parādīt failu

215
 func (DrugAutomaticReduceDetail) TableName() string {
215
 func (DrugAutomaticReduceDetail) TableName() string {
216
 	return "xt_drug_automatic_reduce_detail"
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 Parādīt failu

1093
 
1093
 
1094
 func UpdateDialysisBeforePrepareTwo(info *models.DialysisBeforePrepare) (err error) {
1094
 func UpdateDialysisBeforePrepareTwo(info *models.DialysisBeforePrepare) (err error) {
1095
 	err = writeDb.Model(&models.DialysisBeforePrepare{}).
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
 	return err
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
 func UpdateOrderCountSub(good_type_id int64, good_id int64, number string, org_id int64, count int64) {
1108
 func UpdateOrderCountSub(good_type_id int64, good_id int64, number string, org_id int64, count int64) {
1103
 	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))
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
 }
1116
 }
1111
 
1117
 
1112
 func UpdateUserInfoDetails(good_type_id int64, good_id int64, time int64, org_id int64, patient_id int64, count int64, out *models.WarehouseOutInfo) {
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
 	//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)
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
 	err := XTReadDB().Create(&prepare).Error
1179
 	err := XTReadDB().Create(&prepare).Error
1174
 	return err
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 Parādīt failu

459
 	}
459
 	}
460
 	return &config, nil
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 Parādīt failu

47
 	if isMark > 0 {
47
 	if isMark > 0 {
48
 		db = db.Where("x.is_mark = ?", isMark)
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
 	return hisproject, total, err
51
 	return hisproject, total, err
52
 }
52
 }
53
 
53
 

+ 15 - 0
service/patient_service.go Parādīt failu

1394
 	return
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
 func CreateExportLog(log *models.ExportLog) {
1412
 func CreateExportLog(log *models.ExportLog) {
1398
 	writeDb.Create(&log)
1413
 	writeDb.Create(&log)
1399
 }
1414
 }

+ 18 - 0
service/schedule_service.go Parādīt failu

133
 	return writeDb.Model(&models.Schedule{}).Create(&m).Error
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
 func GetSchedule(orgID, id int64) (*models.Schedule, error) {
154
 func GetSchedule(orgID, id int64) (*models.Schedule, error) {
137
 	var schedule models.Schedule
155
 	var schedule models.Schedule
138
 	var err error
156
 	var err error

+ 1 - 1
service/self_drug_service.go Parādīt failu

500
 func GetDrugStockConfig(orgid int64) (models.XtDrugStockConfig, error) {
500
 func GetDrugStockConfig(orgid int64) (models.XtDrugStockConfig, error) {
501
 
501
 
502
 	config := models.XtDrugStockConfig{}
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
 	return config, err
504
 	return config, err
505
 }
505
 }
506
 
506
 

+ 17 - 2
service/stock_service.go Parādīt failu

969
 		likeKey := "%" + keywords + "%"
969
 		likeKey := "%" + keywords + "%"
970
 		db = db.Joins("join sgj_users.sgj_user_admin_role on sgj_user_admin_role.admin_user_id = xt_drug_warehouse_out.creater")
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
 		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_warehouse_out.manufacturer")
971
 		db = db.Joins("join xt_manufacturer on xt_manufacturer.id = xt_drug_warehouse_out.manufacturer")
972
+
972
 		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
 		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
 
2111
 
2111
 func FindPatientAutomaticReduceRecord(org_id int64, record_time int64, good_id int64, good_type_id int64, patient_id int64) (count int64, err error) {
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
 	return
2115
 	return
2115
 
2116
 
2116
 }
2117
 }
2289
 func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.BaseDrugLib, error) {
2290
 func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.BaseDrugLib, error) {
2290
 	var drug models.BaseDrugLib
2291
 	var drug models.BaseDrugLib
2291
 	var err error
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
 	if err == gorm.ErrRecordNotFound {
2294
 	if err == gorm.ErrRecordNotFound {
2294
 		return nil, err
2295
 		return nil, err
2295
 	}
2296
 	}
2408
 	return &dataconfig, nil
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
 func CreatedDicConfig(dataconfig *models.DictDataconfig) error {
2419
 func CreatedDicConfig(dataconfig *models.DictDataconfig) error {
2412
 
2420
 
2413
 	err := XTWriteDB().Create(&dataconfig).Error
2421
 	err := XTWriteDB().Create(&dataconfig).Error
2480
 	return &dataconfig, nil
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
 func CreateDataConfig(dataconfig *models.Dataconfig) error {
2498
 func CreateDataConfig(dataconfig *models.Dataconfig) error {
2484
 
2499
 
2485
 	err := XTWriteDB().Create(&dataconfig).Error
2500
 	err := XTWriteDB().Create(&dataconfig).Error