Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
0dc25abd22

+ 1 - 1
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3 3
 runmode = dev
4 4
 #dev/prod
5 5
 

+ 59 - 24
controllers/dialysis_api_controller.go View File

@@ -97,6 +97,8 @@ func DialysisApiRegistRouters() {
97 97
 	beego.Router("/api/schedule/getpatientshedule", &DialysisApiController{}, "Get:GetPatientSchedule")
98 98
 
99 99
 	beego.Router("/api/patient/getscheduleprintlist", &DialysisApiController{}, "Get:GetSchedulePrintList")
100
+
101
+	beego.Router("/api/patient/getsolutionlistbyorgid", &DialysisApiController{}, "Get:GetSolutionListByOrgId")
100 102
 }
101 103
 
102 104
 func (c *DialysisApiController) GetQueueCall() {
@@ -4302,6 +4304,13 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4302 4304
 	schedule_type, _ := this.GetInt64("schedule_type")
4303 4305
 
4304 4306
 	start_time := this.GetString("schedule_date")
4307
+
4308
+	advice_ids := this.GetString("ids")
4309
+	var ids []string
4310
+	if advice_ids != "" {
4311
+		ids = strings.Split(advice_ids, ",")
4312
+	}
4313
+
4305 4314
 	timeLayout := "2006-01-02"
4306 4315
 	loc, _ := time.LoadLocation("Local")
4307 4316
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -4311,7 +4320,7 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4311 4320
 
4312 4321
 	goodType, _ := service.GetAllGoodType(orgId)
4313 4322
 	if config.IsOpen != 1 {
4314
-		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4323
+		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4315 4324
 		fmt.Println("list2232323223332323232", list)
4316 4325
 		if err == nil {
4317 4326
 			this.ServeSuccessJSON(map[string]interface{}{
@@ -4328,7 +4337,7 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4328 4337
 		}
4329 4338
 	}
4330 4339
 	if config.IsOpen == 1 {
4331
-		list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4340
+		list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4332 4341
 		if err == nil {
4333 4342
 			this.ServeSuccessJSON(map[string]interface{}{
4334 4343
 				"list":     list,
@@ -4358,32 +4367,35 @@ func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
4358 4367
 	start_time := this.GetString("schedule_date")
4359 4368
 
4360 4369
 	ids := this.GetString("ids")
4361
-	idArray := strings.Split(ids, ",")
4370
+
4371
+	var idArray []string
4372
+	if ids != "" {
4373
+		idArray = strings.Split(ids, ",")
4374
+	}
4375
+
4362 4376
 	timeLayout := "2006-01-02"
4363 4377
 	loc, _ := time.LoadLocation("Local")
4364 4378
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4365 4379
 
4366 4380
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4367
-	fmt.Println("idArray", idArray)
4381
+
4368 4382
 	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
4369
-	fmt.Println("list2323223323223323323223wi", list)
4383
+
4384
+	tablelist, _, err := service.GetDialysisAdviceSchedulistSix(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
4370 4385
 	//获取长期医嘱
4371 4386
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4372 4387
 
4373
-	//获取医嘱模版
4374
-	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4375
-
4376 4388
 	_, config := service.FindXTHisRecordByOrgId(orgId)
4377 4389
 
4378
-	drugList, _ := service.GetAllBaseDrugList(orgId)
4390
+	drugList, _ := service.GetAllBaseDrugListTwenty(orgId)
4379 4391
 	if err == nil {
4380 4392
 		this.ServeSuccessJSON(map[string]interface{}{
4381
-			"list":         list,
4382
-			"total":        total,
4383
-			"adviceList":   adviceList,
4384
-			"templateList": templateList,
4385
-			"config":       config,
4386
-			"drugList":     drugList,
4393
+			"list":       list,
4394
+			"total":      total,
4395
+			"adviceList": adviceList,
4396
+			"config":     config,
4397
+			"drugList":   drugList,
4398
+			"tablelist":  tablelist,
4387 4399
 		})
4388 4400
 		return
4389 4401
 
@@ -4499,7 +4511,12 @@ func (this *DialysisApiController) GetDialysisParameterList() {
4499 4511
 
4500 4512
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4501 4513
 
4502
-	list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4514
+	scheduids := this.GetString("ids")
4515
+	var ids []string
4516
+	if scheduids != "" {
4517
+		ids = strings.Split(scheduids, ",")
4518
+	}
4519
+	list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4503 4520
 
4504 4521
 	dialysisSett, _ := service.GetDialysisSetting(orgId)
4505 4522
 	if err == nil {
@@ -4556,20 +4573,21 @@ func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
4556 4573
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4557 4574
 
4558 4575
 	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
4559
-	drug, _ := service.GetAllDrugMap(orgId)
4576
+
4577
+	tablelist, _ := service.GetDialysisAdviceSchedulistTwo(orgId, schedule_type, partion_type, startTime.Unix())
4578
+
4560 4579
 	//获取长期医嘱
4561 4580
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4562
-	//获取医嘱模版
4563
-	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4564 4581
 
4582
+	drug, _ := service.GetAllBaseDrugListTwenty(orgId)
4565 4583
 	_, config := service.FindXTHisRecordByOrgId(orgId)
4566 4584
 	if err == nil {
4567 4585
 		this.ServeSuccessJSON(map[string]interface{}{
4568
-			"list":         list,
4569
-			"drug":         drug,
4570
-			"adviceList":   adviceList,
4571
-			"templateList": templateList,
4572
-			"config":       config,
4586
+			"list":       list,
4587
+			"drug":       drug,
4588
+			"adviceList": adviceList,
4589
+			"config":     config,
4590
+			"tablelist":  tablelist,
4573 4591
 		})
4574 4592
 		return
4575 4593
 
@@ -4687,3 +4705,20 @@ func (c *DialysisApiController) GetSchedulePrintList() {
4687 4705
 	})
4688 4706
 
4689 4707
 }
4708
+
4709
+func (this *DialysisApiController) GetSolutionListByOrgId() {
4710
+
4711
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4712
+	list, _ := service.GetSolutionListByOrgId(orgId)
4713
+	for _, item := range list {
4714
+		//获取该模式最新的1条数据
4715
+		solution, _ := service.GetNewPatientSolutionByModeId(item.PatientId, item.ModeId, orgId)
4716
+
4717
+		//更新状态值
4718
+		service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, orgId, item.PatientId)
4719
+	}
4720
+	this.ServeSuccessJSON(map[string]interface{}{
4721
+		"list": list,
4722
+	})
4723
+
4724
+}

+ 136 - 1
controllers/his_api_controller.go View File

@@ -5101,7 +5101,9 @@ func (c *HisApiController) GetUploadInfo() {
5101 5101
 			tx.Commit()
5102 5102
 		}
5103 5103
 	}()
5104
-	if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
5104
+	fmt.Println("dec_way", dec_way)
5105
+	if (dec_way == "true" && tmp_decimal == "0") || (dec_way == "true" && tmp_decimal == "") {
5106
+		fmt.Println("tru23332322323323232232332即那里")
5105 5107
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
5106 5108
 		return
5107 5109
 	}
@@ -5296,6 +5298,9 @@ func (c *HisApiController) GetUploadInfo() {
5296 5298
 				customs = append(customs, cus)
5297 5299
 			}
5298 5300
 		}
5301
+
5302
+		//判断库存的地方
5303
+
5299 5304
 		for _, item := range customs {
5300 5305
 			var advice_id int64 = 0
5301 5306
 			var project_id int64 = 0
@@ -5352,6 +5357,7 @@ func (c *HisApiController) GetUploadInfo() {
5352 5357
 		if dec_way == "true" {
5353 5358
 
5354 5359
 			tmpstring := strconv.FormatInt(order.ID, 10)
5360
+			fmt.Println("tmpstring222222222", order.ID)
5355 5361
 			//扣押金
5356 5362
 			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
5357 5363
 			order.Decimal = decimal
@@ -5362,7 +5368,49 @@ func (c *HisApiController) GetUploadInfo() {
5362 5368
 				return
5363 5369
 			}
5364 5370
 		}
5371
+		fmt.Println("err233232233232323232wo", err)
5372
+
5365 5373
 		if err == nil {
5374
+
5375
+			houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5376
+			var goods []*models.DialysisBeforePrepareGoods
5377
+			var newGoods []*models.NewDialysisBeforePrepareGoods
5378
+			var infos []*models.HisDoctorAdviceInfo
5379
+
5380
+			for _, info := range prescriptions {
5381
+				if info.Type == 1 {
5382
+					infos = append(infos, info.HisDoctorAdviceInfo...)
5383
+				}
5384
+				if info.Type == 2 {
5385
+					for _, sumItem := range info.HisPrescriptionProject {
5386
+						if sumItem.Type == 3 {
5387
+							var good models.DialysisBeforePrepareGoods
5388
+							var newGood models.NewDialysisBeforePrepareGoods
5389
+							good.GoodId = sumItem.GoodInfo.ID
5390
+							good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5391
+							count, _ := strconv.Atoi(sumItem.Count)
5392
+							good.Count = int64(count)
5393
+							good.StorehouseId = houseConfig.StorehouseOutInfo
5394
+							good.ProjectId = sumItem.ID
5395
+							goods = append(goods, &good)
5396
+
5397
+							newGood.GoodId = sumItem.GoodInfo.ID
5398
+							newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5399
+							count2, _ := strconv.Atoi(sumItem.Count)
5400
+							newGood.Count = int64(count2)
5401
+							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5402
+							newGood.ProjectId = sumItem.ID
5403
+							newGoods = append(newGoods, &newGood)
5404
+						}
5405
+
5406
+					}
5407
+
5408
+				}
5409
+			}
5410
+			for _, item := range infos {
5411
+				service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5412
+			}
5413
+			service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5366 5414
 			c.ServeSuccessJSON(map[string]interface{}{
5367 5415
 				"msg": "结算成功",
5368 5416
 			})
@@ -5393,6 +5441,46 @@ func (c *HisApiController) GetUploadInfo() {
5393 5441
 				return
5394 5442
 			}
5395 5443
 			if err == nil {
5444
+				houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5445
+				var goods []*models.DialysisBeforePrepareGoods
5446
+				var newGoods []*models.NewDialysisBeforePrepareGoods
5447
+				var infos []*models.HisDoctorAdviceInfo
5448
+
5449
+				for _, info := range prescriptions {
5450
+					if info.Type == 1 {
5451
+						infos = append(infos, info.HisDoctorAdviceInfo...)
5452
+					}
5453
+					if info.Type == 2 {
5454
+						for _, sumItem := range info.HisPrescriptionProject {
5455
+							if sumItem.Type == 3 {
5456
+								var good models.DialysisBeforePrepareGoods
5457
+								var newGood models.NewDialysisBeforePrepareGoods
5458
+								good.GoodId = sumItem.GoodInfo.ID
5459
+								good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5460
+								count, _ := strconv.Atoi(sumItem.Count)
5461
+								good.Count = int64(count)
5462
+								good.StorehouseId = houseConfig.StorehouseOutInfo
5463
+								good.ProjectId = sumItem.ID
5464
+								goods = append(goods, &good)
5465
+
5466
+								newGood.GoodId = sumItem.GoodInfo.ID
5467
+								newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5468
+								count2, _ := strconv.Atoi(sumItem.Count)
5469
+								newGood.Count = int64(count2)
5470
+								newGood.StorehouseId = houseConfig.StorehouseOutInfo
5471
+								newGood.ProjectId = sumItem.ID
5472
+								newGoods = append(newGoods, &newGood)
5473
+							}
5474
+
5475
+						}
5476
+
5477
+					}
5478
+				}
5479
+				for _, item := range infos {
5480
+					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5481
+				}
5482
+				service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5483
+
5396 5484
 				c.ServeSuccessJSON(map[string]interface{}{
5397 5485
 					"msg": "结算成功",
5398 5486
 				})
@@ -5421,6 +5509,53 @@ func (c *HisApiController) Refund() {
5421 5509
 			return
5422 5510
 		}
5423 5511
 	}
5512
+
5513
+	orders, _ := service.GetHisOrderDetailByNumberThree(order.Number, order.UserOrgId)
5514
+	houseConfig, _ := service.GetAllStoreHouseConfig(order.UserOrgId)
5515
+	var goods []*models.DialysisBeforePrepareGoods
5516
+	var newGoods []*models.NewDialysisBeforePrepareGoods
5517
+	var infos []*models.HisDoctorAdviceInfo
5518
+
5519
+	for _, info := range orders {
5520
+		if info.AdviceId > 0 && info.ProjectId == 0 {
5521
+			infos = append(infos, &info.HisDoctorAdviceInfo)
5522
+		}
5523
+		if info.ProjectId > 0 && info.AdviceId == 0 {
5524
+			if info.HisPrescriptionProject.Type == 3 {
5525
+				var good models.DialysisBeforePrepareGoods
5526
+				var newGood models.NewDialysisBeforePrepareGoods
5527
+				good.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
5528
+				good.GoodTypeId = info.HisPrescriptionProject.VMGoodInfo.GoodTypeId
5529
+				count, _ := strconv.Atoi(info.HisPrescriptionProject.Count)
5530
+				good.Count = int64(count)
5531
+				good.StorehouseId = houseConfig.StorehouseOutInfo
5532
+				good.ProjectId = info.HisPrescriptionProject.ID
5533
+
5534
+				goods = append(goods, &good)
5535
+
5536
+				newGood.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
5537
+				newGood.GoodTypeId = info.HisPrescriptionProject.VMGoodInfo.GoodTypeId
5538
+				count2, _ := strconv.Atoi(info.HisPrescriptionProject.Count)
5539
+				newGood.Count = int64(count2)
5540
+				newGood.StorehouseId = houseConfig.StorehouseOutInfo
5541
+				newGood.ProjectId = info.HisPrescriptionProject.ID
5542
+				newGood.RecordDate = order.SettleAccountsDate
5543
+				newGood.UserOrgId = order.UserOrgId
5544
+				newGoods = append(newGoods, &newGood)
5545
+			}
5546
+		}
5547
+	}
5548
+	fmt.Println("infos2323232332233232323232w", infos)
5549
+	for _, item := range infos {
5550
+
5551
+		service.DrugAutoAddCancelInfo(item, adminUser.AdminUser.Id)
5552
+
5553
+	}
5554
+
5555
+	for _, item := range newGoods {
5556
+		service.GoodAutoAddCancelInfo(item, adminUser.AdminUser.Id)
5557
+	}
5558
+
5424 5559
 	c.ServeSuccessJSON(map[string]interface{}{
5425 5560
 		"msg": "退费成功",
5426 5561
 	})

+ 44 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -194,9 +194,12 @@ func (this *DialysisAPIController) Scheduals() {
194 194
 				project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
195 195
 			}
196 196
 
197
+			list, _ := service.GetZoneCountList(orgID, date.Unix())
198
+
197 199
 			this.ServeSuccessJSON(map[string]interface{}{
198 200
 				"scheduals": scheduals,
199 201
 				"project":   project,
202
+				"list":      list,
200 203
 			})
201 204
 		}
202 205
 
@@ -215,12 +218,13 @@ func (this *DialysisAPIController) Scheduals() {
215 218
 		if configs.ID > 0 && configs.IsOpen == 1 {
216 219
 			project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
217 220
 		}
218
-
221
+		list, _ := service.GetZoneCountList(orgID, date.Unix())
219 222
 		this.ServeSuccessJSON(map[string]interface{}{
220 223
 			"scheduals": dat,
221 224
 			"redis":     "true",
222 225
 			"date":      schedualDate,
223 226
 			"project":   project,
227
+			"list":      list,
224 228
 		})
225 229
 
226 230
 	}
@@ -2800,6 +2804,7 @@ func (c *DialysisAPIController) PostSolution() {
2800 2804
 		EpoCount:                   epo_count,
2801 2805
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2802 2806
 		PreImpulse:                 impulse,
2807
+		SolutionStatus:             1,
2803 2808
 	}
2804 2809
 
2805 2810
 	//针对河间咸的
@@ -6978,3 +6983,41 @@ func (this *DialysisAPIController) GetDialysisRecordOrder() {
6978 6983
 		"order": order,
6979 6984
 	})
6980 6985
 }
6986
+
6987
+func (this *DialysisAPIController) GetScheduleTypeByIdList() {
6988
+
6989
+	org_id := this.GetMobileAdminUserInfo().Org.Id
6990
+	fmt.Println("org_id23323322332323233232", org_id)
6991
+	schedule_date := this.GetString("schedule_date")
6992
+	schedule_type, _ := this.GetInt64("schedule_type")
6993
+	timeLayout := "2006-01-02"
6994
+	loc, _ := time.LoadLocation("Local")
6995
+	var startdateunix int64
6996
+	fmt.Println("schedule_date23323232233232323232", schedule_date)
6997
+	if len(schedule_date) > 0 {
6998
+		theTime, err := time.ParseInLocation(timeLayout+"15:04:05", schedule_date+"00:00:00", loc)
6999
+		if err != nil {
7000
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7001
+			return
7002
+		}
7003
+		startdateunix = theTime.Unix()
7004
+	}
7005
+	fmt.Println("startdateunix", startdateunix)
7006
+	list, _ := service.GetScheduleTypeById(org_id, startdateunix, schedule_type)
7007
+	scheduals, _ := service.MobileGetDialysisScheduals(org_id, startdateunix, schedule_type)
7008
+	devices, _ := service.GetAllDevicetByListSix(org_id)
7009
+	for key, item := range scheduals {
7010
+		// 床位信息
7011
+		for _, device := range devices {
7012
+			if item.BedId == device.ID {
7013
+				scheduals[key].DeviceNumber = device
7014
+				break
7015
+			}
7016
+		}
7017
+
7018
+	}
7019
+	this.ServeSuccessJSON(map[string]interface{}{
7020
+		"list":      list,
7021
+		"scheduals": scheduals,
7022
+	})
7023
+}

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

@@ -173,4 +173,6 @@ func MobileAPIControllersRegisterRouters() {
173 173
 	beego.Router("/m/api/patient/getschedulebypatient", &DialysisAPIController{}, "Get:GetScheduleByPatient")
174 174
 
175 175
 	beego.Router("/m/api/getdialysisrecordeorder", &DialysisAPIController{}, "Get:GetDialysisRecordOrder")
176
+
177
+	beego.Router("/m/api/getscheduletypebyidlist", &DialysisAPIController{}, "Get:GetScheduleTypeByIdList")
176 178
 }

+ 25 - 4
controllers/new_mobile_api_controllers/new_manage_api_controller.go View File

@@ -100,18 +100,39 @@ func (this *NewManageApiController) SaveDisInfectionInfo() {
100 100
 	orgid := adminUser.Org.Id
101 101
 	bedid, _ := this.GetInt64("bed_id")
102 102
 	start_time := this.GetString("start_time")
103
-	startdate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
104
-	startdateunix := startdate.Unix()
103
+	//startdate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
104
+	//startdateunix := startdate.Unix()
105 105
 	disinfectime, _ := this.GetInt64("disinfec_time")
106 106
 	endtime := this.GetString("end_time")
107
-	enddate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endtime)
108
-	enddateunix := enddate.Unix()
107
+	//enddate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endtime)
108
+	//enddateunix := enddate.Unix()
109 109
 
110 110
 	scheduledate, _ := this.GetInt64("schedule_date")
111 111
 	zoneid, _ := this.GetInt64("zone_id")
112 112
 	patientid, _ := this.GetInt64("patient_id")
113 113
 	modeid, _ := this.GetInt64("mode_id")
114 114
 	scheduletype, _ := this.GetInt64("schedule_type")
115
+	timeLayout := "2006-01-02"
116
+	loc, _ := time.LoadLocation("Local")
117
+	var startdateunix int64
118
+	if len(start_time) > 0 {
119
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04", start_time, loc)
120
+		if err != nil {
121
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
122
+			return
123
+		}
124
+		startdateunix = theTime.Unix()
125
+	}
126
+	var enddateunix int64
127
+	if len(endtime) > 0 {
128
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04", endtime, loc)
129
+		if err != nil {
130
+			utils.ErrorLog(err.Error())
131
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
132
+			return
133
+		}
134
+		enddateunix = theTime.Unix()
135
+	}
115 136
 
116 137
 	//查询病人信息
117 138
 	patients, _ := service.GetPatientInfoMation(patientid)

+ 15 - 15
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -752,17 +752,21 @@ func (c *StaffScheduleApiController) ChangeScheduleType() {
752 752
 	schedule_date, _ := c.GetInt64("schedule_date")
753 753
 	patient_id, _ := c.GetInt64("patient_id")
754 754
 	bed_id, _ := c.GetInt64("bed_id")
755
-	schedule_week, _ := c.GetInt64("schedule_week")
755
+	//schedule_week, _ := c.GetInt64("schedule_week")
756 756
 	mode_id, _ := c.GetInt64("mode_id")
757 757
 	id, _ := c.GetInt64("id")
758 758
 	org_id := c.GetMobileAdminUserInfo().Org.Id
759 759
 	//查询该班次该床位是否已经存在患者
760 760
 	schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
761 761
 	//查询该床位所属分区
762
-	numberlist, _ := service.GetPartionId(bed_id, org_id)
762
+	//numberlist, _ := service.GetPartionId(bed_id, org_id)
763 763
 	//存在
764 764
 	if schedule.ID > 0 {
765
-
765
+		order, _ := service.GetDialysisOrder(schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
766
+		if order.ID > 0 {
767
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSchedule)
768
+			return
769
+		}
766 770
 		//调换位置
767 771
 		sch := models.Schedule{
768 772
 			PatientId: schedule.PatientId,
@@ -778,20 +782,12 @@ func (c *StaffScheduleApiController) ChangeScheduleType() {
778 782
 
779 783
 	} else {
780 784
 		xtSchedule := models.Schedule{
781
-			UserOrgId:    org_id,
782
-			PartitionId:  numberlist.ZoneId,
783
-			BedId:        bed_id,
784
-			PatientId:    patient_id,
785 785
 			ScheduleDate: schedule_date,
786 786
 			ScheduleType: schedule_type,
787
-			ScheduleWeek: schedule_week,
788
-			ModeId:       mode_id,
789
-			Status:       1,
790
-			CreatedTime:  time.Now().Unix(),
791
-			UpdatedTime:  0,
792
-			IsExport:     0,
787
+			PatientId:    patient_id,
788
+			UserOrgId:    org_id,
793 789
 		}
794
-		service.CreateSchedule(&xtSchedule)
790
+		service.ChangeScheduleClass(xtSchedule)
795 791
 	}
796 792
 	c.ServeSuccessJSON(map[string]interface{}{
797 793
 		"msg": "ok",
@@ -800,7 +796,6 @@ func (c *StaffScheduleApiController) ChangeScheduleType() {
800 796
 
801 797
 func (c *StaffScheduleApiController) ChangeScheduleBed() {
802 798
 
803
-	fmt.Println("jin23323232233222323323232")
804 799
 	schedule_type, _ := c.GetInt64("schedule_type")
805 800
 	schedule_date, _ := c.GetInt64("schedule_date")
806 801
 	patient_id, _ := c.GetInt64("patient_id")
@@ -817,6 +812,11 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
817 812
 	//存在
818 813
 	if schedule.ID > 0 {
819 814
 
815
+		order, _ := service.GetDialysisOrder(schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
816
+		if order.ID > 0 {
817
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSchedule)
818
+			return
819
+		}
820 820
 		//调换位置
821 821
 		sch := models.Schedule{
822 822
 			PatientId: schedule.PatientId,

+ 7 - 1
controllers/patient_api_controller.go View File

@@ -581,6 +581,7 @@ func (c *PatientApiController) EditPatient() {
581 581
 		Lapseto:                   patient.Lapseto,
582 582
 		TrobleShoot:               patient.TrobleShoot,
583 583
 		SchRemark:                 patient.SchRemark,
584
+		TreatmentPlan:             patient.TreatmentPlan,
584 585
 	}
585 586
 	//	//更新病人ID获取新表病人ID
586 587
 	err = service.UpdatepatientTwo(&patientsNew, id)
@@ -917,6 +918,7 @@ func (c *PatientApiController) UpdateDialysisSolution() {
917 918
 			OxygenFlow:                 solution.OxygenFlow,
918 919
 			OxygenTime:                 solution.OxygenTime,
919 920
 			MaxUltrafiltrationRate:     solution.MaxUltrafiltrationRate,
921
+			Amylaceum:                  solution.Amylaceum,
920 922
 		}
921 923
 		service.UpdatePatientDialysisSolutionOne(solution.PatientId, adminUserInfo.CurrentOrgId, &prescription, todayTime.Unix())
922 924
 	}
@@ -3841,6 +3843,11 @@ func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, met
3841 3843
 		max_ultrafiltration_rate, _ := strconv.ParseFloat(dataBody["max_ultrafiltration_rate"].(string), 64)
3842 3844
 		solution.MaxUltrafiltrationRate = max_ultrafiltration_rate
3843 3845
 	}
3846
+
3847
+	if dataBody["amylaceum"] != nil && reflect.TypeOf(dataBody["amylaceum"]).String() == "string" {
3848
+		amylaceum := dataBody["amylaceum"].(string)
3849
+		solution.Amylaceum = amylaceum
3850
+	}
3844 3851
 	return
3845 3852
 }
3846 3853
 
@@ -5199,7 +5206,6 @@ func (c *PatientApiController) GetPatientDialysisLongSolution() {
5199 5206
 	for _, item := range list {
5200 5207
 		//获取该模式最新的1条数据
5201 5208
 		solution, _ := service.GetNewPatientSolutionByModeId(patient_id, item.ModeId, adminUserInfo.CurrentOrgId)
5202
-
5203 5209
 		//更新状态值
5204 5210
 		service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, adminUserInfo.CurrentOrgId, patient_id)
5205 5211
 	}

+ 96 - 0
controllers/stock_in_api_controller.go View File

@@ -149,8 +149,104 @@ func StockManagerApiRegistRouters() {
149 149
 	beego.Router("/api/stock/getprintlist", &StockManagerApiController{}, "Get:GetPrintList")
150 150
 
151 151
 	beego.Router("/api/stock/getwarehouseinfolist", &StockManagerApiController{}, "Get:GetInvetoryWarehouseInfoList")
152
+
153
+	//结算成功后调用操作库存相关接口
154
+	beego.Router("/api/settle/stock", &StockManagerApiController{}, "Get:HandleSettleStock")
155
+	beego.Router("/api/settle/cancelstock", &StockManagerApiController{}, "Get:HandleRefundStock")
152 156
 }
153 157
 
158
+func (c *StockManagerApiController) HandleRefundStock() {
159
+	order_id, _ := c.GetInt64("order_id", 0)
160
+	order, _ := service.GetHisOrderByIDThree(order_id)
161
+	if order.ID == 0 {
162
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
163
+		return
164
+	}
165
+	orders, _ := service.GetHisOrderDetailByNumberThree(order.Number, order.UserOrgId)
166
+	houseConfig, _ := service.GetAllStoreHouseConfig(order.UserOrgId)
167
+	var goods []*models.DialysisBeforePrepareGoods
168
+	var newGoods []*models.NewDialysisBeforePrepareGoods
169
+	var infos []*models.HisDoctorAdviceInfo
170
+
171
+	for _, info := range orders {
172
+		if info.AdviceId > 0 && info.ProjectId == 0 {
173
+			infos = append(infos, &info.HisDoctorAdviceInfo)
174
+		}
175
+		if info.ProjectId > 0 && info.AdviceId == 0 {
176
+			if info.HisPrescriptionProject.Type == 3 {
177
+				var good models.DialysisBeforePrepareGoods
178
+				var newGood models.NewDialysisBeforePrepareGoods
179
+				good.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
180
+				good.GoodTypeId = info.HisPrescriptionProject.VMGoodInfo.GoodTypeId
181
+				count, _ := strconv.Atoi(info.HisPrescriptionProject.Count)
182
+				good.Count = int64(count)
183
+				good.StorehouseId = houseConfig.StorehouseOutInfo
184
+				good.ProjectId = info.HisPrescriptionProject.ID
185
+				goods = append(goods, &good)
186
+
187
+				newGood.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
188
+				newGood.GoodTypeId = info.HisPrescriptionProject.VMGoodInfo.GoodTypeId
189
+				count2, _ := strconv.Atoi(info.HisPrescriptionProject.Count)
190
+				newGood.Count = int64(count2)
191
+				newGood.StorehouseId = houseConfig.StorehouseOutInfo
192
+				newGood.ProjectId = info.HisPrescriptionProject.ID
193
+				newGoods = append(newGoods, &newGood)
194
+			}
195
+		}
196
+	}
197
+	for _, item := range infos {
198
+		//service.HisDrugsDelivery(item.UserOrgId, order.Creator, item)
199
+		service.DrugAutoAddCancelInfo(item, order.Creator)
200
+
201
+	}
202
+
203
+}
204
+func (c *StockManagerApiController) HandleSettleStock() {
205
+
206
+	order_id, _ := c.GetInt64("order_id", 0)
207
+	order, _ := service.GetHisOrderByID(order_id)
208
+	if order.ID == 0 {
209
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
210
+		return
211
+	}
212
+
213
+	orders, _ := service.GetHisOrderDetailByNumberTwo(order.Number, order.UserOrgId)
214
+	houseConfig, _ := service.GetAllStoreHouseConfig(order.UserOrgId)
215
+	var goods []*models.DialysisBeforePrepareGoods
216
+	var newGoods []*models.NewDialysisBeforePrepareGoods
217
+	var infos []*models.HisDoctorAdviceInfo
218
+
219
+	for _, info := range orders {
220
+		if info.AdviceId > 0 && info.ProjectId == 0 {
221
+			infos = append(infos, &info.HisDoctorAdviceInfo)
222
+		}
223
+		if info.ProjectId > 0 && info.AdviceId == 0 {
224
+			if info.HisPrescriptionProject.Type == 3 {
225
+				var good models.DialysisBeforePrepareGoods
226
+				var newGood models.NewDialysisBeforePrepareGoods
227
+				good.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
228
+				good.GoodTypeId = info.HisPrescriptionProject.VMGoodInfo.GoodTypeId
229
+				count, _ := strconv.Atoi(info.HisPrescriptionProject.Count)
230
+				good.Count = int64(count)
231
+				good.StorehouseId = houseConfig.StorehouseOutInfo
232
+				good.ProjectId = info.HisPrescriptionProject.ID
233
+				goods = append(goods, &good)
234
+
235
+				newGood.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
236
+				newGood.GoodTypeId = info.HisPrescriptionProject.VMGoodInfo.GoodTypeId
237
+				count2, _ := strconv.Atoi(info.HisPrescriptionProject.Count)
238
+				newGood.Count = int64(count2)
239
+				newGood.StorehouseId = houseConfig.StorehouseOutInfo
240
+				newGood.ProjectId = info.HisPrescriptionProject.ID
241
+				newGoods = append(newGoods, &newGood)
242
+			}
243
+		}
244
+	}
245
+	service.ConsumablesDeliveryTotal(order.UserOrgId, order.PatientId, order.SettleAccountsDate, goods, newGoods, order.Creator)
246
+	for _, item := range infos {
247
+		service.HisDrugsDelivery(item.UserOrgId, order.Creator, item)
248
+	}
249
+}
154 250
 func (c *StockManagerApiController) CreateWarehouse() {
155 251
 
156 252
 	warehousing_time := c.GetString("warehousing_time")

+ 1 - 1
enums/error_code.go View File

@@ -514,7 +514,7 @@ var ErrCodeMsgs = map[int]string{
514 514
 	ErrorCodeDeletePChargeWrongTwo: "该医嘱所属处方已经收费或已经上传的处方,无法删除",
515 515
 
516 516
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
517
-	ErrorCodeSchedule:                 "该班次该床位已有患者",
517
+	ErrorCodeSchedule:                 "被调用床位已有患者上机",
518 518
 }
519 519
 
520 520
 type SGJError struct {

+ 15 - 0
models/device_models.go View File

@@ -1174,3 +1174,18 @@ func (XtScheduleSix) TableName() string {
1174 1174
 
1175 1175
 	return "xt_schedule"
1176 1176
 }
1177
+
1178
+type XtScheduleSeven struct {
1179
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
1180
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1181
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1182
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1183
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1184
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
1185
+	Count        int64
1186
+}
1187
+
1188
+func (XtScheduleSeven) TableName() string {
1189
+
1190
+	return "xt_schedule"
1191
+}

+ 2 - 0
models/dialysis.go View File

@@ -1103,6 +1103,8 @@ type NewDialysisBeforePrepareGoods struct {
1103 1103
 	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1104 1104
 	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1105 1105
 	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1106
+	RecordDate        int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1107
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1106 1108
 }
1107 1109
 
1108 1110
 type QueueCallConfig struct {

+ 3 - 0
models/drug.go View File

@@ -225,6 +225,9 @@ type BaseDrugLibTwenty struct {
225 225
 	MaxUnit        string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
226 226
 	MinNumber      int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
227 227
 	MinUnit        string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
228
+	Dose           string `gorm:"column:dose" json:"dose" form:"dose"`
229
+	DoseUnit       string `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
230
+	DrugStatus     string `gorm:"column:drug_status" json:"drug_status" form:"drug_status"`
228 231
 	DrugStockLimit string `gorm:"column:drug_stock_limit" json:"drug_stock_limit_count" form:"drug_stock_limit"`
229 232
 }
230 233
 

+ 1 - 0
models/new_monitor.go View File

@@ -110,6 +110,7 @@ type VMMonitoringRecord struct {
110 110
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
111 111
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
112 112
 	Status                 int64   `gorm:"column:status" json:"status"`
113
+	AccumulatedBloodVolume float64 `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
113 114
 }
114 115
 
115 116
 func (VMMonitoringRecord) TableName() string {

+ 25 - 1
models/schedule_models.go View File

@@ -366,13 +366,36 @@ type VmBloodScheduleTwo struct {
366 366
 	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
367 367
 	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
368 368
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
369
-	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
369
+	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
370 370
 }
371 371
 
372 372
 func (VmBloodScheduleTwo) TableName() string {
373 373
 	return "xt_schedule"
374 374
 }
375 375
 
376
+type VmBloodScheduleThree struct {
377
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
378
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
379
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
380
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
381
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
382
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
383
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
384
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
385
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
386
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
387
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
388
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
389
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
390
+	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
391
+	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
392
+	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
393
+}
394
+
395
+func (VmBloodScheduleThree) TableName() string {
396
+	return "xt_schedule"
397
+}
398
+
376 399
 type HisPrescriptionTemplateSix struct {
377 400
 	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
378 401
 	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -404,6 +427,7 @@ type HisPrescriptionInfoTemplateSix struct {
404 427
 	PType                               int64                                  `gorm:"column:p_type" json:"p_type" form:"p_type"`
405 428
 	PTemplateId                         int64                                  `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
406 429
 	HisPrescriptionProjectTemplateSeven []*HisPrescriptionProjectTemplateSeven `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
430
+	HisPrescriptionAdviceTemplate       []*HisPrescriptionAdviceTemplate       `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"his_advice"`
407 431
 	MedType                             string                                 `gorm:"column:med_type" json:"med_type" form:"med_type"`
408 432
 }
409 433
 

+ 23 - 0
service/dialysis_service.go View File

@@ -1862,3 +1862,26 @@ func GetDialysisRecordOrder(org_id int64, patient_id int64, dialysis_date int64)
1862 1862
 	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date = ? and status =1 ", org_id, patient_id, dialysis_date).Find(&order).Error
1863 1863
 	return order, err
1864 1864
 }
1865
+
1866
+func GetSolutionListByOrgId(orgid int64) (list []*models.DialysisSolution, err error) {
1867
+
1868
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Group("patient_id,mode_id").Order("id desc").Find(&list).Error
1869
+
1870
+	return list, err
1871
+}
1872
+
1873
+func GetScheduleTypeById(org_id int64, schedule_date int64, schedule_type int64) (list []*models.XtScheduleSeven, err error) {
1874
+
1875
+	db := XTReadDB().Model(&list).Where("status = 1")
1876
+	if org_id > 0 {
1877
+		db = db.Where("user_org_id = ?", org_id)
1878
+	}
1879
+	if schedule_date > 0 {
1880
+		db = db.Where("schedule_date = ?", schedule_date)
1881
+	}
1882
+	if schedule_type > 0 {
1883
+		db = db.Where("schedule_type = ?", schedule_type)
1884
+	}
1885
+	err = db.Select("partition_id,count(id) as count").Group("partition_id").Scan(&list).Error
1886
+	return list, err
1887
+}

+ 100 - 11
service/dialysis_solution_service.go View File

@@ -41,8 +41,8 @@ func GetLastPatientDialysisSolution(patient_id int64, orgid int64) (models.Dialy
41 41
 	return solution, err
42 42
 }
43 43
 
44
-func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
45
-
44
+func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, ids []string) (schedule []*models.VmBloodSchedule, total int64, err error) {
45
+	fmt.Println("ids23322332323232wode", len(ids))
46 46
 	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("xt_schedule.status = 1")
47 47
 	offset := (page - 1) * limit
48 48
 	if scheduleDate > 0 {
@@ -57,6 +57,9 @@ func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int6
57 57
 	if orgID > 0 {
58 58
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
59 59
 	}
60
+	if len(ids) >= 1 {
61
+		db = db.Where("xt_schedule.id in(?)", ids)
62
+	}
60 63
 
61 64
 	if len(keywords) > 0 {
62 65
 		keywords = "%" + keywords + "%"
@@ -67,10 +70,10 @@ func GetPatientDialysisSolutionGroupList(keywords string, limit int64, page int6
67 70
 		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
68 71
 		err = db.Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
69 72
 	} else {
70
-		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
73
+		err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
71 74
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
72 75
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
73
-			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID).Find(&schedule).Error
76
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID).Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
74 77
 	}
75 78
 
76 79
 	return schedule, total, err
@@ -92,7 +95,7 @@ func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, par
92 95
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
93 96
 	}
94 97
 	fmt.Println("idArray23233223323232233232", len(idArray))
95
-	if len(idArray) > 1 {
98
+	if len(idArray) >= 1 {
96 99
 		db = db.Where("xt_schedule.id in(?)", idArray)
97 100
 	}
98 101
 
@@ -113,7 +116,7 @@ func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, par
113 116
 
114 117
 func GetAllLongAdviceList(user_org_id int64) (advice []*models.DoctorAdvice, err error) {
115 118
 
116
-	err = XTReadDB().Where("user_org_id = ? and advice_type = 1 and status = 1", user_org_id).Find(&advice).Error
119
+	err = XTReadDB().Where("user_org_id = ? and advice_type = 1 and status = 1 and stop_state!=1", user_org_id).Find(&advice).Error
117 120
 	return advice, err
118 121
 }
119 122
 
@@ -136,7 +139,7 @@ func GetDialysisSetting(orgid int64) (models.XtDialysisSetting, error) {
136 139
 	return setting, err
137 140
 }
138 141
 
139
-func GetDialysisParameterList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodSchedule, total int64, err error) {
142
+func GetDialysisParameterList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, ids []string) (schedule []*models.VmBloodSchedule, total int64, err error) {
140 143
 	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("xt_schedule.status = 1")
141 144
 	offset := (page - 1) * limit
142 145
 	if scheduleDate > 0 {
@@ -151,13 +154,16 @@ func GetDialysisParameterList(keywords string, limit int64, page int64, partitio
151 154
 	if orgID > 0 {
152 155
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
153 156
 	}
157
+	if len(ids) >= 1 {
158
+		db = db.Where("xt_schedule.id in(?)", ids)
159
+	}
154 160
 
155 161
 	if len(keywords) > 0 {
156 162
 		keywords = "%" + keywords + "%"
157 163
 		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
158 164
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
159 165
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
160
-			Preload("DialysisSolution", "status = 1 AND user_org_id = ?", orgID).
166
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID).
161 167
 			Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
162 168
 			Preload("XtAssessmentBeforeDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
163 169
 			Preload("ReceiveTreatmentAsses", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
@@ -170,7 +176,7 @@ func GetDialysisParameterList(keywords string, limit int64, page int64, partitio
170 176
 	} else {
171 177
 		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
172 178
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
173
-			Preload("DialysisSolution", "status = 1 AND user_org_id = ?", orgID).
179
+			Preload("DialysisSolution", "status = 1 AND user_org_id = ? and solution_status = 1", orgID).
174 180
 			Preload("DialysisPrescription", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
175 181
 			Preload("XtAssessmentBeforeDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
176 182
 			Preload("ReceiveTreatmentAsses", "status = 1 AND user_org_id = ? and record_date = ?", orgID, scheduleDate).
@@ -236,6 +242,85 @@ func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id
236 242
 
237 243
 }
238 244
 
245
+func GetDialysisAdviceSchedulistTwo(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleTwo, err error) {
246
+
247
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("status = 1")
248
+
249
+	if scheduleDate > 0 {
250
+		db = db.Where("schedule_date = ?", scheduleDate)
251
+	}
252
+	if schedule_type > 0 {
253
+		db = db.Where("schedule_type = ?", schedule_type)
254
+	}
255
+	if partition_id > 0 {
256
+		db = db.Where("partition_id = ?", partition_id)
257
+	}
258
+	if orgID > 0 {
259
+		db = db.Where("user_org_id  = ?", orgID)
260
+	}
261
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
262
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
263
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
264
+		Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
265
+			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
266
+				return db.Where("user_org_id = ? and status = 1 and type = 1", orgID).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
267
+					return db.Where("user_org_id = ? and status = 1", orgID).Preload("Drug", "org_id =? and status = 1", orgID)
268
+				})
269
+			})
270
+		}).Find(&schedule).Error
271
+
272
+	return schedule, err
273
+
274
+}
275
+
276
+func GetDialysisAdviceSchedulistSix(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, idArray []string) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
277
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
278
+	offset := (page - 1) * limit
279
+	if scheduleDate > 0 {
280
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
281
+	}
282
+	if schedule_type > 0 {
283
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
284
+	}
285
+	if partition_id > 0 {
286
+		db = db.Where("xt_schedule.partition_id = ?", partition_id)
287
+	}
288
+	if orgID > 0 {
289
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
290
+	}
291
+	if len(idArray) >= 1 {
292
+		db = db.Where("xt_schedule.id in(?)", idArray)
293
+	}
294
+
295
+	if len(keywords) > 0 {
296
+		keywords = "%" + keywords + "%"
297
+		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
298
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
299
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
300
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
301
+			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
302
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
303
+					return db.Where("user_org_id = ? and status = 1 and type = 1", orgID).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
304
+						return db.Where("user_org_id = ? and status = 1", orgID).Preload("Drug", "org_id =? and status = 1", orgID)
305
+					})
306
+				})
307
+			}).Find(&schedule).Error
308
+	} else {
309
+		err = db.Count(&total).Offset(offset).Limit(limit).Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
310
+			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
311
+			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
312
+			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
313
+				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
314
+					return db.Where("user_org_id = ? and status = 1 and type = 1", orgID).Preload("HisPrescriptionAdviceTemplate", func(db *gorm.DB) *gorm.DB {
315
+						return db.Where("user_org_id = ? and status = 1", orgID).Preload("Drug", "org_id =? and status = 1", orgID)
316
+					})
317
+				})
318
+			}).Find(&schedule).Error
319
+	}
320
+
321
+	return schedule, total, err
322
+}
323
+
239 324
 func GetAllDrugMap(org_id int64) (list []*BaseDrugLib, err error) {
240 325
 
241 326
 	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
@@ -259,6 +344,7 @@ func GetDialysisParameterGoodList(orgID int64, schedule_type int64, partition_id
259 344
 		db = db.Where("user_org_id  = ?", orgID)
260 345
 	}
261 346
 	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
347
+		Preload("DialysisSolution", "status=1 and user_org_id = ? and solution_status = 1", orgID).
262 348
 		Preload("DialysisPrescription", "status = 1 and user_org_id = ?", orgID).
263 349
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
264 350
 		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ?", orgID, scheduleDate).
@@ -277,8 +363,8 @@ func SaveHisDialysis(orgid int64, ids []string) error {
277 363
 	return err
278 364
 }
279 365
 
280
-func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
281
-
366
+func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, ids []string) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
367
+	fmt.Println("ids23322332323232hhha", ids)
282 368
 	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
283 369
 	offset := (page - 1) * limit
284 370
 	if scheduleDate > 0 {
@@ -293,6 +379,9 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
293 379
 	if orgID > 0 {
294 380
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
295 381
 	}
382
+	if len(ids) >= 1 {
383
+		db = db.Where("xt_schedule.id in(?)", ids)
384
+	}
296 385
 
297 386
 	if len(keywords) > 0 {
298 387
 		keywords = "%" + keywords + "%"

+ 6 - 0
service/gobal_config_service.go View File

@@ -990,3 +990,9 @@ func GetDrugWarehouseOutInfoFlow(drug_id int64, start_time int64, end_time int64
990 990
 	err = db.Find(&info).Error
991 991
 	return info, err
992 992
 }
993
+
994
+func GetAllBaseDrugListTwenty(orgid int64) (drug []*models.BaseDrugLibTwenty, err error) {
995
+
996
+	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1 AND  find_in_set('停用',drug_status) = 0", orgid).Find(&drug).Error
997
+	return drug, err
998
+}

+ 48 - 0
service/his_service.go View File

@@ -2540,3 +2540,51 @@ func GetHisPrescriptonProjectById(id int64) (models.HisPrescriptionProject, erro
2540 2540
 	err := XTReadDB().Where("id = ? and status = 1", id).Find(&project).Error
2541 2541
 	return project, err
2542 2542
 }
2543
+
2544
+type HisOrderInfoTwo struct {
2545
+	ID                     int64                      `gorm:"column:id" json:"id" form:"id"`
2546
+	OrderNumber            string                     `gorm:"column:order_number" json:"order_number" form:"order_number"`
2547
+	UploadDate             int64                      `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
2548
+	AdviceId               int64                      `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
2549
+	DetItemFeeSumamt       float64                    `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
2550
+	Cnt                    float64                    `gorm:"column:cnt" json:"cnt" form:"cnt"`
2551
+	Pric                   float64                    `gorm:"column:pric" json:"pric" form:"pric"`
2552
+	PatientId              int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2553
+	MedChrgitmType         string                     `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
2554
+	Status                 int64                      `gorm:"column:status" json:"status" form:"status"`
2555
+	FeedetlSn              string                     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
2556
+	ChldMedcFlag           string                     `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
2557
+	ChrgitmLv              string                     `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
2558
+	UserOrgId              int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2559
+	ProjectId              int64                      `gorm:"column:project_id" json:"project_id" form:"project_id"`
2560
+	ItemId                 int64                      `gorm:"column:item_id" json:"item_id" form:"item_id"`
2561
+	FulamtOwnpayAmt        float64                    `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
2562
+	HisPrescriptionProject HisPrescriptionProject     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
2563
+	HisDoctorAdviceInfo    models.HisDoctorAdviceInfo `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
2564
+}
2565
+
2566
+func (HisOrderInfoTwo) TableName() string {
2567
+	return "his_order_info"
2568
+}
2569
+func GetHisOrderDetailByNumberTwo(order_number string, org_id int64) (order []*HisOrderInfoTwo, err error) {
2570
+	err = readDb.Model(&HisOrderInfoTwo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2571
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
2572
+	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2573
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
2574
+	}).Find(&order).Error
2575
+	return
2576
+}
2577
+
2578
+func GetHisOrderDetailByNumberThree(order_number string, org_id int64) (order []*HisOrderInfoTwo, err error) {
2579
+	err = readDb.Model(&HisOrderInfoTwo{}).Where("order_number = ?", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2580
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("VMHisProject", "status = 1 AND user_org_id = ?", org_id).Preload("VMGoodInfo", "status = 1 AND org_id = ?", org_id)
2581
+	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2582
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
2583
+	}).Find(&order).Error
2584
+	return
2585
+}
2586
+
2587
+func GetHisOrderByIDThree(order_id int64) (order models.HisOrder, err error) {
2588
+	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
2589
+	return
2590
+}

+ 1 - 1
service/his_summary_service.go View File

@@ -9,7 +9,7 @@ import (
9 9
 func GetHisSummaryDetailList(keyword string, item_type int64, patient_id int64, org_id int64, start_time int64, end_time int64) (patients []*models.ChargePatient, err error) {
10 10
 
11 11
 	err = XTReadDB().Table("xt_patients as p").Select("p.id,p.user_org_id,p.name,p.lapseto,p.status").Joins("JOIN his_order AS orders ON orders.patient_id = p.id AND orders.status = 1  AND orders.ctime >= ? AND orders.ctime <= ? AND orders.user_org_id = ? AND orders.order_status = 2 and orders.patient_id = ?", start_time, end_time, org_id, patient_id).Preload("HisChargeOrder", func(db *gorm.DB) *gorm.DB {
12
-		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id,psn_cash_pay,acct_pay,fund_pay_sumamt,is_medicine_insurance,medfee_sumamt").
12
+		return db.Select("id,user_org_id,his_patient_id,settle_accounts_date,status,number,order_status,mdtrt_id,patient_id,psn_cash_pay,acct_pay,fund_pay_sumamt,is_medicine_insurance,medfee_sumamt,maf_pay,hifes_pay").
13 13
 			Preload("HisChargeOrderInfo", func(db *gorm.DB) *gorm.DB {
14 14
 				return db.Select("id,order_number,advice_id,det_item_fee_sumamt,cnt,pric,med_chrgitm_type,status,chld_medc_flag,chrgitm_lv,user_org_id,project_id,type").Where("status = 1").
15 15
 					Preload("HisChargeDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {

+ 119 - 0
service/manage_center_service.go View File

@@ -867,3 +867,122 @@ func DrugAutoAddCancelInfo(advice *models.HisDoctorAdviceInfo, creater int64) er
867 867
 	}
868 868
 	return err
869 869
 }
870
+
871
+func GoodAutoAddCancelInfo(good *models.NewDialysisBeforePrepareGoods, creater int64) error {
872
+
873
+	//查询已经出库数量
874
+	info, _ := GetWareOutInfo(good.GoodId, good.RecordDate, good.UserOrgId)
875
+	if len(info) > 0 {
876
+		houseConfig, _ := GetAllStoreHouseConfig(good.UserOrgId)
877
+
878
+		operation_time := time.Now().Unix()
879
+		//创建退库单
880
+		timeStr := time.Now().Format("2006-01-02")
881
+		timeArr := strings.Split(timeStr, "-")
882
+		total, _ := FindAllCancelStockTotal(good.UserOrgId)
883
+		total = total + 1
884
+		orderNumber := "CKTKD" + strconv.FormatInt(good.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
885
+
886
+		cancelStock := models.CancelStock{
887
+			OrderNumber:  orderNumber,
888
+			OperaTime:    operation_time,
889
+			OrgId:        good.UserOrgId,
890
+			Creater:      creater,
891
+			Ctime:        time.Now().Unix(),
892
+			Status:       1,
893
+			ReturnTime:   good.RecordDate,
894
+			Type:         1,
895
+			StorehouseId: houseConfig.StorehouseOutInfo,
896
+			IsCheck:      1,
897
+		}
898
+		_, msgerrkonde := GetCancelStockDetailByOrderNumberOne(good.RecordDate, good.UserOrgId)
899
+		if msgerrkonde == gorm.ErrRecordNotFound {
900
+			AddSigleCancelStock(&cancelStock)
901
+		}
902
+		cancel, _ := GetLastCancelStockById(good.UserOrgId)
903
+		for _, item := range info {
904
+			manufacturer, _ := GetManufactureById(item.Manufacturer)
905
+			deaerler, _ := GetDealerById(item.Dealer)
906
+
907
+			cancelStockInfo := models.CancelStockInfo{
908
+				GoodId:          good.GoodId,
909
+				CancelStockId:   cancel.ID,
910
+				GoodTypeId:      good.GoodTypeId,
911
+				Count:           item.Count,
912
+				Price:           item.Price,
913
+				Total:           0,
914
+				ProductDate:     item.ProductDate,
915
+				ExpiryDate:      item.ExpiryDate,
916
+				Ctime:           time.Now().Unix(),
917
+				Status:          1,
918
+				OrgId:           good.UserOrgId,
919
+				OrderNumber:     cancel.OrderNumber,
920
+				Type:            0,
921
+				Dealer:          deaerler.DealerName,
922
+				Manufacturer:    manufacturer.ManufacturerName,
923
+				Number:          item.Number,
924
+				RegisterAccount: "",
925
+				Remark:          "",
926
+				WarehouseInfoId: item.WarehouseInfotId,
927
+				PatientId:       item.PatientId,
928
+				RecordDate:      item.SysRecordTime,
929
+				StorehouseId:    houseConfig.StorehouseOutInfo,
930
+				IsCheck:         1,
931
+			}
932
+
933
+			CreateCancelStockInfoOne(&cancelStockInfo)
934
+			cancelInfo, _ := GetLastCancelStockInfoByGoodId(good.GoodId)
935
+			goodList, _ := GetSumGoodList(item.OrgId, houseConfig.StorehouseOutInfo, item.GoodId)
936
+			var over_count int64
937
+			for _, it := range goodList {
938
+				over_count += it.StockCount
939
+			}
940
+			flow := models.VmStockFlow{
941
+				WarehousingId:           item.WarehouseInfotId,
942
+				GoodId:                  item.GoodId,
943
+				Number:                  item.Number,
944
+				LicenseNumber:           item.LicenseNumber,
945
+				Count:                   item.Count,
946
+				UserOrgId:               item.OrgId,
947
+				PatientId:               item.PatientId,
948
+				SystemTime:              item.SysRecordTime,
949
+				ConsumableType:          7,
950
+				IsSys:                   0,
951
+				WarehousingOrder:        "",
952
+				WarehouseOutId:          item.WarehouseOutId,
953
+				WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
954
+				IsEdit:                  0,
955
+				CancelStockId:           cancel.ID,
956
+				CancelOrderNumber:       cancel.OrderNumber,
957
+				Manufacturer:            manufacturer.ID,
958
+				Dealer:                  0,
959
+				Creator:                 creater,
960
+				UpdateCreator:           0,
961
+				Status:                  1,
962
+				Ctime:                   time.Now().Unix(),
963
+				Mtime:                   0,
964
+				Price:                   item.Price,
965
+				WarehousingDetailId:     item.WarehouseInfotId,
966
+				WarehouseOutDetailId:    item.ID,
967
+				CancelOutDetailId:       cancelInfo.ID,
968
+				ProductDate:             item.ProductDate,
969
+				ExpireDate:              item.ExpiryDate,
970
+				StorehouseId:            houseConfig.StorehouseOutInfo,
971
+				OverCount:               over_count,
972
+			}
973
+			CreateStockFlowOne(flow)
974
+
975
+			//回退库存
976
+			UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
977
+			//退库数量增加
978
+			UpdateSumAddCancelCount(good.UserOrgId, good.GoodId, houseConfig.StorehouseOutInfo, good.Count)
979
+			//出库数量减少
980
+			UpdateSumCount(good.UserOrgId, houseConfig.StorehouseOutInfo, good.GoodId, good.Count)
981
+			//删除出库表
982
+			DeleteAutoRedeceDetailTen(good.UserOrgId, item.PatientId, item.SysRecordTime, item.GoodId)
983
+			//更新剩余库存
984
+			UpdateSumGood(good.UserOrgId, houseConfig.StorehouseOutInfo, item.GoodId, over_count)
985
+		}
986
+	}
987
+	return err
988
+}

+ 2 - 1
service/mobile_dialysis_service.go View File

@@ -37,7 +37,7 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
37 37
 		db = db.Where("schedule_type = ?", scheduleType)
38 38
 	}
39 39
 
40
-	err := db.Find(&vms).Error
40
+	err := db.Preload("DialysisSolution", "status = 1 and user_org_id = ? and solution_status = 1", orgID).Find(&vms).Error
41 41
 	return vms, err
42 42
 }
43 43
 
@@ -135,6 +135,7 @@ type MDialysisScheduleVMForList struct {
135 135
 	HisAdvices               []VMHisDoctorAdviceInfo           `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"his_doctor_advice"`
136 136
 	Advices                  []models.VMDoctorAdviceForList    `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
137 137
 	TreatmentSummary         *models.VMTreatmentSummaryForList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
138
+	DialysisSolution         *models.DialysisSolution          `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
138 139
 }
139 140
 
140 141
 func (MDialysisScheduleVMForList) TableName() string {

+ 6 - 0
service/new_stock_service.go View File

@@ -359,3 +359,9 @@ func UpdateLastAutoCount(id int64, count int64) error {
359 359
 	err := XTWriteDB().Model(&detail).Where("id = ?", id).Update(map[string]interface{}{"count": count, "status": 1}).Error
360 360
 	return err
361 361
 }
362
+
363
+func GetWareOutInfo(good_id int64, record_date int64, user_org_id int64) (outinfo []*models.WarehouseOutInfo, err error) {
364
+
365
+	err = XTReadDB().Where("good_id = ? and sys_record_time = ? and org_id = ? and status = 1", good_id, record_date, user_org_id).Find(&outinfo).Error
366
+	return outinfo, err
367
+}

+ 1 - 0
service/new_warehouse_service.go View File

@@ -1838,6 +1838,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1838 1838
 				OverCount:               sum_count,
1839 1839
 				AdviceId:                advice.ID,
1840 1840
 				LastPrice:               warehouse.Price,
1841
+				SystemTime:              advice.AdviceDate,
1841 1842
 			}
1842 1843
 
1843 1844
 			CreateDrugFlowOne(drugflow)

+ 15 - 2
service/patient_service.go View File

@@ -830,7 +830,7 @@ func UpdatePatientLapseto(patientid int64, lapseto models.PatientLapseto) error
830 830
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
831 831
 
832 832
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
833
-		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark}).Error
833
+		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark, "treatment_plan": patientsNew.TreatmentPlan}).Error
834 834
 	return err
835 835
 }
836 836
 
@@ -2459,7 +2459,7 @@ func GetAllMonitorList(orgID int64, scheduleDate int64) (monitor []*models.VMMon
2459 2459
 	monitor_record_list_all, _ := redis.Get(key).Result()
2460 2460
 	fmt.Println("monitor_recorde_list", len(monitor_record_list_all))
2461 2461
 	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2462
-		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2462
+		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Order("monitoring_date asc").Find(&monitor).Error
2463 2463
 		if err != nil {
2464 2464
 			if err == gorm.ErrRecordNotFound {
2465 2465
 				return nil, nil
@@ -2645,6 +2645,19 @@ func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*mod
2645 2645
 	return project, err
2646 2646
 }
2647 2647
 
2648
+func GetZoneCountList(orgid int64, schedule_date int64) (list []*models.XtScheduleSeven, err error) {
2649
+
2650
+	db := XTReadDB().Model(&list).Where("status = 1")
2651
+	if orgid > 0 {
2652
+		db = db.Where("user_org_id = ?", orgid)
2653
+	}
2654
+	if schedule_date > 0 {
2655
+		db = db.Where("schedule_date =?", schedule_date)
2656
+	}
2657
+	err = db.Select("partition_id,count(id) as count").Group("partition_id").Scan(&list).Error
2658
+	return list, err
2659
+}
2660
+
2648 2661
 func GetPatientDialysisLongSolution(patient_id int64, page int64, limit int64, orgid int64) (solution []*models.DialysisSolution, total int64, err error) {
2649 2662
 
2650 2663
 	db := XTReadDB().Model(&solution).Where("status = 1 and solution_status = 1")

+ 6 - 0
service/schedule_service.go View File

@@ -1199,3 +1199,9 @@ func GetLastWeightAfter(patient_id int64, scheduleDate int64, orgid int64) (mode
1199 1199
 	err := XTReadDB().Where("user_org_id = ? and  patient_id = ? and assessment_date < ? and status = 1", orgid, patient_id, scheduleDate).Order("id desc").First(&dislysis).Error
1200 1200
 	return dislysis, err
1201 1201
 }
1202
+
1203
+func ChangeScheduleClass(schedule models.Schedule) error {
1204
+
1205
+	err := XTWriteDB().Model(&schedule).Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status = 1", schedule.PatientId, schedule.ScheduleDate, schedule.UserOrgId).Update(map[string]interface{}{"schedule_type": schedule.ScheduleType}).Error
1206
+	return err
1207
+}