28169 hace 2 meses
padre
commit
802d10d974
Se han modificado 34 ficheros con 928 adiciones y 141 borrados
  1. BIN
      XT_New.exe
  2. 6 6
      controllers/base_api_controller.go
  3. 68 2
      controllers/dialysis_api_controller.go
  4. 41 10
      controllers/drug_stock_api_contorller.go
  5. 29 0
      controllers/gobal_config_api_controller.go
  6. 19 10
      controllers/his_api_controller.go
  7. 57 3
      controllers/mobile_api_controllers/dialysis_api_controller.go
  8. 168 46
      controllers/mobile_api_controllers/patient_api_controller.go
  9. 5 2
      controllers/new_mobile_api_controllers/index_evaluation_api_controller.go
  10. 1 6
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  11. 7 7
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  12. 7 0
      controllers/patient_api_controller.go
  13. 110 0
      controllers/print_data_api_controller.go
  14. 5 4
      controllers/schedule_template_api_controller.go
  15. 20 0
      controllers/self_drug_api_congtroller.go
  16. 143 0
      controllers/sign_api_controller.go
  17. 10 2
      controllers/stock_in_api_controller.go
  18. 6 5
      models/patient_models.go
  19. 7 5
      models/smart_sch.go
  20. 1 1
      service/common_service.go
  21. 7 0
      service/his_service.go
  22. 14 4
      service/mobile_dialysis_service.go
  23. 6 2
      service/patient_schedule_template_service.go
  24. 23 3
      service/patient_service.go
  25. 7 1
      service/patientmanage_service.go
  26. 6 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  27. 11 1
      service/schedule_service.go
  28. 14 0
      service/self_drug_service.go
  29. 85 0
      service/sign_service.go
  30. 2 2
      service/smart_sch.go
  31. 12 10
      service/statistics_service/index_evaluation_service.go
  32. 24 2
      service/stock_service.go
  33. 1 1
      service/user_service.go
  34. 6 6
      service/warhouse_service.go

BIN
XT_New.exe Ver fichero


+ 6 - 6
controllers/base_api_controller.go Ver fichero

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

+ 68 - 2
controllers/dialysis_api_controller.go Ver fichero

@@ -2178,6 +2178,18 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
2178 2178
 	}
2179 2179
 
2180 2180
 	_, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
2181
+
2182
+	if adminUserInfo.CurrentOrgId == 10340 {
2183
+		if condition == 1 {
2184
+			lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.CurrentOrgId, id)
2185
+			if admission_number == "" {
2186
+				admission_number = lastAcceptTreatment.AdmissionNumber
2187
+				his_bed = lastAcceptTreatment.HisBed
2188
+				his_department = lastAcceptTreatment.HisDepartment
2189
+				tumble = lastAcceptTreatment.Tumble
2190
+			}
2191
+		}
2192
+	}
2181 2193
 	receiveTreatmentAsses := models.ReceiveTreatmentAsses{
2182 2194
 		UserOrgId:                    adminUserInfo.CurrentOrgId,
2183 2195
 		PatientId:                    id,
@@ -2858,7 +2870,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2858 2870
 			service.CreateDialysisFinish(finish)
2859 2871
 		}
2860 2872
 
2861
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 {
2873
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
2862 2874
 			var dewater_amount float64
2863 2875
 			dewater_amount = 0
2864 2876
 			if dry_weight > 0 {
@@ -3505,7 +3517,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3505 3517
 		}
3506 3518
 
3507 3519
 		//针对孝昌康桥超滤率计算问题
3508
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 {
3520
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
3509 3521
 			if assessmentBeforeDislysis.ID == 0 {
3510 3522
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3511 3523
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
@@ -4957,6 +4969,55 @@ func (c *DialysisApiController) GetDialysisOrder() {
4957 4969
 	lastSchedule, _ := service.FindLastSchedule(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4958 4970
 
4959 4971
 	numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
4972
+
4973
+	now := time.Now()
4974
+
4975
+	// 计算当前是周几,周一为第1天,周日为第0天
4976
+	weekday := now.Weekday()
4977
+
4978
+	// 计算当前日期是周几,并计算出周一的日期
4979
+	// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
4980
+	mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
4981
+
4982
+	// 设置开始时间为周一的00:00:00
4983
+	startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
4984
+
4985
+	// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
4986
+	endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
4987
+
4988
+	var start_time = startOfTheWeek.Format("2006-01-02")
4989
+
4990
+	var end_time = endOfTheWeek.Format("2006-01-02")
4991
+
4992
+	var startTime int64
4993
+	if len(start_time) > 0 {
4994
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4995
+		if err != nil {
4996
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4997
+			return
4998
+		}
4999
+		startTime = theTime.Unix()
5000
+	}
5001
+	var endTime int64
5002
+	if len(end_time) > 0 {
5003
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
5004
+		if err != nil {
5005
+			utils.ErrorLog(err.Error())
5006
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5007
+			return
5008
+		}
5009
+		endTime = theTime.Unix()
5010
+	}
5011
+
5012
+	scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(patientInfo.ID, startTime, endTime, adminUserInfo.CurrentOrgId)
5013
+
5014
+	dialysis_count := len(scheduleDialyCount)
5015
+
5016
+	var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
5017
+	if adminUserInfo.CurrentOrgId == 10742 {
5018
+		PredialysisEvaluation.DialysisCount = dialysis_count_str
5019
+	}
5020
+
4960 5021
 	//if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
4961 5022
 	//	for _, item := range projects {
4962 5023
 	//		var advice *models.HisDoctorAdviceInfo
@@ -5666,6 +5727,11 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
5666 5727
 			}
5667 5728
 		}
5668 5729
 
5730
+		if advice.DrugId == 0 {
5731
+			drug, _ := service.GetDoctorAdviceByAdviceName(advice.AdviceName, adminUserInfo.CurrentOrgId)
5732
+			advice.DrugId = drug.ID
5733
+		}
5734
+
5669 5735
 		advices = append(advices, &advice)
5670 5736
 	}
5671 5737
 

+ 41 - 10
controllers/drug_stock_api_contorller.go Ver fichero

@@ -1170,7 +1170,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1170 1170
 	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1171 1171
 	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1172 1172
 	number = number + total
1173
-	warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1173
+	warehousing_out_order = "YPCKM" + strconv.FormatInt(number, 10)
1174 1174
 	operation_time := time.Now().Unix()
1175 1175
 	creater := adminUserInfo.AdminUser.Id
1176 1176
 	//创建一个出库单
@@ -1189,7 +1189,9 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1189 1189
 
1190 1190
 	if warehouse_out_id == 0 {
1191 1191
 		//查询是否生成出库单
1192
-		outIsExit, _ := service.GetNewDrugWarehouseOutIsExit(adminUserInfo.CurrentOrgId, 0, operation_time, warehousing_out_order, tx)
1192
+		outIsExit, _ := service.GetNewDrugWarehouseOutIsExit(adminUserInfo.CurrentOrgId, 0, warehousingOutDate.Unix(), warehousing_out_order, tx)
1193
+
1194
+		fmt.Println("outIsExit---------------------", outIsExit)
1193 1195
 		if outIsExit.ID == 0 {
1194 1196
 			service.AddNewSigleDrugWarehouseOut(&warehouseOut, tx)
1195 1197
 		}
@@ -3246,15 +3248,37 @@ func (c *StockDrugApiController) GetDrugOutOrderPrint() {
3246 3248
 	dealerList, _ := service.GetAllDealerList(orgId)
3247 3249
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
3248 3250
 	if order_type == 2 {
3249
-		list, err := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId, storehouse_id, drug_id, order_way)
3250
-		if err == nil {
3251
-			c.ServeSuccessJSON(map[string]interface{}{
3252
-				"list":             list,
3253
-				"dealerList":       dealerList,
3254
-				"manufacturerList": manufacturerList,
3255
-			})
3256
-			return
3251
+		list, _ := service.GetDrugOutOrderInfoPrintList(startTime, endTime, orgId, storehouse_id, drug_id, order_way)
3252
+		if len(list) > 0 {
3253
+			if orgId == 10721 {
3254
+
3255
+				if len(list) > 0 {
3256
+					for _, item := range list {
3257
+						if item.IsSys == 1 {
3258
+							var is_number = item.Count % item.XtBaseDrug.MinNumber
3259
+							if is_number == 0 {
3260
+								item.Count = item.Count / item.XtBaseDrug.MinNumber
3261
+								item.TotalPrice = float64(item.Count) * item.Price
3262
+								item.CountUnit = item.XtBaseDrug.MaxUnit
3263
+							}
3264
+							if is_number != 0 {
3265
+								item.TotalPrice = float64(item.Count) * item.Price
3266
+								item.CountUnit = item.XtBaseDrug.MinUnit
3267
+							}
3268
+
3269
+						}
3270
+					}
3271
+				}
3272
+			}
3257 3273
 		}
3274
+
3275
+		c.ServeSuccessJSON(map[string]interface{}{
3276
+			"list":             list,
3277
+			"dealerList":       dealerList,
3278
+			"manufacturerList": manufacturerList,
3279
+		})
3280
+		return
3281
+
3258 3282
 	}
3259 3283
 
3260 3284
 }
@@ -3281,6 +3305,7 @@ func (c *StockDrugApiController) GetConfigList() {
3281 3305
 func (c *StockDrugApiController) CheckWarehousingInfo() {
3282 3306
 
3283 3307
 	warehousing_id, _ := c.GetInt64("warehousing_id")
3308
+
3284 3309
 	orgId := c.GetAdminUserInfo().CurrentOrgId
3285 3310
 	// 开始外部循环的事务
3286 3311
 	db := service.XTWriteDB()
@@ -3447,6 +3472,8 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3447 3472
 		}
3448 3473
 
3449 3474
 		flowList, _ := service.GetNewDrugFlowList(item.DrugId, item.OrgId, item.ID, tx)
3475
+
3476
+		fmt.Println("FlowList=================", flowList)
3450 3477
 		var his_count int64
3451 3478
 		if len(flowList) > 0 {
3452 3479
 			for _, item := range flowList {
@@ -3462,6 +3489,8 @@ func (c *StockDrugApiController) CheckWarehousingInfo() {
3462 3489
 				}
3463 3490
 			}
3464 3491
 		}
3492
+		fmt.Println("incount_0000000000000000", in_cout)
3493
+		fmt.Println("his_count--------------", his_count)
3465 3494
 
3466 3495
 		if in_cout != his_count {
3467 3496
 			is_success = 1
@@ -3737,6 +3766,8 @@ func (c *StockDrugApiController) CheckDrugOut() {
3737 3766
 				}
3738 3767
 			}
3739 3768
 
3769
+			fmt.Println("now_count=-------------------", now_count)
3770
+			fmt.Println("flow_count_one=-------------------", flow_count_one)
3740 3771
 			if now_count != flow_count_one {
3741 3772
 				is_success = 1
3742 3773
 				tx.Rollback()

+ 29 - 0
controllers/gobal_config_api_controller.go Ver fichero

@@ -1862,6 +1862,27 @@ func (c *GobalConfigApiController) GetDrugOutDetail() {
1862 1862
 	drug_id, _ := c.GetInt64("drug_id")
1863 1863
 	order_way, _ := c.GetInt64("order_way")
1864 1864
 	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit, storehouse_id, drug_id, order_way)
1865
+	if adminInfo.CurrentOrgId == 10721 {
1866
+
1867
+		if len(order) > 0 {
1868
+			for _, item := range order {
1869
+				if item.IsSys == 1 {
1870
+
1871
+					var is_number = item.Count % item.MinNumber
1872
+
1873
+					if is_number == 0 {
1874
+						item.Count = item.Count / item.MinNumber
1875
+						item.TotalPrice = float64(item.Count) * item.Price
1876
+						item.CountUnit = item.MaxUnit
1877
+					}
1878
+					if is_number != 0 {
1879
+						item.TotalPrice = float64(item.Count) * item.Price
1880
+						item.CountUnit = item.MinUnit
1881
+					}
1882
+				}
1883
+			}
1884
+		}
1885
+	}
1865 1886
 
1866 1887
 	houseList, _ := service.GetAllStoreHouseList(adminInfo.CurrentOrgId)
1867 1888
 	patientsList, _ := service.GetAllpatient(adminInfo.CurrentOrgId)
@@ -2509,11 +2530,19 @@ func (c *GobalConfigApiController) GetDrugFlow() {
2509 2530
 
2510 2531
 	list, total, _ := service.GetDrugFlow(drug_id, orgId, limit, page, startTime, endTime, stock_type)
2511 2532
 
2533
+	if len(list) > 0 {
2534
+		for _, item := range list {
2535
+			adviceMap, _ := service.HisDoctorAdviceMap(item.PatientId, item.SystemTime, item.DrugId, item.UserOrgId)
2536
+			item.DrugCode = adviceMap.DrugCode
2537
+		}
2538
+	}
2539
+
2512 2540
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2513 2541
 	dealerList, _ := service.GetAllDealerList(orgId)
2514 2542
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2515 2543
 	houseList, _ := service.GetAllStoreHouseList(orgId)
2516 2544
 	patientList, _ := service.GetAllPatientListSix(orgId)
2545
+
2517 2546
 	c.ServeSuccessJSON(map[string]interface{}{
2518 2547
 		"list":             list,
2519 2548
 		"total":            total,

+ 19 - 10
controllers/his_api_controller.go Ver fichero

@@ -3487,7 +3487,7 @@ func (c *HisApiController) CreateHisPrescription() {
3487 3487
 	var adviceList []models.HisDoctorAdviceInfo
3488 3488
 	var projectList []models.HisPrescriptionProject
3489 3489
 
3490
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 {
3490
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 {
3491 3491
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3492 3492
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3493 3493
 
@@ -3516,6 +3516,7 @@ func (c *HisApiController) CreateHisPrescription() {
3516 3516
 					new_prescription, _ := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
3517 3517
 					tempPrescription = &new_prescription
3518 3518
 					if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
3519
+
3519 3520
 						utils.ErrorLog("type")
3520 3521
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3521 3522
 						return
@@ -3864,13 +3865,13 @@ func (c *HisApiController) CreateHisPrescription() {
3864 3865
 											}
3865 3866
 										}
3866 3867
 
3867
-										fmt.Println("药品名称----------------------", drug.DrugName)
3868
-										fmt.Println("药品名称----------------------", drug.IsUse)
3869
-										fmt.Println("drug_iiiiiiiiiiiiiiiiiiii", drug.ID)
3870
-										fmt.Println("is_user_total-------------------------", is_user_total)
3871
-										fmt.Println("no_user_total-------------------------", no_user_total)
3872
-										fmt.Println("drug.IsUse---------------", drug.IsUse)
3873
-										fmt.Println("00000000000000000000", s.UserOrgId)
3868
+										//fmt.Println("药品名称----------------------", drug.DrugName)
3869
+										//fmt.Println("药品名称----------------------", drug.IsUse)
3870
+										//fmt.Println("drug_iiiiiiiiiiiiiiiiiiii", drug.ID)
3871
+										//fmt.Println("is_user_total-------------------------", is_user_total)
3872
+										//fmt.Println("no_user_total-------------------------", no_user_total)
3873
+										//fmt.Println("drug.IsUse---------------", drug.IsUse)
3874
+										//fmt.Println("00000000000000000000", s.UserOrgId)
3874 3875
 
3875 3876
 										if is_user_total != no_user_total {
3876 3877
 											//出库
@@ -4013,8 +4014,8 @@ func (c *HisApiController) CreateHisPrescription() {
4013 4014
 													history_count += prescribingNumberSevenTy
4014 4015
 												}
4015 4016
 
4016
-												fmt.Println("local_count---------------", local_count)
4017
-												fmt.Println("history_count---------------", history_count)
4017
+												//fmt.Println("local_count---------------", local_count)
4018
+												//fmt.Println("history_count---------------", history_count)
4018 4019
 
4019 4020
 												//如果当前出库数量大于历史出库数量则需要出库
4020 4021
 												if local_count > history_count {
@@ -4471,6 +4472,7 @@ func (c *HisApiController) CreateHisPrescription() {
4471 4472
 
4472 4473
 									//用机构ID区分
4473 4474
 									if adminInfo.CurrentOrgId != 9671 {
4475
+
4474 4476
 										if goodOutConfig.IsOpen == 1 {
4475 4477
 											//耗材出库
4476 4478
 											if p.Type == 3 {
@@ -4521,7 +4523,10 @@ func (c *HisApiController) CreateHisPrescription() {
4521 4523
 												//	}
4522 4524
 												//}
4523 4525
 
4526
+												fmt.Println("nowCount222=================", nowCount)
4527
+												fmt.Println("historyCount-333----------------", historyCount)
4524 4528
 												//如果当前处方数量大于历史数据,则需要出库
4529
+
4525 4530
 												if nowCount > historyCount {
4526 4531
 
4527 4532
 													var cha_count int64
@@ -4644,6 +4649,7 @@ func (c *HisApiController) CreateHisPrescription() {
4644 4649
 												}
4645 4650
 
4646 4651
 												if nowCount == historyCount {
4652
+
4647 4653
 													if historyCount == 0 {
4648 4654
 														recordDateStr := time.Now().Format("2006-01-02")
4649 4655
 														recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
@@ -6063,6 +6069,7 @@ func (c *HisApiController) CreateHisPrescription() {
6063 6069
 				}
6064 6070
 			}
6065 6071
 
6072
+			fmt.Println("耗材----------------------------------", goodOutConfig.IsOpen)
6066 6073
 			//耗材保存处方出库
6067 6074
 			if goodOutConfig.IsOpen == 1 {
6068 6075
 
@@ -6080,6 +6087,8 @@ func (c *HisApiController) CreateHisPrescription() {
6080 6087
 
6081 6088
 					parseIntCount, _ := strconv.ParseInt(item.Count, 10, 64)
6082 6089
 
6090
+					fmt.Println("out_count_five-------------------", out_count_five)
6091
+					fmt.Println("parseIntCount---------------", parseIntCount)
6083 6092
 					if out_count_five != parseIntCount {
6084 6093
 
6085 6094
 						//查询耗材最后一次出库记录

+ 57 - 3
controllers/mobile_api_controllers/dialysis_api_controller.go Ver fichero

@@ -1327,6 +1327,9 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
1327 1327
 			lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.Org.Id, id)
1328 1328
 			if admission_number == "" {
1329 1329
 				admission_number = lastAcceptTreatment.AdmissionNumber
1330
+				his_bed = lastAcceptTreatment.HisBed
1331
+				his_department = lastAcceptTreatment.HisDepartment
1332
+				tumble = lastAcceptTreatment.Tumble
1330 1333
 			}
1331 1334
 		}
1332 1335
 	}
@@ -4036,6 +4039,11 @@ func (this *DialysisAPIController) StartDialysis() {
4036 4039
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4037 4040
 			}
4038 4041
 
4042
+			if adminUserInfo.Org.Id == 10752 {
4043
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4044
+				ultrafiltration_rate = ultrafiltration_rate / 1000
4045
+			}
4046
+
4039 4047
 			if adminUserInfo.Org.Id == 10723 {
4040 4048
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4041 4049
 				ultrafiltration_rate = ultrafiltration_rate / 1000
@@ -4061,6 +4069,25 @@ func (this *DialysisAPIController) StartDialysis() {
4061 4069
 				}
4062 4070
 			}
4063 4071
 
4072
+			fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhh", adminUserInfo.Org.Id)
4073
+			if adminUserInfo.Org.Id == 10752 {
4074
+
4075
+				if prescription.ModeId == 2 {
4076
+					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4077
+					if totalMin == 0 {
4078
+						totalMin = 240
4079
+					}
4080
+					if prescription.ReplacementTotal == 0 {
4081
+						prescription.ReplacementTotal = 15
4082
+					}
4083
+
4084
+					//乘10 除10是为了保留一位小数
4085
+					replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*10) / 10
4086
+
4087
+					fmt.Println("hhhhhhhhhhhhhhhhhhhhh", replacement_rate)
4088
+				}
4089
+			}
4090
+
4064 4091
 			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 {
4065 4092
 				if prescription.ModeId == 2 {
4066 4093
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
@@ -5308,6 +5335,11 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5308 5335
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5309 5336
 			}
5310 5337
 
5338
+			if adminInfo.Org.Id == 10752 {
5339
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
5340
+				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5341
+			}
5342
+
5311 5343
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10599 || adminInfo.Org.Id == 10679 {
5312 5344
 				record.UltrafiltrationRate = 0
5313 5345
 			}
@@ -5425,7 +5457,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5425 5457
 		record.UltrafiltrationVolume = 0
5426 5458
 	}
5427 5459
 
5428
-	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10164 || adminInfo.Org.Id == 10731 {
5460
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10164 || adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10752 {
5429 5461
 		if ultrafiltration_rate > 0 {
5430 5462
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5431 5463
 			record.UltrafiltrationVolume = ultrafiltration_volume / 1000
@@ -5454,7 +5486,19 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5454 5486
 		var displacement_quantity float64
5455 5487
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5456 5488
 		replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*60) / 1000
5489
+		record.ReplacementRate = replacement_rate
5490
+		fmt.Println("hhhhhhhhhhhhhhhhhh", record.ReplacementRate)
5491
+		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5492
+		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5493
+		record.DisplacementQuantity = displacement_quantity
5494
+
5495
+	}
5457 5496
 
5497
+	if adminInfo.Org.Id == 10752 {
5498
+		var replacement_rate float64
5499
+		var displacement_quantity float64
5500
+		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5501
+		replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*60) / 1000
5458 5502
 		record.ReplacementRate = replacement_rate
5459 5503
 
5460 5504
 		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
@@ -6168,6 +6212,7 @@ func (c *DialysisAPIController) GetLongAdviceOne() {
6168 6212
 
6169 6213
 		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id, theStartTime)
6170 6214
 
6215
+		fmt.Println("theStartTime-----------------------", theStartTime)
6171 6216
 		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id, theStartTime)
6172 6217
 
6173 6218
 		for _, advice := range advices {
@@ -6226,7 +6271,7 @@ func (c *DialysisAPIController) GetLongAdviceOne() {
6226 6271
 			count, _ := strconv.ParseInt(dayStr2, 10, 64)
6227 6272
 			oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
6228 6273
 			advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.Org.Id, advice.TemplateId)
6229
-
6274
+			fmt.Println("advices-==---------------", advices)
6230 6275
 			for _, ad := range advices {
6231 6276
 				advice_three = append(advice_three, ad)
6232 6277
 			}
@@ -11513,6 +11558,14 @@ func (c *DialysisAPIController) GetControlMonitorList() {
11513 11558
 		}
11514 11559
 	}
11515 11560
 
11561
+	if pat_type == 13 {
11562
+		for _, item := range monitor {
11563
+			if len(item.MonitoringRecord) < 3 {
11564
+				mds = append(mds, item)
11565
+			}
11566
+		}
11567
+	}
11568
+
11516 11569
 	if pat_type == 10 {
11517 11570
 		for _, item := range monitor {
11518 11571
 			if len(item.MonitoringRecord) == 0 {
@@ -11590,7 +11643,8 @@ func (c *DialysisAPIController) GetAdviceListNoExecution() {
11590 11643
 func (c *DialysisAPIController) GetLastAcceptRecrods() {
11591 11644
 
11592 11645
 	patient_id, _ := c.GetInt64("patient_id")
11593
-	recrods, _ := service.GetLastAcceptRecrods(patient_id)
11646
+	org_id := c.GetMobileAdminUserInfo().Org.Id
11647
+	recrods, _ := service.GetLastAcceptRecrods(patient_id, org_id)
11594 11648
 	c.ServeSuccessJSON(map[string]interface{}{
11595 11649
 		"recrods": recrods,
11596 11650
 	})

+ 168 - 46
controllers/mobile_api_controllers/patient_api_controller.go Ver fichero

@@ -339,25 +339,29 @@ func (c *PatientApiController) EditDoctorAdvice() {
339 339
 				}
340 340
 			}
341 341
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
342
-			if advice.StartTime == sourceAdvice.StartTime {
343
-				err = service.UpdateDoctorAdvice(&advice)
344
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
345
-
346
-				defer redis.Close()
347
-				redis.Set(key, "", time.Second)
348
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
349
-				redis.Set(keyOne, "", time.Second)
350
-				isChangeGroup = false
351
-			} else {
352
-				err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
353
-				isChangeGroup = false
354
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
355
-
356
-				defer redis.Close()
357
-				redis.Set(key, "", time.Second)
358
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
359
-				redis.Set(keyOne, "", time.Second)
342
+			if adminUserInfo.Org.Id != 9779 {
343
+
344
+				if advice.StartTime == sourceAdvice.StartTime {
345
+					err = service.UpdateDoctorAdvice(&advice)
346
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
347
+
348
+					defer redis.Close()
349
+					redis.Set(key, "", time.Second)
350
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
351
+					redis.Set(keyOne, "", time.Second)
352
+					isChangeGroup = false
353
+				} else {
354
+					err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
355
+					isChangeGroup = false
356
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
357
+
358
+					defer redis.Close()
359
+					redis.Set(key, "", time.Second)
360
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
361
+					redis.Set(keyOne, "", time.Second)
362
+				}
360 363
 			}
364
+
361 365
 		} else if len(adviceSlice) > 1 {
362 366
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
363 367
 			if infor.ID > 0 {
@@ -382,31 +386,36 @@ func (c *PatientApiController) EditDoctorAdvice() {
382 386
 				}
383 387
 			}
384 388
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
385
-			if advice.StartTime == sourceAdvice.StartTime {
386
-				err = service.UpdateDoctorAdvice(&advice)
387
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
388 389
 
389
-				defer redis.Close()
390
-				redis.Set(key, "", time.Second)
391
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
392
-				redis.Set(keyOne, "", time.Second)
393
-				isChangeGroup = false
390
+			if adminUserInfo.Org.Id != 9779 {
394 391
 
395
-			} else {
396
-				gruopNo := service.GetMaxAdviceGroupID(adminUserInfo.Org.Id)
397
-				gruopNo = gruopNo + 1
398
-				advice.GroupNo = gruopNo
399
-				advice.AdviceDoctor = adminUserInfo.AdminUser.Id
400
-				err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
401
-				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
392
+				if advice.StartTime == sourceAdvice.StartTime {
393
+					err = service.UpdateDoctorAdvice(&advice)
394
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
402 395
 
403
-				defer redis.Close()
404
-				redis.Set(key, "", time.Second)
405
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
406
-				redis.Set(keyOne, "", time.Second)
407
-				isChangeGroup = true
396
+					defer redis.Close()
397
+					redis.Set(key, "", time.Second)
398
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
399
+					redis.Set(keyOne, "", time.Second)
400
+					isChangeGroup = false
401
+
402
+				} else {
403
+					gruopNo := service.GetMaxAdviceGroupID(adminUserInfo.Org.Id)
404
+					gruopNo = gruopNo + 1
405
+					advice.GroupNo = gruopNo
406
+					advice.AdviceDoctor = adminUserInfo.AdminUser.Id
407
+					err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
408
+					key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
409
+
410
+					defer redis.Close()
411
+					redis.Set(key, "", time.Second)
412
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
413
+					redis.Set(keyOne, "", time.Second)
414
+					isChangeGroup = true
408 415
 
416
+				}
409 417
 			}
418
+
410 419
 		}
411 420
 	} else {
412 421
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
@@ -757,6 +766,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
757 766
 				service.CreateDoctorAdviceLog(adviceLog)
758 767
 			}
759 768
 			advicesOne, _ := service.FindAllDoctorAdviceByGoroupNoOne(adminUserInfo.Org.Id, groupno)
769
+
760 770
 			for _, item := range advicesOne {
761 771
 
762 772
 				//自备药
@@ -775,13 +785,14 @@ func (c *PatientApiController) ExecDoctorAdvice() {
775 785
 					}()
776 786
 
777 787
 					if strings.Contains(item.AdviceName, "自备") {
778
-						fmt.Println("hahhahahahahhh")
779 788
 						if item.DrugId == 0 {
789
+
780 790
 							c.ServeSuccessJSON(map[string]interface{}{
781 791
 								"msg":    "12",
782 792
 								"advice": item,
783 793
 								"ids":    ids,
784 794
 							})
795
+							tx.Rollback()
785 796
 							return
786 797
 						}
787 798
 					}
@@ -810,6 +821,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
810 821
 									"advice": item,
811 822
 									"ids":    ids,
812 823
 								})
824
+								tx.Rollback()
813 825
 								return
814 826
 							}
815 827
 						}
@@ -843,6 +855,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
843 855
 									"msg":    "3",
844 856
 									"advice": item,
845 857
 								})
858
+								tx.Rollback()
846 859
 								return
847 860
 							}
848 861
 						}
@@ -1114,7 +1127,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1114 1127
 
1115 1128
 				}
1116 1129
 				//恒泰中医院
1117
-				if item.UserOrgId == 10490 || item.UserOrgId == 10602 {
1130
+				if item.UserOrgId == 10490 || item.UserOrgId == 10602 || item.UserOrgId == 10697 {
1118 1131
 					if item.DrugId == 0 || item.DrugNameId == 0 {
1119 1132
 						//从字典里面查找
1120 1133
 						drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
@@ -1147,6 +1160,19 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1147 1160
 
1148 1161
 					selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
1149 1162
 
1163
+					if strings.Contains(item.AdviceName, "自备") {
1164
+						if item.DrugId == 0 {
1165
+
1166
+							c.ServeSuccessJSON(map[string]interface{}{
1167
+								"msg":    "12",
1168
+								"advice": item,
1169
+								"ids":    ids,
1170
+							})
1171
+							tx.Rollback()
1172
+							return
1173
+						}
1174
+					}
1175
+
1150 1176
 					if selfBasedrug.IsSelfDrug == 1 {
1151 1177
 
1152 1178
 						//查询是否有库存
@@ -1170,6 +1196,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1170 1196
 									"advice": item,
1171 1197
 									"ids":    ids,
1172 1198
 								})
1199
+								tx.Rollback()
1173 1200
 								return
1174 1201
 							}
1175 1202
 						}
@@ -1202,6 +1229,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1202 1229
 									"msg":    "3",
1203 1230
 									"advice": item,
1204 1231
 								})
1232
+								tx.Rollback()
1205 1233
 								return
1206 1234
 							}
1207 1235
 						}
@@ -1521,6 +1549,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1521 1549
 
1522 1550
 				}
1523 1551
 			}
1552
+
1524 1553
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
1525 1554
 
1526 1555
 			//记录日志
@@ -1576,9 +1605,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1576 1605
 		//药品管理信息
1577 1606
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.Org.Id)
1578 1607
 
1579
-		//自备药信息
1580
-		//privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
1581
-
1582 1608
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
1583 1609
 
1584 1610
 		if drugStockConfig.IsOpen == 1 {
@@ -1997,6 +2023,55 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1997 2023
 		//	}
1998 2024
 		//}
1999 2025
 
2026
+		//自备药
2027
+		selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
2028
+
2029
+		if selfPrescriptionOutOpen.IsOpen == 1 {
2030
+
2031
+			if groupno > 0 {
2032
+				advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
2033
+
2034
+				if len(advices) > 0 {
2035
+
2036
+					for _, item := range advices {
2037
+
2038
+						if item.DrugId > 0 && item.ExecutionStaff == 0 {
2039
+
2040
+							//查询这个病人 这个药是否已经出库
2041
+							outInfo, _ := service.GetSelfDrugOutInfo(item.PatientId, item.AdviceDate, item.DrugId)
2042
+
2043
+							if len(outInfo) > 0 {
2044
+
2045
+								service.ModifyExecutionAdvice(item.ID, execution_staff, theTime.Unix())
2046
+							}
2047
+						}
2048
+
2049
+					}
2050
+				}
2051
+
2052
+			} else {
2053
+				advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
2054
+
2055
+				if len(advices) > 0 {
2056
+
2057
+					for _, item := range advices {
2058
+
2059
+						if item.DrugId > 0 && item.ExecutionStaff == 0 {
2060
+
2061
+							//查询这个病人 这个药是否已经出库
2062
+							outInfo, _ := service.GetSelfDrugOutInfo(item.PatientId, item.AdviceDate, item.DrugId)
2063
+
2064
+							if len(outInfo) > 0 {
2065
+
2066
+								service.ModifyExecutionAdvice(item.ID, execution_staff, theTime.Unix())
2067
+							}
2068
+						}
2069
+
2070
+					}
2071
+				}
2072
+			}
2073
+		}
2074
+
2000 2075
 		c.ServeSuccessJSON(map[string]interface{}{
2001 2076
 			"msg":    "1",
2002 2077
 			"advice": advice,
@@ -3753,9 +3828,9 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
3753 3828
 	if evaluation.DryWeight > 0 {
3754 3829
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3755 3830
 
3756
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 {
3831
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 {
3757 3832
 
3758
-			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 {
3833
+			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3759 3834
 				dewater_amount = dewater_amount * 1000
3760 3835
 			}
3761 3836
 
@@ -4478,7 +4553,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
4478 4553
 	}
4479 4554
 
4480 4555
 	//针对孝昌康桥超滤率计算问题
4481
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 {
4556
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 {
4482 4557
 		if evaluation.ID == 0 {
4483 4558
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4484 4559
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
@@ -6107,6 +6182,53 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
6107 6182
 	dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.Org.Id)
6108 6183
 	lastWeight, _ := service.MobileGetLast(adminUserInfo.Org.Id, patientInfo.ID, xttime)
6109 6184
 	numberList, _ := service.GetAllBedNumberList(adminUserInfo.Org.Id)
6185
+
6186
+	now := time.Now()
6187
+
6188
+	// 计算当前是周几,周一为第1天,周日为第0天
6189
+	weekday := now.Weekday()
6190
+
6191
+	// 计算当前日期是周几,并计算出周一的日期
6192
+	// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
6193
+	mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
6194
+
6195
+	// 设置开始时间为周一的00:00:00
6196
+	startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
6197
+
6198
+	// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
6199
+	endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
6200
+
6201
+	var start_time = startOfTheWeek.Format("2006-01-02")
6202
+
6203
+	var end_time = endOfTheWeek.Format("2006-01-02")
6204
+
6205
+	var startTime int64
6206
+	if len(start_time) > 0 {
6207
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6208
+		if err != nil {
6209
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6210
+			return
6211
+		}
6212
+		startTime = theTime.Unix()
6213
+	}
6214
+	var endTime int64
6215
+	if len(end_time) > 0 {
6216
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6217
+		if err != nil {
6218
+			utils.ErrorLog(err.Error())
6219
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6220
+			return
6221
+		}
6222
+		endTime = theTime.Unix()
6223
+	}
6224
+
6225
+	scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(patientInfo.ID, startTime, endTime, adminUserInfo.Org.Id)
6226
+
6227
+	dialysis_count_one := len(scheduleDialyCount)
6228
+
6229
+	var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count_one) + "次"
6230
+	PredialysisEvaluation.DialysisCount = dialysis_count_str
6231
+
6110 6232
 	if config.IsOpen == 1 {
6111 6233
 		c.ServeSuccessJSON(map[string]interface{}{
6112 6234
 			"users":                   adminUser,

+ 5 - 2
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go Ver fichero

@@ -1,12 +1,13 @@
1 1
 package new_mobile_api_controllers
2 2
 
3 3
 import (
4
+	"fmt"
5
+	"time"
6
+
4 7
 	"XT_New/enums"
5 8
 	"XT_New/models"
6 9
 	"XT_New/service/statistics_service"
7 10
 	"XT_New/utils"
8
-	"fmt"
9
-	"time"
10 11
 )
11 12
 
12 13
 type IndexEvaluationApiController struct {
@@ -912,7 +913,9 @@ func (this *IndexEvaluationApiController) GetDefaultPatient() {
912 913
 }
913 914
 
914 915
 func (this *IndexEvaluationApiController) GetAllPatients() {
916
+
915 917
 	adminUserInfo := this.GetMobileAdminUserInfo()
918
+
916 919
 	patients, _ := statistics_service.GetOrgPatients(adminUserInfo.Org.Id)
917 920
 	if patients == nil {
918 921
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)

+ 1 - 6
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go Ver fichero

@@ -728,21 +728,16 @@ func (this *NewDialysisApiController) GetDryWeight() {
728 728
 	timeLayout := "2006-01-02"
729 729
 	loc, _ := time.LoadLocation("Local")
730 730
 	id, _ := this.GetInt64("id")
731
-	fmt.Print("id", id)
732 731
 	patient, _ := service.GetPatientDetailTwo(id)
733 732
 	start := this.GetString("startime")
734 733
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
735 734
 	startime := startTimes.Unix()
736
-	fmt.Print("startime", startime)
735
+
737 736
 	end := this.GetString("endtime")
738 737
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 23:59:59", loc)
739
-
740 738
 	endtime := endTimes.Unix()
741
-	fmt.Print("endtime", endtime)
742 739
 	limit, _ := this.GetInt64("limit")
743
-	fmt.Print("limit", limit)
744 740
 	page, _ := this.GetInt64("page")
745
-	fmt.Print("page", page)
746 741
 	adminInfo := this.GetMobileAdminUserInfo()
747 742
 	orgid := adminInfo.Org.Id
748 743
 	dryweight, total, err := service.GetDryWeight(patient.BloodId, startime, endtime, limit, page, orgid)

+ 7 - 7
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Ver fichero

@@ -1039,13 +1039,13 @@ func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
1039 1039
 	}
1040 1040
 	schedule.ScheduleDate = theTime.Unix()
1041 1041
 
1042
-	timeNow := time.Now().Format("2006-01-02")
1043
-	if timeNow > scheduleDate {
1044
-		utils.ErrorLog(timeNow)
1045
-		utils.ErrorLog(scheduleDate)
1046
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
1047
-		return
1048
-	}
1042
+	//timeNow := time.Now().Format("2006-01-02")
1043
+	//if timeNow > scheduleDate {
1044
+	//	utils.ErrorLog(timeNow)
1045
+	//	utils.ErrorLog(scheduleDate)
1046
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
1047
+	//	return
1048
+	//}
1049 1049
 
1050 1050
 	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
1051 1051
 		utils.ErrorLog("schedule_type")

+ 7 - 0
controllers/patient_api_controller.go Ver fichero

@@ -1981,6 +1981,11 @@ func (c *PatientApiController) CreateGroupAdvice() {
1981 1981
 			}
1982 1982
 		}
1983 1983
 
1984
+		if advice.DrugId == 0 {
1985
+			drug, _ := service.GetDoctorAdviceByAdviceName(advice.AdviceName, adminUserInfo.CurrentOrgId)
1986
+			advice.DrugId = drug.ID
1987
+		}
1988
+
1984 1989
 		advices = append(advices, &advice)
1985 1990
 	}
1986 1991
 
@@ -4482,7 +4487,9 @@ func (c *PatientApiController) DeleteDoctorAdvice() {
4482 4487
 }
4483 4488
 
4484 4489
 func (c *PatientApiController) DeleteGroupAdvice() {
4490
+
4485 4491
 	groupNo, _ := c.GetInt64("groupno", 0)
4492
+
4486 4493
 	if groupNo <= 0 {
4487 4494
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4488 4495
 		return

+ 110 - 0
controllers/print_data_api_controller.go Ver fichero

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"strconv"
5 6
 	"strings"
6 7
 	"time"
7 8
 
@@ -63,6 +64,58 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
63 64
 
64 65
 			//透前评估
65 66
 			assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
67
+
68
+			now := time.Now()
69
+
70
+			// 计算当前是周几,周一为第1天,周日为第0天
71
+			weekday := now.Weekday()
72
+
73
+			// 计算当前日期是周几,并计算出周一的日期
74
+			// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
75
+			mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
76
+
77
+			// 设置开始时间为周一的00:00:00
78
+			startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
79
+
80
+			// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
81
+			endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
82
+
83
+			var start_time = startOfTheWeek.Format("2006-01-02")
84
+
85
+			var end_time = endOfTheWeek.Format("2006-01-02")
86
+
87
+			timeLayout := "2006-01-02"
88
+			loc, _ := time.LoadLocation("Local")
89
+
90
+			var startTime int64
91
+			if len(start_time) > 0 {
92
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
93
+				if err != nil {
94
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
95
+					return
96
+				}
97
+				startTime = theTime.Unix()
98
+			}
99
+			var endTime int64
100
+			if len(end_time) > 0 {
101
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
102
+				if err != nil {
103
+					utils.ErrorLog(err.Error())
104
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
105
+					return
106
+				}
107
+				endTime = theTime.Unix()
108
+			}
109
+			scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
110
+
111
+			dialysis_count := len(scheduleDialyCount)
112
+
113
+			var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
114
+
115
+			if adminUserInfo.CurrentOrgId == 10742 {
116
+				assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
117
+			}
118
+
66 119
 			item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
67 120
 
68 121
 			//透后评估
@@ -159,6 +212,63 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
159 212
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
160 213
 		for _, item := range schedules {
161 214
 
215
+			//透前评估
216
+			assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
217
+
218
+			now := time.Now()
219
+
220
+			// 计算当前是周几,周一为第1天,周日为第0天
221
+			weekday := now.Weekday()
222
+
223
+			// 计算当前日期是周几,并计算出周一的日期
224
+			// 通过减去当前是周几的偏移量再加1来实现(因为Weekday()返回的是从周日开始的索引,而我们想要从周一开始)
225
+			mondayone := now.AddDate(0, 0, -(int(weekday)+6)%7) // 或者使用 monday := now.Add(-time.Hour * 24 * (int(weekday)+6)%7)
226
+
227
+			// 设置开始时间为周一的00:00:00
228
+			startOfTheWeek := time.Date(mondayone.Year(), mondayone.Month(), mondayone.Day(), 0, 0, 0, 0, mondayone.Location())
229
+
230
+			// 设置结束时间为周日的23:59:59(周一的日期基础上加6天)
231
+			endOfTheWeek := startOfTheWeek.AddDate(0, 0, 6).Add(24*time.Hour - time.Second) // 或者使用 endOfTheWeek := monday.AddDate(0, 0, 7).Add(-time.Second)
232
+
233
+			var start_time = startOfTheWeek.Format("2006-01-02")
234
+
235
+			var end_time = endOfTheWeek.Format("2006-01-02")
236
+
237
+			timeLayout := "2006-01-02"
238
+			loc, _ := time.LoadLocation("Local")
239
+
240
+			var startTime int64
241
+			if len(start_time) > 0 {
242
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
243
+				if err != nil {
244
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
245
+					return
246
+				}
247
+				startTime = theTime.Unix()
248
+			}
249
+			var endTime int64
250
+			if len(end_time) > 0 {
251
+				theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
252
+				if err != nil {
253
+					utils.ErrorLog(err.Error())
254
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
255
+					return
256
+				}
257
+				endTime = theTime.Unix()
258
+			}
259
+
260
+			scheduleDialyCount, _ := service.GetPatientScheduleDialyCount(item.PatientID, startTime, endTime, adminUserInfo.CurrentOrgId)
261
+
262
+			fmt.Println("scheduleDialyCount------------------", scheduleDialyCount)
263
+			dialysis_count := len(scheduleDialyCount)
264
+
265
+			var dialysis_count_str = "一周" + strconv.Itoa(dialysis_count) + "次"
266
+			if adminUserInfo.CurrentOrgId == 10742 {
267
+				assessmentBeforeDislysisVM.DialysisCount = dialysis_count_str
268
+			}
269
+
270
+			item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
271
+
162 272
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
163 273
 			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
164 274
 				if this.GetAdminUserInfo().CurrentOrgId == 10445 {

+ 5 - 4
controllers/schedule_template_api_controller.go Ver fichero

@@ -1,15 +1,16 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7 4
 	"encoding/json"
8 5
 	"fmt"
9 6
 	"strconv"
10 7
 	"strings"
11 8
 	"time"
12 9
 
10
+	"XT_New/enums"
11
+	"XT_New/models"
12
+	"XT_New/service"
13
+
13 14
 	"github.com/astaxie/beego"
14 15
 )
15 16
 
@@ -1166,7 +1167,6 @@ func (this *PatientScheduleTemplateAPIController) InitData() {
1166 1167
 
1167 1168
 	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId, ids)
1168 1169
 
1169
-	fmt.Println("deviceNumbers233323232332232323223233223323232323", deviceNumbers)
1170 1170
 	if getDeviceNumbersErr != nil {
1171 1171
 		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
1172 1172
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1747,6 +1747,7 @@ type ParamModelSchedule struct {
1747 1747
 }
1748 1748
 
1749 1749
 func (this *PatientScheduleTemplateAPIController) GetPatientList() {
1750
+
1750 1751
 	patients, err := service.GetSchTemplatePatientList(this.GetAdminUserInfo().CurrentOrgId)
1751 1752
 	if err != nil {
1752 1753
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 20 - 0
controllers/self_drug_api_congtroller.go Ver fichero

@@ -195,6 +195,8 @@ func SelfDrugRouters() {
195 195
 
196 196
 	beego.Router("/api/drug/getpatientadvicelistdetail", &SelfDrugApiController{}, "Get:GetPatientAdviceListDetail")
197 197
 
198
+	beego.Router("/api/drug/getselfdrugwarehouseinfo", &SelfDrugApiController{}, "Get:GetSelfDrugWarhouseInfo")
199
+
198 200
 }
199 201
 
200 202
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -6514,8 +6516,11 @@ func (this *SelfDrugApiController) GetPatientAdviceList() {
6514 6516
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6515 6517
 
6516 6518
 	adviceList, _ := service.GetNewPatientAdviceList(patient_id, startTime, endTime, orgId)
6519
+
6520
+	drugInfo, _ := service.GetSelfDrugWarehouseInfoByPatientId(patient_id, orgId)
6517 6521
 	this.ServeSuccessJSON(map[string]interface{}{
6518 6522
 		"adviceList": adviceList,
6523
+		"drugInfo":   drugInfo,
6519 6524
 	})
6520 6525
 }
6521 6526
 
@@ -6560,3 +6565,18 @@ func (this *SelfDrugApiController) GetPatientAdviceListDetail() {
6560 6565
 	})
6561 6566
 
6562 6567
 }
6568
+
6569
+func (this *SelfDrugApiController) GetSelfDrugWarhouseInfo() {
6570
+
6571
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6572
+	patient_id, _ := this.GetInt64("patient_id")
6573
+
6574
+	drug_id, _ := this.GetInt64("drug_id")
6575
+
6576
+	drugInfo, _ := service.GetSelfDrugWarhouseInfoByPatient(drug_id, patient_id, orgId)
6577
+
6578
+	this.ServeSuccessJSON(map[string]interface{}{
6579
+		"drugInfo": drugInfo,
6580
+	})
6581
+
6582
+}

+ 143 - 0
controllers/sign_api_controller.go Ver fichero

@@ -1439,6 +1439,149 @@ func (this *SignApiController) ToAutoDiagnose() {
1439 1439
 	//}
1440 1440
 	//tx.Commit()
1441 1441
 
1442
+	//adminInfo := this.GetAdminUserInfo()
1443
+	//prescriptionList, _ := service.GetHisPRrescriptionByUserOrgId(10752)
1444
+	//
1445
+	//fmt.Println("prescriptionList", prescriptionList)
1446
+	//
1447
+	//db := service.XTWriteDB()
1448
+	//tx := db.Begin()
1449
+	//if len(prescriptionList) > 0 {
1450
+	//	for _, item := range prescriptionList {
1451
+	//
1452
+	//		// 在函数结束时处理事务回滚
1453
+	//		defer func() {
1454
+	//			if r := recover(); r != nil {
1455
+	//				tx.Rollback()
1456
+	//			}
1457
+	//		}()
1458
+	//		var cha_count int64
1459
+	//
1460
+	//		historyCount, _ := strconv.ParseInt(item.Count, 10, 64)
1461
+	//
1462
+	//		cha_count = historyCount
1463
+	//
1464
+	//		timeStr := "2025-02-04"
1465
+	//		timeArr := strings.Split(timeStr, "-")
1466
+	//
1467
+	//		total, _ := service.FindAllWarehouseOut(adminInfo.CurrentOrgId)
1468
+	//
1469
+	//		total = total + 1
1470
+	//		warehousing_out_order := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1471
+	//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1472
+	//		number = number + total
1473
+	//		warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1474
+	//
1475
+	//		operation_time := item.RecordDate
1476
+	//		creater := this.GetAdminUserInfo().AdminUser.Id
1477
+	//
1478
+	//		recordDateStr := "2025-02-04"
1479
+	//		recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1480
+	//		nowtime := recordDate.Unix()
1481
+	//		storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
1482
+	//		warehouseOut := models.WarehouseOut{
1483
+	//			WarehouseOutOrderNumber: warehousing_out_order,
1484
+	//			OperationTime:           operation_time,
1485
+	//			OrgId:                   adminInfo.CurrentOrgId,
1486
+	//			Creater:                 5685,
1487
+	//			Ctime:                   nowtime,
1488
+	//			Status:                  1,
1489
+	//			WarehouseOutTime:        nowtime,
1490
+	//			Type:                    1,
1491
+	//			StorehouseId:            storeConfig.StorehouseOutInfo,
1492
+	//			IsCheck:                 1,
1493
+	//			IsSys:                   1,
1494
+	//		}
1495
+	//		//查询是否生成出库单
1496
+	//		out, _ := service.FindNewPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
1497
+	//		if out.ID == 0 {
1498
+	//			service.AddNewSigleWarehouseOut(&warehouseOut, tx)
1499
+	//		}
1500
+	//
1501
+	//		lastOut, _ := service.FindNewLastPrescriptionWarehouseOut(adminInfo.CurrentOrgId, nowtime, tx)
1502
+	//
1503
+	//		goodObj, _ := service.GetNewGoodInformationByGoodIdThirty(item.ProjectId, tx)
1504
+	//		houseConfig, _ := service.GetNewAllStoreHouseConfig(item.UserOrgId, tx)
1505
+	//
1506
+	//		dialyPrepareOne := models.DialysisBeforePrepare{
1507
+	//			GoodTypeId:   goodObj.GoodTypeId,
1508
+	//			GoodId:       item.ProjectId,
1509
+	//			PatientId:    item.PatientId,
1510
+	//			RecordDate:   item.RecordDate,
1511
+	//			UserOrgId:    adminInfo.CurrentOrgId,
1512
+	//			Count:        cha_count,
1513
+	//			Ctime:        time.Now().Unix(),
1514
+	//			Creater:      5685,
1515
+	//			Status:       1,
1516
+	//			StorehouseId: houseConfig.StorehouseOutInfo,
1517
+	//			ProjectId:    item.ID,
1518
+	//		}
1519
+	//		//出库
1520
+	//		service.ConsumableNewHisPrescriptionDelivery(adminInfo.CurrentOrgId, item.PatientId, item.RecordDate, &dialyPrepareOne, &lastOut, creater, tx)
1521
+	//	}
1522
+	//}
1523
+	//tx.Commit()
1524
+	//return
1525
+
1526
+	//
1527
+
1528
+	adviceInfo, _ := service.GetHisDoctorAdviceByUserOrgId(10752)
1529
+	adminInfo := this.GetAdminUserInfo()
1530
+	db := service.XTWriteDB()
1531
+	tx := db.Begin()
1532
+	if len(adviceInfo) > 0 {
1533
+		for _, item := range adviceInfo {
1534
+
1535
+			drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
1536
+			var local_count int64
1537
+			if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1538
+
1539
+				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1540
+				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1541
+
1542
+				local_count += prescribingNumberSevenTy * drug.MinNumber
1543
+			}
1544
+
1545
+			if item.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1546
+
1547
+				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1548
+				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1549
+				local_count += prescribingNumberSevenTy
1550
+			}
1551
+
1552
+			if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
1553
+
1554
+				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1555
+				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1556
+				local_count += prescribingNumberSevenTy
1557
+			}
1558
+
1559
+			item.PrescribingNumberUnit = drug.MinUnit
1560
+
1561
+			service.BloodNewHisDrugsDelivery(item.UserOrgId, 5685, item, tx)
1562
+
1563
+			storeConfig, _ := service.GetNewAllStoreHouseConfig(item.UserOrgId, tx)
1564
+
1565
+			stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
1566
+			var sum_count int64
1567
+			for _, its := range stockInfo {
1568
+				baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
1569
+				if its.MaxUnit == baseDrug.MaxUnit {
1570
+					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1571
+				}
1572
+				sum_count += its.StockMaxNumber + its.StockMinNumber
1573
+			}
1574
+			//更新基础库存
1575
+			service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
1576
+			//剩余库存
1577
+			service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
1578
+
1579
+			over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
1580
+			service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
1581
+		}
1582
+	}
1583
+
1584
+	tx.Commit()
1442 1585
 	this.ServeSuccessJSON(map[string]interface{}{
1443 1586
 		"msg": "ok",
1444 1587
 	})

+ 10 - 2
controllers/stock_in_api_controller.go Ver fichero

@@ -1238,7 +1238,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1238 1238
 	warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1239 1239
 	number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1240 1240
 	number = number + total
1241
-	warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
1241
+	warehousing_out_order = "CKM" + strconv.FormatInt(number, 10)
1242 1242
 
1243 1243
 	operation_time := time.Now().Unix()
1244 1244
 	creater := adminUserInfo.AdminUser.Id
@@ -1277,7 +1277,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
1277 1277
 
1278 1278
 	if warehouseOut_id == 0 {
1279 1279
 		//查询是否生成出库单
1280
-		warehouseOutObj, _ := service.FindStockOutByIsSysOne(adminUserInfo.CurrentOrgId, 0, operation_time, warehousing_out_order, tx)
1280
+		warehouseOutObj, _ := service.FindStockOutByIsSysOne(adminUserInfo.CurrentOrgId, 0, warehousingOutDate.Unix(), warehousing_out_order, tx)
1281 1281
 
1282 1282
 		if warehouseOutObj.ID == 0 {
1283 1283
 			service.AddSigleWarehouseOut(&warehouseOut, tx)
@@ -5171,10 +5171,18 @@ func (this *StockManagerApiController) GetStockFlow() {
5171 5171
 	}
5172 5172
 
5173 5173
 	list, total, _ := service.GetStockFlowList(limit, page, consumable_type, orgId, startTime, endTime, good_id)
5174
+
5175
+	//if len(list) > 0 {
5176
+	//	for _, item := range list {
5177
+	//		hisPrescription, _ := service.GetHidsDoctorAdvice(item.GoodId, orgId, item.PatientId, item.SystemTime)
5178
+	//		item.GoodCode = hisPrescription.good
5179
+	//	}
5180
+	//}
5174 5181
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
5175 5182
 	good, _ := service.GetGoodInformationByGoodId(good_id)
5176 5183
 	houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
5177 5184
 	patients, _ := service.GetAllPatientListSix(adminUserInfo.CurrentOrgId)
5185
+
5178 5186
 	this.ServeSuccessJSON(map[string]interface{}{
5179 5187
 		"list":             list,
5180 5188
 		"total":            total,

+ 6 - 5
models/patient_models.go Ver fichero

@@ -1150,11 +1150,12 @@ type VmInspection struct {
1150 1150
 }
1151 1151
 
1152 1152
 type BloodXtPatients struct {
1153
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
1154
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1155
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1156
-	Name       string `gorm:"column:name" json:"name" form:"name"`
1157
-	IdCardNo   string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1153
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1154
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1155
+	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1156
+	Name        string `gorm:"column:name" json:"name" form:"name"`
1157
+	IdCardNo    string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
1158
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1158 1159
 }
1159 1160
 
1160 1161
 func (BloodXtPatients) TableName() string {

+ 7 - 5
models/smart_sch.go Ver fichero

@@ -1,11 +1,13 @@
1 1
 package models
2 2
 
3 3
 type SmartSchPatient struct {
4
-	ID         int64  `gorm:"column:id" json:"id" form:"id"`
5
-	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
-	Name       string `gorm:"column:name" json:"name" form:"name"`
7
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
8
-	Lapseto    int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
4
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	Name        string `gorm:"column:name" json:"name" form:"name"`
7
+	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
8
+	Lapseto     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
9
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
10
+
9 11
 	//SmartSchedule []*SmartSchedule `gorm:"-" json:"sch"`
10 12
 }
11 13
 

+ 1 - 1
service/common_service.go Ver fichero

@@ -482,7 +482,7 @@ func GetDialysisAgeData(orgID int64, lapsetotype int64, sourcetype int64) (count
482 482
 
483 483
 func GetCurentOrgPatients(orgid int64) (patients []*models.BloodXtPatients, err error) {
484 484
 
485
-	err = XTReadDB().Where("user_org_id = ? and status =1", orgid).Order("created_time desc").Find(&patients).Error
485
+	err = XTReadDB().Where("user_org_id = ? and status =1 and patient_type =1", orgid).Order("created_time desc").Find(&patients).Error
486 486
 	return patients, err
487 487
 }
488 488
 

+ 7 - 0
service/his_service.go Ver fichero

@@ -1066,6 +1066,13 @@ func GetLastHisProject(patient_id int64, user_org_id int64, record_date int64, t
1066 1066
 	return prescriptionProject, err
1067 1067
 }
1068 1068
 
1069
+func GetHisWarehouseOutInfo(patient_id int64, user_org_id int64, sys_record_time int64, tx *gorm.DB, good_id int64) (outinfo []*models.WarehouseOutInfo, err error) {
1070
+
1071
+	err = tx.Where("patient_id = ? and user_org_id = ? and sys_record_time = ? and good_id = ? an status=1", patient_id, user_org_id, sys_record_time, good_id).Find(&outinfo).Error
1072
+
1073
+	return outinfo, err
1074
+}
1075
+
1069 1076
 func CreateHisProjectThree(project *models.HisPrescriptionProject) (err error) {
1070 1077
 	tx := writeDb.Begin()
1071 1078
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {

+ 14 - 4
service/mobile_dialysis_service.go Ver fichero

@@ -2120,9 +2120,10 @@ func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.Dialy
2120 2120
 }
2121 2121
 
2122 2122
 type MobileUrgentSchedulePatientVM struct {
2123
-	ID         int64  `gorm:"column:id" json:"id"`
2124
-	Name       string `gorm:"column:name" json:"name"`
2125
-	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no"`
2123
+	ID          int64  `gorm:"column:id" json:"id"`
2124
+	Name        string `gorm:"column:name" json:"name"`
2125
+	DialysisNo  string `gorm:"column:dialysis_no" json:"dialysis_no"`
2126
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
2126 2127
 }
2127 2128
 
2128 2129
 func (MobileUrgentSchedulePatientVM) TableName() string {
@@ -2140,7 +2141,8 @@ func (MobileUrgentScheduleTreatmentModeVM) TableName() string {
2140 2141
 
2141 2142
 func MobileGetAllPatientsForUrgentSchedule(orgID int64, record_date int64) ([]*MobileUrgentSchedulePatientVM, error) {
2142 2143
 	var vms []*MobileUrgentSchedulePatientVM = make([]*MobileUrgentSchedulePatientVM, 0)
2143
-	rows, err := readDb.Raw("SELECT p.*  FROM xt_patients as p  WHERE (p.user_org_id = ? AND p.status = 1 AND p.lapseto = 1) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = p.id AND  d.user_org_id = p.user_org_id  )", orgID, record_date).Rows()
2144
+
2145
+	rows, err := readDb.Raw("SELECT p.*  FROM xt_patients as p  WHERE (p.user_org_id = ? AND p.status = 1 AND p.lapseto = 1 and p.patient_type =1) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = p.id AND  d.user_org_id = p.user_org_id  )", orgID, record_date).Rows()
2144 2146
 	defer rows.Close()
2145 2147
 	if err != nil {
2146 2148
 		return nil, err
@@ -10049,3 +10051,11 @@ func GetDrugIsShow(id int64, org_id int64) (models.XtBaseDrug, error) {
10049 10051
 
10050 10052
 	return baseDrug, err
10051 10053
 }
10054
+
10055
+func GetDoctorAdviceByAdviceName(advice_name string, user_org_id int64) (models.BaseDrugLibSeven, error) {
10056
+
10057
+	drugLib := models.BaseDrugLibSeven{}
10058
+	err := XTReadDB().Where("drug_name = ? and org_id = ? and status=1", advice_name, user_org_id).Find(&drugLib).Error
10059
+
10060
+	return drugLib, err
10061
+}

+ 6 - 2
service/patient_schedule_template_service.go Ver fichero

@@ -301,6 +301,7 @@ type PatientScheduleTemplatePatientVM struct {
301 301
 	DialysisNo  string                      `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
302 302
 	FirstLetter string                      `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
303 303
 	Contagions  []*PatientScheduleContagion `gorm:"ForeignKey:PatientID" json:"contagions"`
304
+	PatientType int64                       `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
304 305
 }
305 306
 
306 307
 func (PatientScheduleTemplatePatientVM) TableName() string {
@@ -319,11 +320,12 @@ func (PatientScheduleContagion) TableName() string {
319 320
 }
320 321
 
321 322
 func PatientScheduleTemplateGetAllValidPatient(orgID int64) ([]*PatientScheduleTemplatePatientVM, error) {
323
+
322 324
 	var vms []*PatientScheduleTemplatePatientVM
323 325
 	err := readDb.
324 326
 		Model(&PatientScheduleTemplatePatientVM{}).
325 327
 		Preload("Contagions", "status = 1").
326
-		Where("user_org_id = ? and lapseto=1 AND status = 1", orgID).
328
+		Where("user_org_id = ? and lapseto=1 AND status = 1 and patient_type =1", orgID).
327 329
 		Find(&vms).
328 330
 		Error
329 331
 	if err != nil {
@@ -898,6 +900,7 @@ type SchTemplatePatient struct {
898 900
 	DialysisNo   string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
899 901
 	IsInfectious int64  `gorm:"column:is_infectious" json:"is_infectious"`
900 902
 	FirstLetter  string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
903
+	PatientType  int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
901 904
 }
902 905
 
903 906
 func (SchTemplatePatient) TableName() string {
@@ -905,8 +908,9 @@ func (SchTemplatePatient) TableName() string {
905 908
 }
906 909
 
907 910
 func GetSchTemplatePatientList(orgID int64) ([]*SchTemplatePatient, error) {
911
+
908 912
 	var patients []*SchTemplatePatient
909
-	err := readDb.Model(&SchTemplatePatient{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1", orgID).Find(&patients).Error
913
+	err := readDb.Model(&SchTemplatePatient{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1 and patient_type =1", orgID).Find(&patients).Error
910 914
 	return patients, err
911 915
 }
912 916
 

+ 23 - 3
service/patient_service.go Ver fichero

@@ -1936,7 +1936,8 @@ func FindLastDryWeightAdjust(orgID int64, id int64) (weight models.SgjPatientDry
1936 1936
 }
1937 1937
 
1938 1938
 func GetSchedualPatientByKeyWord(orgID int64, keywords string, date int64) (patient []*models.Patients, err error) {
1939
-	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 ", orgID)
1939
+
1940
+	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 and patient_type =1 ", orgID)
1940 1941
 	if len(keywords) > 0 {
1941 1942
 		likekey := "%" + keywords + "%"
1942 1943
 		err = db.Where("(name LIKE ? OR dialysis_no LIKE ?) AND NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = xt_patients.id AND  d.user_org_id = xt_patients.user_org_id)", likekey, likekey, date).Find(&patient).Error
@@ -3332,10 +3333,15 @@ func GetDialysisInformationList(user_org_id int64, advice_date int64) (informati
3332 3333
 }
3333 3334
 
3334 3335
 func GetNewAllMonitorList(orgID int64, scheduleDate int64, pat_type int64) (monitor []*models.VMMonitoringRecord, err error) {
3336
+
3335 3337
 	if pat_type == 0 || pat_type == 9 {
3336 3338
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3337 3339
 	}
3338 3340
 
3341
+	if pat_type == 13 {
3342
+		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ? and ultrafiltration_volume>0", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3343
+	}
3344
+
3339 3345
 	if pat_type == 10 {
3340 3346
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ? AND accumulated_blood_volume = 0", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
3341 3347
 	}
@@ -3617,10 +3623,10 @@ func GetDialysisOrderCountTenEight(patient_id int64, recordDate int64) (models.V
3617 3623
 	return order, err
3618 3624
 }
3619 3625
 
3620
-func GetLastAcceptRecrods(patient_id int64) (models.ReceiveTreatmentAsses, error) {
3626
+func GetLastAcceptRecrods(patient_id int64, user_org_id int64) (models.ReceiveTreatmentAsses, error) {
3621 3627
 
3622 3628
 	treatmentAsses := models.ReceiveTreatmentAsses{}
3623
-	err := XTReadDB().Where("patient_id = ? and status= 1 and admission_number!=''", patient_id).Last(&treatmentAsses).Error
3629
+	err := XTReadDB().Where("patient_id = ? and status= 1 and admission_number!='' and user_org_id =? ", patient_id, user_org_id).Last(&treatmentAsses).Error
3624 3630
 	return treatmentAsses, err
3625 3631
 }
3626 3632
 
@@ -5020,3 +5026,17 @@ func GetNewInspectionByProjectId(patient_id int64, project_id int64, inspect_dat
5020 5026
 
5021 5027
 	return inspection, err
5022 5028
 }
5029
+
5030
+func GetSelfDrugOutInfo(patient_id int64, sys_record_time int64, drug_id int64) (outInfo []*models.XtSelfDrugWarehouseOutInfo, err error) {
5031
+
5032
+	err = XTReadDB().Where("patient_id = ? and sys_record_time = ? and drug_id = ? and status=1", patient_id, sys_record_time, drug_id).Find(&outInfo).Error
5033
+
5034
+	return outInfo, err
5035
+}
5036
+
5037
+func ModifyExecutionAdvice(id int64, execution_staff int64, ExecutionTime int64) error {
5038
+
5039
+	err := XTWriteDB().Model(&models.DoctorAdvice{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"execution_staff": execution_staff, "execution_state": 1, "execution_time": ExecutionTime}).Error
5040
+
5041
+	return err
5042
+}

+ 7 - 1
service/patientmanage_service.go Ver fichero

@@ -585,7 +585,7 @@ func GetDryWeight(patientid int64, startime int64, endtime int64, limit int64, p
585 585
 	}
586 586
 	offset := (page - 1) * limit
587 587
 	err = db.Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Group("x.id").
588
-		Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.adjusted_value,x.user_id,x.user_org_id,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creator").Scan(&dryWeight).Error
588
+		Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.adjusted_value,x.user_id,x.user_org_id,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creator and r.org_id = x.user_org_id").Scan(&dryWeight).Error
589 589
 	return dryWeight, total, err
590 590
 }
591 591
 
@@ -1183,6 +1183,12 @@ func GetAllBedNumberList(orgid int64) (number []*models.DeviceNumber, err error)
1183 1183
 	return number, err
1184 1184
 }
1185 1185
 
1186
+func GetPatientScheduleDialyCount(patient_id int64, start_time int64, end_time int64, org_id int64) (schedule []*models.XtSchedule, err error) {
1187
+
1188
+	err = XTReadDB().Where("patient_id = ? and schedule_date>=? and schedule_date<=? and user_org_id = ? and status=1", patient_id, start_time, end_time, org_id).Find(&schedule).Error
1189
+	return schedule, err
1190
+}
1191
+
1186 1192
 func GetAllGroupOne(orgid int64) (group []*models.DeviceGroup, err error) {
1187 1193
 
1188 1194
 	err = XTReadDB().Model(&group).Where("org_id =?", orgid).Find(&group).Error

+ 6 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver fichero

@@ -489,6 +489,12 @@ func GetBatchAssessmentBeforeDislysisVM(orgid int64, patient_id int64, assessmen
489 489
 	return AssessmentBeforeDislysisVM, err
490 490
 }
491 491
 
492
+func GetPatientScheduleDialyCount(patient_id int64, start_time int64, end_time int64, org_id int64) (schedule []*models.XtSchedule, err error) {
493
+
494
+	err = p_service.XTReadDB().Where("patient_id = ? and schedule_date>=? and schedule_date<=? and user_org_id = ? and status=1", patient_id, start_time, end_time, org_id).Find(&schedule).Error
495
+	return schedule, err
496
+}
497
+
492 498
 func GetBatchAssessmentAfterDislysisVM(orgid int64, patient_id int64, assessment_date int64) (AssessmentAfterDislysisVM, error) {
493 499
 
494 500
 	assessmentAfterDislysisVM := AssessmentAfterDislysisVM{}

+ 11 - 1
service/schedule_service.go Ver fichero

@@ -46,7 +46,7 @@ func GetPatientWithScheduleAndSolution(orgID int64, keywords string, weekStart,
46 46
 		Preload("DialysisSolutions", "user_org_id=? and initiate_mode=1 and affirm_state=1 and parent_id=0 and status=1", orgID).
47 47
 		Preload("Schedules", "user_org_id=? and schedule_date>=? and schedule_date<= ? and status=1", orgID, weekStart, weekEnd).
48 48
 		Preload("Contagions", "status=1").
49
-		Where("p.user_org_id=? and p.lapseto=1 and p.status=1", orgID)
49
+		Where("p.user_org_id=? and p.lapseto=1 and p.status=1 and p.patient_type =1", orgID)
50 50
 	if len(keywords) > 0 {
51 51
 		likeKey := "%" + keywords + "%"
52 52
 		db = db.Where("p.name LIKE ? or p.first_letter LIKE ?", likeKey, likeKey)
@@ -1206,9 +1206,19 @@ func GetThreeWeekList(startime int64, endtime int64, orgid int64, scheduletype i
1206 1206
 	if startime > 0 {
1207 1207
 		db = db.Where("x.schedule_date >=?", startime)
1208 1208
 	}
1209
+
1210
+	if startime == 0 {
1211
+		db = db.Where("x.schedule_date >=1739116800")
1212
+	}
1213
+
1209 1214
 	if endtime > 0 {
1210 1215
 		db = db.Where("x.schedule_date <=?", endtime)
1211 1216
 	}
1217
+
1218
+	if endtime == 0 {
1219
+		db = db.Where("x.schedule_date <=1739635200")
1220
+	}
1221
+
1212 1222
 	if orgid > 0 {
1213 1223
 		db = db.Where("x.user_org_id = ?", orgid)
1214 1224
 	}

+ 14 - 0
service/self_drug_service.go Ver fichero

@@ -3951,6 +3951,13 @@ func FindSelfBaseDrugLibRecord(org_id int64, id int64, tx *gorm.DB) (lib models.
3951 3951
 	return lib, err
3952 3952
 }
3953 3953
 
3954
+func FindNewSelfBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err error) {
3955
+
3956
+	err = XTReadDB().Model(&models.BaseDrugLib{}).Where("id = ? AND org_id = ?  AND status = 1", id, org_id).First(&lib).Error
3957
+
3958
+	return lib, err
3959
+}
3960
+
3954 3961
 func GetSelfBaseDrugMedical(id int64, tx *gorm.DB) (models.XtBaseDrug, error) {
3955 3962
 	drug := models.XtBaseDrug{}
3956 3963
 	err := tx.Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error
@@ -5418,3 +5425,10 @@ func GetHisDocInfoList(drug_id int64, user_org_id int64) (info []*models.HisDoct
5418 5425
 
5419 5426
 	return info, err
5420 5427
 }
5428
+
5429
+func GetSelfDrugWarhouseInfoByPatient(drug_id int64, patient_id int64, user_org_id int64) (info []*models.XtSelfDrugWarehouseInfo, err error) {
5430
+
5431
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and org_id = ? and status=1 and is_check=1", drug_id, patient_id, user_org_id).Order("ctime desc").Find(&info).Error
5432
+
5433
+	return info, err
5434
+}

+ 85 - 0
service/sign_service.go Ver fichero

@@ -6,11 +6,16 @@ import (
6 6
 	"crypto/sha1"
7 7
 	"encoding/base64"
8 8
 	"encoding/json"
9
+	"errors"
9 10
 	"fmt"
11
+	"strconv"
12
+	"strings"
10 13
 
11 14
 	"XT_New/models"
12 15
 	"XT_New/utils"
13 16
 	"github.com/astaxie/beego"
17
+	"github.com/jinzhu/gorm"
18
+
14 19
 	//"github.com/jung-kurt/gofpdf"
15 20
 	"io/ioutil"
16 21
 	"net/http"
@@ -2400,3 +2405,83 @@ func GetSelfDrugWarehouseOutInfo(patient_id int64, drug_id int64, advice_Date in
2400 2405
 
2401 2406
 	return outInfo, err
2402 2407
 }
2408
+
2409
+func GetHisPRrescriptionByUserOrgId(user_org_id int64) (prescription []*models.HisPrescriptionProject, err error) {
2410
+
2411
+	err = XTReadDB().Where("user_org_id = ? and status = 1 and type =3 and record_date =1738598400", 10752).Find(&prescription).Error
2412
+
2413
+	return prescription, err
2414
+}
2415
+
2416
+func GetHisDoctorAdviceByUserOrgId(user_org_id int64) (info []*models.HisDoctorAdviceInfo, err error) {
2417
+
2418
+	err = XTReadDB().Where("user_org_id = ? and status =1 and advice_date = 1738512000", user_org_id).Find(&info).Error
2419
+
2420
+	return info, err
2421
+}
2422
+
2423
+func BloodNewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
2424
+
2425
+	// 1.判断药品是否来自专用字典的药品库
2426
+	// 2.判断当天当前机构有没有创建出库单,没有则创建
2427
+	// 3.创建出库流程
2428
+	// 3.1 实现先进先出逻辑 由于药品执行后,不可以修改和删除,所以不考虑出库后的退库和修改出库数量等
2429
+
2430
+	isHasWay := false
2431
+	record_time := int64(0)
2432
+	isHasWay = true
2433
+	record_time = advice.RecordDate
2434
+
2435
+	if isHasWay {
2436
+		//判断当天当前机构有没有创建出库单,没有则创建
2437
+		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
2438
+		houseConfig, _ := GetAllStoreHouseConfig(orgID)
2439
+		if err == gorm.ErrRecordNotFound {
2440
+			timeStr := "2025-02-03"
2441
+			timeArr := strings.Split(timeStr, "-")
2442
+			total, _ := FindAllDrugWarehouseOut(orgID)
2443
+			total = total + 1
2444
+			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
2445
+			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
2446
+			number = number + total
2447
+			warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
2448
+
2449
+			warehouseOut := models.DrugWarehouseOut{
2450
+				WarehouseOutOrderNumber: warehousing_out_order,
2451
+				OperationTime:           record_time,
2452
+				OrgId:                   orgID,
2453
+				Creater:                 creater,
2454
+				Ctime:                   record_time,
2455
+				Status:                  1,
2456
+				WarehouseOutTime:        record_time,
2457
+				Dealer:                  0,
2458
+				Manufacturer:            0,
2459
+				Type:                    1,
2460
+				IsSys:                   1,
2461
+				StorehouseId:            houseConfig.DrugStorehouseOut,
2462
+				IsCheck:                 1,
2463
+			}
2464
+			err := AddNewSigleDrugWarehouseOut(&warehouseOut, tx)
2465
+			if err != nil {
2466
+				utils.TraceLog("创建出库单失败 err = %v", err)
2467
+				return err
2468
+			} else {
2469
+				out = warehouseOut
2470
+			}
2471
+		}
2472
+
2473
+		//出库流程
2474
+		//1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
2475
+		drup, _ := FindNewBaseDrugLibRecord(orgID, advice.DrugId, tx)
2476
+		if drup.ID > 0 {
2477
+			prescribingNumber := advice.PrescribingNumber
2478
+			HisStoryBloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber, advice.PrescribingNumberUnit, tx)
2479
+
2480
+		} else {
2481
+			return errors.New("药品信息不存在")
2482
+		}
2483
+
2484
+	}
2485
+
2486
+	return
2487
+}

+ 2 - 2
service/smart_sch.go Ver fichero

@@ -9,7 +9,7 @@ import (
9 9
 
10 10
 func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*models.SmartSchPatient, err error) {
11 11
 	if orgID != 10517 {
12
-		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3", orgID)
12
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto !=3 and patient_type =1", orgID)
13 13
 		if len(keywords) > 0 {
14 14
 			likekey := "%" + keywords + "%"
15 15
 			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error
@@ -19,7 +19,7 @@ func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*model
19 19
 	}
20 20
 
21 21
 	if orgID == 10517 {
22
-		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto =1", orgID)
22
+		db := readDb.Model(&models.SmartSchPatient{}).Where("user_org_id=? and status=1 and  lapseto =1 and patient_type =1", orgID)
23 23
 		if len(keywords) > 0 {
24 24
 			likekey := "%" + keywords + "%"
25 25
 			err = db.Where("name LIKE ? OR dialysis_no LIKE ?", likekey, likekey).Find(&patient).Error

+ 12 - 10
service/statistics_service/index_evaluation_service.go Ver fichero

@@ -1,13 +1,14 @@
1 1
 package statistics_service
2 2
 
3 3
 import (
4
-	"XT_New/models"
5
-	"XT_New/service"
6 4
 	"fmt"
7
-	"github.com/jinzhu/gorm"
8 5
 	"math"
9 6
 	"strconv"
10 7
 	"strings"
8
+
9
+	"XT_New/models"
10
+	"XT_New/service"
11
+	"github.com/jinzhu/gorm"
11 12
 )
12 13
 
13 14
 func GetOrgFirstPatientInfo(user_org_id int64) (patient *models.Patients, err error) {
@@ -1930,12 +1931,13 @@ func GetPatientInspectionBarChartData(user_org_id int64, start_time int64, end_t
1930 1931
 }
1931 1932
 
1932 1933
 type VMPatient struct {
1933
-	ID        int64  `gorm:"column:id" json:"id" form:"id"`
1934
-	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1935
-	UserId    int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
1936
-	Name      string `gorm:"column:name" json:"name" form:"name"`
1937
-	Lapseto   int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1938
-	Status    int64  `gorm:"column:status" json:"status" form:"status"`
1934
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1935
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1936
+	UserId      int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
1937
+	Name        string `gorm:"column:name" json:"name" form:"name"`
1938
+	Lapseto     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1939
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
1940
+	PatientType int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
1939 1941
 }
1940 1942
 
1941 1943
 func (VMPatient) TableName() string {
@@ -1945,7 +1947,7 @@ func (VMPatient) TableName() string {
1945 1947
 func GetOrgPatients(user_org_id int64) (patient *[]VMPatient, err error) {
1946 1948
 	db := service.XTReadDB()
1947 1949
 	var tempPatient []VMPatient
1948
-	findErr := db.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1", user_org_id).Find(&tempPatient).Error
1950
+	findErr := db.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1 AND lapseto = 1 and patient_type =1", user_org_id).Find(&tempPatient).Error
1949 1951
 	if findErr == gorm.ErrRecordNotFound {
1950 1952
 		return nil, nil
1951 1953
 	}

+ 24 - 2
service/stock_service.go Ver fichero

@@ -1821,7 +1821,7 @@ func FindAllDrugWarehouseOut(org_id int64) (total int64, err error) {
1821 1821
 
1822 1822
 func FindAllSelfDrugWarehouseOut(org_id int64, tx *gorm.DB) (total int64, err error) {
1823 1823
 
1824
-	err = tx.Model(&models.XtSelfDrugWarehouseOut{}).Where("org_id = ?", org_id).Count(&total).Error
1824
+	err = tx.Model(&models.XtDrugWarehouseOut{}).Where("org_id = ?", org_id).Count(&total).Error
1825 1825
 	if err != gorm.ErrRecordNotFound {
1826 1826
 		if err != nil {
1827 1827
 			tx.Rollback()
@@ -6234,6 +6234,13 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
6234 6234
 	return flow, total, err
6235 6235
 }
6236 6236
 
6237
+func GetHidsDoctorAdvice(good_id int64, user_org_id int64, patient_id int64, record_date int64) (models.HisPrescriptionProject, error) {
6238
+
6239
+	project := models.HisPrescriptionProject{}
6240
+	err = XTReadDB().Where("project_id = ? and type =3 and user_org_id = ? and record_date =? and patient_id = ?", good_id, user_org_id, record_date, patient_id).Find(&project).Error
6241
+	return project, err
6242
+}
6243
+
6237 6244
 func GetLastGoodListByPatientId(recordtime int64, patientid int64, goodid int64, goodtypeid int64) (models.AutomaticReduceDetail, error) {
6238 6245
 
6239 6246
 	detail := models.AutomaticReduceDetail{}
@@ -6371,6 +6378,14 @@ func GetDrugFlow(drugid int64, orgid int64, limit int64, page int64, startTime i
6371 6378
 	return drug_flow, total, err
6372 6379
 }
6373 6380
 
6381
+func HisDoctorAdviceMap(patient_id int64, advice_date int64, drug_id int64, user_org_id int64) (models.HisDoctorAdviceInfo, error) {
6382
+
6383
+	advicelist := models.HisDoctorAdviceInfo{}
6384
+	err = XTReadDB().Where("patient_id = ? and  drug_id = ? and user_org_id = ? and advice_date = ? and status=1", patient_id, drug_id, user_org_id, advice_date).Find(&advicelist).Error
6385
+
6386
+	return advicelist, err
6387
+}
6388
+
6374 6389
 func GetDrugWarehouseOutInfoIsExit(drug_id int64, patient_id int64, recordtime int64) (*models.DrugWarehouseOutInfo, error) {
6375 6390
 
6376 6391
 	outInfo := models.DrugWarehouseOutInfo{}
@@ -11093,11 +11108,18 @@ func GetNewPatientAdviceList(patient_id int64, start_time int64, end_time int64,
11093 11108
 	if user_org_id > 0 {
11094 11109
 		db = db.Where("user_org_id = ?", user_org_id)
11095 11110
 	}
11096
-	err = db.Find(&advice).Error
11111
+	err = db.Order("drug_id desc").Find(&advice).Error
11097 11112
 
11098 11113
 	return advice, err
11099 11114
 }
11100 11115
 
11116
+func GetSelfDrugWarehouseInfoByPatientId(patient_id int64, user_org_id int64) (drugInfo []*models.XtSelfDrugWarehouseInfo, err error) {
11117
+
11118
+	err = XTReadDB().Where("patient_id = ? and org_id = ? and status =1 and is_check =1", patient_id, user_org_id).Find(&drugInfo).Error
11119
+	return drugInfo, err
11120
+
11121
+}
11122
+
11101 11123
 func GetPatientAdviceListDetail(patient_id int64, start_time int64, end_time int64, user_org_id int64, advice_name string) (advice []*models.DoctorAdvice, err error) {
11102 11124
 
11103 11125
 	db := XTReadDB().Model(&advice).Where("status = 1")

+ 1 - 1
service/user_service.go Ver fichero

@@ -101,7 +101,7 @@ func GetAllAdminUsersTwo(orgId int64) (list []*AdminUserList, err error) {
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 102
 
103 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
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.org_id=?", orgId).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&list).Error
105 105
 	} else {
106 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 107
 	}

+ 6 - 6
service/warhouse_service.go Ver fichero

@@ -11190,7 +11190,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11190 11190
 			over_count += its.StockMaxNumber + its.StockMinNumber
11191 11191
 		}
11192 11192
 
11193
-		drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11193
+		//drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11194 11194
 		drugflow := models.DrugFlow{
11195 11195
 			WarehouseOutId:          warehouseout.ID,
11196 11196
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -11212,7 +11212,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11212 11212
 			IsEdit:                  1,
11213 11213
 			Creator:                 0,
11214 11214
 			IsSys:                   0,
11215
-			WarehouseOutDetailId:    drugWareInfo.ID,
11215
+			WarehouseOutDetailId:    advice.ID,
11216 11216
 			AdviceId:                advice.ID,
11217 11217
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11218 11218
 			StorehouseId:            advice.StorehouseId,
@@ -11237,7 +11237,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11237 11237
 		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11238 11238
 			UserOrgId:          advice.OrgId,
11239 11239
 			DrugId:             advice.DrugId,
11240
-			WarehouseOutInfoId: drugWareInfo.ID,
11240
+			WarehouseOutInfoId: advice.ID,
11241 11241
 			RecordDate:         advice.SysRecordTime,
11242 11242
 			Status:             1,
11243 11243
 			Ctime:              time.Now().Unix(),
@@ -11275,7 +11275,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11275 11275
 			}
11276 11276
 			over_count += its.StockMaxNumber + its.StockMinNumber
11277 11277
 		}
11278
-		drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11278
+		//drugWareInfo, _ := GetLastNewWarehouseOutInfoById(advice.DrugId, tx)
11279 11279
 		drugflow := models.DrugFlow{
11280 11280
 			WarehouseOutId:          warehouseout.ID,
11281 11281
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -11297,7 +11297,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11297 11297
 			IsEdit:                  1,
11298 11298
 			Creator:                 0,
11299 11299
 			IsSys:                   0,
11300
-			WarehouseOutDetailId:    drugWareInfo.ID,
11300
+			WarehouseOutDetailId:    advice.ID,
11301 11301
 			AdviceId:                advice.ID,
11302 11302
 			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
11303 11303
 			StorehouseId:            advice.StorehouseId,
@@ -11319,7 +11319,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11319 11319
 		outInfoLog := models.XtDrugWarehouseOutInfoLog{
11320 11320
 			UserOrgId:          advice.OrgId,
11321 11321
 			DrugId:             advice.DrugId,
11322
-			WarehouseOutInfoId: drugWareInfo.ID,
11322
+			WarehouseOutInfoId: advice.ID,
11323 11323
 			RecordDate:         advice.SysRecordTime,
11324 11324
 			Status:             1,
11325 11325
 			Ctime:              time.Now().Unix(),