Browse Source

2024/6/17

28169 2 months ago
parent
commit
428923aec9

BIN
XT_New.exe View File


+ 4 - 4
controllers/base_api_controller.go View File

@@ -83,7 +83,7 @@ func (this *BaseAuthAPIController) Prepare() {
83 83
 		userAdmin.ModifyTime = 1530786071
84 84
 		var subscibe models.ServeSubscibe
85 85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10206 //机构id
86
+		subscibe.OrgId = 10633 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,7 +93,7 @@ func (this *BaseAuthAPIController) Prepare() {
93 93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94 94
 		subscibes[4] = &subscibe
95 95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10206 //机构id小英9675或4
96
+		adminUserInfo.CurrentOrgId = 10633 //机构id小英9675或4
97 97
 		adminUserInfo.CurrentAppId = 7421  //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10206 //机构id小英9675或4
332
+		subscibe.OrgId = 10633 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,7 +339,7 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10206 //机构id小英9675或4
342
+		adminUserInfo.CurrentOrgId = 10633 //机构id小英9675或4
343 343
 		adminUserInfo.CurrentAppId = 7421  //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes

+ 1 - 1
controllers/dialysis_api_controller.go View File

@@ -3178,7 +3178,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3178 3178
 		}
3179 3179
 
3180 3180
 		//针对孝昌康桥超滤率计算问题
3181
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 {
3181
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 {
3182 3182
 			if assessmentBeforeDislysis.ID == 0 {
3183 3183
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3184 3184
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {

+ 4 - 0
controllers/doctors_api_controller.go View File

@@ -109,6 +109,8 @@ func (c *DoctorsApiController) ScheduleAdvices() {
109 109
 	config, _ := service.GetHisDoctorConfig(orgID)
110 110
 	project_config, _ := service.GetHisProjectConfig(orgID)
111 111
 
112
+	drugs, _ := service.GetAllBaseDrugLibListTwo(orgID)
113
+
112 114
 	if config.IsOpen == 0 || config.IsOpen == 2 {
113 115
 		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency, keyword)
114 116
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
@@ -127,6 +129,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
127 129
 				"adminUser":      adminUser,
128 130
 				"config":         config,
129 131
 				"project_config": project_config,
132
+				"drugs":          drugs,
130 133
 			})
131 134
 		}
132 135
 	}
@@ -167,6 +170,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
167 170
 				"project_config": project_config,
168 171
 				"project":        project,
169 172
 				"drug":           drug,
173
+				"drugs":          drugs,
170 174
 			})
171 175
 		}
172 176
 	}

+ 441 - 8
controllers/his_api_controller.go View File

@@ -3197,7 +3197,7 @@ func (c *HisApiController) CreateHisPrescription() {
3197 3197
 	var adviceList []models.HisDoctorAdviceInfo
3198 3198
 	var projectList []models.HisPrescriptionProject
3199 3199
 
3200
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 {
3200
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 {
3201 3201
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3202 3202
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3203 3203
 
@@ -3824,7 +3824,445 @@ func (c *HisApiController) CreateHisPrescription() {
3824 3824
 
3825 3825
 								//查询保存耗材出库开关是否打开
3826 3826
 								if p.PatientId != 30038 {
3827
-									if goodOutConfig.IsOpen == 1 {
3827
+
3828
+									//用机构ID区分
3829
+									if adminInfo.CurrentOrgId != 10721 && adminInfo.CurrentOrgId != 10164 {
3830
+										if goodOutConfig.IsOpen == 1 {
3831
+											//耗材出库
3832
+											if p.Type == 3 {
3833
+
3834
+												//对比当前数据和历史出库数据
3835
+
3836
+												historyProject, _ := service.GetHistoryProject(p.PatientId, p.UserOrgId, p.RecordDate, p.ID, p.ProjectId, tx)
3837
+
3838
+												historyCount, _ := strconv.ParseInt(historyProject.Count, 10, 64)
3839
+
3840
+												nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
3841
+
3842
+												//如果当前处方数量大于历史数据,则需要出库
3843
+												if nowCount > historyCount {
3844
+
3845
+													var cha_count int64
3846
+													cha_count = nowCount - historyCount
3847
+
3848
+													timeStr := time.Now().Format("2006-01-02")
3849
+													timeArr := strings.Split(timeStr, "-")
3850
+													total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
3851
+
3852
+													total = total + 1
3853
+													warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
3854
+													number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
3855
+													number = number + total
3856
+													warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
3857
+
3858
+													operation_time := time.Now().Unix()
3859
+													creater := c.GetAdminUserInfo().AdminUser.Id
3860
+
3861
+													recordDateStr := time.Now().Format("2006-01-02")
3862
+													recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3863
+													nowtime := recordDate.Unix()
3864
+													warehouseOut := models.WarehouseOut{
3865
+														WarehouseOutOrderNumber: warehousing_out_order,
3866
+														OperationTime:           operation_time,
3867
+														OrgId:                   adminInfo.CurrentOrgId,
3868
+														Creater:                 creater,
3869
+														Ctime:                   time.Now().Unix(),
3870
+														Status:                  1,
3871
+														WarehouseOutTime:        nowtime,
3872
+														Type:                    1,
3873
+														StorehouseId:            storeConfig.StorehouseOutInfo,
3874
+														IsCheck:                 1,
3875
+														IsSys:                   1,
3876
+													}
3877
+													//查询是否生成出库单
3878
+													out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
3879
+													if out.ID == 0 {
3880
+														service.AddNewSigleWarehouseOut(&warehouseOut, tx)
3881
+													}
3882
+
3883
+													lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
3884
+
3885
+													goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
3886
+													houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
3887
+
3888
+													dialyPrepareOne := models.DialysisBeforePrepare{
3889
+														GoodTypeId:   goodObj.GoodTypeId,
3890
+														GoodId:       p.ProjectId,
3891
+														PatientId:    p.PatientId,
3892
+														RecordDate:   p.RecordDate,
3893
+														UserOrgId:    adminInfo.CurrentOrgId,
3894
+														Count:        cha_count,
3895
+														Ctime:        time.Now().Unix(),
3896
+														Creater:      creater,
3897
+														Status:       1,
3898
+														StorehouseId: houseConfig.StorehouseOutInfo,
3899
+														ProjectId:    p.ID,
3900
+													}
3901
+													//出库
3902
+													service.ConsumableNewHisPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, tx)
3903
+
3904
+												}
3905
+
3906
+												//如果当前处方数量小于历史数据,怎需要退库
3907
+												if nowCount < historyCount {
3908
+
3909
+													var cha_count int64
3910
+													cha_count = historyCount - nowCount
3911
+													goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
3912
+													creater := c.GetAdminUserInfo().AdminUser.Id
3913
+
3914
+													newPrescriptionProject := &models.HisPrescriptionProject{
3915
+														ID:                   p.ID,
3916
+														ProjectId:            p.ProjectId,
3917
+														Price:                p.Price,
3918
+														UserOrgId:            p.UserOrgId,
3919
+														Status:               1,
3920
+														Ctime:                time.Now().Unix(),
3921
+														Mtime:                time.Now().Unix(),
3922
+														PatientId:            p.PatientId,
3923
+														HisPatientId:         p.HisPatientId,
3924
+														RecordDate:           p.RecordDate,
3925
+														PrescriptionId:       p.PrescriptionId,
3926
+														Count:                p.Count,
3927
+														FeedetlSn:            p.FeedetlSn,
3928
+														MedListCodg:          p.MedListCodg,
3929
+														SingleDose:           p.SingleDose,
3930
+														DeliveryWay:          p.DeliveryWay,
3931
+														ExecutionFrequency:   p.ExecutionFrequency,
3932
+														Day:                  p.Day,
3933
+														HisProject:           models.HisProject{},
3934
+														GoodInfo:             models.GoodInfo{},
3935
+														Remark:               p.Remark,
3936
+														Unit:                 p.Unit,
3937
+														Type:                 p.Type,
3938
+														Doctor:               p.Doctor,
3939
+														ExecutionTime:        p.ExecutionTime,
3940
+														ExecutionStaff:       p.ExecutionStaff,
3941
+														ExecutionState:       p.ExecutionState,
3942
+														CheckTime:            p.CheckTime,
3943
+														CheckState:           p.CheckState,
3944
+														Checker:              p.Checker,
3945
+														StartTime:            p.StartTime,
3946
+														TeamId:               p.TeamId,
3947
+														XtHisProjectTeam:     models.XtHisProjectTeam{},
3948
+														FrequencyType:        p.FrequencyType,
3949
+														DayCount:             p.DayCount,
3950
+														WeekDay:              p.WeekDay,
3951
+														IsCheckTeam:          p.IsCheckTeam,
3952
+														HisOrderInfo:         models.HisOrderInfo{},
3953
+														ExecutionFrequencyId: p.ExecutionFrequencyId,
3954
+														IsOut:                p.IsOut,
3955
+														YbSyncStatus:         p.YbSyncStatus,
3956
+													}
3957
+
3958
+													service.NewHisGoodCancelInfo(adminInfo.CurrentOrgId, creater, newPrescriptionProject, cha_count, goodObj, tx)
3959
+
3960
+													service.NewHisGoodAutoCancelInfo(adminInfo.CurrentOrgId, creater, newPrescriptionProject, cha_count, goodObj, tx)
3961
+
3962
+												}
3963
+
3964
+												if nowCount == historyCount {
3965
+													if historyCount == 0 {
3966
+														recordDateStr := time.Now().Format("2006-01-02")
3967
+														recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3968
+														nowtime := recordDate.Unix()
3969
+														lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
3970
+														goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
3971
+														houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
3972
+														creater := c.GetAdminUserInfo().AdminUser.Id
3973
+														dialyPrepareOne := models.DialysisBeforePrepare{
3974
+															GoodTypeId:   goodObj.GoodTypeId,
3975
+															GoodId:       p.ProjectId,
3976
+															PatientId:    p.PatientId,
3977
+															RecordDate:   p.RecordDate,
3978
+															UserOrgId:    adminInfo.CurrentOrgId,
3979
+															Count:        nowCount,
3980
+															Ctime:        time.Now().Unix(),
3981
+															Creater:      creater,
3982
+															Status:       1,
3983
+															StorehouseId: houseConfig.StorehouseOutInfo,
3984
+															ProjectId:    p.ID,
3985
+														}
3986
+														//出库
3987
+														service.ConsumableNewHisPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, tx)
3988
+													}
3989
+												}
3990
+
3991
+												lastHisProject, _ := service.GetLastHisProject(p.PatientId, p.UserOrgId, p.RecordDate, tx, p.ProjectId)
3992
+												//查询历史出库数据
3993
+												flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
3994
+
3995
+												var out_count_five int64
3996
+												for _, item := range flowGood {
3997
+													out_count_five += item.Count
3998
+												}
3999
+												parseIntCount, _ := strconv.ParseInt(p.Count, 10, 64)
4000
+
4001
+												//如果当前处方的出库数量和已经出库的数量不一致,需要进行退库或者出库
4002
+												if out_count_five != parseIntCount {
4003
+													service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
4004
+													detail := models.AutomaticReduceDetail{
4005
+														WarehouseOutId:          0,
4006
+														WarehouseOutOrderNumber: "",
4007
+														PatientId:               p.PatientId,
4008
+														Ctime:                   time.Now().Unix(),
4009
+														Mtime:                   0,
4010
+														Status:                  1,
4011
+														RecordTime:              p.RecordDate,
4012
+														OrgId:                   p.UserOrgId,
4013
+														GoodId:                  p.ProjectId,
4014
+														GoodTypeId:              0,
4015
+														Count:                   parseIntCount,
4016
+														Type:                    0,
4017
+														ProjectId:               lastHisProject.ID,
4018
+														StorehouseId:            0,
4019
+													}
4020
+
4021
+													service.CreateNewAutoDetail(detail, tx)
4022
+												}
4023
+												//	//查询耗材最后一次出库记录
4024
+												//	wareOut, _ := service.GetLastGoodWarehouseOutInfoByProjectId(p.ProjectId, patient_id, recordDateTime, lastHisProject.ID)
4025
+												//	//查询默认出库仓库库存
4026
+												//	storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
4027
+												//	if len(wareOut) > 0 {
4028
+												//
4029
+												//		for _, it := range wareOut {
4030
+												//			//回退库存
4031
+												//			service.ModifyGoodWarehouseInfo(it.GoodId, it.WarehouseInfotId, it.OrgId, it.Count)
4032
+												//
4033
+												//			//删除出库记录
4034
+												//			service.DeleteGoodWarehouseOutInfo(it.GoodId, it.SysRecordTime, it.OrgId, it.ProjectId)
4035
+												//
4036
+												//		}
4037
+												//	}
4038
+												//
4039
+												//	timeStr := time.Now().Format("2006-01-02")
4040
+												//	timeArr := strings.Split(timeStr, "-")
4041
+												//	total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
4042
+												//
4043
+												//	total = total + 1
4044
+												//	warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
4045
+												//	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
4046
+												//	number = number + total
4047
+												//	warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
4048
+												//
4049
+												//	operation_time := time.Now().Unix()
4050
+												//	creater := c.GetAdminUserInfo().AdminUser.Id
4051
+												//
4052
+												//	recordDateStr := time.Now().Format("2006-01-02")
4053
+												//	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
4054
+												//	nowtime := recordDate.Unix()
4055
+												//	warehouseOut := models.WarehouseOut{
4056
+												//		WarehouseOutOrderNumber: warehousing_out_order,
4057
+												//		OperationTime:           operation_time,
4058
+												//		OrgId:                   adminInfo.CurrentOrgId,
4059
+												//		Creater:                 creater,
4060
+												//		Ctime:                   time.Now().Unix(),
4061
+												//		Status:                  1,
4062
+												//		WarehouseOutTime:        nowtime,
4063
+												//		Type:                    1,
4064
+												//		StorehouseId:            storeConfig.StorehouseOutInfo,
4065
+												//		IsCheck:                 1,
4066
+												//		IsSys:                   1,
4067
+												//	}
4068
+												//	//查询是否生成出库单
4069
+												//	out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
4070
+												//	if out.ID == 0 {
4071
+												//		service.AddNewSigleWarehouseOut(&warehouseOut, tx)
4072
+												//	}
4073
+												//
4074
+												//	lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
4075
+												//
4076
+												//	goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(p.ProjectId, tx)
4077
+												//	houseConfig, _ := service.GetNewAllStoreHouseConfig(p.UserOrgId, tx)
4078
+												//
4079
+												//	dialyPrepareOne := models.DialysisBeforePrepare{
4080
+												//		GoodTypeId:   goodObj.GoodTypeId,
4081
+												//		GoodId:       p.ProjectId,
4082
+												//		PatientId:    p.PatientId,
4083
+												//		RecordDate:   p.RecordDate,
4084
+												//		UserOrgId:    adminInfo.CurrentOrgId,
4085
+												//		Count:        parseIntCount,
4086
+												//		Ctime:        time.Now().Unix(),
4087
+												//		Creater:      creater,
4088
+												//		Status:       1,
4089
+												//		StorehouseId: houseConfig.StorehouseOutInfo,
4090
+												//		ProjectId:    lastHisProject.ID,
4091
+												//	}
4092
+												//	//判断是否是零用耗材(非零用)
4093
+												//	if goodObj.IsUse == 2 || goodObj.IsUse == 0 {
4094
+												//
4095
+												//		//查询历史出库数据
4096
+												//		flowGood, _ := service.GetNewStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
4097
+												//		var out_count int64
4098
+												//		for _, item := range flowGood {
4099
+												//			out_count += item.Count
4100
+												//		}
4101
+												//		//如果历史数和当前数据不想等才进行退库出库
4102
+												//		if out_count != parseIntCount {
4103
+												//			service.ConsumableNewPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount, tx)
4104
+												//
4105
+												//			service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
4106
+												//			detail := models.AutomaticReduceDetail{
4107
+												//				WarehouseOutId:          0,
4108
+												//				WarehouseOutOrderNumber: "",
4109
+												//				PatientId:               p.PatientId,
4110
+												//				Ctime:                   time.Now().Unix(),
4111
+												//				Mtime:                   0,
4112
+												//				Status:                  1,
4113
+												//				RecordTime:              p.RecordDate,
4114
+												//				OrgId:                   p.UserOrgId,
4115
+												//				GoodId:                  p.ProjectId,
4116
+												//				GoodTypeId:              0,
4117
+												//				Count:                   parseIntCount,
4118
+												//				Type:                    0,
4119
+												//				ProjectId:               lastHisProject.ID,
4120
+												//				StorehouseId:            0,
4121
+												//			}
4122
+												//
4123
+												//			service.CreateNewAutoDetail(detail, tx)
4124
+												//
4125
+												//			//查询剩余库存
4126
+												//			goodList, _ := service.GetNewAllGoodSumCount(p.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, tx)
4127
+												//			var sum_count int64
4128
+												//			for _, item := range goodList {
4129
+												//				sum_count += item.StockCount
4130
+												//			}
4131
+												//
4132
+												//			//更新剩余库存
4133
+												//			service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, p.ProjectId, adminInfo.CurrentOrgId, sum_count, tx)
4134
+												//
4135
+												//			//耗材
4136
+												//			service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
4137
+												//
4138
+												//		}
4139
+												//		//判断是否是零用耗材(零用但是是出库耗材)
4140
+												//		if goodObj.IsUse == 1 && goodObj.IsWarehouse == 1 {
4141
+												//
4142
+												//			//查询历史出库数据
4143
+												//			flowGood, _ := service.GetStockFlowIsBatchNumberSeventy(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID)
4144
+												//			var out_count int64
4145
+												//			for _, item := range flowGood {
4146
+												//				out_count += item.Count
4147
+												//			}
4148
+												//			//如果历史数和当前数据不想等才进行退库出库
4149
+												//			if out_count != parseIntCount {
4150
+												//				service.ConsumableNewPrescriptionDelivery(adminInfo.CurrentOrgId, p.PatientId, p.RecordDate, &dialyPrepareOne, &lastOut, creater, parseIntCount, tx)
4151
+												//
4152
+												//				service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
4153
+												//				detail := models.AutomaticReduceDetail{
4154
+												//					WarehouseOutId:          0,
4155
+												//					WarehouseOutOrderNumber: "",
4156
+												//					PatientId:               p.PatientId,
4157
+												//					Ctime:                   time.Now().Unix(),
4158
+												//					Mtime:                   0,
4159
+												//					Status:                  1,
4160
+												//					RecordTime:              p.RecordDate,
4161
+												//					OrgId:                   p.UserOrgId,
4162
+												//					GoodId:                  p.ProjectId,
4163
+												//					GoodTypeId:              0,
4164
+												//					Count:                   parseIntCount,
4165
+												//					Type:                    0,
4166
+												//					ProjectId:               p.ID,
4167
+												//					StorehouseId:            0,
4168
+												//				}
4169
+												//
4170
+												//				service.CreateNewAutoDetail(detail, tx)
4171
+												//
4172
+												//				//查询剩余库存
4173
+												//				goodList, _ := service.GetNewAllGoodSumCount(p.ProjectId, adminInfo.CurrentOrgId, houseConfig.StorehouseOutInfo, tx)
4174
+												//				var sum_count int64
4175
+												//				for _, item := range goodList {
4176
+												//					sum_count += item.StockCount
4177
+												//				}
4178
+												//
4179
+												//				//更新剩余库存
4180
+												//				service.UpdateNewGoodFlushCount(houseConfig.StorehouseOutInfo, p.ProjectId, adminInfo.CurrentOrgId, sum_count, tx)
4181
+												//
4182
+												//				//耗材
4183
+												//				service.UpdateNewGoodSumCountSeven(sum_count, p.ProjectId, adminInfo.CurrentOrgId, tx)
4184
+												//			}
4185
+												//
4186
+												//		}
4187
+												//
4188
+												//	}
4189
+												//
4190
+												//}
4191
+
4192
+												//记录日志
4193
+												byterequest, _ := json.Marshal(p)
4194
+												adviceLog := models.XtDoctorAdviceLog{
4195
+													UserOrgId:   p.UserOrgId,
4196
+													PatientId:   p.PatientId,
4197
+													AdminUserId: adminInfo.AdminUser.Id,
4198
+													Module:      1,
4199
+													ErrLog:      string(byterequest),
4200
+													Status:      1,
4201
+													Ctime:       time.Now().Unix(),
4202
+													Mtime:       0,
4203
+													Source:      "电脑端新建his项目",
4204
+													RecordDate:  p.RecordDate,
4205
+												}
4206
+												service.CreateDoctorAdviceLog(adviceLog)
4207
+
4208
+												projectList = append(projectList, p)
4209
+
4210
+												if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
4211
+													//新增或者编辑项目,修改对应的标签数据
4212
+													labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
4213
+													if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
4214
+														var label models.HisLabelPrintInfo
4215
+														project, _ := service.GetProjectDetail(p.ProjectId)
4216
+														if project.CostClassify == 3 { //类别为检验检查
4217
+															if p.TeamId > 0 { //检验检查组套
4218
+																tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
4219
+																if tempLabel.ID == 0 {
4220
+																	team, _ := service.GetProjectTeamDetail(p.TeamId)
4221
+																	label.Number = tempPrescription.PrescriptionNumber
4222
+																	label.ProjectId = project.ID
4223
+																	label.Status = 1
4224
+																	label.IsPrint = 2
4225
+																	label.DoctorId = info.DoctorId
4226
+																	label.UserOrgId = p.UserOrgId
4227
+																	label.PatientId = patient_id
4228
+																	label.RecordDate = recordDateTime
4229
+																	label.Ctime = time.Now().Unix()
4230
+																	label.Mtime = time.Now().Unix()
4231
+																	label.ItemId = p.TeamId
4232
+																	label.FeedetlSn = p.FeedetlSn
4233
+																	label.PProjectId = p.ID
4234
+																	label.ProjectName = team.ProjectTeam
4235
+																	label.PatientName = patient.Name
4236
+																	service.CreateNewHisLabelRecord(&label, tx)
4237
+																}
4238
+															} else { //单条检验检查项目
4239
+																label.Number = tempPrescription.PrescriptionNumber
4240
+																label.ProjectId = project.ID
4241
+																label.Status = 1
4242
+																label.DoctorId = info.DoctorId
4243
+																label.UserOrgId = p.UserOrgId
4244
+																label.PatientId = patient_id
4245
+																label.RecordDate = recordDateTime
4246
+																label.IsPrint = 2
4247
+																label.Ctime = time.Now().Unix()
4248
+																label.Mtime = time.Now().Unix()
4249
+																label.FeedetlSn = p.FeedetlSn
4250
+																label.PProjectId = p.ID
4251
+																label.ItemId = p.TeamId
4252
+																label.ProjectName = project.ProjectName
4253
+																label.PatientName = patient.Name
4254
+																service.CreateNewHisLabelRecord(&label, tx)
4255
+															}
4256
+														}
4257
+													}
4258
+												}
4259
+
4260
+											}
4261
+										}
4262
+									}
4263
+
4264
+									if adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10164 {
4265
+
3828 4266
 										//耗材出库
3829 4267
 										if p.Type == 3 {
3830 4268
 
@@ -3836,9 +4274,6 @@ func (c *HisApiController) CreateHisPrescription() {
3836 4274
 
3837 4275
 											nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
3838 4276
 
3839
-											//fmt.Println("p----------------------------------------------------", p.ProjectId)
3840
-											//fmt.Println("p----------------------------------------------------", nowCount)
3841
-											//fmt.Println("p----------------------------------------------------", historyCount)
3842 4277
 											//如果当前处方数量大于历史数据,则需要出库
3843 4278
 											if nowCount > historyCount {
3844 4279
 
@@ -3998,9 +4433,6 @@ func (c *HisApiController) CreateHisPrescription() {
3998 4433
 											}
3999 4434
 											parseIntCount, _ := strconv.ParseInt(p.Count, 10, 64)
4000 4435
 
4001
-											//fmt.Println("p.ProjectId-----------------", p.ProjectId)
4002
-											//fmt.Println("out_count_five===============", out_count_five)
4003
-											//fmt.Println("parseIntCount===============", parseIntCount)
4004 4436
 											//如果当前处方的出库数量和已经出库的数量不一致,需要进行退库或者出库
4005 4437
 											if out_count_five != parseIntCount {
4006 4438
 												service.UpdateNewAutomaticReduce(p.PatientId, p.RecordDate, p.ProjectId, lastHisProject.ID, tx)
@@ -4262,6 +4694,7 @@ func (c *HisApiController) CreateHisPrescription() {
4262 4694
 
4263 4695
 										}
4264 4696
 									}
4697
+
4265 4698
 								}
4266 4699
 
4267 4700
 								//插入检验数据

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

@@ -960,7 +960,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
960 960
 		}
961 961
 
962 962
 		//针对患者称重两次没有数据的问题
963
-		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 {
963
+		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 {
964 964
 
965 965
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
966 966
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)

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

@@ -6469,6 +6469,8 @@ func (c *DialysisAPIController) CreateConsumables() {
6469 6469
 			}
6470 6470
 		}
6471 6471
 
6472
+		fmt.Println("active-----------------------", active)
6473
+		fmt.Println("len(goods)-----------------------", len(goods))
6472 6474
 		//新增
6473 6475
 		if active == 1 && len(goods) > 0 {
6474 6476
 			for _, item := range dialysisBefor {

+ 18 - 19
controllers/patient_dataconfig_api_controller.go View File

@@ -262,15 +262,15 @@ func (this *PatientDataConfigAPIController) DeleteSickHistory() {
262 262
 	}
263 263
 
264 264
 	adminUserInfo := this.GetAdminUserInfo()
265
-	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
266
-	if getPatientErr != nil {
267
-		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
268
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
269
-		return
270
-	} else if patient == nil {
271
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
272
-		return
273
-	}
265
+	//patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
266
+	//if getPatientErr != nil {
267
+	//	this.ErrorLog("获取患者信息失败:%v", getPatientErr)
268
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
269
+	//	return
270
+	//} else if patient == nil {
271
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
272
+	//	return
273
+	//}
274 274
 
275 275
 	recordIDStrs := strings.Split(idsStr, ",")
276 276
 	recordIDs := make([]int64, 0, len(recordIDStrs))
@@ -312,17 +312,16 @@ func (this *PatientDataConfigAPIController) ModifySickHistory() {
312 312
 	//loc, _ := time.LoadLocation("Local")
313 313
 	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
314 314
 
315
-	fmt.Println("checkDate--------------", checkDate)
316 315
 	adminUserInfo := this.GetAdminUserInfo()
317
-	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
318
-	if getPatientErr != nil {
319
-		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
320
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
321
-		return
322
-	} else if patient == nil {
323
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
324
-		return
325
-	}
316
+	//patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
317
+	//if getPatientErr != nil {
318
+	//	this.ErrorLog("获取患者信息失败:%v", getPatientErr)
319
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
320
+	//	return
321
+	//} else if patient == nil {
322
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
323
+	//	return
324
+	//}
326 325
 
327 326
 	now := time.Now().Unix()
328 327
 

+ 17 - 5
models/stock_models.go View File

@@ -344,17 +344,29 @@ func (WarehouseOutInfoNight) TableName() string {
344 344
 }
345 345
 
346 346
 type WarehouseOutInfoSeven struct {
347
-	ID            int64 `gorm:"column:id" json:"id"`
348
-	Count         int64 `gorm:"column:count" json:"count"`
349
-	SysRecordTime int64 `gorm:"column:sys_record_time" json:"sys_record_time"`
350
-	PatientId     int64 `gorm:"column:patient_id" json:"patient_id"`
351
-	GoodId        int64 `gorm:"column:good_id" json:"good_id"`
347
+	ID            int64                  `gorm:"column:id" json:"id"`
348
+	Count         int64                  `gorm:"column:count" json:"count"`
349
+	SysRecordTime int64                  `gorm:"column:sys_record_time" json:"sys_record_time"`
350
+	PatientId     int64                  `gorm:"column:patient_id" json:"patient_id"`
351
+	GoodId        int64                  `gorm:"column:good_id" json:"good_id"`
352
+	GoodInfo      XtGoodInformationTenty `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
352 353
 }
353 354
 
354 355
 func (WarehouseOutInfoSeven) TableName() string {
355 356
 	return "xt_warehouse_out_info"
356 357
 }
357 358
 
359
+type XtGoodInformationTenty struct {
360
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
361
+	GoodTypeId int64 `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
362
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
363
+	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
364
+}
365
+
366
+func (XtGoodInformationTenty) TableName() string {
367
+	return "xt_good_information"
368
+}
369
+
358 370
 type SalesReturn struct {
359 371
 	ID           int64  `gorm:"column:id" json:"id"`
360 372
 	OrderNumber  string `gorm:"column:order_number" json:"order_number"`

+ 1 - 1
service/mobile_dialysis_service.go View File

@@ -3127,7 +3127,7 @@ func GetPatientAutoMatic(patient_id int64, orgID int64, record_time int64, good_
3127 3127
 
3128 3128
 func GetAllWarehouseOutSumList(patient_id int64, orgID int64, record_time int64) (info []*models.WarehouseOutInfoSeven, err error) {
3129 3129
 
3130
-	err = XTReadDB().Where("patient_id = ? and org_id = ? and sys_record_time = ? and status = 1", patient_id, orgID, record_time).Find(&info).Error
3130
+	err = XTReadDB().Where("patient_id = ? and org_id = ? and sys_record_time = ? and status = 1", patient_id, orgID, record_time).Preload("GoodInfo", "status=1 and org_id = ?", orgID).Find(&info).Error
3131 3131
 	return info, err
3132 3132
 }
3133 3133
 

+ 7 - 0
service/self_drug_service.go View File

@@ -600,6 +600,13 @@ func GetAllBaseDrugLibList(org_id int64) (drugs []*Drugs, err error) {
600 600
 	return
601 601
 }
602 602
 
603
+func GetAllBaseDrugLibListTwo(org_id int64) (drugs []*Drugs, err error) {
604
+
605
+	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&drugs).Error
606
+
607
+	return drugs, err
608
+}
609
+
603 610
 type PrivateDrug struct {
604 611
 	DrugName           string         `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
605 612
 	ID                 int64          `gorm:"column:id" json:"id" form:"id"`

+ 2 - 2
service/statistis_qc_service.go View File

@@ -126,7 +126,7 @@ func GetDialysisStats(start int64, end int64, mode int64, org_id int64, time_way
126 126
         JOIN
127 127
             xt_treatment_mode t ON p.mode_id = t.mode_id
128 128
         WHERE
129
-            FROM_UNIXTIME(p.record_date) >= ? AND FROM_UNIXTIME(p.record_date) <= ? AND p.user_org_id = ? and p.mode_id = ?
129
+            FROM_UNIXTIME(p.record_date) >= ? AND FROM_UNIXTIME(p.record_date) <= ? AND p.user_org_id = ? and p.mode_id = ? and p.status=1
130 130
         GROUP BY
131 131
            日期
132 132
     `, strings.Join(selectClauses, ", "))
@@ -141,7 +141,7 @@ func GetDialysisStats(start int64, end int64, mode int64, org_id int64, time_way
141 141
         JOIN
142 142
             xt_treatment_mode t ON p.mode_id = t.mode_id
143 143
         WHERE
144
-            FROM_UNIXTIME(p.record_date) >= ? AND FROM_UNIXTIME(p.record_date) <= ? AND p.user_org_id = ? 
144
+            FROM_UNIXTIME(p.record_date) >= ? AND FROM_UNIXTIME(p.record_date) <= ? AND p.user_org_id = ? and p.status=1
145 145
         GROUP BY
146 146
            日期
147 147
     `, strings.Join(selectClauses, ", "))

+ 1 - 1
service/stock_service.go View File

@@ -9796,7 +9796,7 @@ func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit in
9796 9796
 		db = db.Where("is_upload = 2 or is_upload =0")
9797 9797
 	}
9798 9798
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
9799
-
9799
+	fmt.Println("totla====================", total)
9800 9800
 	return list, total, err
9801 9801
 }
9802 9802