Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 3 days ago
parent
commit
132312f94b

BIN
XT_New.exe View File


+ 6 - 6
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 = 10028 //机构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 = 10028 //机构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 = 10028 //机构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 = 10028 //机构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 View 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)

+ 111 - 124
controllers/his_api_controller.go View File

@@ -2246,11 +2246,97 @@ func (c *HisApiController) CreateHisPrescription() {
2246 2246
 	//已发药和已收费限制逻辑
2247 2247
 	isMidicine := false
2248 2248
 	isCharge := false
2249
+	//是否有库存
2250
+	isSumCount := false
2251
+
2252
+	is_sum_total := false
2253
+
2254
+	var drug_name = ""
2255
+
2256
+	var good_name = ""
2257
+
2249 2258
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
2250 2259
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
2251 2260
 		if len(prescriptions) > 0 {
2252 2261
 			for _, item := range prescriptions {
2253 2262
 				items := item.(map[string]interface{})
2263
+
2264
+				if adminInfo.CurrentOrgId == 9478 {
2265
+					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
2266
+						advices := items["advices"].([]interface{})
2267
+						if len(advices) > 0 {
2268
+							for _, advice := range advices {
2269
+								var adviceId int64
2270
+								if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
2271
+									adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
2272
+								}
2273
+								var drug_id int64
2274
+								if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
2275
+									drug_id = int64(advice.(map[string]interface{})["id"].(float64))
2276
+								}
2277
+								drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
2278
+								//查询该药品是否存在开药记录
2279
+								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
2280
+								if advicelist.ID == 0 {
2281
+									if drug.IsUse != 1 {
2282
+										if drug.SumCount == 0 {
2283
+											drug_name = drug.DrugName
2284
+											isSumCount = true
2285
+										}
2286
+									}
2287
+
2288
+								}
2289
+							}
2290
+						}
2291
+					}
2292
+
2293
+					if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
2294
+						projects := items["project"].([]interface{})
2295
+						if len(projects) > 0 {
2296
+							for _, project := range projects {
2297
+
2298
+								var project_id int64
2299
+								var project_type int64
2300
+								var project_name string
2301
+
2302
+								if project.(map[string]interface{})["project_id"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_id"]).String() == "float64" {
2303
+									project_id = int64(project.(map[string]interface{})["project_id"].(float64))
2304
+								}
2305
+
2306
+								if project.(map[string]interface{})["type"] != nil || reflect.TypeOf(project.(map[string]interface{})["type"]).String() == "float64" {
2307
+									project_type = int64(project.(map[string]interface{})["type"].(float64))
2308
+								}
2309
+
2310
+								if project.(map[string]interface{})["project_name"] != nil || reflect.TypeOf(project.(map[string]interface{})["project_name"]).String() == "string" {
2311
+									project_name = project.(map[string]interface{})["project_name"].(string)
2312
+
2313
+								}
2314
+
2315
+								if project_type == 3 {
2316
+
2317
+									//查找该耗材的出库记录
2318
+									goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
2319
+
2320
+									if len(goodWarehouseInfo) == 0 {
2321
+										//查询耗材库存
2322
+										list, _ := service.GetGoodWarehouseInfoSevenTen(project_id, storeConfig.StorehouseOutInfo)
2323
+
2324
+										var stock_count int64
2325
+										for _, it := range list {
2326
+											stock_count += it.StockCount
2327
+										}
2328
+
2329
+										if stock_count == 0 {
2330
+											good_name = project_name
2331
+											is_sum_total = true
2332
+										}
2333
+									}
2334
+								}
2335
+							}
2336
+						}
2337
+					}
2338
+				}
2339
+
2254 2340
 				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
2255 2341
 					utils.ErrorLog("id")
2256 2342
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -2278,6 +2364,25 @@ func (c *HisApiController) CreateHisPrescription() {
2278 2364
 		return
2279 2365
 	}
2280 2366
 
2367
+	if adminInfo.CurrentOrgId == 9478 {
2368
+		//不是保存处方出库
2369
+		drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
2370
+
2371
+		if drugOutConfig.IsOpen == 1 {
2372
+			if isSumCount == true {
2373
+				c.ServeDynamicFailJsonSend(drug_name + "库存不足,保存失败")
2374
+				return
2375
+			}
2376
+		}
2377
+
2378
+		if goodOutConfig.IsOpen == 1 {
2379
+			if is_sum_total == true {
2380
+				c.ServeDynamicFailJsonSend(good_name + "库存不足,保存失败")
2381
+				return
2382
+			}
2383
+		}
2384
+	}
2385
+
2281 2386
 	// 开始主事务
2282 2387
 	db := service.XTWriteDB()
2283 2388
 	tx := db.Begin()
@@ -3359,8 +3464,6 @@ func (c *HisApiController) CreateHisPrescription() {
3359 3464
 											//查询该患者耗材的历史数据
3360 3465
 											ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
3361 3466
 
3362
-											fmt.Println("ordProject-----------------------", ordProject.ProjectId)
3363
-
3364 3467
 											count, _ := strconv.ParseInt(ordProject.Count, 10, 64)
3365 3468
 
3366 3469
 											//数量发生改变
@@ -3534,7 +3637,7 @@ func (c *HisApiController) CreateHisPrescription() {
3534 3637
 	var adviceList []models.HisDoctorAdviceInfo
3535 3638
 	var projectList []models.HisPrescriptionProject
3536 3639
 
3537
-	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 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 || adminInfo.CurrentOrgId == 9478 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10768 {
3640
+	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 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 || adminInfo.CurrentOrgId == 9478 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10768 || adminInfo.CurrentOrgId == 10164 {
3538 3641
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3539 3642
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3540 3643
 
@@ -3675,6 +3778,7 @@ func (c *HisApiController) CreateHisPrescription() {
3675 3778
 					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
3676 3779
 						advices := items["advices"].([]interface{})
3677 3780
 						groupNo := int64(0)
3781
+
3678 3782
 						if len(advices) > 0 {
3679 3783
 							for _, advice := range advices {
3680 3784
 								tx := db.Begin()
@@ -3807,6 +3911,7 @@ func (c *HisApiController) CreateHisPrescription() {
3807 3911
 												if base.ID > 0 {
3808 3912
 													tx.Rollback()
3809 3913
 													c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
3914
+
3810 3915
 													return
3811 3916
 
3812 3917
 												}
@@ -3816,6 +3921,7 @@ func (c *HisApiController) CreateHisPrescription() {
3816 3921
 												if drugMedical.SumCount == 0 {
3817 3922
 													tx.Rollback()
3818 3923
 													c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3924
+
3819 3925
 													return
3820 3926
 
3821 3927
 												}
@@ -3825,77 +3931,10 @@ func (c *HisApiController) CreateHisPrescription() {
3825 3931
 												if len(list) == 0 {
3826 3932
 													tx.Rollback()
3827 3933
 													c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3934
+
3828 3935
 													return
3829 3936
 												}
3830 3937
 
3831
-												//针对康德
3832
-												//if s.UserOrgId == 10402 || s.UserOrgId == 10164 {
3833
-												//	//获取该药品的总入库数量
3834
-												//	drugWarehouseinfo, _ := service.GetAllDrugInfoList(s.DrugId, s.UserOrgId)
3835
-												//
3836
-												//	//获取该药品总共开了多少支医嘱
3837
-												//	hisDocInfoList, _ := service.GetHisDocInfoList(s.DrugId, s.UserOrgId)
3838
-												//	var in_count int64
3839
-												//	var in_prescription_number_total int64
3840
-												//	if len(drugWarehouseinfo) > 0 {
3841
-												//		for _, item := range drugWarehouseinfo {
3842
-												//			if item.MaxUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3843
-												//
3844
-												//				in_count += item.WarehousingCount * drugMedical.MinNumber
3845
-												//			}
3846
-												//
3847
-												//			if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3848
-												//
3849
-												//				in_count += item.WarehousingCount
3850
-												//			}
3851
-												//
3852
-												//			if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3853
-												//
3854
-												//				in_count += item.WarehousingCount
3855
-												//			}
3856
-												//
3857
-												//		}
3858
-												//	}
3859
-												//
3860
-												//	if len(hisDocInfoList) > 0 {
3861
-												//
3862
-												//		for _, item := range hisDocInfoList {
3863
-												//			if item.PrescribingNumberUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3864
-												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3865
-												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3866
-												//
3867
-												//				in_prescription_number_total += prescribingNumberSevenTy * drug.MinNumber
3868
-												//			}
3869
-												//
3870
-												//			if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3871
-												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3872
-												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3873
-												//				in_prescription_number_total += prescribingNumberSevenTy
3874
-												//			}
3875
-												//
3876
-												//			if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3877
-												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3878
-												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3879
-												//				in_prescription_number_total += prescribingNumberSevenTy
3880
-												//			}
3881
-												//		}
3882
-												//	}
3883
-												//	//
3884
-												//	//fmt.Println("no_user_total------------------------------", no_user_total)
3885
-												//	//fmt.Println("in_prescription_number_total---------------------------", in_prescription_number_total)
3886
-												//	//fmt.Println("in_count----------------------------------", in_count)
3887
-												//
3888
-												//	//如果已经开过的医嘱 加上未开的医嘱数量 大于 入库总数量则提示库存不足
3889
-												//	if no_user_total+in_prescription_number_total > in_count {
3890
-												//		tx.Rollback()
3891
-												//		c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3892
-												//		return
3893
-												//	}
3894
-												//
3895
-												//}
3896
-
3897
-												//查询该药品所有入库数量
3898
-
3899 3938
 											}
3900 3939
 
3901 3940
 											if s.ID > 0 {
@@ -3905,20 +3944,13 @@ func (c *HisApiController) CreateHisPrescription() {
3905 3944
 												if base.ID > 0 {
3906 3945
 													tx.Rollback()
3907 3946
 													c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
3947
+
3908 3948
 													return
3909 3949
 
3910 3950
 												}
3911 3951
 											}
3912 3952
 										}
3913 3953
 
3914
-										//fmt.Println("药品名称----------------------", drug.DrugName)
3915
-										//fmt.Println("药品名称----------------------", drug.IsUse)
3916
-										//fmt.Println("drug_iiiiiiiiiiiiiiiiiiii", drug.ID)
3917
-										//fmt.Println("is_user_total-------------------------", is_user_total)
3918
-										//fmt.Println("no_user_total-------------------------", no_user_total)
3919
-										//fmt.Println("drug.IsUse---------------", drug.IsUse)
3920
-										//fmt.Println("00000000000000000000", s.UserOrgId)
3921
-
3922 3954
 										if is_user_total != no_user_total {
3923 3955
 											//出库
3924 3956
 											//针对御享天源
@@ -4531,46 +4563,6 @@ func (c *HisApiController) CreateHisPrescription() {
4531 4563
 
4532 4564
 												nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
4533 4565
 
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 4566
 												//如果当前处方数量大于历史数据,则需要出库
4575 4567
 
4576 4568
 												if nowCount > historyCount {
@@ -6110,7 +6102,6 @@ func (c *HisApiController) CreateHisPrescription() {
6110 6102
 				}
6111 6103
 			}
6112 6104
 
6113
-			fmt.Println("耗材----------------------------------", goodOutConfig.IsOpen)
6114 6105
 			//耗材保存处方出库
6115 6106
 			if goodOutConfig.IsOpen == 1 {
6116 6107
 
@@ -6128,8 +6119,6 @@ func (c *HisApiController) CreateHisPrescription() {
6128 6119
 
6129 6120
 					parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
6130 6121
 
6131
-					fmt.Println("out_count_five-------------------", out_count_five)
6132
-					fmt.Println("parseIntCount---------------", parseIntCount)
6133 6122
 					if out_count_five != parseIntCount {
6134 6123
 
6135 6124
 						//查询耗材最后一次出库记录
@@ -7098,7 +7087,6 @@ func (c *HisApiController) DeletePrescription() {
7098 7087
 			//查询今日是否有出库数据
7099 7088
 			lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, item.AdviceDate, tx, 1)
7100 7089
 
7101
-			fmt.Println("lastWarehouseOut-----------------------------------", lastWarehouseOut)
7102 7090
 			if lastWarehouseOut.ID == 0 {
7103 7091
 				service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
7104 7092
 			}
@@ -7155,7 +7143,6 @@ func (c *HisApiController) DeletePrescription() {
7155 7143
 			warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
7156 7144
 		}
7157 7145
 
7158
-		fmt.Println("长度-------------------------------", warehousingOutInfo)
7159 7146
 		for _, it := range warehousingOutInfo {
7160 7147
 			//查询今日是否有出库数据
7161 7148
 			lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(c.GetAdminUserInfo().CurrentOrgId, it.SysRecordTime, tx, 1)

+ 61 - 0
controllers/inspection_api_controller.go View 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
+}

+ 29 - 7
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -3044,6 +3044,13 @@ func (c *DialysisAPIController) Finish() {
3044 3044
 			tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
3045 3045
 		}
3046 3046
 
3047
+		if adminUserInfo.Org.Id == 9829 {
3048
+			tempassessmentAfterDislysis.SystolicBloodPressure = endmonitorRecords.SystolicBloodPressure
3049
+			tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
3050
+			tempassessmentAfterDislysis.Temperature = endmonitorRecords.Temperature
3051
+			tempassessmentAfterDislysis.BreathingRate = endmonitorRecords.BreathingRate
3052
+		}
3053
+
3047 3054
 		if adminUserInfo.Org.Id == 10766 {
3048 3055
 			tempassessmentAfterDislysis.SystolicBloodPressure = endmonitorRecords.SystolicBloodPressure
3049 3056
 			tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
@@ -3118,7 +3125,7 @@ func (c *DialysisAPIController) Finish() {
3118 3125
 
3119 3126
 	}
3120 3127
 
3121
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10693 || adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10735 || adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10766 {
3128
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10693 || adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10735 || adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10766 || adminUserInfo.Org.Id == 9829 {
3122 3129
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
3123 3130
 
3124 3131
 		if adminUserInfo.Org.Id != 10702 {
@@ -3130,6 +3137,11 @@ func (c *DialysisAPIController) Finish() {
3130 3137
 					evaluation.SystolicBloodPressure = SystolicBloodPressureOne
3131 3138
 				}
3132 3139
 
3140
+				if adminUserInfo.Org.Id == 9829 {
3141
+					SystolicBloodPressureOne, _ := strconv.ParseFloat(fmonitorRecords.MonitorSystolicBloodPressureOne, 64)
3142
+					evaluation.SystolicBloodPressure = SystolicBloodPressureOne
3143
+				}
3144
+
3133 3145
 				pre := models.PredialysisEvaluation{
3134 3146
 					SystolicBloodPressure: evaluation.SystolicBloodPressure,
3135 3147
 				}
@@ -3154,6 +3166,11 @@ func (c *DialysisAPIController) Finish() {
3154 3166
 					DiastolicBloodPressureOne, _ := strconv.ParseFloat(fmonitorRecords.MonitorDiastolicBloodPressureOne, 64)
3155 3167
 					evaluation.DiastolicBloodPressure = DiastolicBloodPressureOne
3156 3168
 				}
3169
+
3170
+				if adminUserInfo.Org.Id == 9829 {
3171
+					DiastolicBloodPressureOne, _ := strconv.ParseFloat(fmonitorRecords.MonitorDiastolicBloodPressureOne, 64)
3172
+					evaluation.DiastolicBloodPressure = DiastolicBloodPressureOne
3173
+				}
3157 3174
 				pres := models.PredialysisEvaluation{
3158 3175
 					DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
3159 3176
 				}
@@ -3179,6 +3196,11 @@ func (c *DialysisAPIController) Finish() {
3179 3196
 					pulseFrequency, _ := strconv.ParseFloat(endmonitorRecords.MonitorPulseFrequencyOne, 64)
3180 3197
 					evaluation.PulseFrequency = pulseFrequency
3181 3198
 				}
3199
+
3200
+				if adminUserInfo.Org.Id == 9829 {
3201
+					pulseFrequency, _ := strconv.ParseFloat(endmonitorRecords.MonitorPulseFrequencyOne, 64)
3202
+					evaluation.PulseFrequency = pulseFrequency
3203
+				}
3182 3204
 				press := models.PredialysisEvaluation{
3183 3205
 					PulseFrequency: evaluation.PulseFrequency,
3184 3206
 				}
@@ -3996,11 +4018,11 @@ func (this *DialysisAPIController) StartDialysis() {
3996 4018
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescription)
3997 4019
 			return
3998 4020
 		}
3999
-		advices, _ := service.GetDialysisPrescriptionDoctorAdviceList(adminUserInfo.Org.Id, patientID, schedulestartTime)
4000
-		if len(advices) == 0 {
4001
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescription)
4002
-			return
4003
-		}
4021
+		//advices, _ := service.GetDialysisPrescriptionDoctorAdviceList(adminUserInfo.Org.Id, patientID, schedulestartTime)
4022
+		//if len(advices) == 0 {
4023
+		//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePrescription)
4024
+		//	return
4025
+		//}
4004 4026
 	}
4005 4027
 
4006 4028
 	//查询该床位是否有人用了
@@ -6316,7 +6338,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
6316 6338
 		dialysisRecord.EndTime = endTime
6317 6339
 	}
6318 6340
 
6319
-	if adminUserInfo.Org.Id == 10766 || adminUserInfo.Org.Id == 10164 {
6341
+	if adminUserInfo.Org.Id == 10766 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 9478 {
6320 6342
 		//查询第一条监测
6321 6343
 		firstMonitor, _ := service.GetFirstMonitor(tempDialysisRecord.PatientId, tempDialysisRecord.DialysisDate)
6322 6344
 

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

@@ -3515,7 +3515,7 @@ func (c *PatientApiController) CheckDoctorAdvice() {
3515 3515
 		if groupno > 0 {
3516 3516
 			advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
3517 3517
 			for _, item := range advices {
3518
-				if item.CheckState == 0 {
3518
+				if item.CheckState == 0 || item.CheckState == 2 {
3519 3519
 					advice = item
3520 3520
 				}
3521 3521
 
@@ -3547,7 +3547,7 @@ func (c *PatientApiController) CheckDoctorAdvice() {
3547 3547
 		} else {
3548 3548
 			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
3549 3549
 			for _, item := range advices {
3550
-				if item.CheckState == 0 {
3550
+				if item.CheckState == 0 || item.CheckState == 2 {
3551 3551
 					advice = item
3552 3552
 
3553 3553
 				}

+ 6 - 1
controllers/patient_api_controller.go View 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
 }

+ 2 - 1
controllers/role_controller.go View File

@@ -1292,7 +1292,7 @@ func (this *RoleAPIController) EditAdminInitData() {
1292 1292
 		}
1293 1293
 	}
1294 1294
 	org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
1295
-
1295
+	userAdmin, _ := service.GetAdminUserPassWord(admin_user_id)
1296 1296
 	redisClient := service.RedisClient()
1297 1297
 	defer redisClient.Close()
1298 1298
 	qntoken, _ := redisClient.Get("qn_token").Result()
@@ -1303,6 +1303,7 @@ func (this *RoleAPIController) EditAdminInitData() {
1303 1303
 		"qntoken":         qntoken,
1304 1304
 		"isSubSuperAdmin": isSubSuperAdmin,
1305 1305
 		"org":             org,
1306
+		"userAdmin":       userAdmin,
1306 1307
 	})
1307 1308
 }
1308 1309
 

+ 1 - 0
controllers/self_drug_api_congtroller.go View 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 View 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 View 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 View 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 View File

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

+ 3 - 3
service/dialysis_service.go View 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 View 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
+}

+ 9 - 0
service/login_service.go View File

@@ -180,6 +180,15 @@ func GetOrgById(orgID int64) (*models.Org, error) {
180 180
 	return &org, nil
181 181
 }
182 182
 
183
+func GetAdminUserPassWord(admin_user_id int64) (models.SgjUserAdmin, error) {
184
+
185
+	userAdmin := models.SgjUserAdmin{}
186
+
187
+	err = XTReadDB().Where("id = ?", admin_user_id).Find(&userAdmin).Error
188
+
189
+	return userAdmin, err
190
+}
191
+
183 192
 func GetAppById(appID int64) (*models.OrgApp, error) {
184 193
 	var app models.OrgApp
185 194
 	err := readUserDb.Model(&models.OrgApp{}).Where("id = ?", appID).First(&app).Error

+ 22 - 0
service/manage_center_service.go View 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 View 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 View 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 View 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 View 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