Ver código fonte

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

陈少旭 2 semanas atrás
pai
commit
a22033eedb
33 arquivos alterados com 1400 adições e 172 exclusões
  1. BIN
      XT_New.exe
  2. 2 2
      controllers/dialysis_api_controller.go
  3. 122 22
      controllers/drug_stock_api_contorller.go
  4. 145 37
      controllers/his_api_controller.go
  5. 11 1
      controllers/manager_center_api_controller.go
  6. 1 1
      controllers/mobile_api_controllers/check_weight_api_controller.go
  7. 35 3
      controllers/mobile_api_controllers/dialysis_api_controller.go
  8. 354 29
      controllers/patient_api_controller.go
  9. 12 1
      controllers/patient_dataconfig_api_controller.go
  10. 27 0
      controllers/pharmacy_controller.go
  11. 2 2
      controllers/print_data_api_controller.go
  12. 84 0
      controllers/self_drug_api_congtroller.go
  13. 54 10
      controllers/stock_in_api_controller.go
  14. 3 0
      enums/error_code.go
  15. 87 0
      models/dialysis.go
  16. 21 17
      models/drug.go
  17. 21 0
      models/patient_models.go
  18. 1 0
      models/schedule_models.go
  19. 2 2
      service/dialysis_solution_service.go
  20. 1 1
      service/gobal_config_service.go
  21. 2 0
      service/his_service.go
  22. 3 3
      service/mobile_dialysis_service.go
  23. 1 5
      service/new_stock_service.go
  24. 40 0
      service/patient_dataconfig_service.go
  25. 153 2
      service/patient_service.go
  26. 1 1
      service/patientmanage_service.go
  27. 8 1
      service/pharmacy_service.go
  28. 2 2
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  29. 14 0
      service/self_drug_service.go
  30. 18 6
      service/smart_sch.go
  31. 148 10
      service/stock_service.go
  32. 7 2
      service/user_service.go
  33. 18 12
      service/warhouse_service.go

BIN
XT_New.exe Ver arquivo


+ 2 - 2
controllers/dialysis_api_controller.go Ver arquivo

@@ -4863,12 +4863,12 @@ func (c *DialysisApiController) GetDialysisOrder() {
4863 4863
 	}
4864 4864
 	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
4865 4865
 
4866
-		if xttime <= 1703952000 {
4866
+		if xttime <= 1735574400 {
4867 4867
 			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4868 4868
 			patientInfo.TotalDialysis = dialysis_count
4869 4869
 		}
4870 4870
 
4871
-		if xttime >= 1704038400 {
4871
+		if xttime >= 1735660800 {
4872 4872
 			dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4873 4873
 			patientInfo.TotalDialysis = dialysis_count
4874 4874
 		}

+ 122 - 22
controllers/drug_stock_api_contorller.go Ver arquivo

@@ -13,7 +13,6 @@ import (
13 13
 	"XT_New/service"
14 14
 	"XT_New/utils"
15 15
 	"github.com/astaxie/beego"
16
-	"github.com/jinzhu/gorm"
17 16
 )
18 17
 
19 18
 type StockDrugApiController struct {
@@ -3280,10 +3279,6 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3280 3279
 
3281 3280
 	warehousing_id, _ := c.GetInt64("warehousing_id")
3282 3281
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3283
-	houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3284
-
3285
-	checker := c.GetAdminUserInfo().AdminUser.Id
3286
-
3287 3282
 	// 开始外部循环的事务
3288 3283
 	db := service.XTWriteDB()
3289 3284
 	tx := db.Begin()
@@ -3294,13 +3289,32 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3294 3289
 			tx.Rollback()
3295 3290
 		}
3296 3291
 	}()
3292
+	houseConfig, _ := service.GetNewAllStoreHouseConfig(orgId, tx)
3293
+
3294
+	checker := c.GetAdminUserInfo().AdminUser.Id
3297 3295
 
3298 3296
 	//更改核对状态
3299 3297
 	service.CheckNewWarehousingInfo(warehousing_id, orgId, checker, tx)
3300 3298
 
3301 3299
 	list, _ := service.GetNewWarehousingInfoByList(warehousing_id, orgId, tx)
3300
+
3301
+	var is_success = 2
3302 3302
 	for _, item := range list {
3303
+		var his_warehousing_count = item.WarehousingCount
3304
+		var his_max_unit = item.MaxUnit
3305
+		var in_cout int64
3303 3306
 		medical, _ := service.GetNewBaseDrugMedical(item.DrugId, tx)
3307
+
3308
+		if his_max_unit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3309
+			in_cout = his_warehousing_count * medical.MinNumber
3310
+		}
3311
+		if his_max_unit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3312
+			in_cout = his_warehousing_count
3313
+		}
3314
+		if his_max_unit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
3315
+			in_cout = his_warehousing_count
3316
+		}
3317
+
3304 3318
 		if item.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3305 3319
 			//新增库存
3306 3320
 			service.AddNewDrugWarehouseStockMaxNumber(item.WarehousingCount, item.ID, tx)
@@ -3392,8 +3406,9 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3392 3406
 			over_count += it.StockMaxNumber + it.StockMinNumber
3393 3407
 		}
3394 3408
 		//查询该仓库是否有默认数据
3395
-		_, errcode := service.GetNewDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId, tx)
3396
-		if errcode == gorm.ErrRecordNotFound {
3409
+		drugStockCount, _ := service.GetNewDrugStockCount(item.StorehouseId, item.DrugId, item.OrgId, tx)
3410
+
3411
+		if drugStockCount.ID == 0 {
3397 3412
 			drugStock := models.XtDrugStockCount{
3398 3413
 				UserOrgId:      item.OrgId,
3399 3414
 				StorehouseId:   item.StorehouseId,
@@ -3409,17 +3424,45 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3409 3424
 			}
3410 3425
 			service.CreateNewDrugStockSum(drugStock, tx)
3411 3426
 
3412
-		} else if errcode == nil {
3427
+		}
3428
+		if drugStockCount.ID > 0 {
3413 3429
 			service.UpdateNewDrugStockSum(item.StorehouseId, item.DrugId, item.OrgId, total_count, over_count, tx)
3414 3430
 		}
3415
-	}
3416 3431
 
3417
-	tx.Commit()
3432
+		flowList, _ := service.GetNewDrugFlowList(item.DrugId, item.OrgId, item.ID, tx)
3433
+		var his_count int64
3434
+		if len(flowList) > 0 {
3435
+			for _, item := range flowList {
3436
+				baseDrug, _ := service.GetNewBaseDrugMedical(item.DrugId, tx)
3437
+				if item.MaxUnit == baseDrug.MaxUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3438
+					his_count = item.Count * baseDrug.MinNumber
3439
+				}
3440
+				if item.MaxUnit == baseDrug.MinUnit && baseDrug.MaxUnit != baseDrug.MinUnit {
3441
+					his_count = item.Count
3442
+				}
3443
+				if item.MaxUnit == baseDrug.MaxUnit && baseDrug.MaxUnit == baseDrug.MinUnit {
3444
+					his_count = item.Count
3445
+				}
3446
+			}
3447
+		}
3418 3448
 
3449
+		if in_cout != his_count {
3450
+			is_success = 1
3451
+			tx.Rollback()
3452
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
3453
+			return
3454
+		}
3455
+	}
3456
+
3457
+	if is_success != 1 {
3458
+		tx.Commit()
3459
+	}
3419 3460
 	c.ServeSuccessJSON(map[string]interface{}{
3420 3461
 		"list": list,
3421 3462
 	})
3422 3463
 
3464
+	return
3465
+
3423 3466
 }
3424 3467
 
3425 3468
 func (c *StockDrugApiController) ReturnCheckWarehouseingInfo() {
@@ -3581,6 +3624,7 @@ func (c *StockDrugApiController) CheckDrugOut() {
3581 3624
 				"max_unit":               drup.MaxUnit,
3582 3625
 				"msg":                    2,
3583 3626
 			})
3627
+			tx.Rollback()
3584 3628
 			return
3585 3629
 		}
3586 3630
 	}
@@ -3607,7 +3651,12 @@ func (c *StockDrugApiController) CheckDrugOut() {
3607 3651
 
3608 3652
 	}
3609 3653
 	warehousingOutInfoListThree, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3654
+
3655
+	var is_success = 2
3610 3656
 	for _, it := range warehousingOutInfoListThree {
3657
+
3658
+		var his_count = it.Count
3659
+		var his_count_unit = it.CountUnit
3611 3660
 		medical, _ := service.GetNewBaseDrugMedical(it.DrugId, tx)
3612 3661
 		drup, _ := service.FindNewBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
3613 3662
 		//出库逻辑
@@ -3635,6 +3684,47 @@ func (c *StockDrugApiController) CheckDrugOut() {
3635 3684
 		}
3636 3685
 		//更新基础库库存
3637 3686
 		service.UpdateNewBaseDrugSumTwo(it.DrugId, sum_count_one, it.OrgId, tx)
3687
+
3688
+		if it.OrgId == 10164 || it.OrgId == 10721 {
3689
+			var now_count int64
3690
+
3691
+			if his_count_unit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3692
+				now_count = his_count * medical.MinNumber
3693
+			}
3694
+			if his_count_unit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3695
+				now_count = his_count
3696
+			}
3697
+			if his_count_unit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3698
+				now_count = his_count
3699
+			}
3700
+
3701
+			var flow_count int64
3702
+
3703
+			//查询该药品的出库数量
3704
+			drugflowlist, _ := service.GetDrugOutFlowByWarehouseOut(it.DrugId, it.ID, it.OrgId, tx)
3705
+			if len(drugflowlist) > 0 {
3706
+				for _, items := range drugflowlist {
3707
+
3708
+					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3709
+						flow_count = items.Count * medical.MinNumber
3710
+					}
3711
+					if items.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3712
+						flow_count = items.Count
3713
+					}
3714
+					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3715
+						flow_count = items.Count
3716
+					}
3717
+				}
3718
+			}
3719
+
3720
+			if now_count != flow_count {
3721
+				is_success = 1
3722
+				tx.Rollback()
3723
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
3724
+				return
3725
+			}
3726
+		}
3727
+
3638 3728
 	}
3639 3729
 
3640 3730
 	out := models.DrugWarehouseOut{
@@ -3643,18 +3733,22 @@ func (c *StockDrugApiController) CheckDrugOut() {
3643 3733
 	//更新审核状态
3644 3734
 	service.UpdateNewCheckDrugOut(out, warehouse_out_id, tx)
3645 3735
 
3646
-	tx.Commit()
3736
+	//查询
3737
+	if is_success != 1 {
3738
+		tx.Commit()
3739
+		c.ServeSuccessJSON(map[string]interface{}{
3740
+			"warehousingOutInfoList": warehousingOutInfoList,
3741
+			"drug_name":              "",
3742
+			"dose":                   "",
3743
+			"dose_unit":              "",
3744
+			"min_number":             "",
3745
+			"min_unit":               "",
3746
+			"max_unit":               "",
3747
+			"msg":                    1,
3748
+		})
3749
+		return
3750
+	}
3647 3751
 
3648
-	c.ServeSuccessJSON(map[string]interface{}{
3649
-		"warehousingOutInfoList": warehousingOutInfoList,
3650
-		"drug_name":              "",
3651
-		"dose":                   "",
3652
-		"dose_unit":              "",
3653
-		"min_number":             "",
3654
-		"min_unit":               "",
3655
-		"max_unit":               "",
3656
-		"msg":                    1,
3657
-	})
3658 3752
 }
3659 3753
 
3660 3754
 func (c *StockDrugApiController) ToReturnCheck() {
@@ -3690,11 +3784,16 @@ func (c *StockDrugApiController) ToReturnCheck() {
3690 3784
 	//调用出库逻辑
3691 3785
 	for _, item := range list {
3692 3786
 		medical, _ := service.GetBaseDrugMedical(item.DrugId)
3787
+
3693 3788
 		if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3694
-			service.UpdateNewDrugMaxNumber(item.Count, item.WarehouseInfoId, tx)
3789
+
3695 3790
 			var sum_out_count int64
3696 3791
 			sum_out_count = item.Count * medical.MinNumber
3792
+
3793
+			service.UpdateNewDrugMaxNumberOne(sum_out_count, item.WarehouseInfoId, tx)
3794
+
3697 3795
 			service.ModifyNewReduceDrugInformation(item.DrugId, sum_out_count, item.OrgId, tx)
3796
+
3698 3797
 			drugInfoList, _ := service.FindNewDrugWarehouseInfoList(item.DrugId, item.OrgId, tx)
3699 3798
 			var drug_max_number int64
3700 3799
 			var drug_min_number int64
@@ -3723,6 +3822,7 @@ func (c *StockDrugApiController) ToReturnCheck() {
3723 3822
 			service.CreatedNewDrugFlushInfo(drugFlushInfo, tx)
3724 3823
 			service.DeleteNewDrugOutFlow(item.ID, item.OrgId, tx)
3725 3824
 		}
3825
+
3726 3826
 		if item.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3727 3827
 			service.UpdateDrugMaxNumber(item.Count, item.WarehouseInfoId)
3728 3828
 			var sum_out_count int64

+ 145 - 37
controllers/his_api_controller.go Ver arquivo

@@ -3619,7 +3619,6 @@ func (c *HisApiController) CreateHisPrescription() {
3619 3619
 
3620 3620
 					if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
3621 3621
 						advices := items["advices"].([]interface{})
3622
-						//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
3623 3622
 						groupNo := int64(0)
3624 3623
 						if len(advices) > 0 {
3625 3624
 							for _, advice := range advices {
@@ -3695,6 +3694,7 @@ func (c *HisApiController) CreateHisPrescription() {
3695 3694
 									if drugOutConfig.IsOpen == 1 {
3696 3695
 
3697 3696
 										drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, s.DrugId)
3697
+
3698 3698
 										// 查询该药品最后一次出库记录
3699 3699
 										druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(s.DrugId, patient_id, recordDateTime, s.ID)
3700 3700
 
@@ -3741,6 +3741,110 @@ func (c *HisApiController) CreateHisPrescription() {
3741 3741
 
3742 3742
 										}
3743 3743
 
3744
+										//库存不足
3745
+										if s.UserOrgId != 10206 {
3746
+											if s.ID == 0 {
3747
+												//查询改药品是否已经停用
3748
+												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
3749
+
3750
+												if base.ID > 0 {
3751
+													tx.Rollback()
3752
+													c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
3753
+													return
3754
+
3755
+												}
3756
+
3757
+												drugMedical, _ := service.GetBaseDrugMedical(s.DrugId)
3758
+
3759
+												if drugMedical.SumCount == 0 {
3760
+													tx.Rollback()
3761
+													c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3762
+													return
3763
+
3764
+												}
3765
+
3766
+												//针对康德
3767
+												//if s.UserOrgId == 10402 || s.UserOrgId == 10164 {
3768
+												//	//获取该药品的总入库数量
3769
+												//	drugWarehouseinfo, _ := service.GetAllDrugInfoList(s.DrugId, s.UserOrgId)
3770
+												//
3771
+												//	//获取该药品总共开了多少支医嘱
3772
+												//	hisDocInfoList, _ := service.GetHisDocInfoList(s.DrugId, s.UserOrgId)
3773
+												//	var in_count int64
3774
+												//	var in_prescription_number_total int64
3775
+												//	if len(drugWarehouseinfo) > 0 {
3776
+												//		for _, item := range drugWarehouseinfo {
3777
+												//			if item.MaxUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3778
+												//
3779
+												//				in_count += item.WarehousingCount * drugMedical.MinNumber
3780
+												//			}
3781
+												//
3782
+												//			if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3783
+												//
3784
+												//				in_count += item.WarehousingCount
3785
+												//			}
3786
+												//
3787
+												//			if item.MaxUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3788
+												//
3789
+												//				in_count += item.WarehousingCount
3790
+												//			}
3791
+												//
3792
+												//		}
3793
+												//	}
3794
+												//
3795
+												//	if len(hisDocInfoList) > 0 {
3796
+												//
3797
+												//		for _, item := range hisDocInfoList {
3798
+												//			if item.PrescribingNumberUnit == drugMedical.MaxUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3799
+												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3800
+												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3801
+												//
3802
+												//				in_prescription_number_total += prescribingNumberSevenTy * drug.MinNumber
3803
+												//			}
3804
+												//
3805
+												//			if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit != drugMedical.MinUnit {
3806
+												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3807
+												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3808
+												//				in_prescription_number_total += prescribingNumberSevenTy
3809
+												//			}
3810
+												//
3811
+												//			if item.PrescribingNumberUnit == drugMedical.MinUnit && drugMedical.MaxUnit == drugMedical.MinUnit {
3812
+												//				prescribingNumberTenty := strconv.FormatFloat(s.PrescribingNumber, 'f', -1, 64)
3813
+												//				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
3814
+												//				in_prescription_number_total += prescribingNumberSevenTy
3815
+												//			}
3816
+												//		}
3817
+												//	}
3818
+												//	//
3819
+												//	//fmt.Println("no_user_total------------------------------", no_user_total)
3820
+												//	//fmt.Println("in_prescription_number_total---------------------------", in_prescription_number_total)
3821
+												//	//fmt.Println("in_count----------------------------------", in_count)
3822
+												//
3823
+												//	//如果已经开过的医嘱 加上未开的医嘱数量 大于 入库总数量则提示库存不足
3824
+												//	if no_user_total+in_prescription_number_total > in_count {
3825
+												//		tx.Rollback()
3826
+												//		c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
3827
+												//		return
3828
+												//	}
3829
+												//
3830
+												//}
3831
+
3832
+												//查询该药品所有入库数量
3833
+
3834
+											}
3835
+											if s.ID > 0 {
3836
+												//查询改药品是否已经停用
3837
+												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
3838
+
3839
+												if base.ID > 0 {
3840
+													tx.Rollback()
3841
+													c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
3842
+													return
3843
+
3844
+												}
3845
+											}
3846
+										}
3847
+
3744 3848
 										//fmt.Println("药品名称----------------------", drug.DrugName)
3745 3849
 										//fmt.Println("药品名称----------------------", drug.IsUse)
3746 3850
 										//fmt.Println("is_user_total-------------------------", is_user_total)
@@ -3751,7 +3855,7 @@ func (c *HisApiController) CreateHisPrescription() {
3751 3855
 										if is_user_total != no_user_total {
3752 3856
 											//出库
3753 3857
 											//针对御享天源
3754
-											if drug.IsUse == 1 && s.UserOrgId == 10635 {
3858
+											if drug.IsUse == 1 && s.UserOrgId == 10635 && s.UserOrgId == 9671 {
3755 3859
 
3756 3860
 												creater := adminInfo.AdminUser.Id
3757 3861
 												newadviceInfo := &models.HisDoctorAdviceInfo{
@@ -4127,40 +4231,6 @@ func (c *HisApiController) CreateHisPrescription() {
4127 4231
 								timeFormat := tempTime.Format("20060102150405")
4128 4232
 								s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
4129 4233
 
4130
-								if s.UserOrgId != 10206 {
4131
-									if s.ID == 0 {
4132
-										//查询改药品是否已经停用
4133
-										base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
4134
-
4135
-										if base.ID > 0 {
4136
-											tx.Rollback()
4137
-											c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
4138
-											return
4139
-
4140
-										}
4141
-
4142
-										drugMedical, _ := service.GetBaseDrugMedical(s.DrugId)
4143
-
4144
-										if drugMedical.SumCount == 0 {
4145
-											tx.Rollback()
4146
-											c.ServeDynamicFailJsonSend(drugMedical.DrugName + "库存不足,保存失败!")
4147
-											return
4148
-
4149
-										}
4150
-									}
4151
-									if s.ID > 0 {
4152
-										//查询改药品是否已经停用
4153
-										base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)
4154
-
4155
-										if base.ID > 0 {
4156
-											tx.Rollback()
4157
-											c.ServeDynamicFailJsonSend(base.DrugName + "已停用!请更换其他药品")
4158
-											return
4159
-
4160
-										}
4161
-									}
4162
-								}
4163
-
4164 4234
 								//赤峰
4165 4235
 								if adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10489 {
4166 4236
 
@@ -4313,7 +4383,7 @@ func (c *HisApiController) CreateHisPrescription() {
4313 4383
 								if p.PatientId != 30038 {
4314 4384
 
4315 4385
 									//用机构ID区分
4316
-									if adminInfo.CurrentOrgId != 9671 && adminInfo.CurrentOrgId != 10164 {
4386
+									if adminInfo.CurrentOrgId != 9671 {
4317 4387
 										if goodOutConfig.IsOpen == 1 {
4318 4388
 											//耗材出库
4319 4389
 											if p.Type == 3 {
@@ -4326,6 +4396,44 @@ func (c *HisApiController) CreateHisPrescription() {
4326 4396
 
4327 4397
 												nowCount, _ := strconv.ParseInt(p.Count, 10, 64)
4328 4398
 
4399
+												////针对康德
4400
+												//if p.UserOrgId == 10164 || p.UserOrgId == 10402 {
4401
+												//
4402
+												//	//查询耗材的总入库数量
4403
+												//	warehouseInfo, _ := service.GetAllWarehouseInfo(p.ProjectId, adminInfo.CurrentOrgId)
4404
+												//
4405
+												//	//查询该耗材的总出库数量
4406
+												//	prescriptionGood, _ := service.GetHisPrescriptionByGoodId(p.ProjectId, adminInfo.CurrentOrgId)
4407
+												//
4408
+												//	var all_good_count int64
4409
+												//
4410
+												//	var prescription_count int64
4411
+												//	if len(warehouseInfo) > 0 {
4412
+												//
4413
+												//		for _, item := range warehouseInfo {
4414
+												//			all_good_count += item.WarehousingCount
4415
+												//		}
4416
+												//	}
4417
+												//	if len(prescriptionGood) > 0 {
4418
+												//		for _, item := range prescriptionGood {
4419
+												//
4420
+												//			hisCount, _ := strconv.ParseInt(item.Count, 10, 64)
4421
+												//			prescription_count += hisCount
4422
+												//		}
4423
+												//	}
4424
+												//
4425
+												//	//fmt.Println("prescription_count-------------------------", prescription_count)
4426
+												//	//fmt.Println("nowCount-------------------------", nowCount)
4427
+												//	//fmt.Println("all_good_count-------------------------", all_good_count)
4428
+												//
4429
+												//	if prescription_count+nowCount > all_good_count {
4430
+												//		goodInfoOne, _ := service.GetGoodInformationByGoodIdOne(p.ProjectId)
4431
+												//		tx.Rollback()
4432
+												//		c.ServeDynamicFailJsonSend(goodInfoOne.GoodName + "耗材无库存,保存失败!")
4433
+												//		return
4434
+												//	}
4435
+												//}
4436
+
4329 4437
 												//如果当前处方数量大于历史数据,则需要出库
4330 4438
 												if nowCount > historyCount {
4331 4439
 

+ 11 - 1
controllers/manager_center_api_controller.go Ver arquivo

@@ -168,6 +168,10 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
168 168
 	is_zero_flag, _ := c.GetInt64("is_zero_flag")
169 169
 
170 170
 	specification_name := c.GetString("specification_name")
171
+
172
+	scan_code := c.GetString("scan_code")
173
+	drug_identification_code := c.GetString("drug_identification_code")
174
+
171 175
 	hans := drug_name // 要转换的汉字字符串
172 176
 
173 177
 	// 创建一个拼音转换器
@@ -260,6 +264,8 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
260 264
 		IsSelfDrug:                  is_self_drug,
261 265
 		SpecificationName:           specification_name,
262 266
 		IsZeroFlag:                  is_zero_flag,
267
+		ScanCode:                    scan_code,
268
+		DrugIdentificationCode:      drug_identification_code,
263 269
 	}
264 270
 	drugLib.FirstLetter = firstLetter
265 271
 	drugLib.Pinyin = firstLetter
@@ -385,6 +391,8 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
385 391
 	is_self_drug, _ := c.GetInt64("is_self_drug")
386 392
 	specification_name := c.GetString("specification_name")
387 393
 	is_zero_flag, _ := c.GetInt64("is_zero_flag")
394
+	scan_code := c.GetString("scan_code")
395
+	drug_identification_code := c.GetString("drug_identification_code")
388 396
 
389 397
 	adminInfo := c.GetAdminUserInfo()
390 398
 	drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
@@ -484,6 +492,8 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
484 492
 		IsSelfDrug:                  is_self_drug,
485 493
 		SpecificationName:           specification_name,
486 494
 		IsZeroFlag:                  is_zero_flag,
495
+		ScanCode:                    scan_code,
496
+		DrugIdentificationCode:      drug_identification_code,
487 497
 	}
488 498
 	if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
489 499
 
@@ -2322,7 +2332,7 @@ func (c *ManagerCenterApiController) CreateDiagnose() {
2322 2332
 	wubi := c.GetString("wubi")
2323 2333
 
2324 2334
 	sort, _ := c.GetInt64("sort")
2325
-	fmt.Println("sort-------------------", sort)
2335
+
2326 2336
 	if len(class_name) <= 0 {
2327 2337
 		utils.ErrorLog("len(class_name) == 0")
2328 2338
 

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Ver arquivo

@@ -977,7 +977,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
977 977
 		}
978 978
 
979 979
 		//针对患者称重两次没有数据的问题
980
-		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 {
980
+		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10745 {
981 981
 
982 982
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
983 983
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)

+ 35 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go Ver arquivo

@@ -3904,6 +3904,10 @@ func (this *DialysisAPIController) StartDialysis() {
3904 3904
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3905 3905
 			}
3906 3906
 
3907
+			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
3908
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3909
+			}
3910
+
3907 3911
 			if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10679 { //adminUserInfo.Org.Id == 9538
3908 3912
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3909 3913
 			}
@@ -5188,6 +5192,12 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5188 5192
 
5189 5193
 			}
5190 5194
 
5195
+			//重庆塘坝卫生院
5196
+			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 {
5197
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5198
+				record.UltrafiltrationRate = ultrafiltration_rate
5199
+			}
5200
+
5191 5201
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10679 {
5192 5202
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5193 5203
 				record.UltrafiltrationRate = ultrafiltration_rate
@@ -5320,13 +5330,16 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5320 5330
 			if adminInfo.Org.Id == 10735 {
5321 5331
 
5322 5332
 				lastMonitorRecordList, _ := service.GetLastMonitorRecordList(patientID, monitorDate, adminInfo.Org.Id)
5333
+				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5334
+				var ultrafiltration_rate_one = math.Floor(prescription.TargetUltrafiltration*1000/float64(totalMin)*60*1000) / 1000
5335
+
5323 5336
 				if lastMonitorRecordList.ID > 0 {
5324
-					record.UltrafiltrationRate = lastMonitorRecordList.UltrafiltrationRate
5325
-					ultrafiltration_volume := math.Floor(float64(record.OperateTime+1800-fristrecord.OperateTime) / 3600 * lastMonitorRecordList.UltrafiltrationRate)
5337
+					record.UltrafiltrationRate = ultrafiltration_rate_one
5338
+					ultrafiltration_volume := math.Floor(float64(record.OperateTime+1800-fristrecord.OperateTime) / 3600 * ultrafiltration_rate_one)
5326 5339
 
5327 5340
 					record.UltrafiltrationVolume = ultrafiltration_volume
5328 5341
 				} else {
5329
-					ultrafiltration_volume := math.Floor(float64(record.OperateTime+1800-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5342
+					ultrafiltration_volume := math.Floor(float64(record.OperateTime+1800-fristrecord.OperateTime) / 3600 * ultrafiltration_rate_one)
5330 5343
 
5331 5344
 					record.UltrafiltrationVolume = ultrafiltration_volume
5332 5345
 				}
@@ -5422,6 +5435,25 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5422 5435
 
5423 5436
 	}
5424 5437
 
5438
+	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 {
5439
+
5440
+		var replacement_rate float64
5441
+		var displacement_quantity float64
5442
+		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5443
+		replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*60) / 1000
5444
+
5445
+		record.ReplacementRate = replacement_rate
5446
+
5447
+		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5448
+		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5449
+		record.DisplacementQuantity = displacement_quantity
5450
+	}
5451
+
5452
+	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 {
5453
+		ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5454
+		record.UltrafiltrationVolume = ultrafiltration_volume
5455
+	}
5456
+
5425 5457
 	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 {
5426 5458
 
5427 5459
 		var replacement_rate float64

+ 354 - 29
controllers/patient_api_controller.go Ver arquivo

@@ -14,6 +14,7 @@ import (
14 14
 	"XT_New/models"
15 15
 	"XT_New/service"
16 16
 	"XT_New/utils"
17
+	"github.com/astaxie/beego/config"
17 18
 	"github.com/jinzhu/gorm"
18 19
 	"github.com/mozillazg/go-pinyin"
19 20
 
@@ -210,6 +211,20 @@ func PatientApiRegistRouters() {
210 211
 
211 212
 	beego.Router("/api/patient/getpatientrescuerecordlist", &PatientApiController{}, "Get:GetPatientRescureRecordList")
212 213
 
214
+	beego.Router("/api/patient/getmonitorsearchlist", &PatientApiController{}, "Get:GetMonitorSearchList")
215
+
216
+	beego.Router("/api/patient/getsummarysearchlist", &PatientApiController{}, "Get:GetSummarySearchList")
217
+
218
+	beego.Router("/api/patient/getpatientdryweightlist", &PatientApiController{}, "Get:GetPatientDryWeightList")
219
+
220
+	beego.Router("/api/patient/getdialysissystemlist", &PatientApiController{}, "Get:GetDialysisSystemList")
221
+
222
+	beego.Router("/api/patient/getpatientadvicelist", &PatientApiController{}, "Get:GetPatientAdviceList")
223
+
224
+	beego.Router("/api/patient/getpatientinspectionlist", &PatientApiController{}, "Get:GetPatientInspectionList")
225
+
226
+	beego.Router("/api/patient/getinspectionbyprojectid", &PatientApiController{}, "Get:GetInspectionByProjectId")
227
+
213 228
 }
214 229
 func (c *PatientApiController) GetExportList() {
215 230
 	startTime := c.GetString("start_time")
@@ -8647,34 +8662,82 @@ func (this *PatientApiController) GetAutoPatientContent() {
8647 8662
 
8648 8663
 	lastBefor, _ := service.GetPatientLastBefor(patient_id, startTime, endTime, orgId)
8649 8664
 
8650
-	this.ServeSuccessJSON(map[string]interface{}{
8651
-		"prescription":                         prescription,
8652
-		"berfor":                               berfor,
8653
-		"monitorList":                          monitorList,
8654
-		"dryweightList":                        dryweightList,
8655
-		"inpectionList":                        inpectionList,
8656
-		"dialysisOrder":                        dialysisOrder,
8657
-		"patient":                              patient,
8658
-		"longAdvice":                           longAdvice,
8659
-		"groupPrescriptionList":                groupPrescriptionList,
8660
-		"after":                                after,
8661
-		"max_blood_flow_volume":                monitor.BloodFlowVolume,
8662
-		"max_befor_systolic_blood_pressure":    maxBeforSystolicBloodPressure.SystolicBloodPressure,
8663
-		"min_befor_systolic_blood_pressure":    minBeforSystolicBloodPressure.SystolicBloodPressure,
8664
-		"max_befor_diastolic_blood_pressure":   maxBeforDiastolicBloodPressure.DiastolicBloodPressure,
8665
-		"min_befor_diastolic_blood_pressure":   minBeforDiastolicBloodPressure.DiastolicBloodPressure,
8666
-		"max_after_systolic_blood_pressure":    maxAfterSystolicBloodPressure.SystolicBloodPressure,
8667
-		"min_after_systolic_blood_pressure":    minAfterSystolicBloodPressure.SystolicBloodPressure,
8668
-		"max_after_diastolic_blood_pressure":   maxAfterDiastolicBloodPressure.DiastolicBloodPressure,
8669
-		"min_after_diastolic_blood_pressure":   minAfterDiastolicBloodPressure.DiastolicBloodPressure,
8670
-		"max_monitor_systolic_blood_pressure":  maxMonitorSystolicBloodPressure.SystolicBloodPressure,
8671
-		"min_monitor_systolic_blood_pressure":  minMonitorSystolicBloodPressure.SystolicBloodPressure,
8672
-		"max_monitor_diastolic_blood_pressure": maxMonitorDiastolicBloodPressure.DiastolicBloodPressure,
8673
-		"min_monitor_diastolic_blood_pressure": minMonitorDiastolicBloodPressure.DiastolicBloodPressure,
8674
-		"lastDryWeight":                        lastDryWeight,
8675
-		"patientVascularAccess":                patientVascularAccess,
8676
-		"lastBefor":                            lastBefor,
8677
-	})
8665
+	_, configs := service.FindXTHisRecordByOrgId(orgId)
8666
+
8667
+	//血透
8668
+	if configs.IsOpen != 1 {
8669
+		this.ServeSuccessJSON(map[string]interface{}{
8670
+			"prescription":                         prescription,
8671
+			"berfor":                               berfor,
8672
+			"monitorList":                          monitorList,
8673
+			"dryweightList":                        dryweightList,
8674
+			"inpectionList":                        inpectionList,
8675
+			"dialysisOrder":                        dialysisOrder,
8676
+			"patient":                              patient,
8677
+			"longAdvice":                           longAdvice,
8678
+			"groupPrescriptionList":                groupPrescriptionList,
8679
+			"after":                                after,
8680
+			"max_blood_flow_volume":                monitor.BloodFlowVolume,
8681
+			"max_befor_systolic_blood_pressure":    maxBeforSystolicBloodPressure.SystolicBloodPressure,
8682
+			"min_befor_systolic_blood_pressure":    minBeforSystolicBloodPressure.SystolicBloodPressure,
8683
+			"max_befor_diastolic_blood_pressure":   maxBeforDiastolicBloodPressure.DiastolicBloodPressure,
8684
+			"min_befor_diastolic_blood_pressure":   minBeforDiastolicBloodPressure.DiastolicBloodPressure,
8685
+			"max_after_systolic_blood_pressure":    maxAfterSystolicBloodPressure.SystolicBloodPressure,
8686
+			"min_after_systolic_blood_pressure":    minAfterSystolicBloodPressure.SystolicBloodPressure,
8687
+			"max_after_diastolic_blood_pressure":   maxAfterDiastolicBloodPressure.DiastolicBloodPressure,
8688
+			"min_after_diastolic_blood_pressure":   minAfterDiastolicBloodPressure.DiastolicBloodPressure,
8689
+			"max_monitor_systolic_blood_pressure":  maxMonitorSystolicBloodPressure.SystolicBloodPressure,
8690
+			"min_monitor_systolic_blood_pressure":  minMonitorSystolicBloodPressure.SystolicBloodPressure,
8691
+			"max_monitor_diastolic_blood_pressure": maxMonitorDiastolicBloodPressure.DiastolicBloodPressure,
8692
+			"min_monitor_diastolic_blood_pressure": minMonitorDiastolicBloodPressure.DiastolicBloodPressure,
8693
+			"lastDryWeight":                        lastDryWeight,
8694
+			"patientVascularAccess":                patientVascularAccess,
8695
+			"lastBefor":                            lastBefor,
8696
+		})
8697
+	}
8698
+
8699
+	//his
8700
+	if configs.IsOpen == 1 {
8701
+
8702
+		hisadvice, _ := service.GetHisPrecriptionadviceList(orgId, patient_id, startTime, endTime)
8703
+		if len(hisadvice) > 0 {
8704
+			if len(hisadvice) > 0 {
8705
+				for _, item := range hisadvice {
8706
+					baseDrug, _ := service.GetBasedrugByIdOne(item.DrugId, orgId)
8707
+					item.StartTime = item.CreatedTime
8708
+					item.AdviceDesc = baseDrug.Dose + baseDrug.DoseUnit + "*" + config.ToString(baseDrug.MinNumber) + baseDrug.MinUnit + "/" + baseDrug.MaxUnit
8709
+				}
8710
+			}
8711
+		}
8712
+		this.ServeSuccessJSON(map[string]interface{}{
8713
+			"prescription":                         prescription,
8714
+			"berfor":                               berfor,
8715
+			"monitorList":                          monitorList,
8716
+			"dryweightList":                        dryweightList,
8717
+			"inpectionList":                        inpectionList,
8718
+			"dialysisOrder":                        dialysisOrder,
8719
+			"patient":                              patient,
8720
+			"longAdvice":                           hisadvice,
8721
+			"groupPrescriptionList":                groupPrescriptionList,
8722
+			"after":                                after,
8723
+			"max_blood_flow_volume":                monitor.BloodFlowVolume,
8724
+			"max_befor_systolic_blood_pressure":    maxBeforSystolicBloodPressure.SystolicBloodPressure,
8725
+			"min_befor_systolic_blood_pressure":    minBeforSystolicBloodPressure.SystolicBloodPressure,
8726
+			"max_befor_diastolic_blood_pressure":   maxBeforDiastolicBloodPressure.DiastolicBloodPressure,
8727
+			"min_befor_diastolic_blood_pressure":   minBeforDiastolicBloodPressure.DiastolicBloodPressure,
8728
+			"max_after_systolic_blood_pressure":    maxAfterSystolicBloodPressure.SystolicBloodPressure,
8729
+			"min_after_systolic_blood_pressure":    minAfterSystolicBloodPressure.SystolicBloodPressure,
8730
+			"max_after_diastolic_blood_pressure":   maxAfterDiastolicBloodPressure.DiastolicBloodPressure,
8731
+			"min_after_diastolic_blood_pressure":   minAfterDiastolicBloodPressure.DiastolicBloodPressure,
8732
+			"max_monitor_systolic_blood_pressure":  maxMonitorSystolicBloodPressure.SystolicBloodPressure,
8733
+			"min_monitor_systolic_blood_pressure":  minMonitorSystolicBloodPressure.SystolicBloodPressure,
8734
+			"max_monitor_diastolic_blood_pressure": maxMonitorDiastolicBloodPressure.DiastolicBloodPressure,
8735
+			"min_monitor_diastolic_blood_pressure": minMonitorDiastolicBloodPressure.DiastolicBloodPressure,
8736
+			"lastDryWeight":                        lastDryWeight,
8737
+			"patientVascularAccess":                patientVascularAccess,
8738
+			"lastBefor":                            lastBefor,
8739
+		})
8740
+	}
8678 8741
 
8679 8742
 }
8680 8743
 
@@ -8697,7 +8760,19 @@ func (this *PatientApiController) ModifyCoursePrint() {
8697 8760
 	id := int64(dataBody["id"].(float64))
8698 8761
 	content := dataBody["content"].(string)
8699 8762
 
8700
-	coursePrint, _ := service.ModifyCoursePrint(id, content)
8763
+	record_date := dataBody["record_date"].(string)
8764
+	timeLayout := "2006-01-02"
8765
+	loc, _ := time.LoadLocation("Local")
8766
+	var theStartTime int64
8767
+	if len(record_date) > 0 {
8768
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
8769
+		if err != nil {
8770
+			utils.ErrorLog(err.Error())
8771
+		}
8772
+		theStartTime = theTime.Unix()
8773
+	}
8774
+
8775
+	coursePrint, _ := service.ModifyCoursePrint(id, content, theStartTime)
8701 8776
 
8702 8777
 	this.ServeSuccessJSON(map[string]interface{}{
8703 8778
 		"coursePrint": coursePrint,
@@ -8723,3 +8798,253 @@ func (this *PatientApiController) GetPatientRescureRecordList() {
8723 8798
 		"operators":        operators,
8724 8799
 	})
8725 8800
 }
8801
+
8802
+func (this *PatientApiController) GetMonitorSearchList() {
8803
+
8804
+	timeLayout := "2006-01-02"
8805
+	loc, _ := time.LoadLocation("Local")
8806
+	start_time := this.GetString("start_time")
8807
+	end_time := this.GetString("end_time")
8808
+	patient_id, _ := this.GetInt64("patient_id")
8809
+
8810
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8811
+	var startTime int64
8812
+	if len(start_time) > 0 {
8813
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8814
+		if err != nil {
8815
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8816
+			return
8817
+		}
8818
+		startTime = theTime.Unix()
8819
+	}
8820
+
8821
+	var endTime int64
8822
+	if len(end_time) > 0 {
8823
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8824
+		if err != nil {
8825
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8826
+			return
8827
+		}
8828
+		endTime = theTime.Unix()
8829
+	}
8830
+
8831
+	monitorList, _ := service.GetMonitorSearchList(patient_id, orgId, startTime, endTime)
8832
+
8833
+	this.ServeSuccessJSON(map[string]interface{}{
8834
+		"monitorList": monitorList,
8835
+	})
8836
+
8837
+}
8838
+
8839
+func (this *PatientApiController) GetSummarySearchList() {
8840
+
8841
+	timeLayout := "2006-01-02"
8842
+	loc, _ := time.LoadLocation("Local")
8843
+	start_time := this.GetString("start_time")
8844
+	end_time := this.GetString("end_time")
8845
+	patient_id, _ := this.GetInt64("patient_id")
8846
+
8847
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8848
+	var startTime int64
8849
+	if len(start_time) > 0 {
8850
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8851
+		if err != nil {
8852
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8853
+			return
8854
+		}
8855
+		startTime = theTime.Unix()
8856
+	}
8857
+
8858
+	var endTime int64
8859
+	if len(end_time) > 0 {
8860
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8861
+		if err != nil {
8862
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8863
+			return
8864
+		}
8865
+		endTime = theTime.Unix()
8866
+	}
8867
+
8868
+	summaryList, _ := service.GetSummarySearchList(patient_id, orgId, startTime, endTime)
8869
+
8870
+	this.ServeSuccessJSON(map[string]interface{}{
8871
+		"summaryList": summaryList,
8872
+	})
8873
+}
8874
+
8875
+func (this *PatientApiController) GetPatientDryWeightList() {
8876
+
8877
+	timeLayout := "2006-01-02"
8878
+	loc, _ := time.LoadLocation("Local")
8879
+	start_time := this.GetString("start_time")
8880
+	end_time := this.GetString("end_time")
8881
+	patient_id, _ := this.GetInt64("patient_id")
8882
+
8883
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8884
+	var startTime int64
8885
+	if len(start_time) > 0 {
8886
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8887
+		if err != nil {
8888
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8889
+			return
8890
+		}
8891
+		startTime = theTime.Unix()
8892
+	}
8893
+
8894
+	var endTime int64
8895
+	if len(end_time) > 0 {
8896
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8897
+		if err != nil {
8898
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8899
+			return
8900
+		}
8901
+		endTime = theTime.Unix()
8902
+	}
8903
+
8904
+	dryWeightList, _ := service.GetPatientDryWeightList(patient_id, orgId, startTime, endTime)
8905
+
8906
+	this.ServeSuccessJSON(map[string]interface{}{
8907
+		"dryWeightList": dryWeightList,
8908
+	})
8909
+}
8910
+
8911
+func (this *PatientApiController) GetDialysisSystemList() {
8912
+
8913
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8914
+
8915
+	prescription, _ := service.GetDialysisSystemList(orgId)
8916
+
8917
+	this.ServeSuccessJSON(map[string]interface{}{
8918
+		"prescription": prescription,
8919
+	})
8920
+}
8921
+
8922
+func (this *PatientApiController) GetPatientAdviceList() {
8923
+
8924
+	timeLayout := "2006-01-02"
8925
+	loc, _ := time.LoadLocation("Local")
8926
+	start_time := this.GetString("start_time")
8927
+	end_time := this.GetString("end_time")
8928
+	patient_id, _ := this.GetInt64("patient_id")
8929
+	advice_type, _ := this.GetInt64("advice_type")
8930
+
8931
+	orgId := this.GetAdminUserInfo().CurrentOrgId
8932
+	var startTime int64
8933
+	if len(start_time) > 0 {
8934
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8935
+		if err != nil {
8936
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8937
+			return
8938
+		}
8939
+		startTime = theTime.Unix()
8940
+	}
8941
+
8942
+	var endTime int64
8943
+	if len(end_time) > 0 {
8944
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
8945
+		if err != nil {
8946
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
8947
+			return
8948
+		}
8949
+		endTime = theTime.Unix()
8950
+	}
8951
+
8952
+	_, configs := service.FindXTHisRecordByOrgId(orgId)
8953
+
8954
+	if configs.IsOpen == 1 {
8955
+
8956
+		if advice_type == 1 {
8957
+			hisLongadvicelist, _ := service.GetHisPrecriptionadviceList(orgId, patient_id, startTime, endTime)
8958
+			if len(hisLongadvicelist) > 0 {
8959
+				for _, item := range hisLongadvicelist {
8960
+					item.StartTime = item.CreatedTime
8961
+					baseDrug, _ := service.GetBasedrugByIdOne(item.DrugId, orgId)
8962
+					item.AdviceDesc = baseDrug.Dose + baseDrug.DoseUnit + "*" + config.ToString(baseDrug.MinNumber) + baseDrug.MinUnit + "/" + baseDrug.MaxUnit
8963
+				}
8964
+			}
8965
+			this.ServeSuccessJSON(map[string]interface{}{
8966
+				"advicelist": hisLongadvicelist,
8967
+			})
8968
+			return
8969
+		} else {
8970
+			fmt.Println("hhhhhh")
8971
+			advicelist, _ := service.GetHisadviceList(orgId, patient_id, startTime, endTime)
8972
+			if len(advicelist) > 0 {
8973
+				for _, item := range advicelist {
8974
+					item.StartTime = item.CreatedTime
8975
+					baseDrug, _ := service.GetBasedrugByIdOne(item.DrugId, orgId)
8976
+					item.AdviceDesc = baseDrug.Dose + baseDrug.DoseUnit + "*" + config.ToString(baseDrug.MinNumber) + baseDrug.MinUnit + "/" + baseDrug.MaxUnit
8977
+				}
8978
+			}
8979
+			this.ServeSuccessJSON(map[string]interface{}{
8980
+				"advicelist": advicelist,
8981
+			})
8982
+			return
8983
+		}
8984
+
8985
+	}
8986
+
8987
+	if configs.IsOpen != 1 {
8988
+		advicelist, _ := service.GetPatientAdviceList(patient_id, orgId, startTime, endTime, advice_type)
8989
+		this.ServeSuccessJSON(map[string]interface{}{
8990
+			"advicelist": advicelist,
8991
+		})
8992
+		return
8993
+	}
8994
+	return
8995
+
8996
+}
8997
+
8998
+func (this *PatientApiController) GetPatientInspectionList() {
8999
+
9000
+	timeLayout := "2006-01-02"
9001
+	loc, _ := time.LoadLocation("Local")
9002
+	start_time := this.GetString("start_time")
9003
+	end_time := this.GetString("end_time")
9004
+	patient_id, _ := this.GetInt64("patient_id")
9005
+
9006
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9007
+	var startTime int64
9008
+	if len(start_time) > 0 {
9009
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9010
+		if err != nil {
9011
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9012
+			return
9013
+		}
9014
+		startTime = theTime.Unix()
9015
+	}
9016
+
9017
+	var endTime int64
9018
+	if len(end_time) > 0 {
9019
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9020
+		if err != nil {
9021
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9022
+			return
9023
+		}
9024
+		endTime = theTime.Unix()
9025
+	}
9026
+
9027
+	groupList, _ := service.GetNewPatientGroupInspectionList(patient_id, orgId, startTime, endTime)
9028
+
9029
+	inspection, _ := service.GetNewPatientInspectionList(patient_id, orgId, startTime, endTime)
9030
+
9031
+	this.ServeSuccessJSON(map[string]interface{}{
9032
+		"groupList":  groupList,
9033
+		"inspection": inspection,
9034
+	})
9035
+}
9036
+
9037
+func (this *PatientApiController) GetInspectionByProjectId() {
9038
+
9039
+	patient_id, _ := this.GetInt64("patient_id")
9040
+	project_id, _ := this.GetInt64("project_id")
9041
+	inspect_date, _ := this.GetInt64("inspect_date")
9042
+
9043
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9044
+
9045
+	inspection, _ := service.GetNewInspectionByProjectId(patient_id, project_id, inspect_date, orgId)
9046
+
9047
+	this.ServeSuccessJSON(map[string]interface{}{
9048
+		"inspection": inspection,
9049
+	})
9050
+}

+ 12 - 1
controllers/patient_dataconfig_api_controller.go Ver arquivo

@@ -931,6 +931,17 @@ func (this *PatientDataConfigAPIController) Rescues() {
931 931
 func (this *PatientDataConfigAPIController) CreateRescue() {
932 932
 	patientID, _ := this.GetInt64("patient_id")
933 933
 	content := this.GetString("content")
934
+	record_date := this.GetString("record_date")
935
+	timeLayout := "2006-01-02"
936
+	loc, _ := time.LoadLocation("Local")
937
+	var theStartTime int64
938
+	if len(record_date) > 0 {
939
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
940
+		if err != nil {
941
+			utils.ErrorLog(err.Error())
942
+		}
943
+		theStartTime = theTime.Unix()
944
+	}
934 945
 	if patientID <= 0 || len(content) == 0 {
935 946
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
936 947
 		return
@@ -952,7 +963,7 @@ func (this *PatientDataConfigAPIController) CreateRescue() {
952 963
 		OrgID:      adminUserInfo.CurrentOrgId,
953 964
 		PatientID:  patientID,
954 965
 		Recorder:   adminUserInfo.AdminUser.Id,
955
-		RecordTime: now,
966
+		RecordTime: theStartTime,
956 967
 		Content:    content,
957 968
 		Status:     1,
958 969
 		CreateTime: now,

+ 27 - 0
controllers/pharmacy_controller.go Ver arquivo

@@ -50,6 +50,8 @@ func PharmacyApiRegistRouters() {
50 50
 
51 51
 	beego.Router("/api/pharmacy/changeZeroFlag", &PharmacyController{}, "Get:ChangeZeroFlag")
52 52
 
53
+	beego.Router("/api/pharmacy/getdrugtocalcount", &PharmacyController{}, "Get:GetDrugTocalCount")
54
+
53 55
 }
54 56
 
55 57
 // 测试
@@ -1446,3 +1448,28 @@ func (this *PharmacyController) ChangeZeroFlag() {
1446 1448
 	})
1447 1449
 
1448 1450
 }
1451
+
1452
+func (this *PharmacyController) GetDrugTocalCount() {
1453
+
1454
+	timeLayout := "2006-01-02"
1455
+	loc, _ := time.LoadLocation("Local")
1456
+	drug_id, _ := this.GetInt64("drug_id")
1457
+	start_time := this.GetString("start_time")
1458
+	var startTime int64
1459
+	if len(start_time) > 0 {
1460
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1461
+		if err != nil {
1462
+			fmt.Println(err)
1463
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1464
+			return
1465
+		}
1466
+		startTime = theTime.Unix()
1467
+	}
1468
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1469
+
1470
+	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1471
+
1472
+	this.ServeSuccessJSON(map[string]interface{}{
1473
+		"adviceList": adviceList,
1474
+	})
1475
+}

+ 2 - 2
controllers/print_data_api_controller.go Ver arquivo

@@ -107,14 +107,14 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
107 107
 
108 108
 			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
109 109
 
110
-				if item.ScheduleDate <= 1703952000 {
110
+				if item.ScheduleDate <= 1735574400 {
111 111
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
112 112
 
113 113
 					item.Patient.TotalDialysis = listOne.Count
114 114
 					item.Count = listOne.Count
115 115
 				}
116 116
 
117
-				if item.ScheduleDate >= 1704038400 {
117
+				if item.ScheduleDate >= 1735660800 {
118 118
 
119 119
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
120 120
 

+ 84 - 0
controllers/self_drug_api_congtroller.go Ver arquivo

@@ -191,6 +191,10 @@ func SelfDrugRouters() {
191 191
 
192 192
 	beego.Router("/api/drug/modifydrugcodewarehouseinfo", &SelfDrugApiController{}, "Post:ModifyDrugCodeWarehosueInfo")
193 193
 
194
+	beego.Router("/api/drug/getpatientadvicelist", &SelfDrugApiController{}, "Get:GetPatientAdviceList")
195
+
196
+	beego.Router("/api/drug/getpatientadvicelistdetail", &SelfDrugApiController{}, "Get:GetPatientAdviceListDetail")
197
+
194 198
 }
195 199
 
196 200
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -6474,3 +6478,83 @@ func (c *SelfDrugApiController) ModifyDrugCodeWarehosueInfo() {
6474 6478
 	})
6475 6479
 
6476 6480
 }
6481
+
6482
+func (this *SelfDrugApiController) GetPatientAdviceList() {
6483
+
6484
+	patient_id, _ := this.GetInt64("patient_id")
6485
+
6486
+	start_time := this.GetString("start_time")
6487
+
6488
+	end_time := this.GetString("end_time")
6489
+
6490
+	timeLayout := "2006-01-02"
6491
+	loc, _ := time.LoadLocation("Local")
6492
+	var startTime int64
6493
+	if len(start_time) > 0 {
6494
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6495
+		if err != nil {
6496
+			fmt.Println(err)
6497
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6498
+			return
6499
+		}
6500
+		startTime = theTime.Unix()
6501
+	}
6502
+	var endTime int64
6503
+	if len(end_time) > 0 {
6504
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6505
+		if err != nil {
6506
+			utils.ErrorLog(err.Error())
6507
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6508
+			return
6509
+		}
6510
+		endTime = theTime.Unix()
6511
+	}
6512
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6513
+
6514
+	adviceList, _ := service.GetNewPatientAdviceList(patient_id, startTime, endTime, orgId)
6515
+	this.ServeSuccessJSON(map[string]interface{}{
6516
+		"adviceList": adviceList,
6517
+	})
6518
+}
6519
+
6520
+func (this *SelfDrugApiController) GetPatientAdviceListDetail() {
6521
+
6522
+	patient_id, _ := this.GetInt64("patient_id")
6523
+
6524
+	start_time := this.GetString("start_time")
6525
+
6526
+	end_time := this.GetString("end_time")
6527
+
6528
+	timeLayout := "2006-01-02"
6529
+	loc, _ := time.LoadLocation("Local")
6530
+	var startTime int64
6531
+	if len(start_time) > 0 {
6532
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6533
+		if err != nil {
6534
+			fmt.Println(err)
6535
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6536
+			return
6537
+		}
6538
+		startTime = theTime.Unix()
6539
+	}
6540
+	var endTime int64
6541
+	if len(end_time) > 0 {
6542
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6543
+		if err != nil {
6544
+			utils.ErrorLog(err.Error())
6545
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6546
+			return
6547
+		}
6548
+		endTime = theTime.Unix()
6549
+	}
6550
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6551
+
6552
+	advice_name := this.GetString("advice_name")
6553
+
6554
+	adviceList, _ := service.GetPatientAdviceListDetail(patient_id, startTime, endTime, orgId, advice_name)
6555
+
6556
+	this.ServeSuccessJSON(map[string]interface{}{
6557
+		"adviceList": adviceList,
6558
+	})
6559
+
6560
+}

+ 54 - 10
controllers/stock_in_api_controller.go Ver arquivo

@@ -7304,6 +7304,7 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7304 7304
 
7305 7305
 	////出库逻辑
7306 7306
 	for _, item := range warehousingOutInfo {
7307
+
7307 7308
 		// 查询该耗材是否有库存
7308 7309
 		warehouseOne, _ := service.FindNewWarehousingInfoTen(item.GoodId, item.StorehouseId, tx)
7309 7310
 
@@ -7323,10 +7324,14 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7323 7324
 		}
7324 7325
 
7325 7326
 	}
7327
+	var is_scucess = 2
7328
+
7326 7329
 	for _, item := range warehousingOutInfo {
7327 7330
 
7328 7331
 		creater := this.GetAdminUserInfo().AdminUser.Id
7329 7332
 
7333
+		var now_count = item.Count
7334
+
7330 7335
 		//出库
7331 7336
 		err := service.ConsumablesNewDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater, tx)
7332 7337
 
@@ -7353,12 +7358,31 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7353 7358
 		//基础库扣减库存
7354 7359
 		service.UpdateNewGoodInfoReduceSumCount(item.GoodId, total_count, orgId, tx)
7355 7360
 
7361
+		var flow_count int64
7362
+		flowList, _ := service.GetGoodFlowByWarehouseOutId(item.GoodId, item.OrgId, item.ID, tx)
7363
+		if len(flowList) > 0 {
7364
+			for _, items := range flowList {
7365
+				flow_count += items.Count
7366
+			}
7367
+		}
7368
+
7369
+		if now_count != flow_count {
7370
+			is_scucess = 1
7371
+			tx.Rollback()
7372
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
7373
+			return
7374
+
7375
+		}
7376
+
7356 7377
 	}
7357 7378
 
7358 7379
 	//审核单据
7359 7380
 	err := service.UpdatedNewWarehouseOut(id, tx)
7360 7381
 
7361
-	tx.Commit()
7382
+	if is_scucess != 1 {
7383
+		tx.Commit()
7384
+	}
7385
+
7362 7386
 	if err == nil {
7363 7387
 		this.ServeSuccessJSON(map[string]interface{}{
7364 7388
 			"msg":                "2",
@@ -7366,6 +7390,7 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7366 7390
 			"specification_name": "",
7367 7391
 			"storehose_name":     "",
7368 7392
 		})
7393
+		return
7369 7394
 	}
7370 7395
 
7371 7396
 }
@@ -7449,12 +7474,13 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7449 7474
 	checker := this.GetAdminUserInfo().AdminUser.Id
7450 7475
 	//更改审核状态
7451 7476
 	err := service.UpdateNewCheckWarehouseInfo(warehousing_info_id, checker, tx)
7477
+	var is_success = 2
7452 7478
 	if err == nil {
7453 7479
 		list, _ := service.GetNewWarehouseInfoList(warehousing_info_id, orgId, tx)
7454 7480
 
7455 7481
 		for _, item := range list {
7482
+			var now_count = item.WarehousingCount
7456 7483
 			service.UpdateNewWarehouseInfoByIdListThree(item.WarehousingCount, item.ID, tx)
7457
-
7458 7484
 			//查询该耗材剩余库存库
7459 7485
 			stockList, _ := service.GetNewStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, orgId, tx)
7460 7486
 			var total_count int64
@@ -7466,9 +7492,6 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7466 7492
 			//基础库插入数据
7467 7493
 			service.UpdateNewGoodInfoAddSumCount(item.GoodId, total_count, orgId, sum_in_count, tx)
7468 7494
 
7469
-			//查询该仓库是否有数据
7470
-			_, errcode := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
7471
-
7472 7495
 			goodList, _ := service.GetNewSumGoodList(orgId, item.StorehouseId, item.GoodId, tx)
7473 7496
 			var flush_count int64
7474 7497
 			for _, it := range goodList {
@@ -7495,8 +7518,8 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7495 7518
 				Dealer:                  item.Dealer,
7496 7519
 				Creator:                 Creator,
7497 7520
 				UpdateCreator:           0,
7498
-				Status:                  1,
7499 7521
 				Ctime:                   item.Ctime,
7522
+				Status:                  1,
7500 7523
 				Mtime:                   0,
7501 7524
 				Price:                   item.PackingPrice,
7502 7525
 				WarehousingDetailId:     item.ID,
@@ -7518,7 +7541,9 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7518 7541
 			//创建出库流水
7519 7542
 			service.CreateNewStockFlowOne(stockFlow, tx)
7520 7543
 
7521
-			if errcode == gorm.ErrRecordNotFound {
7544
+			//查询该仓库是否有数据
7545
+			stockCount, _ := service.GetNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, tx)
7546
+			if stockCount.ID == 0 {
7522 7547
 
7523 7548
 				goodCount := models.XtGoodStockCount{
7524 7549
 					UserOrgId:        orgId,
@@ -7535,13 +7560,32 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7535 7560
 				}
7536 7561
 				service.CreateNewGoodCount(goodCount, tx)
7537 7562
 			}
7538
-			if errcode == nil {
7563
+			if stockCount.ID > 0 {
7539 7564
 				service.UpdateNewGoodStockCount(orgId, item.StorehouseId, item.GoodId, item.WarehousingCount, flush_count, tx)
7540 7565
 			}
7566
+
7567
+			//查询该耗材的流水数量
7568
+			goodFlowList, _ := service.GetInitGoodFlow(orgId, item.GoodId, item.ID, tx)
7569
+
7570
+			var flow_count int64
7571
+			if len(goodFlowList) > 0 {
7572
+				for _, item := range goodFlowList {
7573
+					flow_count += item.Count
7574
+				}
7575
+			}
7576
+
7577
+			if now_count != flow_count {
7578
+				is_success = 1
7579
+				tx.Rollback()
7580
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
7581
+				return
7582
+			}
7583
+
7541 7584
 		}
7542 7585
 	}
7543
-
7544
-	tx.Commit()
7586
+	if is_success != 1 {
7587
+		tx.Commit()
7588
+	}
7545 7589
 
7546 7590
 	if err == nil {
7547 7591
 		this.ServeSuccessJSON(map[string]interface{}{

+ 3 - 0
enums/error_code.go Ver arquivo

@@ -287,6 +287,8 @@ const ( // ErrorCode
287 287
 	ErrorTimeCodeParamWrong = 600000012
288 288
 
289 289
 	ErrorCodeAuthWrong = 600000013
290
+
291
+	ErrorCodeFlow = 600000014
290 292
 )
291 293
 
292 294
 var ErrCodeMsgs = map[int]string{
@@ -552,6 +554,7 @@ var ErrCodeMsgs = map[int]string{
552 554
 
553 555
 	ErrorTimeCodeParamWrong: "时间跨度不能超过一个月",
554 556
 	ErrorCodeAuthWrong:      "尚未实名认证,请先认证",
557
+	ErrorCodeFlow:           "网络错误,数据异常,审核失败",
555 558
 }
556 559
 
557 560
 type SGJError struct {

+ 87 - 0
models/dialysis.go Ver arquivo

@@ -1815,3 +1815,90 @@ type XtDoctorAdviceOne struct {
1815 1815
 func (XtDoctorAdviceOne) TableName() string {
1816 1816
 	return "xt_doctor_advice"
1817 1817
 }
1818
+
1819
+type PatientNewSchedule struct {
1820
+	ID                              int64                           `gorm:"column:id" json:"id" form:"id"`
1821
+	UserOrgId                       int64                           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1822
+	PatientId                       int64                           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1823
+	ModeId                          int64                           `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1824
+	Status                          int64                           `gorm:"column:status" json:"status" form:"status"`
1825
+	ScheduleDate                    int64                           `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1826
+	PatientMonitoringRecord         []*PatientMonitoringRecord      `gorm:"ForeignKey:PatientId,MonitoringDate;AssociationForeignKey:PatientId,ScheduleDate" json:"monitor"`
1827
+	PatientAssessmentAfterDislysis  PatientAssessmentAfterDislysis  `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"after"`
1828
+	PatientAssessmentBeforeDislysis PatientAssessmentBeforeDislysis `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"befor"`
1829
+}
1830
+
1831
+func (PatientNewSchedule) TableName() string {
1832
+	return "xt_schedule"
1833
+}
1834
+
1835
+type PatientNewScheduleOne struct {
1836
+	ID                      int64                   `gorm:"column:id" json:"id" form:"id"`
1837
+	UserOrgId               int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1838
+	PatientId               int64                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1839
+	ModeId                  int64                   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1840
+	Status                  int64                   `gorm:"column:status" json:"status" form:"status"`
1841
+	ScheduleDate            int64                   `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1842
+	PatientTreatmentSummary PatientTreatmentSummary `gorm:"ForeignKey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate" json:"summary"`
1843
+}
1844
+
1845
+func (PatientNewScheduleOne) TableName() string {
1846
+	return "xt_schedule"
1847
+}
1848
+
1849
+type PatientMonitoringRecord struct {
1850
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1851
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1852
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1853
+	DialysisOrderId        int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1854
+	MonitoringDate         int64   `gorm:"column:monitoring_date" json:"monitoring_date" form:"monitoring_date"`
1855
+	MonitoringTime         string  `gorm:"column:monitoring_time" json:"monitoring_time" form:"monitoring_time"`
1856
+	BreathingRate          string  `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
1857
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1858
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1859
+}
1860
+
1861
+func (PatientMonitoringRecord) TableName() string {
1862
+	return "xt_monitoring_record"
1863
+}
1864
+
1865
+type PatientAssessmentAfterDislysis struct {
1866
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1867
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1868
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1869
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1870
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1871
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
1872
+}
1873
+
1874
+func (PatientAssessmentAfterDislysis) TableName() string {
1875
+	return "xt_assessment_after_dislysis"
1876
+}
1877
+
1878
+type PatientAssessmentBeforeDislysis struct {
1879
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1880
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1881
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1882
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
1883
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
1884
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
1885
+}
1886
+
1887
+func (PatientAssessmentBeforeDislysis) TableName() string {
1888
+	return "xt_assessment_before_dislysis"
1889
+}
1890
+
1891
+type PatientTreatmentSummary struct {
1892
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
1893
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1894
+	PatientId       int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1895
+	AssessmentDate  int64  `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
1896
+	DialysisOrderId int64  `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
1897
+	Mission         string `gorm:"column:mission" json:"mission" form:"mission"`
1898
+	DialysisSummary string `gorm:"column:dialysis_summary" json:"dialysis_summary" form:"dialysis_summary"`
1899
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
1900
+}
1901
+
1902
+func (PatientTreatmentSummary) TableName() string {
1903
+	return "xt_treatment_summary"
1904
+}

+ 21 - 17
models/drug.go Ver arquivo

@@ -85,13 +85,15 @@ type BaseDrugLib struct {
85 85
 	Bby01     string `gorm:"column:bby01" json:"bby01" form:"bby01"`
86 86
 	Bbx01     string `gorm:"column:bbx01" json:"bbx01" form:"bbx01"`
87 87
 
88
-	FirstLetter        string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
89
-	IsProject          int64  `gorm:"column:is_project" json:"is_project" form:"is_project"`
90
-	DrugDosageFormName string `gorm:"column:drug_dosage_form_name" json:"drug_dosage_form_name" form:"drug_dosage_form_name"`
91
-	IsShow             int64  `gorm:"column:is_show" json:"is_show" form:"is_show"`
92
-	IsSelfDrug         int64  `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
93
-	SpecificationName  string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
94
-	IsZeroFlag         int64  `gorm:"column:is_zero_flag" json:"is_zero_flag" form:"is_zero_flag"`
88
+	FirstLetter            string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
89
+	IsProject              int64  `gorm:"column:is_project" json:"is_project" form:"is_project"`
90
+	DrugDosageFormName     string `gorm:"column:drug_dosage_form_name" json:"drug_dosage_form_name" form:"drug_dosage_form_name"`
91
+	IsShow                 int64  `gorm:"column:is_show" json:"is_show" form:"is_show"`
92
+	IsSelfDrug             int64  `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
93
+	SpecificationName      string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
94
+	IsZeroFlag             int64  `gorm:"column:is_zero_flag" json:"is_zero_flag" form:"is_zero_flag"`
95
+	ScanCode               string `gorm:"column:scan_code" json:"scan_code" form:"scan_code"`
96
+	DrugIdentificationCode string `gorm:"column:drug_identification_code" json:"drug_identification_code" form:"drug_identification_code"`
95 97
 }
96 98
 
97 99
 func (BaseDrugLib) TableName() string {
@@ -145,16 +147,18 @@ func (BaseDrugLibTwentyOne) TableName() string {
145 147
 }
146 148
 
147 149
 type BaseDrugLibEleven struct {
148
-	ID               int64  `gorm:"column:id" json:"id" form:"id"`
149
-	DrugName         string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
150
-	Manufacturer     int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
151
-	ManufacturerName string `gorm:"column:manufacturer_name" json:"manufacturer_name"`
152
-	MaxUnit          string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
153
-	MinNumber        int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
154
-	MinUnit          string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
155
-	Dose             string `gorm:"column:dose" json:"dose" form:"dose"`
156
-	DoseUnit         string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
157
-	IsZeroFlag       int64  `gorm:"column:is_zero_flag" json:"is_zero_flag" form:"is_zero_flag"`
150
+	ID                     int64  `gorm:"column:id" json:"id" form:"id"`
151
+	DrugName               string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
152
+	Manufacturer           int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
153
+	ManufacturerName       string `gorm:"column:manufacturer_name" json:"manufacturer_name"`
154
+	MaxUnit                string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
155
+	MinNumber              int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
156
+	MinUnit                string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
157
+	Dose                   string `gorm:"column:dose" json:"dose" form:"dose"`
158
+	DoseUnit               string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
159
+	IsZeroFlag             int64  `gorm:"column:is_zero_flag" json:"is_zero_flag" form:"is_zero_flag"`
160
+	ScanCode               string `gorm:"column:scan_code" json:"scan_code" form:"scan_code"`
161
+	DrugIdentificationCode string `gorm:"column:drug_identification_code" json:"drug_identification_code" form:"drug_identification_code"`
158 162
 }
159 163
 
160 164
 func (BaseDrugLibEleven) TableName() string {

+ 21 - 0
models/patient_models.go Ver arquivo

@@ -3082,3 +3082,24 @@ func (BtAssessmentBeforeDislysis) TableName() string {
3082 3082
 
3083 3083
 	return "xt_assessment_before_dislysis"
3084 3084
 }
3085
+
3086
+type BtInspection struct {
3087
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
3088
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3089
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
3090
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
3091
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
3092
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
3093
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
3094
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
3095
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
3096
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
3097
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
3098
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
3099
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
3100
+}
3101
+
3102
+func (BtInspection) TableName() string {
3103
+
3104
+	return "xt_inspection"
3105
+}

+ 1 - 0
models/schedule_models.go Ver arquivo

@@ -477,6 +477,7 @@ type VmBloodScheduleTwo struct {
477 477
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
478 478
 	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
479 479
 	HisPrescriptionProject     []*HisPrescriptionProject  `gorm:"ForeignKey:PatientId,schedule_date;AssociationForeignKey:PatientId,RecordDate" json:"his_prescription_project"`
480
+	DialysisSolution           DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
480 481
 }
481 482
 
482 483
 func (VmBloodScheduleTwo) TableName() string {

+ 2 - 2
service/dialysis_solution_service.go Ver arquivo

@@ -425,7 +425,7 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
425 425
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
426 426
 					return db.Where("org_id = ? and status = 1", orgID)
427 427
 				})
428
-			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
428
+			}).Preload("DialysisSolution", "status =1 and user_org_id = ? and solution_status=1").Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
429 429
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
430 430
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
431 431
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
@@ -443,7 +443,7 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
443 443
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
444 444
 					return db.Where("org_id = ? and status = 1", orgID)
445 445
 				})
446
-			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
446
+			}).Preload("DialysisSolution", "status =1 and user_org_id = ? and solution_status=1", orgID).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
447 447
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
448 448
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
449 449
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)

+ 1 - 1
service/gobal_config_service.go Ver arquivo

@@ -665,7 +665,7 @@ func GetAllBaseDrugListTwo(orgid int64) (drug []*models.BaseDrugLibEleven, err e
665 665
 	if orgid > 0 {
666 666
 		db = db.Where("x.org_id =?", orgid)
667 667
 	}
668
-	err = db.Select("x.id,x.drug_name,p.manufacturer_name,x.dose,x.dose_unit,x.min_number,x.max_unit,x.min_unit").Joins("left join xt_manufacturer as p on p.id =x.manufacturer").Scan(&drug).Error
668
+	err = db.Select("x.id,x.drug_name,p.manufacturer_name,x.dose,x.dose_unit,x.min_number,x.max_unit,x.min_unit,x.scan_code,x.drug_identification_code").Joins("left join xt_manufacturer as p on p.id =x.manufacturer").Scan(&drug).Error
669 669
 	return drug, err
670 670
 }
671 671
 

+ 2 - 0
service/his_service.go Ver arquivo

@@ -2549,7 +2549,9 @@ func GetHisPrescriptionProjectsByID(id int64) (projects []*models.HisPrescriptio
2549 2549
 }
2550 2550
 
2551 2551
 func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
2552
+
2552 2553
 	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id = 0", user_org_id, patient_id, record_time).Find(&projects).Error
2554
+
2553 2555
 	return
2554 2556
 }
2555 2557
 

+ 3 - 3
service/mobile_dialysis_service.go Ver arquivo

@@ -2889,12 +2889,12 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
2889 2889
 }
2890 2890
 
2891 2891
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2892
-	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1640966400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2892
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1704038400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2893 2893
 	return
2894 2894
 }
2895 2895
 
2896 2896
 func GetDialysisOrderCountTwo(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2897
-	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1704038400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2897
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1735660800 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2898 2898
 	return
2899 2899
 }
2900 2900
 
@@ -8269,7 +8269,7 @@ func GetDialysisTotalCountOne(org_id int64, patient_id int64) (models.BloodDialy
8269 8269
 	order := models.BloodDialysisOrderCount{}
8270 8270
 	db := XTReadDB().Table("xt_dialysis_order as o")
8271 8271
 
8272
-	err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o left join xt_schedule as x on x.patient_id = o.patient_id where o.status =1 and o.user_org_id = ? and o.patient_id = ? and o.dialysis_date>=1704038400 and  x.schedule_date = o.dialysis_date and x.status = 1 ", org_id, patient_id).Scan(&order).Error
8272
+	err = db.Raw("select count(o.id) as count,o.patient_id from xt_dialysis_order as o left join xt_schedule as x on x.patient_id = o.patient_id where o.status =1 and o.user_org_id = ? and o.patient_id = ? and o.dialysis_date>=1735660800 and  x.schedule_date = o.dialysis_date and x.status = 1 ", org_id, patient_id).Scan(&order).Error
8273 8273
 
8274 8274
 	return order, err
8275 8275
 }

+ 1 - 5
service/new_stock_service.go Ver arquivo

@@ -348,15 +348,11 @@ func GetNewDrugStockCount(storehouse_id int64, drug_id int64, org_id int64, tx *
348 348
 	drugStockCount := models.XtDrugStockCount{}
349 349
 	var err error
350 350
 	err = tx.Where("storehouse_id = ? and drug_id = ? and user_org_id  = ? and status = 1", storehouse_id, drug_id, org_id).Find(&drugStockCount).Error
351
-	if err == gorm.ErrRecordNotFound {
351
+	if err != gorm.ErrRecordNotFound {
352 352
 		if err != nil {
353 353
 			tx.Rollback()
354 354
 			return nil, err
355 355
 		}
356
-		return nil, err
357
-	}
358
-	if err != nil {
359
-		return nil, err
360 356
 	}
361 357
 	return &drugStockCount, nil
362 358
 }

+ 40 - 0
service/patient_dataconfig_service.go Ver arquivo

@@ -182,3 +182,43 @@ func GetLongDoctorAdvice(org_id int64, patient_id int64, start_time int64, end_t
182 182
 
183 183
 	return advice, err
184 184
 }
185
+
186
+func GetHisPrecriptionadviceList(org_id int64, patient_id int64, start_time int64, end_time int64) (advice []*models.HisPrescriptionAdviceTemplate, err error) {
187
+
188
+	db := XTReadDB().Model(&advice).Where("status =1")
189
+	if org_id > 0 {
190
+		db = db.Where("user_org_id =?", org_id)
191
+	}
192
+	if patient_id > 0 {
193
+		db = db.Where("patient_id = ?", patient_id)
194
+	}
195
+	if start_time > 0 {
196
+		db = db.Where("created_time>=?", start_time)
197
+	}
198
+	if end_time > 0 {
199
+		db = db.Where("created_time<=?", end_time)
200
+	}
201
+	err = db.Find(&advice).Error
202
+
203
+	return advice, err
204
+}
205
+
206
+func GetHisadviceList(org_id int64, patient_id int64, start_time int64, end_time int64) (advice []*models.HisDoctorAdviceInfo, err error) {
207
+
208
+	db := XTReadDB().Model(&advice).Where("status =1")
209
+	if org_id > 0 {
210
+		db = db.Where("user_org_id =?", org_id)
211
+	}
212
+	if patient_id > 0 {
213
+		db = db.Where("patient_id = ?", patient_id)
214
+	}
215
+	if start_time > 0 {
216
+		db = db.Where("advice_date>=?", start_time)
217
+	}
218
+	if end_time > 0 {
219
+		db = db.Where("advice_date<=?", end_time)
220
+	}
221
+	err = db.Find(&advice).Error
222
+
223
+	return advice, err
224
+}

+ 153 - 2
service/patient_service.go Ver arquivo

@@ -4735,11 +4735,11 @@ func GetPatientRescueRecord(id int64) (models.XtPatientRescueRecord, error) {
4735 4735
 	return rescueRecords, err
4736 4736
 }
4737 4737
 
4738
-func ModifyCoursePrint(id int64, content string) (models.XtPatientRescueRecord, error) {
4738
+func ModifyCoursePrint(id int64, content string, record_date int64) (models.XtPatientRescueRecord, error) {
4739 4739
 
4740 4740
 	rescueRecord := models.XtPatientRescueRecord{}
4741 4741
 
4742
-	err := XTWriteDB().Model(&rescueRecord).Where("id = ? and status=1", id).Updates(map[string]interface{}{"content": content}).Error
4742
+	err := XTWriteDB().Model(&rescueRecord).Where("id = ? and status=1", id).Updates(map[string]interface{}{"content": content, "record_time": record_date}).Error
4743 4743
 
4744 4744
 	return rescueRecord, err
4745 4745
 }
@@ -4860,3 +4860,154 @@ func GetPatientLastBefor(patient_id int64, start_time int64, end_time int64, org
4860 4860
 
4861 4861
 	return beforeDislysis, err
4862 4862
 }
4863
+
4864
+func GetMonitorSearchList(patient_id int64, user_org_id int64, start_time int64, end_time int64) (schedule []*models.PatientNewSchedule, err error) {
4865
+
4866
+	db := XTReadDB().Model(&schedule).Where("status= 1")
4867
+
4868
+	if patient_id > 0 {
4869
+		db = db.Where("patient_id = ?", patient_id)
4870
+	}
4871
+	if user_org_id > 0 {
4872
+		db = db.Where("user_org_id = ?", user_org_id)
4873
+	}
4874
+	if start_time > 0 {
4875
+		db = db.Where("schedule_date>=?", start_time)
4876
+	}
4877
+	if end_time > 0 {
4878
+		db = db.Where("schedule_date<=?", end_time)
4879
+	}
4880
+
4881
+	err = db.Preload("PatientMonitoringRecord", "user_org_id = ? and status=1", user_org_id).Preload("PatientAssessmentAfterDislysis", "user_org_id = ? and status=1", user_org_id).Preload("PatientAssessmentBeforeDislysis", "user_org_id = ? and status=1", user_org_id).Find(&schedule).Error
4882
+
4883
+	return schedule, err
4884
+
4885
+}
4886
+
4887
+func GetSummarySearchList(patient_id int64, user_org_id int64, start_time int64, end_time int64) (schedule []*models.PatientNewScheduleOne, err error) {
4888
+
4889
+	db := XTReadDB().Model(&schedule).Where("status= 1")
4890
+
4891
+	if patient_id > 0 {
4892
+		db = db.Where("patient_id = ?", patient_id)
4893
+	}
4894
+	if user_org_id > 0 {
4895
+		db = db.Where("user_org_id = ?", user_org_id)
4896
+	}
4897
+	if start_time > 0 {
4898
+		db = db.Where("schedule_date>=?", start_time)
4899
+	}
4900
+	if end_time > 0 {
4901
+		db = db.Where("schedule_date<=?", end_time)
4902
+	}
4903
+
4904
+	err = db.Preload("PatientTreatmentSummary", "user_org_id = ? and status=1", user_org_id).Find(&schedule).Error
4905
+
4906
+	return schedule, err
4907
+}
4908
+
4909
+func GetPatientDryWeightList(patient_id int64, user_org_id int64, start_time int64, end_time int64) (dry []*models.SgjPatientDryweight, err error) {
4910
+
4911
+	db := XTReadDB().Model(&dry).Where("status=1")
4912
+
4913
+	if patient_id > 0 {
4914
+		db = db.Where("patient_id = ?", patient_id)
4915
+	}
4916
+	if user_org_id > 0 {
4917
+		db = db.Where("user_org_id = ?", user_org_id)
4918
+	}
4919
+	if start_time > 0 {
4920
+		db = db.Where("ctime>=?", start_time)
4921
+	}
4922
+	if end_time > 0 {
4923
+		db = db.Where("ctime<=?", end_time)
4924
+	}
4925
+	err = db.Find(&dry).Error
4926
+
4927
+	return dry, err
4928
+}
4929
+
4930
+func GetDialysisSystemList(user_org_id int64) (prescription []*models.SystemPrescription, err error) {
4931
+
4932
+	err = XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&prescription).Error
4933
+
4934
+	return prescription, err
4935
+}
4936
+
4937
+func GetPatientAdviceList(patient_id int64, user_org_id int64, start_time int64, end_time int64, advice_type int64) (list []*models.XtDoctorAdvice, err error) {
4938
+
4939
+	db := XTReadDB().Model(&list).Where("status= 1")
4940
+
4941
+	if patient_id > 0 {
4942
+		db = db.Where("patient_id = ?", patient_id)
4943
+	}
4944
+	if user_org_id > 0 {
4945
+		db = db.Where("user_org_id = ?", user_org_id)
4946
+	}
4947
+	if start_time > 0 {
4948
+		db = db.Where("advice_date>=?", start_time)
4949
+	}
4950
+	if end_time > 0 {
4951
+		db = db.Where("advice_date<=?", end_time)
4952
+	}
4953
+	if advice_type > 0 {
4954
+		db = db.Where("advice_type = ?", advice_type)
4955
+	}
4956
+
4957
+	err = db.Find(&list).Error
4958
+
4959
+	return list, err
4960
+
4961
+}
4962
+
4963
+func GetNewPatientGroupInspectionList(patient_id int64, org_id int64, start_time int64, end_time int64) (inspection []*models.BtInspection, err error) {
4964
+
4965
+	db := XTReadDB().Model(&inspection).Where("status= 1")
4966
+
4967
+	if patient_id > 0 {
4968
+		db = db.Where("patient_id = ?", patient_id)
4969
+	}
4970
+
4971
+	if org_id > 0 {
4972
+		db = db.Where("org_id = ?", org_id)
4973
+	}
4974
+	if start_time > 0 {
4975
+		db = db.Where("inspect_date>=?", start_time)
4976
+	}
4977
+	if end_time > 0 {
4978
+		db = db.Where("inspect_date<=?", end_time)
4979
+	}
4980
+	err = db.Group("project_id,inspect_date").Order("project_id").Find(&inspection).Error
4981
+
4982
+	return inspection, err
4983
+}
4984
+
4985
+func GetNewPatientInspectionList(patient_id int64, org_id int64, start_time int64, end_time int64) (inspection []*models.XtInspection, err error) {
4986
+
4987
+	db := XTReadDB().Model(&inspection).Where("status= 1")
4988
+
4989
+	if patient_id > 0 {
4990
+		db = db.Where("patient_id = ?", patient_id)
4991
+	}
4992
+
4993
+	if org_id > 0 {
4994
+		db = db.Where("org_id = ?", org_id)
4995
+	}
4996
+	if start_time > 0 {
4997
+		db = db.Where("inspect_date>=?", start_time)
4998
+	}
4999
+	if end_time > 0 {
5000
+		db = db.Where("inspect_date<=?", end_time)
5001
+	}
5002
+	err = db.Find(&inspection).Error
5003
+
5004
+	return inspection, err
5005
+
5006
+}
5007
+
5008
+func GetNewInspectionByProjectId(patient_id int64, project_id int64, inspect_date int64, org_id int64) (inspection []*models.XtInspection, err error) {
5009
+
5010
+	err = XTReadDB().Where("patient_id = ? and project_id = ? and inspect_date = ? and status=1 and org_id = ?", patient_id, project_id, inspect_date, org_id).Find(&inspection).Error
5011
+
5012
+	return inspection, err
5013
+}

+ 1 - 1
service/patientmanage_service.go Ver arquivo

@@ -951,7 +951,7 @@ func GetNewPatient(id int64) (models.XtPatientsNew, error) {
951 951
 
952 952
 func UpdatedPatient(patients models.Patients, id int64) error {
953 953
 
954
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan, "patient_type": patients.PatientType}).Error
954
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan, "patient_type": patients.PatientType, "updated_time": time.Now().Unix()}).Error
955 955
 
956 956
 	return err
957 957
 }

+ 8 - 1
service/pharmacy_service.go Ver arquivo

@@ -2466,7 +2466,7 @@ func ChangeHisDrugCode(id int64, drug_code string, user_org_id int64) (models.Hi
2466 2466
 
2467 2467
 	err := XTWriteDB().Model(&adviceInfo).Where("id = ? and user_org_id = ? and status =1", id, user_org_id).Updates(map[string]interface{}{"drug_code": drug_code}).Error
2468 2468
 
2469
-	fmt.Println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeee", err)
2469
+	fmt.Println("", err)
2470 2470
 	return adviceInfo, err
2471 2471
 }
2472 2472
 
@@ -2560,3 +2560,10 @@ func DispensingMedicineTwo(orgid, patient_id, advice_date, drug_id, creater int6
2560 2560
 
2561 2561
 	return
2562 2562
 }
2563
+
2564
+func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2565
+
2566
+	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2567
+
2568
+	return advice, err
2569
+}

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver arquivo

@@ -236,13 +236,13 @@ func GetDialysisOrderCountTen(patient_id int64, recordDate int64) (models.VmDial
236 236
 
237 237
 func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
238 238
 	order := models.VmDialysisOrder{}
239
-	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1672502400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
239
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
240 240
 	return order, err
241 241
 }
242 242
 
243 243
 func GetDialysisOrderCountNight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
244 244
 	order := models.VmDialysisOrder{}
245
-	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
245
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1735660800 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
246 246
 	return order, err
247 247
 }
248 248
 

+ 14 - 0
service/self_drug_service.go Ver arquivo

@@ -5397,3 +5397,17 @@ func ModifyDrugCodeWarehosueInfo(id int64, drug_code string) (models.XtDrugWareh
5397 5397
 
5398 5398
 	return drugWarehouseInfo, err
5399 5399
 }
5400
+
5401
+func GetAllDrugInfoList(drug_id int64, user_org_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
5402
+
5403
+	err = XTReadDB().Where("drug_id = ? and org_id = ? and status =1 and is_check =1", drug_id, user_org_id).Find(&info).Find(&info).Error
5404
+
5405
+	return info, err
5406
+}
5407
+
5408
+func GetHisDocInfoList(drug_id int64, user_org_id int64) (info []*models.HisDoctorAdviceInfo, err error) {
5409
+
5410
+	err = XTReadDB().Where("drug_id = ? and user_org_id = ? and status=1", drug_id, user_org_id).Find(&info).Error
5411
+
5412
+	return info, err
5413
+}

+ 18 - 6
service/smart_sch.go Ver arquivo

@@ -8,12 +8,24 @@ import (
8 8
 )
9 9
 
10 10
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
11
-	db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3", orgID)
12
-	if len(keywords) > 0 {
13
-		likekey := "%" + keywords + "%"
14
-		err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
15
-	} else {
16
-		err = db.Find(&patient).Error
11
+	if orgID != 10517 {
12
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3", orgID)
13
+		if len(keywords) > 0 {
14
+			likekey := "%" + keywords + "%"
15
+			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
16
+		} else {
17
+			err = db.Find(&patient).Error
18
+		}
19
+	}
20
+
21
+	if orgID == 10517 {
22
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto =1", orgID)
23
+		if len(keywords) > 0 {
24
+			likekey := "%" + keywords + "%"
25
+			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
26
+		} else {
27
+			err = db.Find(&patient).Error
28
+		}
17 29
 	}
18 30
 
19 31
 	//for _, item := range patient {

+ 148 - 10
service/stock_service.go Ver arquivo

@@ -666,11 +666,11 @@ func CreateNewDrugWarehousingInfo(warehousingInfo []*models.DrugWarehouseInfo, t
666 666
 	if len(warehousingInfo) > 0 {
667 667
 
668 668
 		if len(warehousingInfo) > 0 {
669
-			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number,stock_min_number,storehouse_id) VALUES "
669
+			thisSQL := "INSERT INTO xt_drug_warehouse_info (warehousing_id, drug_id, number, product_date,expiry_date,warehousing_count,price,total_price,dealer,manufacturer,remark,ctime,mtime,status,org_id,warehousing_order,type,retail_price,retail_total_price,stock_max_number,max_unit,min_unit,batch_number,stock_min_number,storehouse_id,drug_code) VALUES "
670 670
 			insertParams := make([]string, 0)
671 671
 			insertData := make([]interface{}, 0)
672 672
 			for _, info := range warehousingInfo {
673
-				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
673
+				insertParams = append(insertParams, "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)")
674 674
 				insertData = append(insertData, info.WarehousingId)
675 675
 				insertData = append(insertData, info.DrugId)
676 676
 				insertData = append(insertData, info.Number)
@@ -696,6 +696,7 @@ func CreateNewDrugWarehousingInfo(warehousingInfo []*models.DrugWarehouseInfo, t
696 696
 				insertData = append(insertData, info.BatchNumber)
697 697
 				insertData = append(insertData, info.StockMinNumber)
698 698
 				insertData = append(insertData, info.StorehouseId)
699
+				insertData = append(insertData, info.DrugCode)
699 700
 			}
700 701
 			thisSQL += strings.Join(insertParams, ", ")
701 702
 			err = tx.Exec(thisSQL, insertData...).Error
@@ -1871,6 +1872,20 @@ func GetNewDrugWarehouseOutIsExit(org_id int64, is_sys int, record_time int64, w
1871 1872
 	return drugWarehouseOut, err
1872 1873
 }
1873 1874
 
1875
+func GetNewDrugWarehouseOutIsExitOne(org_id int64, is_sys int, record_time int64, warehousing_out_order string, tx *gorm.DB, id int64) (models.DrugWarehouseOut, error) {
1876
+
1877
+	drugWarehouseOut := models.DrugWarehouseOut{}
1878
+	err := tx.Where("is_sys = ? AND status = 1 AND org_id = ? AND id = ?", is_sys, org_id, id).Find(&drugWarehouseOut).Error
1879
+	if err != gorm.ErrRecordNotFound {
1880
+		if err != nil {
1881
+			tx.Rollback()
1882
+			return drugWarehouseOut, err
1883
+		}
1884
+	}
1885
+
1886
+	return drugWarehouseOut, err
1887
+}
1888
+
1874 1889
 func AddSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut) error {
1875 1890
 	err := writeDb.Create(&warehouseOut).Error
1876 1891
 	return err
@@ -3527,7 +3542,7 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3527 3542
 		return
3528 3543
 	} else {
3529 3544
 		db := readDb.Model(&models.WarehouseOutInfo{})
3530
-		db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0 ", orgId)
3545
+		db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1 AND xt_warehouse_out_info.is_check = 1 AND xt_warehouse_out_info.count <> 0 ", orgId)
3531 3546
 
3532 3547
 		if len(keywords) > 0 {
3533 3548
 			likeKey := "%" + keywords + "%"
@@ -3537,7 +3552,7 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3537 3552
 
3538 3553
 			db = db.Where("sgj_user_admin_role.user_name LIKE ? OR xt_warehouse_out_info.warehouse_out_order_number LIKE ?  OR xt_good_information.specification_name LIKE ?  OR xt_good_information.good_name LIKE ?", likeKey, likeKey, likeKey, likeKey).Group("xt_warehouse_out_info.id")
3539 3554
 		} else {
3540
-			db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3555
+			db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id and xt_warehouse_out.org_id = xt_warehouse_out_info.org_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3541 3556
 		}
3542 3557
 
3543 3558
 		if manufacturer > 0 {
@@ -3552,8 +3567,8 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3552 3567
 			db = db.Where("xt_warehouse_out_info.storehouse_id = ?", storehouse_id)
3553 3568
 		}
3554 3569
 
3555
-		db = db.Preload("WarehouseOut", "status = 1 AND org_id = ?", orgId)
3556
-		db = db.Preload("WarehousingInfoNight", "status=1 and org_id = ?", orgId)
3570
+		db = db.Preload("WarehouseOut", "status = 1 AND org_id = ? and is_check =1", orgId)
3571
+		db = db.Preload("WarehousingInfoNight", "status=1 and org_id = ? and is_check =1", orgId)
3557 3572
 		db = db.Preload("GoodInfo", "status = 1 AND org_id = ?", orgId)
3558 3573
 		db = db.Count(&total)
3559 3574
 		offset := (page - 1) * limit
@@ -3565,7 +3580,7 @@ func FindStockOutDetailList(orgId int64, page int64, limit int64, startTime int6
3565 3580
 
3566 3581
 func GetStockOutDetailTotal(orgId int64, startTime int64, endTime int64, keywords string, manufacturer int64, order_type int64, dealer int64, storehouse_id int64) (err error, totalPrice float64) {
3567 3582
 	db := readDb.Model(&models.WarehouseOutInfo{})
3568
-	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1  AND xt_warehouse_out_info.good_id <> 0 AND xt_warehouse_out_info.count <> 0", orgId)
3583
+	db = db.Where("xt_warehouse_out_info.org_id = ? AND xt_warehouse_out_info.status = 1  AND xt_warehouse_out_info.count > 0", orgId)
3569 3584
 
3570 3585
 	if len(keywords) > 0 {
3571 3586
 		likeKey := "%" + keywords + "%"
@@ -3575,7 +3590,7 @@ func GetStockOutDetailTotal(orgId int64, startTime int64, endTime int64, keyword
3575 3590
 
3576 3591
 		db = db.Where("sgj_user_admin_role.user_name LIKE ? OR xt_warehouse_out_info.warehouse_out_order_number LIKE ?", likeKey, likeKey).Group("xt_warehouse_out_info.id")
3577 3592
 	} else {
3578
-		db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3593
+		db = db.Joins("join xt_warehouse_out on xt_warehouse_out.id = xt_warehouse_out_info.warehouse_out_id and   xt_warehouse_out.org_id = xt_warehouse_out_info.org_id AND xt_warehouse_out.warehouse_out_time >=? AND xt_warehouse_out.warehouse_out_time<= ? AND xt_warehouse_out.status = 1 AND xt_warehouse_out.org_id = ?", startTime, endTime, orgId)
3579 3594
 	}
3580 3595
 
3581 3596
 	if manufacturer > 0 {
@@ -9107,7 +9122,6 @@ func UpdateNewCheckDrugOut(out models.DrugWarehouseOut, id int64, tx *gorm.DB) e
9107 9122
 		tx.Rollback()
9108 9123
 		return err
9109 9124
 	}
9110
-	tx.Commit()
9111 9125
 	return err
9112 9126
 }
9113 9127
 
@@ -9162,6 +9176,18 @@ func UpdateNewDrugMaxNumber(count int64, id int64, tx *gorm.DB) error {
9162 9176
 	return err
9163 9177
 }
9164 9178
 
9179
+func UpdateNewDrugMaxNumberOne(count int64, id int64, tx *gorm.DB) error {
9180
+
9181
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
9182
+	if err != gorm.ErrRecordNotFound {
9183
+		if err != nil {
9184
+			tx.Rollback()
9185
+			return err
9186
+		}
9187
+	}
9188
+	return err
9189
+}
9190
+
9165 9191
 func UpdateDrugMinNumber(count int64, id int64) error {
9166 9192
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
9167 9193
 	return err
@@ -9319,6 +9345,19 @@ func UpdateNewGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64,
9319 9345
 
9320 9346
 }
9321 9347
 
9348
+func GetGoodFlowByWarehouseOutId(good_id int64, user_org_id int64, id int64, tx *gorm.DB) (flow []*models.VmStockFlow, err error) {
9349
+
9350
+	err = tx.Where("good_id = ? and user_org_id = ? and warehouse_out_detail_id = ? and status=1", good_id, user_org_id, id).Find(&flow).Error
9351
+
9352
+	if err != gorm.ErrRecordNotFound {
9353
+		if err != nil {
9354
+			tx.Rollback()
9355
+			return flow, err
9356
+		}
9357
+	}
9358
+	return
9359
+}
9360
+
9322 9361
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
9323 9362
 
9324 9363
 	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
@@ -9905,6 +9944,20 @@ func GetGoodInformationByGoodIdOne(good_id int64) (models.GoodInformationFourty,
9905 9944
 	return info, err
9906 9945
 }
9907 9946
 
9947
+func GetAllWarehouseInfo(good_id int64, user_org_id int64) (info []*models.WarehousingInfo, err error) {
9948
+
9949
+	err = XTReadDB().Where("good_id = ? and user_org_id =? and status=1 and is_check =1", good_id, user_org_id).Find(&info).Error
9950
+
9951
+	return info, err
9952
+}
9953
+
9954
+func GetHisPrescriptionByGoodId(good_id int64, user_org_id int64) (project []*models.HisPrescriptionProject, err error) {
9955
+
9956
+	err = XTReadDB().Where("project_id  = ? and user_org_id =? and status=1 and type =3", good_id, user_org_id).Find(&project).Error
9957
+
9958
+	return project, err
9959
+}
9960
+
9908 9961
 func GetHisDocById(id int64, orgid int64) (models.HisDoctorAdvice, error) {
9909 9962
 
9910 9963
 	advice := models.HisDoctorAdvice{}
@@ -10862,7 +10915,7 @@ func GetHisDrugCodeQuery(orgId int64, start_time int64, end_time int64, limit in
10862 10915
 		db = db.Where("is_upload = 2 or is_upload =0")
10863 10916
 	}
10864 10917
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&list).Error
10865
-	fmt.Println("totla====================", total)
10918
+
10866 10919
 	return list, total, err
10867 10920
 }
10868 10921
 
@@ -10872,3 +10925,88 @@ func GetDrugWarehouseOutInfoByDrugCode(drug_id int64, patient_id int64, advice_d
10872 10925
 
10873 10926
 	return outinfo, err
10874 10927
 }
10928
+
10929
+func GetNewGoodWarehouseOutInfo(good_id int64, user_org_id int64, warehouse_out_id int64, tx *gorm.DB) (info []*models.WarehouseOutInfo, err error) {
10930
+
10931
+	err = tx.Where("good_id = ? and org_id = ? and warehouse_out_id = ? and status= 1", good_id, user_org_id, warehouse_out_id).Find(&info).Error
10932
+
10933
+	if err != gorm.ErrRecordNotFound {
10934
+		if err != nil {
10935
+			tx.Rollback()
10936
+			return info, err
10937
+		}
10938
+	}
10939
+	return info, err
10940
+}
10941
+
10942
+func GetInitGoodFlow(user_org_id int64, good_id int64, warehousing_detail_id int64, tx *gorm.DB) (list []*models.VmStockFlow, err error) {
10943
+
10944
+	err = tx.Where("user_org_id = ? and good_id = ? and warehousing_detail_id = ? and status=1", user_org_id, good_id, warehousing_detail_id).Find(&list).Error
10945
+
10946
+	if err != gorm.ErrRecordNotFound {
10947
+		if err != nil {
10948
+			tx.Rollback()
10949
+			return list, err
10950
+		}
10951
+	}
10952
+	return list, err
10953
+}
10954
+
10955
+func GetNewDrugFlowList(drug_id int64, user_org_id int64, warehousing_detail_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
10956
+
10957
+	err = tx.Where("drug_id = ? and user_org_id =? and warehousing_detail_id = ? and status=1", drug_id, user_org_id, warehousing_detail_id).Find(&flow).Error
10958
+	if err != gorm.ErrRecordNotFound {
10959
+		if err != nil {
10960
+			tx.Rollback()
10961
+			return flow, err
10962
+		}
10963
+	}
10964
+	return flow, err
10965
+}
10966
+
10967
+func GetNewPatientAdviceList(patient_id int64, start_time int64, end_time int64, user_org_id int64) (advice []*models.DoctorAdvice, err error) {
10968
+
10969
+	db := XTReadDB().Model(&advice).Where("status=1 and advice_type =2")
10970
+
10971
+	if patient_id > 0 {
10972
+		db = db.Where("patient_id = ?", patient_id)
10973
+	}
10974
+	if start_time > 0 {
10975
+		db = db.Where("advice_date>=?", start_time)
10976
+	}
10977
+	if end_time > 0 {
10978
+		db = db.Where("advice_date<=?", end_time)
10979
+	}
10980
+	if user_org_id > 0 {
10981
+		db = db.Where("user_org_id = ?", user_org_id)
10982
+	}
10983
+	err = db.Find(&advice).Error
10984
+
10985
+	return advice, err
10986
+}
10987
+
10988
+func GetPatientAdviceListDetail(patient_id int64, start_time int64, end_time int64, user_org_id int64, advice_name string) (advice []*models.DoctorAdvice, err error) {
10989
+
10990
+	db := XTReadDB().Model(&advice).Where("status = 1")
10991
+
10992
+	if patient_id > 0 {
10993
+		db = db.Where("patient_id = ?", patient_id)
10994
+	}
10995
+	if start_time > 0 {
10996
+		db = db.Where("advice_date>=?", start_time)
10997
+	}
10998
+
10999
+	if end_time > 0 {
11000
+		db = db.Where("advice_date<=?", end_time)
11001
+	}
11002
+
11003
+	if user_org_id > 0 {
11004
+		db = db.Where("user_org_id = ?", user_org_id)
11005
+	}
11006
+	if len(advice_name) > 0 {
11007
+		db = db.Where("advice_name =?", advice_name)
11008
+	}
11009
+	err = db.Order("advice_date asc").Find(&advice).Error
11010
+
11011
+	return advice, err
11012
+}

+ 7 - 2
service/user_service.go Ver arquivo

@@ -99,7 +99,12 @@ func GetAllAdminUsers(orgId, appid int64) (list []*AdminUserList, err error) {
99 99
 func GetAllAdminUsersTwo(orgId int64) (list []*AdminUserList, err error) {
100 100
 
101 101
 	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
102
-	//err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1  and ua.status=1").Select("ua.id, uar.user_name as name, uar.user_type").Scan(&list).Error
102
+
103
+	if orgId == 10724 {
104
+		err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
105
+	} else {
106
+		err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("uar.status=1 and uar.org_id=?  and ua.status=1", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
107
+	}
103 108
 	return
104 109
 }
105 110
 
@@ -181,7 +186,7 @@ func GetLastData(orgid int64) (models.SgjPatientDryweight, error) {
181 186
 
182 187
 func UpdateDialysisPrescription(patientid int64, orgid int64, dryweight float64, prescription models.PredialysisEvaluation) error {
183 188
 
184
-	err := XTWriteDB().Model(&prescription).Where("patient_id = ? AND user_org_id = ? and assessment_date = ?", patientid, orgid, prescription.AssessmentDate).Update(map[string]interface{}{"dry_weight": prescription.DryWeight, "mtime": time.Now().Unix()}).Error
189
+	err := XTWriteDB().Model(&prescription).Where("patient_id = ? AND user_org_id = ? and assessment_date = ?", patientid, orgid, prescription.AssessmentDate).Update(map[string]interface{}{"dry_weight": prescription.DryWeight, "updated_time": time.Now().Unix()}).Error
185 190
 	fmt.Println("错误是设么", err)
186 191
 	return err
187 192
 }

+ 18 - 12
service/warhouse_service.go Ver arquivo

@@ -6133,6 +6133,18 @@ func UpdateGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64,
6133 6133
 	return err
6134 6134
 }
6135 6135
 
6136
+func GetDrugOutFlowByWarehouseOut(drug_id int64, warehouse_out_detail_id int64, org_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
6137
+
6138
+	err = tx.Where("drug_id = ? and warehouse_out_detail_id = ? and user_org_id = ? and status=1", drug_id, warehouse_out_detail_id, org_id).Find(&flow).Error
6139
+	if err != gorm.ErrRecordNotFound {
6140
+		if err != nil {
6141
+			tx.Rollback()
6142
+			return flow, err
6143
+		}
6144
+	}
6145
+	return flow, err
6146
+}
6147
+
6136 6148
 func UpdateNewGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64, over_count int64, tx *gorm.DB) error {
6137 6149
 
6138 6150
 	err := tx.Model(models.WarehouseOutInfo{}).Where("id = ?  and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count}).Error
@@ -6443,18 +6455,15 @@ func ModifyGoodSumCount(storehouse_id int64, count int64, user_org_id int64, goo
6443 6455
 
6444 6456
 func ModifyNewGoodSumCount(storehouse_id int64, count int64, user_org_id int64, good_id int64, tx *gorm.DB) error {
6445 6457
 
6446
-	err = tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count + ?", count)).Error
6447
-	if err != nil {
6448
-		tx.Rollback()
6449
-		return err
6450
-	}
6458
+	err := tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count + ?", count)).Error
6451 6459
 
6452 6460
 	err = tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_act_out_count", gorm.Expr("stock_act_out_count + ?", count)).Error
6461
+
6462
+	fmt.Println("err---------------------------", err)
6453 6463
 	if err != nil {
6454 6464
 		tx.Rollback()
6455 6465
 		return err
6456 6466
 	}
6457
-
6458 6467
 	return err
6459 6468
 }
6460 6469
 
@@ -10907,12 +10916,6 @@ func ConsumablesNewDeliveryThirty(orgID int64, record_time int64, goods *models.
10907 10916
 		//更新出库数量
10908 10917
 		ModifyNewGoodSumCount(goods.StorehouseId, goods.Count, goods.OrgId, goods.GoodId, tx)
10909 10918
 
10910
-		if warehouse.StockCount < maxNumber {
10911
-			tx.Rollback()
10912
-			return errors.New("库存数量不足")
10913
-
10914
-		}
10915
-
10916 10919
 		return nil
10917 10920
 	} else {
10918 10921
 		// 出库完成后,要将该批次库存清零
@@ -10978,6 +10981,7 @@ func ConsumablesNewDeliveryThirty(orgID int64, record_time int64, goods *models.
10978 10981
 		ModifyNewGoodSumCount(goods.StorehouseId, stock_number, goods.OrgId, goods.GoodId, tx)
10979 10982
 
10980 10983
 		goods.Count = deliver_number - stock_number
10984
+
10981 10985
 		ConsumablesNewDeliveryThirty(orgID, record_time, goods, warehouseOut, count, creator, tx)
10982 10986
 	}
10983 10987
 	return nil
@@ -11195,6 +11199,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11195 11199
 			SystemTime:              advice.SysRecordTime,
11196 11200
 			PatientId:               advice.PatientId,
11197 11201
 			Remark:                  advice.Remark,
11202
+			OperateTime:             time.Now().Unix(),
11198 11203
 		}
11199 11204
 		if warehouse.RetailPrice == 0 {
11200 11205
 			drugflow.Price = advice.Price
@@ -11266,6 +11271,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11266 11271
 			SystemTime:              advice.SysRecordTime,
11267 11272
 			PatientId:               advice.PatientId,
11268 11273
 			Remark:                  advice.Remark,
11274
+			OperateTime:             time.Now().Unix(),
11269 11275
 		}
11270 11276
 
11271 11277
 		CreateNewDrugFlowOne(drugflow, tx)