xmg123 4 giorni fa
parent
commit
1f55495c29

BIN
XT_New.exe Vedi File


+ 6 - 6
controllers/base_api_controller.go Vedi 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 = 10265 //机构id
86
+		subscibe.OrgId = 10164 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,8 +93,8 @@ 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 = 10265 //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 12123 //4
96
+		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 11811 //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
100 100
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -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 = 10265 //机构id小英9675或4
332
+		subscibe.OrgId = 10164 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,8 +339,8 @@ 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 = 10265 //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 12123 //4
342
+		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 11811 //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes
346 346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 5 - 0
controllers/drug_stock_api_contorller.go Vedi File

@@ -3361,6 +3361,8 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3361 3361
 
3362 3362
 		}
3363 3363
 
3364
+		service.ModifyDrugWarehouseInfoById(item.ID, in_cout, tx)
3365
+
3364 3366
 		Creator := c.GetAdminUserInfo().AdminUser.Id
3365 3367
 
3366 3368
 		//查询默认仓库
@@ -3562,6 +3564,9 @@ func (c *StockDrugApiController) ReturnCheckWarehouseingInfo() {
3562 3564
 
3563 3565
 	}
3564 3566
 	for _, item := range list {
3567
+
3568
+		//清空库存
3569
+		service.DeleteModiftyDrugWarehouseInfo(item.ID, tx)
3565 3570
 		//删除流水
3566 3571
 		service.UpdateNewWarehousingInfoFlow(item.ID, orgId, tx)
3567 3572
 		medical, _ := service.GetNewBaseDrugMedical(item.DrugId, tx)

+ 105 - 115
controllers/his_api_controller.go Vedi File

@@ -2248,12 +2248,97 @@ func (c *HisApiController) CreateHisPrescription() {
2248 2248
 	//已发药和已收费限制逻辑
2249 2249
 	isMidicine := false
2250 2250
 	isCharge := false
2251
+	//是否有库存
2252
+	isSumCount := false
2253
+
2254
+	is_sum_total := false
2255
+
2256
+	var drug_name = ""
2257
+
2258
+	var good_name = ""
2251 2259
 
2252 2260
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
2253 2261
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
2254 2262
 		if len(prescriptions) > 0 {
2255 2263
 			for _, item := range prescriptions {
2256 2264
 				items := item.(map[string]interface{})
2265
+
2266
+				if adminInfo.CurrentOrgId == 9478 {
2267
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
2268
+						advices := items["advices"].([]interface{})
2269
+						if len(advices) > 0 {
2270
+							for _, advice := range advices {
2271
+								var adviceId int64
2272
+								if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
2273
+									adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
2274
+								}
2275
+								var drug_id int64
2276
+								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
2277
+									drug_id = int64(advice.(map[string]interface{})["id"].(float64))
2278
+								}
2279
+								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2280
+								//查询该药品是否存在开药记录
2281
+								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
2282
+								if advicelist.ID == 0 {
2283
+									if drug.IsUse != 1 {
2284
+										if drug.SumCount == 0 {
2285
+											drug_name = drug.DrugName
2286
+											isSumCount = true
2287
+										}
2288
+									}
2289
+
2290
+								}
2291
+							}
2292
+						}
2293
+					}
2294
+
2295
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
2296
+						projects := items["project"].([]interface{})
2297
+						if len(projects) > 0 {
2298
+							for _, project := range projects {
2299
+
2300
+								var project_id int64
2301
+								var project_type int64
2302
+								var project_name string
2303
+
2304
+								if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
2305
+									project_id = int64(project.(map[string]interface{})["project_id"].(float64))
2306
+								}
2307
+
2308
+								if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
2309
+									project_type = int64(project.(map[string]interface{})["type"].(float64))
2310
+								}
2311
+
2312
+								if project.(map[string]interface{})["project_name"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_name"]).String() == "string" {
2313
+									project_name = project.(map[string]interface{})["project_name"].(string)
2314
+
2315
+								}
2316
+
2317
+								if project_type == 3 {
2318
+
2319
+									//查找该耗材的出库记录
2320
+									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
2321
+
2322
+									if len(goodWarehouseInfo) == 0 {
2323
+										//查询耗材库存
2324
+										list, _ := service.GetGoodWarehouseInfoSevenTen(project_id, storeConfig.StorehouseOutInfo)
2325
+
2326
+										var stock_count int64
2327
+										for _, it := range list {
2328
+											stock_count += it.StockCount
2329
+										}
2330
+
2331
+										if stock_count == 0 {
2332
+											good_name = project_name
2333
+											is_sum_total = true
2334
+										}
2335
+									}
2336
+								}
2337
+							}
2338
+						}
2339
+					}
2340
+				}
2341
+
2257 2342
 				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
2258 2343
 					utils.ErrorLog("id")
2259 2344
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -2281,6 +2366,25 @@ func (c *HisApiController) CreateHisPrescription() {
2281 2366
 		return
2282 2367
 	}
2283 2368
 
2369
+	if adminInfo.CurrentOrgId == 9478 {
2370
+		//不是保存处方出库
2371
+		drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
2372
+
2373
+		if drugOutConfig.IsOpen == 1 {
2374
+			if isSumCount == true {
2375
+				c.ServeDynamicFailJsonSend(drug_name + "库存不足,保存失败")
2376
+				return
2377
+			}
2378
+		}
2379
+
2380
+		if goodOutConfig.IsOpen == 1 {
2381
+			if is_sum_total == true {
2382
+				c.ServeDynamicFailJsonSend(good_name + "库存不足,保存失败")
2383
+				return
2384
+			}
2385
+		}
2386
+	}
2387
+
2284 2388
 	// 开始主事务
2285 2389
 	db := service.XTWriteDB()
2286 2390
 	tx := db.Begin()
@@ -3362,8 +3466,6 @@ func (c *HisApiController) CreateHisPrescription() {
3362 3466
 											//查询该患者耗材的历史数据
3363 3467
 											ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
3364 3468
 
3365
-											fmt.Println("ordProject-----------------------", ordProject.ProjectId)
3366
-
3367 3469
 											count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
3368 3470
 
3369 3471
 											//数量发生改变
@@ -3817,7 +3919,7 @@ func (c *HisApiController) CreateHisPrescription() {
3817 3919
 												}
3818 3920
 
3819 3921
 												drugMedical, _ := service.GetBaseDrugMedical(s.DrugId)
3820
-												fmt.Println("0000000000000000000000", drugMedical.SumCount)
3922
+
3821 3923
 												if drugMedical.SumCount == 0 {
3822 3924
 													tx.Rollback()
3823 3925
 													c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
@@ -3835,74 +3937,6 @@ func (c *HisApiController) CreateHisPrescription() {
3835 3937
 													return
3836 3938
 												}
3837 3939
 
3838
-												//针对康德
3839
-												//if s.UserOrgId == 10402 || s.UserOrgId == 10164 {
3840
-												//	//获取该药品的总入库数量
3841
-												//	drugWarehouseinfo, _ := service.GetAllDrugInfoList(s.DrugId, s.UserOrgId)
3842
-												//
3843
-												//	//获取该药品总共开了多少支医嘱
3844
-												//	hisDocInfoList, _ := service.GetHisDocInfoList(s.DrugId, s.UserOrgId)
3845
-												//	var in_count int64
3846
-												//	var in_prescription_number_total int64
3847
-												//	if len(drugWarehouseinfo) > 0 {
3848
-												//		for _, item := range drugWarehouseinfo {
3849
-												//			if item.MaxUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3850
-												//
3851
-												//				in_count += item.WarehousingCount * drugMedical.MinNumber
3852
-												//			}
3853
-												//
3854
-												//			if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3855
-												//
3856
-												//				in_count += item.WarehousingCount
3857
-												//			}
3858
-												//
3859
-												//			if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3860
-												//
3861
-												//				in_count += item.WarehousingCount
3862
-												//			}
3863
-												//
3864
-												//		}
3865
-												//	}
3866
-												//
3867
-												//	if len(hisDocInfoList) > 0 {
3868
-												//
3869
-												//		for _, item := range hisDocInfoList {
3870
-												//			if item.PrescribingNumberUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3871
-												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3872
-												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3873
-												//
3874
-												//				in_prescription_number_total += prescribingNumberSevenTy * drug.MinNumber
3875
-												//			}
3876
-												//
3877
-												//			if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3878
-												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3879
-												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3880
-												//				in_prescription_number_total += prescribingNumberSevenTy
3881
-												//			}
3882
-												//
3883
-												//			if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3884
-												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3885
-												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3886
-												//				in_prescription_number_total += prescribingNumberSevenTy
3887
-												//			}
3888
-												//		}
3889
-												//	}
3890
-												//	//
3891
-												//	//fmt.Println("no_user_total------------------------------", no_user_total)
3892
-												//	//fmt.Println("in_prescription_number_total---------------------------", in_prescription_number_total)
3893
-												//	//fmt.Println("in_count----------------------------------", in_count)
3894
-												//
3895
-												//	//如果已经开过的医嘱 加上未开的医嘱数量 大于 入库总数量则提示库存不足
3896
-												//	if no_user_total+in_prescription_number_total > in_count {
3897
-												//		tx.Rollback()
3898
-												//		c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3899
-												//		return
3900
-												//	}
3901
-												//
3902
-												//}
3903
-
3904
-												//查询该药品所有入库数量
3905
-
3906 3940
 											}
3907 3941
 
3908 3942
 											if s.ID > 0 {
@@ -4531,46 +4565,6 @@ func (c *HisApiController) CreateHisPrescription() {
4531 4565
 
4532 4566
 												nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
4533 4567
 
4534
-												////针对康德
4535
-												//if p.UserOrgId == 10164 || p.UserOrgId == 10402 {
4536
-												//
4537
-												//	//查询耗材的总入库数量
4538
-												//	warehouseInfo, _ := service.GetAllWarehouseInfo(p.ProjectId, adminInfo.CurrentOrgId)
4539
-												//
4540
-												//	//查询该耗材的总出库数量
4541
-												//	prescriptionGood, _ := service.GetHisPrescriptionByGoodId(p.ProjectId, adminInfo.CurrentOrgId)
4542
-												//
4543
-												//	var all_good_count int64
4544
-												//
4545
-												//	var prescription_count int64
4546
-												//	if len(warehouseInfo) > 0 {
4547
-												//
4548
-												//		for _, item := range warehouseInfo {
4549
-												//			all_good_count += item.WarehousingCount
4550
-												//		}
4551
-												//	}
4552
-												//	if len(prescriptionGood) > 0 {
4553
-												//		for _, item := range prescriptionGood {
4554
-												//
4555
-												//			hisCount, _ := strconv.ParseInt(item.Count, 10, 64)
4556
-												//			prescription_count += hisCount
4557
-												//		}
4558
-												//	}
4559
-												//
4560
-												//	//fmt.Println("prescription_count-------------------------", prescription_count)
4561
-												//	//fmt.Println("nowCount-------------------------", nowCount)
4562
-												//	//fmt.Println("all_good_count-------------------------", all_good_count)
4563
-												//
4564
-												//	if prescription_count+nowCount > all_good_count {
4565
-												//		goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
4566
-												//		tx.Rollback()
4567
-												//		c.ServeDynamicFailJsonSend(goodInfoOne.GoodName + "耗材无库存,保存失败!")
4568
-												//		return
4569
-												//	}
4570
-												//}
4571
-
4572
-												fmt.Println("nowCount222=================", nowCount)
4573
-												fmt.Println("historyCount-333----------------", historyCount)
4574 4568
 												//如果当前处方数量大于历史数据,则需要出库
4575 4569
 
4576 4570
 												if nowCount > historyCount {
@@ -6127,8 +6121,6 @@ func (c *HisApiController) CreateHisPrescription() {
6127 6121
 
6128 6122
 					parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
6129 6123
 
6130
-					fmt.Println("out_count_five-------------------", out_count_five)
6131
-					fmt.Println("parseIntCount---------------", parseIntCount)
6132 6124
 					if out_count_five != parseIntCount {
6133 6125
 
6134 6126
 						//查询耗材最后一次出库记录
@@ -7097,7 +7089,6 @@ func (c *HisApiController) DeletePrescription() {
7097 7089
 			//查询今日是否有出库数据
7098 7090
 			lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, item.AdviceDate, tx, 1)
7099 7091
 
7100
-			fmt.Println("lastWarehouseOut-----------------------------------", lastWarehouseOut)
7101 7092
 			if lastWarehouseOut.ID == 0 {
7102 7093
 				service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
7103 7094
 			}
@@ -7154,7 +7145,6 @@ func (c *HisApiController) DeletePrescription() {
7154 7145
 			warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
7155 7146
 		}
7156 7147
 
7157
-		fmt.Println("长度-------------------------------", warehousingOutInfo)
7158 7148
 		for _, it := range warehousingOutInfo {
7159 7149
 			//查询今日是否有出库数据
7160 7150
 			lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, it.SysRecordTime, tx, 1)

+ 61 - 0
controllers/inspection_api_controller.go Vedi File

@@ -46,6 +46,10 @@ func InspectionApiRegistRouters() {
46 46
 
47 47
 	beego.Router("/api/getinspectionchildlist", &InspectionApiController{}, "Get:GetInspectionChildList")
48 48
 
49
+	beego.Router("/api/patient/getmajorinpsectionlist", &InspectionApiController{}, "Get:GetMajorInpsectionList")
50
+
51
+	beego.Router("/api/patient/getpatientinspectionlist", &InspectionApiController{}, "Get:GetInspectionProjectList")
52
+
49 53
 }
50 54
 func (c *InspectionApiController) SetInspectionRemind() {
51 55
 	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
@@ -1198,3 +1202,60 @@ func (c *InspectionApiController) GetInspectionChildList() {
1198 1202
 		"referenceList": referenceList,
1199 1203
 	})
1200 1204
 }
1205
+
1206
+func (c *InspectionApiController) GetMajorInpsectionList() {
1207
+
1208
+	patient_id, _ := c.GetInt64("patient_id")
1209
+
1210
+	org_id := c.GetAdminUserInfo().CurrentOrgId
1211
+
1212
+	patient, _ := service.GetPatientByIDOne(org_id, patient_id)
1213
+	inspection, _ := service.GetInspectionGroup(patient_id, org_id)
1214
+
1215
+	referenceList, _ := service.GetInspetionRefenceList(org_id)
1216
+
1217
+	if len(inspection) > 0 {
1218
+		for _, item := range inspection {
1219
+			lastInspection, _ := service.GetLastInspectionProject(patient_id, org_id, item.ProjectId)
1220
+			item.InspectDate = lastInspection.InspectDate
1221
+			inspecList, _ := service.GetInspectionByProjectId(patient_id, org_id, item.ProjectId)
1222
+			item.Count = int64(len(inspecList))
1223
+		}
1224
+	}
1225
+	c.ServeSuccessJSON(map[string]interface{}{
1226
+		"referenceList": referenceList,
1227
+		"inspection":    inspection,
1228
+		"patient":       patient,
1229
+	})
1230
+}
1231
+
1232
+func (c *InspectionApiController) GetInspectionProjectList() {
1233
+
1234
+	project_id, _ := c.GetInt64("project_id")
1235
+
1236
+	patient_id, _ := c.GetInt64("patient_id")
1237
+
1238
+	limit, _ := c.GetInt64("limit")
1239
+
1240
+	page, _ := c.GetInt64("page")
1241
+
1242
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1243
+
1244
+	//先把日期归成整数
1245
+	service.UpdateInspectionProject(project_id, patient_id, orgId)
1246
+
1247
+	inspection, total, _ := service.GetInspectionProjectListByGroup(project_id, orgId, patient_id, limit, page)
1248
+
1249
+	if len(inspection) > 0 {
1250
+		for _, item := range inspection {
1251
+			project, _ := service.GetInspctionListByProject(item.PatientId, item.InspectDate, item.ProjectId)
1252
+			item.Child = project
1253
+		}
1254
+	}
1255
+
1256
+	c.ServeSuccessJSON(map[string]interface{}{
1257
+		"total":      total,
1258
+		"inspection": inspection,
1259
+	})
1260
+	return
1261
+}

+ 1 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Vedi File

@@ -6338,7 +6338,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
6338 6338
 		dialysisRecord.EndTime = endTime
6339 6339
 	}
6340 6340
 
6341
-	if adminUserInfo.Org.Id == 10766 || adminUserInfo.Org.Id == 10164 {
6341
+	if adminUserInfo.Org.Id == 10766 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 9478 {
6342 6342
 		//查询第一条监测
6343 6343
 		firstMonitor, _ := service.GetFirstMonitor(tempDialysisRecord.PatientId, tempDialysisRecord.DialysisDate)
6344 6344
 

+ 6 - 1
controllers/patient_api_controller.go Vedi File

@@ -331,6 +331,7 @@ func (c *PatientApiController) GetPatientsList() {
331 331
 	patient_type, _ := c.GetInt64("patient_type")
332 332
 	nurse, _ := c.GetInt64("nurse")
333 333
 	insuplc_admdvs_name := c.GetString("insuplc_admdvs_name")
334
+	insurance_type, _ := c.GetInt64("insurance_type")
334 335
 	if page <= 0 {
335 336
 		page = 1
336 337
 	}
@@ -369,7 +370,7 @@ func (c *PatientApiController) GetPatientsList() {
369 370
 
370 371
 	var patients []*models.Patients
371 372
 	var total int64
372
-	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime, patientSoureType, nurse, patient_type, insuplc_admdvs_name)
373
+	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime, patientSoureType, nurse, patient_type, insuplc_admdvs_name, insurance_type)
373 374
 
374 375
 	c.ServeSuccessJSON(map[string]interface{}{
375 376
 		"patients": patients,
@@ -1170,12 +1171,16 @@ func (c *PatientApiController) GetPatient() {
1170 1171
 	diseases := service.GetPatientDiseases(patient.ID)
1171 1172
 	contagions := service.GetPatientContagions(patient.ID)
1172 1173
 	patientVascularAccessOne, _ := service.GetPatientVascularAccessOne(patient.ID)
1174
+
1175
+	viewModels, _, _ := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 100)
1176
+
1173 1177
 	c.ServeSuccessJSON(map[string]interface{}{
1174 1178
 		"patient":                  patient,
1175 1179
 		"diseases":                 diseases,
1176 1180
 		"contagions":               contagions,
1177 1181
 		"infections":               infections,
1178 1182
 		"patientVascularAccessOne": patientVascularAccessOne,
1183
+		"viewModels":               viewModels,
1179 1184
 	})
1180 1185
 	return
1181 1186
 }

+ 1 - 0
controllers/self_drug_api_congtroller.go Vedi File

@@ -4025,6 +4025,7 @@ func (this *SelfDrugApiController) GetGoodNewPurchaseStockQuery() {
4025 4025
 			}
4026 4026
 			//
4027 4027
 			outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
4028
+
4028 4029
 			for _, it := range outInfo {
4029 4030
 				item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
4030 4031
 			}

+ 1 - 1
controllers/stock_in_api_controller.go Vedi File

@@ -7434,7 +7434,7 @@ func (this *StockManagerApiController) ReturnCheckWarehouseOut() {
7434 7434
 	list, err := service.GetNewWarehouseOutById(id, orgId, tx)
7435 7435
 	for _, item := range list {
7436 7436
 
7437
-		service.ModifyGoodOutInfoLog(item.GoodId, item.ID, tx)
7437
+		service.ModifyGoodOutInfoLog(item.GoodId, item.ID, item.SysRecordTime, item.OrgId, tx)
7438 7438
 		//回退库存
7439 7439
 		service.UpdateaNewGoodWarehouseInfo(item.Count, item.GoodId, item.OrgId, item.WarehouseInfotId, tx)
7440 7440
 

+ 1 - 0
models/drug_stock.go Vedi File

@@ -92,6 +92,7 @@ type DrugWarehouseInfo struct {
92 92
 	ManafacturerName          string  `gorm:"column:manafacturer_name" json:"manafacturer_name" form:"manafacturer_name"`
93 93
 	DealerName                string  `gorm:"column:dealer_name" json:"dealer_name" form:"dealer_name"`
94 94
 	DrugCode                  string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
95
+	SumCount                  int64   `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
95 96
 }
96 97
 
97 98
 func (DrugWarehouseInfo) TableName() string {

+ 1 - 0
models/inspection_models.go Vedi File

@@ -71,6 +71,7 @@ type InspectionReference struct {
71 71
 	SystemProjectId  int64  `gorm:"column:system_project_id" json:"system_project_id" form:"system_project_id"`
72 72
 	SystemItemId     int64  `gorm:"column:system_item_id" json:"system_item_id" form:"system_item_id"`
73 73
 	Sort             int64  `gorm:"column:sort" json:"sort" form:"sort"`
74
+	InspectionType   int64  `gorm:"column:inspection_type" json:"inspection_type" form:"inspection_type"`
74 75
 	//remind 	 XtCheckRemind   `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ProjectId" json:"good_info"`
75 76
 }
76 77
 

+ 1 - 0
models/patient_models.go Vedi File

@@ -238,6 +238,7 @@ type Patients struct {
238 238
 	FamalityRecord           string  `gorm:"column:famality_record" json:"famality_record" form:"famality_record"`
239 239
 	InsuplcAdmdvs            string  `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
240 240
 	OrgLogo                  string  `gorm:"column:org_logo" json:"org_logo" form:"org_logo"`
241
+	Insutype                 string  `gorm:"column:insutype" json:"insutype" form:"insutype"`
241 242
 }
242 243
 
243 244
 func (Patients) TableName() string {

+ 3 - 3
service/dialysis_service.go Vedi File

@@ -2809,7 +2809,7 @@ func BatchAdviceDoctorList(patient_id int64, advice_date int64, id int64, user_o
2809 2809
 
2810 2810
 	advice := models.DoctorAdvice{}
2811 2811
 
2812
-	err := XTWriteDB().Model(&advice).Where("id = ? and patient_id = ? and advice_date =? and user_org_id = ? and check_state=0", id, patient_id, advice_date, user_org_id).Updates(map[string]interface{}{"checker": checker, "check_state": 1, "check_time": check_time}).Error
2812
+	err := XTWriteDB().Model(&advice).Where("id = ? and patient_id = ? and advice_date =? and user_org_id = ? and (check_state=0 or check_state =2)", id, patient_id, advice_date, user_org_id).Updates(map[string]interface{}{"checker": checker, "check_state": 1, "check_time": check_time}).Error
2813 2813
 
2814 2814
 	return advice, err
2815 2815
 }
@@ -2818,7 +2818,7 @@ func BatchHisAdviceDoctorList(patient_id int64, advice_date int64, id int64, use
2818 2818
 
2819 2819
 	advice := models.HisDoctorAdvice{}
2820 2820
 
2821
-	err := XTWriteDB().Model(&advice).Where("id = ? and patient_id = ? and advice_date =? and user_org_id = ? and check_state=0", id, patient_id, advice_date, user_org_id).Updates(map[string]interface{}{"checker": checker, "check_state": 1, "check_time": check_time}).Error
2821
+	err := XTWriteDB().Model(&advice).Where("id = ? and patient_id = ? and advice_date =? and user_org_id = ? and (check_state=0 or check_state =2)", id, patient_id, advice_date, user_org_id).Updates(map[string]interface{}{"checker": checker, "check_state": 1, "check_time": check_time}).Error
2822 2822
 
2823 2823
 	return advice, err
2824 2824
 }
@@ -2827,7 +2827,7 @@ func BatchHisPrescriptionProject(patient_id int64, record_date int64, id int64,
2827 2827
 
2828 2828
 	project := models.HisPrescriptionProject{}
2829 2829
 
2830
-	err := XTWriteDB().Model(&project).Where("id = ? and patient_id = ? and record_date =? and user_org_id = ? and check_state=0", id, patient_id, record_date, user_org_id).Updates(map[string]interface{}{"checker": checker, "check_state": 1, "check_time": check_time}).Error
2830
+	err := XTWriteDB().Model(&project).Where("id = ? and patient_id = ? and record_date =? and user_org_id = ? and (check_state=0 or check_state =2)", id, patient_id, record_date, user_org_id).Updates(map[string]interface{}{"checker": checker, "check_state": 1, "check_time": check_time}).Error
2831 2831
 
2832 2832
 	return project, err
2833 2833
 

+ 36 - 3
service/inspection_service.go Vedi File

@@ -2,7 +2,6 @@ package service
2 2
 
3 3
 import (
4 4
 	"errors"
5
-	"fmt"
6 5
 	"strings"
7 6
 	"time"
8 7
 
@@ -112,8 +111,6 @@ func EditPatientInspection(add []models.Inspection, edit []models.Inspection, no
112 111
 
113 112
 	if len(edit) > 0 {
114 113
 		for _, item := range edit {
115
-			fmt.Println("o----------------------", item.ItemId)
116
-			fmt.Println("value----------------------", item.InspectValue)
117 114
 			err = tx.Save(&item).Error
118 115
 			if err != nil {
119 116
 				tx.Rollback()
@@ -463,3 +460,39 @@ func GetNewInspectionDetailList(project_id int64, inspect_value int64, patient_i
463 460
 
464 461
 	return inpection, err
465 462
 }
463
+
464
+func GetInspetionRefenceList(orgId int64) (reference []*models.InspectionReference, err error) {
465
+
466
+	var count int
467
+	err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = 0", orgId).Count(&count).Error
468
+	if count > 0 {
469
+		err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = 0", orgId).Group("project_id").Order("project_id,created_time").Find(&reference).Error
470
+	} else {
471
+		err = readDb.Model(&models.InspectionReference{}).Where("org_id=0 and status=1 and inspection_type = 0").Group("project_id").Order("project_id,created_time").Find(&reference).Error
472
+	}
473
+
474
+	return reference, err
475
+}
476
+
477
+func UpdateInspectionProject(project_id int64, patient_id int64, org_id int64) (models.XtInspection, error) {
478
+
479
+	inspection := models.XtInspection{}
480
+	query := `UPDATE xt_inspection SET inspect_date = UNIX_TIMESTAMP(FROM_UNIXTIME(inspect_date, '%Y-%m-%d 00:00:00')) WHERE project_id = ? and patient_id = ? and org_id = ? and status=1`
481
+	err := XTWriteDB().Model(&inspection).Exec(query, project_id, patient_id, org_id).Error
482
+	return inspection, err
483
+
484
+}
485
+
486
+func GetInspectionProjectListByGroup(project_id int64, org_id int64, patient_id int64, limit int64, page int64) (inspection []*models.Inspection, total int64, err error) {
487
+
488
+	err = readDb.Where("patient_id =? and project_id = ? and org_id = ? and status=1", patient_id, project_id, org_id).Group("inspect_date").Offset(page - 1).Limit(limit).Find(&inspection).Error
489
+
490
+	return inspection, total, err
491
+}
492
+
493
+func GetInspctionListByProject(patient_id int64, inspect_date int64, project_id int64) (inspection []*models.Inspection, err error) {
494
+
495
+	err = readDb.Where("patient_id = ? and inspect_date = ? and project_id = ? and status =1", patient_id, inspect_date, project_id).Find(&inspection).Error
496
+
497
+	return inspection, err
498
+}

+ 22 - 0
service/manage_center_service.go Vedi File

@@ -253,6 +253,13 @@ func GetSelfDrugAutoWarehouseOutNight(patient_id int64, advicedate int64, drugid
253 253
 	return night, err
254 254
 }
255 255
 
256
+func ModifyDrugWarehouseInfoId(id int64, count int64) error {
257
+
258
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status=1", id).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", count)).Error
259
+
260
+	return err
261
+}
262
+
256 263
 func UpdateDrugWarehouse(id int64, info models.DrugWarehouseInfo) error {
257 264
 	err := writeDb.Model(&models.DrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", info.StockMinNumber)).Error
258 265
 	return err
@@ -541,6 +548,9 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
541 548
 					warehouseInfo := models.DrugWarehouseInfo{
542 549
 						StockMinNumber: its.Count,
543 550
 					}
551
+
552
+					ModifyDrugWarehouseInfoId(its.WarehouseInfoId, its.Count)
553
+
544 554
 					UpdateDrugWarehouse(its.WarehouseInfoId, warehouseInfo)
545 555
 
546 556
 					//增加退库数量
@@ -553,6 +563,12 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
553 563
 					warehouseInfo := models.DrugWarehouseInfo{
554 564
 						StockMaxNumber: its.Count,
555 565
 					}
566
+
567
+					drug, _ := GetBaseDrugMedical(advice.DrugId)
568
+
569
+					var sum_count = its.Count * drug.MinNumber
570
+
571
+					ModifyDrugWarehouseInfoId(its.WarehouseInfoId, sum_count)
556 572
 					UpdateDrugWarehouseOne(its.WarehouseInfoId, warehouseInfo)
557 573
 
558 574
 					//增加退库数量
@@ -565,6 +581,12 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
565 581
 					warehouseInfo := models.DrugWarehouseInfo{
566 582
 						StockMaxNumber: its.Count,
567 583
 					}
584
+					drug, _ := GetBaseDrugMedical(advice.DrugId)
585
+
586
+					var sum_count = its.Count * drug.MinNumber
587
+
588
+					ModifyDrugWarehouseInfoId(its.WarehouseInfoId, sum_count)
589
+
568 590
 					UpdateDrugWarehouseOne(its.WarehouseInfoId, warehouseInfo)
569 591
 					//增加退库数量
570 592
 					AddCancelSumCountOne(storeHouseConfig.DrugStorehouseOut, advice.DrugId, advice.UserOrgId, its.Count*drug.MinNumber)

+ 10 - 11
service/new_warehouse_service.go Vedi File

@@ -1612,8 +1612,10 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1612 1612
 			warehouse.StockMinNumber = 0
1613 1613
 		}
1614 1614
 
1615
+		UpdateDrugWarehouseInfoSumCountOne(warehouse.ID, deliver_number)
1615 1616
 		//扣减库存数据
1616 1617
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
1618
+
1617 1619
 		if errThree != nil {
1618 1620
 			drugError := models.XtDrugError{
1619 1621
 				UserOrgId:             orgID,
@@ -2119,6 +2121,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2119 2121
 			StorehouseId:      storeConfig.DrugStorehouseOut,
2120 2122
 			IsCheck:           1,
2121 2123
 		}
2124
+		UpdateDrugWarehouseInfoSumCountOne(warehouse.ID, 0)
2122 2125
 		//扣减库存
2123 2126
 		errThree := UpDateDrugWarehouseInfoByStock(&info)
2124 2127
 
@@ -4557,9 +4560,6 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4557 4560
 		maxNumber = deliver_number / drup.MinNumber
4558 4561
 		minNumber = deliver_number % drup.MinNumber
4559 4562
 
4560
-		//fmt.Println("max_Number=====================", maxNumber)
4561
-		//fmt.Println("minNumber=====================", minNumber)
4562
-
4563 4563
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4564 4564
 			minNumber = maxNumber
4565 4565
 		}
@@ -4596,8 +4596,6 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4596 4596
 
4597 4597
 		warehouse.Mtime = time.Now().Unix()
4598 4598
 
4599
-		//fmt.Println("hahhahahah", warehouse.StockMinNumber)
4600
-		//fmt.Println("howowowoowow", minNumber)
4601 4599
 		if warehouse.StockMinNumber < minNumber {
4602 4600
 
4603 4601
 			if warehouse.MaxUnit != warehouse.MinUnit {
@@ -4608,10 +4606,6 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4608 4606
 			if warehouse.MaxUnit != warehouse.MinUnit {
4609 4607
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4610 4608
 			}
4611
-			//fmt.Println("minNumber------", minNumber)
4612
-			//fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4613
-			//fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4614
-			//fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4615 4609
 
4616 4610
 			if warehouse.MaxUnit == warehouse.MinUnit {
4617 4611
 				//改动的地方
@@ -4643,8 +4637,6 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4643 4637
 
4644 4638
 		}
4645 4639
 
4646
-		//fmt.Println("maxNumber", maxNumber)
4647
-		//fmt.Println("minNumber", maxNumber)
4648 4640
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
4649 4641
 			if (warehouse.StockMinNumber - deliver_number) >= 0 {
4650 4642
 
@@ -4663,6 +4655,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4663 4655
 			warehouse.StockMinNumber = 0
4664 4656
 		}
4665 4657
 
4658
+		UpdateDrugWarehouseInfoSumCount(warehouse.ID, deliver_number, tx)
4659
+
4666 4660
 		//扣减库存数据
4667 4661
 		UpDateNewDrugWarehouseInfoByStock(&warehouse, tx)
4668 4662
 
@@ -4823,6 +4817,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4823 4817
 			StorehouseId:      storeConfig.DrugStorehouseOut,
4824 4818
 			IsCheck:           1,
4825 4819
 		}
4820
+
4821
+		UpdateDrugWarehouseInfoSumCount(warehouse.ID, 0, tx)
4826 4822
 		//扣减库存
4827 4823
 		UpDateNewDrugWarehouseInfoByStock(&info, tx)
4828 4824
 
@@ -4989,6 +4985,8 @@ func NewHisDrugCancelInfo(orgID int64, creater int64, advice *models.HisDoctorAd
4989 4985
 		//退库 退回 cha_count 的数量
4990 4986
 		ModifyNewDrugWarehouseInfoStockMinNumber(cha_count, drugOutInfo.DrugId, drugOutInfo.OrgId, drugOutInfo.WarehouseInfoId, tx)
4991 4987
 
4988
+		ModifyDrugWareshoueInfoId(cha_count, drugOutInfo.DrugId, drugOutInfo.OrgId, drugOutInfo.WarehouseInfoId, tx)
4989
+
4992 4990
 		if out_count == cha_count {
4993 4991
 			//删除该出库单
4994 4992
 			DeleteDrugWarehouseOutInfoByNumber(drugOutInfo.ID, tx)
@@ -5120,6 +5118,7 @@ func NewHisDrugCancelInfo(orgID int64, creater int64, advice *models.HisDoctorAd
5120 5118
 		//把该出库单的数量退完
5121 5119
 		ModifyNewDrugWarehouseInfoStockMinNumber(out_count, drugOutInfo.DrugId, drugOutInfo.OrgId, drugOutInfo.WarehouseInfoId, tx)
5122 5120
 
5121
+		ModifyDrugWareshoueInfoId(out_count, drugOutInfo.DrugId, drugOutInfo.OrgId, drugOutInfo.WarehouseInfoId, tx)
5123 5122
 		//删除该出库单
5124 5123
 		DeleteDrugWarehouseOutInfoByNumber(drugOutInfo.ID, tx)
5125 5124
 

+ 6 - 2
service/patient_service.go Vedi File

@@ -14,7 +14,7 @@ import (
14 14
 )
15 15
 
16 16
 // GetPatientList 返回患者的列表
17
-func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64, nurse int64, patient_type int64, insuplc_admdvs_name string) (patients []*models.Patients, total int64, err error) {
17
+func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64, nurse int64, patient_type int64, insuplc_admdvs_name string, insurance_type int64) (patients []*models.Patients, total int64, err error) {
18 18
 
19 19
 	db := readDb.Table("xt_patients as p").Where("p.status=1")
20 20
 	if orgID > 0 {
@@ -65,6 +65,10 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
65 65
 		db = db.Where("p.reimbursement_way_id = ?", reimbursementWay)
66 66
 	}
67 67
 
68
+	if insurance_type > 0 {
69
+		db = db.Where("p.insutype = ?", insurance_type)
70
+	}
71
+
68 72
 	if isStartTime {
69 73
 		db = db.Where("p.created_time>=?", startTime)
70 74
 	}
@@ -102,7 +106,7 @@ func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bind
102 106
 
103 107
 	}
104 108
 
105
-	return
109
+	return patients, total, err
106 110
 
107 111
 }
108 112
 

+ 57 - 6
service/stock_service.go Vedi File

@@ -1211,7 +1211,7 @@ func FindAllWarehousingList(orgId int64, page int64, limit int64, startTime int6
1211 1211
 	if check_type > 0 {
1212 1212
 		db = db.Where("xt_warehouse.is_check = ?", check_type)
1213 1213
 	}
1214
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("xt_warehouse.ctime desc").Find(&list).Error
1214
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("xt_warehouse.warehousing_time desc").Find(&list).Error
1215 1215
 	return
1216 1216
 }
1217 1217
 
@@ -1460,7 +1460,7 @@ func FindAllDrugWarehousingListOne(orgId int64, page int64, limit int64, startTi
1460 1460
 	}
1461 1461
 	db = db.Count(&total)
1462 1462
 	offset := (page - 1) * limit
1463
-	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.ctime desc").Find(&list).Error
1463
+	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse.warehousing_time desc").Find(&list).Error
1464 1464
 	return
1465 1465
 }
1466 1466
 
@@ -3172,6 +3172,24 @@ func UpDateDrugWarehouseInfoByStock(info *models.XtDrugWarehouseInfo) (err error
3172 3172
 	return err
3173 3173
 }
3174 3174
 
3175
+func UpdateDrugWarehouseInfoSumCount(id int64, deliver_number int64, tx *gorm.DB) error {
3176
+
3177
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status=1 and is_check=1", id).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", deliver_number)).Error
3178
+
3179
+	if err != nil {
3180
+		tx.Rollback()
3181
+		return err
3182
+	}
3183
+	return err
3184
+}
3185
+
3186
+func UpdateDrugWarehouseInfoSumCountOne(id int64, deliver_number int64) error {
3187
+
3188
+	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status=1 and is_check=1", id).UpdateColumn("sum_count", gorm.Expr("sum_count - ?", deliver_number)).Error
3189
+
3190
+	return err
3191
+}
3192
+
3175 3193
 func UpDateNewDrugWarehouseInfoByStock(info *models.XtDrugWarehouseInfo, tx *gorm.DB) (err error) {
3176 3194
 	err = tx.Save(&info).Error
3177 3195
 
@@ -8600,17 +8618,17 @@ func UpdateaGoodWarehouseInfo(count int64, good_id int64, orgid int64, warehouse
8600 8618
 
8601 8619
 }
8602 8620
 
8603
-func ModifyGoodOutInfoLog(good_id int64, id int64, tx *gorm.DB) (models.XtGoodWarehouseOutInfoLog, error) {
8621
+func ModifyGoodOutInfoLog(good_id int64, id int64, record_date int64, user_org_id int64, tx *gorm.DB) error {
8604 8622
 
8605 8623
 	outInfoLog := models.XtGoodWarehouseOutInfoLog{}
8606 8624
 
8607
-	err := tx.Model(&outInfoLog).Where("good_id = ? and warehouse_out_info_id = ?", good_id, id).Updates(map[string]interface{}{"status": 0}).Error
8625
+	err := tx.Model(&outInfoLog).Where("good_id = ? and warehouse_out_info_id = ? and status=1 and record_date = ? and user_org_id = ?", good_id, id, record_date, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
8608 8626
 
8609 8627
 	if err != nil {
8610 8628
 		tx.Rollback()
8611
-		return outInfoLog, err
8629
+		return err
8612 8630
 	}
8613
-	return outInfoLog, err
8631
+	return err
8614 8632
 
8615 8633
 }
8616 8634
 
@@ -8966,6 +8984,17 @@ func UpdateWarehousingInfoFlow(id int64, orgid int64) error {
8966 8984
 	return err
8967 8985
 }
8968 8986
 
8987
+func DeleteModiftyDrugWarehouseInfo(id int64, tx *gorm.DB) error {
8988
+
8989
+	info := models.DrugWarehouseInfo{}
8990
+	err := tx.Model(&info).Where("id= ? and status=1", id).Updates(map[string]interface{}{"sum_count": 0}).Error
8991
+	if err != nil {
8992
+		tx.Rollback()
8993
+		return err
8994
+	}
8995
+	return err
8996
+}
8997
+
8969 8998
 func UpdateNewWarehousingInfoFlow(id int64, orgid int64, tx *gorm.DB) error {
8970 8999
 
8971 9000
 	err := tx.Model(&models.DrugFlow{}).Where("warehousing_detail_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"status": 0}).Error
@@ -9003,6 +9032,18 @@ func AddNewDrugWarehouseStockMinNumber(count int64, id int64, tx *gorm.DB) error
9003 9032
 	return err
9004 9033
 }
9005 9034
 
9035
+func ModifyDrugWarehouseInfoById(id int64, sum_count int64, tx *gorm.DB) error {
9036
+
9037
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"sum_count": sum_count}).Error
9038
+
9039
+	if err != nil {
9040
+		tx.Rollback()
9041
+		return err
9042
+	}
9043
+
9044
+	return err
9045
+}
9046
+
9006 9047
 func ReturnCheckWarehouseingInfo(id int64, orgid int64) error {
9007 9048
 	tx := XTWriteDB().Begin()
9008 9049
 	err := XTWriteDB().Model(&models.DrugWarehouse{}).Where("id = ? and status = 1 and org_id = ?", id, orgid).Update(map[string]interface{}{"is_check": 2}).Error
@@ -9746,6 +9787,16 @@ func ModifyNewDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid i
9746 9787
 	return err
9747 9788
 }
9748 9789
 
9790
+func ModifyDrugWareshoueInfoId(count int64, drugid int64, orgid int64, id int64, tx *gorm.DB) error {
9791
+
9792
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("sum_count", gorm.Expr("sum_count + ?", count)).Error
9793
+	if err != nil {
9794
+		tx.Rollback()
9795
+		return err
9796
+	}
9797
+	return err
9798
+}
9799
+
9749 9800
 func ModifyDrugCancelStockInfo(id int64, info *models.DrugCancelStockInfo) error {
9750 9801
 
9751 9802
 	err := XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "price": info.Price, "total": info.Total, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "register_account": info.RegisterAccount, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit, "batch_number_id": info.BatchNumberId, "storehouse_id": info.StorehouseId}).Error

+ 4 - 6
service/warhouse_service.go Vedi File

@@ -10000,6 +10000,7 @@ func AutoSelfDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, ware
10000 10000
 			warehouse.StockMinNumber = 0
10001 10001
 		}
10002 10002
 
10003
+		UpdateDrugWarehouseInfoSumCount(warehouse.ID, deliver_number, tx)
10003 10004
 		errThree := UpDateSelfDrugWarehouseInfoByStock(&warehouse, tx)
10004 10005
 
10005 10006
 		if errThree != nil {
@@ -10090,7 +10091,7 @@ func AutoSelfDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, ware
10090 10091
 		warehouse.StockMaxNumber = 0
10091 10092
 		warehouse.StockMinNumber = 0
10092 10093
 		warehouse.Mtime = time.Now().Unix()
10093
-
10094
+		UpdateDrugWarehouseInfoSumCount(warehouse.ID, 0, tx)
10094 10095
 		errThree := UpDateSelfDrugWarehouseInfoByStock(&warehouse, tx)
10095 10096
 		if errThree != nil {
10096 10097
 			return errThree
@@ -10333,6 +10334,7 @@ func AutoSelfDrugDeliverInfoFourtyTwo(orgID int64, prescribingNumber int64, ware
10333 10334
 			warehouse.StockMinNumber = 0
10334 10335
 		}
10335 10336
 
10337
+		UpdateDrugWarehouseInfoSumCount(warehouse.ID, deliver_number, tx)
10336 10338
 		errThree := UpDateSelfDrugWarehouseInfoByStock(&warehouse, tx)
10337 10339
 
10338 10340
 		if errThree != nil {
@@ -10413,10 +10415,6 @@ func AutoSelfDrugDeliverInfoFourtyTwo(orgID int64, prescribingNumber int64, ware
10413 10415
 		//出库数量相加
10414 10416
 		AddSelfDrugCount(advice.DrugId, orgID, advice.PatientId, drugflow.Count, tx)
10415 10417
 
10416
-		//fmt.Println("advice-------------------------------------", advice.ID)
10417
-		//fmt.Println("warehouse-------------------------------------", warehouse.ID)
10418
-		//fmt.Println("over_count====================================", over_count)
10419
-
10420 10418
 		return nil
10421 10419
 
10422 10420
 	} else {
@@ -10427,7 +10425,7 @@ func AutoSelfDrugDeliverInfoFourtyTwo(orgID int64, prescribingNumber int64, ware
10427 10425
 		warehouse.StockMaxNumber = 0
10428 10426
 		warehouse.StockMinNumber = 0
10429 10427
 		warehouse.Mtime = time.Now().Unix()
10430
-
10428
+		UpdateDrugWarehouseInfoSumCount(warehouse.ID, 0, tx)
10431 10429
 		errThree := UpDateSelfDrugWarehouseInfoByStock(&warehouse, tx)
10432 10430
 		if errThree != nil {
10433 10431
 			return errThree