Browse Source

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

csx 2 years ago
parent
commit
2070107c4e
43 changed files with 11096 additions and 638 deletions
  1. 788 33
      controllers/dialysis_api_controller.go
  2. 27 4
      controllers/dialysis_record_api_controller.go
  3. 145 97
      controllers/doctors_api_controller.go
  4. 3 0
      controllers/drug_pharmacy_management_controller.go
  5. 7 8
      controllers/drug_stock_api_contorller.go
  6. 42 1
      controllers/gobal_config_api_controller.go
  7. 421 28
      controllers/his_api_controller.go
  8. 7 1
      controllers/mobile_api_controllers/check_weight_api_controller.go
  9. 578 31
      controllers/mobile_api_controllers/dialysis_api_controller.go
  10. 1 0
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  11. 8 4
      controllers/mobile_api_controllers/doctor_advice_api_controller.go
  12. 10 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  13. 46 10
      controllers/mobile_api_controllers/patient_api_controller.go
  14. 25 4
      controllers/new_mobile_api_controllers/new_manage_api_controller.go
  15. 20 16
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  16. 10 5
      controllers/patient_api_controller.go
  17. 114 30
      controllers/print_data_api_controller.go
  18. 65 2
      controllers/schedule_api_controller.go
  19. 15 0
      models/device_models.go
  20. 171 19
      models/dialysis.go
  21. 3 0
      models/drug.go
  22. 12 0
      models/good_models.go
  23. 16 0
      models/his_models.go
  24. 1 0
      models/new_monitor.go
  25. 46 0
      models/patient_models.go
  26. 84 16
      models/schedule_models.go
  27. 176 0
      service/dialysis_service.go
  28. 100 11
      service/dialysis_solution_service.go
  29. 20 3
      service/doctor_schedule_service.go
  30. 6 0
      service/gobal_config_service.go
  31. 115 0
      service/his_service.go
  32. 119 0
      service/manage_center_service.go
  33. 4 13
      service/manage_service.go
  34. 1261 198
      service/mobile_dialysis_service.go
  35. 6 0
      service/new_stock_service.go
  36. 13 9
      service/new_warehouse_service.go
  37. 125 78
      service/patient_service.go
  38. 144 1
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  39. 134 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go
  40. 27 6
      service/schedule_service.go
  41. 89 1
      service/stock_service.go
  42. 1 1
      service/user_service.go
  43. 6091 8
      service/warhouse_service.go

+ 788 - 33
controllers/dialysis_api_controller.go View File

@@ -97,6 +97,16 @@ 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")
102
+
103
+	beego.Router("/api/schedule/excutiondoctoradvice", &DialysisApiController{}, "Get:ExcutionDoctorAdvice")
104
+
105
+	beego.Router("/api/schedule/checknewdoctoradvice", &DialysisApiController{}, "Get:CheckNewDoctorAdvice")
106
+
107
+	beego.Router("/api/schedule/settlenewdoctoradvice", &DialysisApiController{}, "Get:SettleNewDoctorAdvice")
108
+
109
+	beego.Router("/api/schedule/excutiondoctoradvicebyid", &DialysisApiController{}, "Get:ExcutionDoctorAdviceById")
100 110
 }
101 111
 
102 112
 func (c *DialysisApiController) GetQueueCall() {
@@ -309,6 +319,8 @@ func (c *DialysisApiController) PostPrescription() {
309 319
 	drhy_water := c.GetString("drhy_water")
310 320
 	dry_water_hour := c.GetString("dry_water_hour")
311 321
 	water_machine := c.GetString("water_machine")
322
+	add_amount, _ := c.GetFloat("add_amount")
323
+	reduce_amount, _ := c.GetFloat("reduce_amount")
312 324
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
313 325
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
314 326
 
@@ -414,6 +426,8 @@ func (c *DialysisApiController) PostPrescription() {
414 426
 		DrhyWater:                  drhy_water,
415 427
 		DryWaterHour:               dry_water_hour,
416 428
 		WaterMachine:               water_machine,
429
+		AddAmount:                  add_amount,
430
+		ReduceAmount:               reduce_amount,
417 431
 	}
418 432
 
419 433
 	if appRole.UserType == 2 || appRole.UserType == 1 {
@@ -643,6 +657,8 @@ func (c *DialysisApiController) PostSoulution() {
643 657
 	dry_water_hour := c.GetString("dry_water_hour")
644 658
 	drhy_water := c.GetString("drhy_water")
645 659
 	water_machine := c.GetString("water_machine")
660
+	add_amount, _ := c.GetFloat("add_amount")
661
+	reduce_amount, _ := c.GetFloat("reduce_amount")
646 662
 	var prescription_doctor int64
647 663
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
648 664
 
@@ -760,6 +776,8 @@ func (c *DialysisApiController) PostSoulution() {
760 776
 		DryWaterHour:               dry_water_hour,
761 777
 		DrhyWater:                  drhy_water,
762 778
 		WaterMachine:               water_machine,
779
+		AddAmount:                  add_amount,
780
+		ReduceAmount:               reduce_amount,
763 781
 	}
764 782
 
765 783
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -3457,7 +3475,7 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
3457 3475
 		advice.UserOrgId = adminUserInfo.CurrentOrgId
3458 3476
 		advice.PatientId = patient
3459 3477
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3460
-
3478
+		advice.IsSettle = 2
3461 3479
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
3462 3480
 			utils.ErrorLog("advice_name")
3463 3481
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -3584,7 +3602,7 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
3584 3602
 					child.UserOrgId = adminUserInfo.CurrentOrgId
3585 3603
 					child.PatientId = patient
3586 3604
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
3587
-
3605
+					child.IsSettle = 2
3588 3606
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
3589 3607
 						utils.ErrorLog("child advice_name")
3590 3608
 						return
@@ -3690,15 +3708,16 @@ func (c *DialysisApiController) GetSolution() {
3690 3708
 	solution, err := service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3691 3709
 	prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3692 3710
 	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, mode_id)
3693
-
3711
+	dialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient_id, adminUserInfo.CurrentOrgId)
3694 3712
 	if err != nil {
3695 3713
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3696 3714
 		return
3697 3715
 	}
3698 3716
 	c.ServeSuccessJSON(map[string]interface{}{
3699
-		"solution":            solution,
3700
-		"prescription":        prescription,
3701
-		"system_prescription": system_prescription,
3717
+		"solution":             solution,
3718
+		"prescription":         prescription,
3719
+		"system_prescription":  system_prescription,
3720
+		"dialysisPrescription": dialysisPrescription,
3702 3721
 	})
3703 3722
 
3704 3723
 }
@@ -3802,7 +3821,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
3802 3821
 				record.UltrafiltrationRate = ultrafiltration_rate
3803 3822
 			}
3804 3823
 
3805
-			if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 {
3824
+			if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 || adminInfo.CurrentOrgId == 10432 {
3806 3825
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3807 3826
 
3808 3827
 				record.UltrafiltrationRate = ultrafiltration_rate
@@ -3830,7 +3849,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
3830 3849
 
3831 3850
 	}
3832 3851
 
3833
-	if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 {
3852
+	if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 || adminInfo.CurrentOrgId == 10432 {
3834 3853
 
3835 3854
 		if ultrafiltration_rate > 0 {
3836 3855
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
@@ -4302,6 +4321,13 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4302 4321
 	schedule_type, _ := this.GetInt64("schedule_type")
4303 4322
 
4304 4323
 	start_time := this.GetString("schedule_date")
4324
+
4325
+	advice_ids := this.GetString("ids")
4326
+	var ids []string
4327
+	if advice_ids != "" {
4328
+		ids = strings.Split(advice_ids, ",")
4329
+	}
4330
+
4305 4331
 	timeLayout := "2006-01-02"
4306 4332
 	loc, _ := time.LoadLocation("Local")
4307 4333
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -4311,7 +4337,7 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4311 4337
 
4312 4338
 	goodType, _ := service.GetAllGoodType(orgId)
4313 4339
 	if config.IsOpen != 1 {
4314
-		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4340
+		list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4315 4341
 		fmt.Println("list2232323223332323232", list)
4316 4342
 		if err == nil {
4317 4343
 			this.ServeSuccessJSON(map[string]interface{}{
@@ -4328,7 +4354,7 @@ func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
4328 4354
 		}
4329 4355
 	}
4330 4356
 	if config.IsOpen == 1 {
4331
-		list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4357
+		list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4332 4358
 		if err == nil {
4333 4359
 			this.ServeSuccessJSON(map[string]interface{}{
4334 4360
 				"list":     list,
@@ -4358,32 +4384,35 @@ func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
4358 4384
 	start_time := this.GetString("schedule_date")
4359 4385
 
4360 4386
 	ids := this.GetString("ids")
4361
-	idArray := strings.Split(ids, ",")
4387
+
4388
+	var idArray []string
4389
+	if ids != "" {
4390
+		idArray = strings.Split(ids, ",")
4391
+	}
4392
+
4362 4393
 	timeLayout := "2006-01-02"
4363 4394
 	loc, _ := time.LoadLocation("Local")
4364 4395
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4365 4396
 
4366 4397
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4367
-	fmt.Println("idArray", idArray)
4398
+
4368 4399
 	list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
4369
-	fmt.Println("list2323223323223323323223wi", list)
4400
+
4401
+	tablelist, _, err := service.GetDialysisAdviceSchedulistSix(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
4370 4402
 	//获取长期医嘱
4371 4403
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4372 4404
 
4373
-	//获取医嘱模版
4374
-	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4375
-
4376 4405
 	_, config := service.FindXTHisRecordByOrgId(orgId)
4377 4406
 
4378
-	drugList, _ := service.GetAllBaseDrugList(orgId)
4407
+	drugList, _ := service.GetAllBaseDrugListTwenty(orgId)
4379 4408
 	if err == nil {
4380 4409
 		this.ServeSuccessJSON(map[string]interface{}{
4381
-			"list":         list,
4382
-			"total":        total,
4383
-			"adviceList":   adviceList,
4384
-			"templateList": templateList,
4385
-			"config":       config,
4386
-			"drugList":     drugList,
4410
+			"list":       list,
4411
+			"total":      total,
4412
+			"adviceList": adviceList,
4413
+			"config":     config,
4414
+			"drugList":   drugList,
4415
+			"tablelist":  tablelist,
4387 4416
 		})
4388 4417
 		return
4389 4418
 
@@ -4499,7 +4528,12 @@ func (this *DialysisApiController) GetDialysisParameterList() {
4499 4528
 
4500 4529
 	orgId := this.GetAdminUserInfo().CurrentOrgId
4501 4530
 
4502
-	list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId)
4531
+	scheduids := this.GetString("ids")
4532
+	var ids []string
4533
+	if scheduids != "" {
4534
+		ids = strings.Split(scheduids, ",")
4535
+	}
4536
+	list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
4503 4537
 
4504 4538
 	dialysisSett, _ := service.GetDialysisSetting(orgId)
4505 4539
 	if err == nil {
@@ -4556,20 +4590,21 @@ func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
4556 4590
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4557 4591
 
4558 4592
 	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
4559
-	drug, _ := service.GetAllDrugMap(orgId)
4593
+
4594
+	tablelist, _ := service.GetDialysisAdviceSchedulistTwo(orgId, schedule_type, partion_type, startTime.Unix())
4595
+
4560 4596
 	//获取长期医嘱
4561 4597
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
4562
-	//获取医嘱模版
4563
-	templateList, _ := service.GetAllHisAdviceTemplateList(orgId)
4564 4598
 
4599
+	drug, _ := service.GetAllBaseDrugListTwenty(orgId)
4565 4600
 	_, config := service.FindXTHisRecordByOrgId(orgId)
4566 4601
 	if err == nil {
4567 4602
 		this.ServeSuccessJSON(map[string]interface{}{
4568
-			"list":         list,
4569
-			"drug":         drug,
4570
-			"adviceList":   adviceList,
4571
-			"templateList": templateList,
4572
-			"config":       config,
4603
+			"list":       list,
4604
+			"drug":       drug,
4605
+			"adviceList": adviceList,
4606
+			"config":     config,
4607
+			"tablelist":  tablelist,
4573 4608
 		})
4574 4609
 		return
4575 4610
 
@@ -4676,7 +4711,10 @@ func (c *DialysisApiController) GetSchedulePrintList() {
4676 4711
 	adminUserInfo := c.GetAdminUserInfo()
4677 4712
 
4678 4713
 	list, total, _ := service.GetSchedulePrintList(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
4679
-
4714
+	for _, item := range list {
4715
+		order, _ := service.GetLastOrder(item.UserOrgId, item.PatientId, item.ScheduleDate)
4716
+		item.DialysisOrderTwenty = order
4717
+	}
4680 4718
 	listOne, _ := service.GetSchedulePrintListOne(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
4681 4719
 	numberList, _ := service.GetAllBedNumberSix(adminUserInfo.CurrentOrgId)
4682 4720
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -4687,3 +4725,720 @@ func (c *DialysisApiController) GetSchedulePrintList() {
4687 4725
 	})
4688 4726
 
4689 4727
 }
4728
+
4729
+func (this *DialysisApiController) GetSolutionListByOrgId() {
4730
+
4731
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4732
+	list, _ := service.GetSolutionListByOrgId(orgId)
4733
+	for _, item := range list {
4734
+		//获取该模式最新的1条数据
4735
+		solution, _ := service.GetNewPatientSolutionByModeId(item.PatientId, item.ModeId, orgId)
4736
+
4737
+		//更新状态值
4738
+		service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, orgId, item.PatientId)
4739
+	}
4740
+	this.ServeSuccessJSON(map[string]interface{}{
4741
+		"list": list,
4742
+	})
4743
+
4744
+}
4745
+
4746
+func (this *DialysisApiController) ExcutionDoctorAdvice() {
4747
+
4748
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4749
+	is_open, _ := this.GetInt64("is_open")
4750
+	idsStr := this.GetString("str")
4751
+	recordIDStrs := strings.Split(idsStr, ",")
4752
+	start_time := this.GetString("advice_date")
4753
+	exec_time, _ := this.GetInt64("exec_time")
4754
+	timeLayout := "2006-01-02"
4755
+	loc, _ := time.LoadLocation("Local")
4756
+	var startTime int64
4757
+	if len(start_time) > 0 {
4758
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4759
+		if err != nil {
4760
+			//fmt.Println(err)
4761
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4762
+			return
4763
+		}
4764
+		startTime = theTime.Unix()
4765
+	}
4766
+	config, _ := service.GetDrugOpenConfigOne(orgId)
4767
+	pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
4768
+	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
4769
+	//his医嘱
4770
+	if is_open == 1 {
4771
+
4772
+		groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
4773
+		//查找未执行医嘱
4774
+		list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
4775
+		for _, item := range list {
4776
+			if item.Checker == this.GetAdminUserInfo().AdminUser.Id {
4777
+				this.ServeSuccessJSON(map[string]interface{}{
4778
+					"msg": "3",
4779
+				})
4780
+				return
4781
+			}
4782
+		}
4783
+		for _, item := range groupList {
4784
+			for _, it := range list {
4785
+				if item.DrugId == it.DrugId {
4786
+					item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
4787
+				}
4788
+			}
4789
+		}
4790
+
4791
+		for _, item := range groupList {
4792
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4793
+			var sum_out_count int64
4794
+			for _, it := range item.ChildDoctorAdvice {
4795
+				var prescribing_number int64
4796
+				stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
4797
+				parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
4798
+				if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4799
+					prescribing_number = parseIntPrescribingNumber * medical.MinNumber
4800
+				}
4801
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4802
+					prescribing_number = parseIntPrescribingNumber
4803
+				}
4804
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4805
+					prescribing_number = parseIntPrescribingNumber
4806
+				}
4807
+				sum_out_count += prescribing_number
4808
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId)
4809
+				//库存不足
4810
+				if sum_out_count > drugStockOut.FlushCount {
4811
+					this.ServeSuccessJSON(map[string]interface{}{
4812
+						"msg":  "2",
4813
+						"drug": medical,
4814
+					})
4815
+					return
4816
+				}
4817
+			}
4818
+		}
4819
+		creater := this.GetAdminUserInfo().AdminUser.Id
4820
+		//执行出库逻辑
4821
+		for _, item := range list {
4822
+			hisadvice := &models.HisDoctorAdviceInfo{
4823
+				ID:                    item.ID,
4824
+				UserOrgId:             item.UserOrgId,
4825
+				PatientId:             item.PatientId,
4826
+				AdviceType:            item.AdviceType,
4827
+				AdviceDate:            item.AdviceDate,
4828
+				StartTime:             item.StartTime,
4829
+				AdviceName:            item.AdviceName,
4830
+				AdviceDesc:            item.AdviceDesc,
4831
+				ReminderDate:          item.ReminderDate,
4832
+				SingleDose:            item.SingleDose,
4833
+				SingleDoseUnit:        item.SingleDoseUnit,
4834
+				DrugSpec:              item.DrugSpec,
4835
+				DrugSpecUnit:          item.DrugSpecUnit,
4836
+				PrescribingNumber:     item.PrescribingNumber,
4837
+				PrescribingNumberUnit: item.PrescribingNumberUnit,
4838
+				DeliveryWay:           item.DeliveryWay,
4839
+				ExecutionFrequency:    item.ExecutionFrequency,
4840
+				AdviceDoctor:          item.AdviceDoctor,
4841
+				Status:                1,
4842
+				CreatedTime:           item.CreatedTime,
4843
+				UpdatedTime:           item.UpdatedTime,
4844
+				AdviceAffirm:          item.AdviceAffirm,
4845
+				Remark:                item.Remark,
4846
+				StopTime:              item.StopTime,
4847
+				StopReason:            item.StopReason,
4848
+				StopDoctor:            item.StopDoctor,
4849
+				StopState:             item.StopState,
4850
+				ParentId:              item.ParentId,
4851
+				ExecutionTime:         item.ExecutionTime,
4852
+				ExecutionStaff:        creater,
4853
+				ExecutionState:        item.ExecutionState,
4854
+				Checker:               item.Checker,
4855
+				RecordDate:            item.RecordDate,
4856
+				DialysisOrderId:       item.DialysisOrderId,
4857
+				CheckTime:             item.CheckTime,
4858
+				CheckState:            item.CheckState,
4859
+				RemindType:            item.RemindType,
4860
+				FrequencyType:         item.FrequencyType,
4861
+				DayCount:              item.DayCount,
4862
+				WeekDay:               item.WeekDay,
4863
+				TemplateId:            item.TemplateId,
4864
+				Modifier:              item.Modifier,
4865
+				Way:                   item.Way,
4866
+				DrugId:                item.DrugId,
4867
+				ExecutionFrequencyId:  item.ExecutionFrequencyId,
4868
+			}
4869
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4870
+			if medical.IsUse == 2 {
4871
+				if config.IsOpen != 1 {
4872
+					if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
4873
+						service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
4874
+
4875
+					}
4876
+					//不通过药房发药
4877
+					if pharmacyConfig.IsOpen != 1 {
4878
+						service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
4879
+					}
4880
+					//查询默认仓库
4881
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
4882
+					//查询默认仓库剩余多少库存
4883
+					var sum_count int64
4884
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
4885
+					for _, its := range stockInfo {
4886
+						if its.MaxUnit == medical.MaxUnit {
4887
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
4888
+						}
4889
+						sum_count += its.StockMaxNumber + its.StockMinNumber
4890
+					}
4891
+					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
4892
+					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
4893
+				}
4894
+			}
4895
+
4896
+			info := models.HisDoctorAdviceInfo{
4897
+				ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
4898
+				ExecutionTime:  exec_time,
4899
+				ExecutionState: 1,
4900
+				UpdatedTime:    time.Now().Unix(),
4901
+			}
4902
+			//执行医嘱
4903
+			service.UpdateHisDoctorAdviceExecution(info, item.ID)
4904
+
4905
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
4906
+			redis := service.RedisClient()
4907
+			//清空key 值
4908
+			redis.Set(key, "", time.Second)
4909
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
4910
+
4911
+			redis.Set(keyTwo, "", time.Second)
4912
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
4913
+			redis.Set(keyThree, "", time.Second)
4914
+			toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
4915
+			theTime := toTime.Format("2006-01-02")
4916
+
4917
+			fmt.Println("theTIME", theTime)
4918
+			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
4919
+
4920
+			redis.Set(keyFour, "", time.Second)
4921
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
4922
+			redis.Set(keyFive, "", time.Second)
4923
+		}
4924
+
4925
+	} else {
4926
+
4927
+		groupList, _ := service.GetExcutionDoctorAdviceGroupList(recordIDStrs, startTime, orgId)
4928
+		//查找未执行医嘱
4929
+		list, _ := service.GetExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
4930
+		for _, item := range groupList {
4931
+			for _, it := range list {
4932
+				if item.DrugId == it.DrugId {
4933
+					item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
4934
+				}
4935
+			}
4936
+		}
4937
+
4938
+		for _, item := range groupList {
4939
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4940
+			var sum_out_count int64
4941
+			for _, it := range item.ChildDoctorAdvice {
4942
+				var prescribing_number int64
4943
+				stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
4944
+				parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
4945
+				if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4946
+					prescribing_number = parseIntPrescribingNumber * medical.MinNumber
4947
+				}
4948
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4949
+					prescribing_number = parseIntPrescribingNumber
4950
+				}
4951
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4952
+					prescribing_number = parseIntPrescribingNumber
4953
+				}
4954
+				sum_out_count += prescribing_number
4955
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId)
4956
+				//库存不足
4957
+				if sum_out_count > drugStockOut.FlushCount {
4958
+					this.ServeSuccessJSON(map[string]interface{}{
4959
+						"msg":  "2",
4960
+						"drug": medical,
4961
+					})
4962
+					return
4963
+				}
4964
+			}
4965
+		}
4966
+
4967
+		for _, item := range list {
4968
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4969
+			dadvice := &models.DoctorAdvice{
4970
+				ID:                    item.ID,
4971
+				UserOrgId:             item.UserOrgId,
4972
+				PatientId:             item.PatientId,
4973
+				AdviceType:            item.AdviceType,
4974
+				AdviceDate:            item.AdviceDate,
4975
+				StartTime:             item.StartTime,
4976
+				AdviceName:            item.AdviceName,
4977
+				AdviceDesc:            item.AdviceDesc,
4978
+				ReminderDate:          item.ReminderDate,
4979
+				SingleDose:            item.SingleDose,
4980
+				SingleDoseUnit:        item.SingleDoseUnit,
4981
+				DrugSpec:              item.DrugSpec,
4982
+				DrugSpecUnit:          item.DrugSpecUnit,
4983
+				PrescribingNumber:     item.PrescribingNumber,
4984
+				PrescribingNumberUnit: item.PrescribingNumberUnit,
4985
+				DeliveryWay:           item.DeliveryWay,
4986
+				ExecutionFrequency:    item.ExecutionFrequency,
4987
+				AdviceDoctor:          item.AdviceDoctor,
4988
+				Status:                1,
4989
+				CreatedTime:           item.CreatedTime,
4990
+				UpdatedTime:           item.UpdatedTime,
4991
+				AdviceAffirm:          item.AdviceAffirm,
4992
+				Remark:                item.Remark,
4993
+				StopTime:              item.StopTime,
4994
+				StopReason:            item.StopReason,
4995
+				StopDoctor:            item.StopDoctor,
4996
+				StopState:             item.StopState,
4997
+				ParentId:              item.ParentId,
4998
+				ExecutionTime:         item.ExecutionTime,
4999
+				ExecutionStaff:        item.ExecutionStaff,
5000
+				ExecutionState:        item.ExecutionState,
5001
+				Checker:               item.Checker,
5002
+				RecordDate:            item.ReminderDate,
5003
+				DialysisOrderId:       item.DialysisOrderId,
5004
+				CheckTime:             item.CheckTime,
5005
+				CheckState:            item.CheckState,
5006
+				RemindType:            item.RemindType,
5007
+				FrequencyType:         item.FrequencyType,
5008
+				DayCount:              item.DayCount,
5009
+				WeekDay:               item.WeekDay,
5010
+				TemplateId:            item.TemplateId,
5011
+				Modifier:              item.Modifier,
5012
+				Way:                   item.Way,
5013
+				DrugId:                item.DrugId,
5014
+			}
5015
+			if medical.IsUse == 2 {
5016
+				if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
5017
+					service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
5018
+				}
5019
+				if pharmacyConfig.IsOpen != 1 {
5020
+					service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
5021
+				}
5022
+
5023
+				//更新字典里面的库存
5024
+				stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
5025
+				var sum_count int64
5026
+				for _, its := range stockInfo {
5027
+					baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
5028
+					if its.MaxUnit == baseDrug.MaxUnit {
5029
+						its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
5030
+					}
5031
+					sum_count += its.StockMaxNumber + its.StockMinNumber
5032
+				}
5033
+				service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
5034
+				//剩余库存
5035
+				service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5036
+			}
5037
+
5038
+			info := models.DoctorAdvice{
5039
+				ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
5040
+				ExecutionTime:  exec_time,
5041
+				ExecutionState: 1,
5042
+				UpdatedTime:    time.Now().Unix(),
5043
+			}
5044
+			//执行医嘱
5045
+			service.UpdateDoctorAdviceExecution(info, item.ID)
5046
+		}
5047
+
5048
+	}
5049
+
5050
+	this.ServeSuccessJSON(map[string]interface{}{
5051
+		"msg": "1",
5052
+	})
5053
+	return
5054
+}
5055
+
5056
+func (this *DialysisApiController) CheckNewDoctorAdvice() {
5057
+
5058
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5059
+	idsStr := this.GetString("str")
5060
+	recordIDStrs := strings.Split(idsStr, ",")
5061
+	start_time := this.GetString("advice_date")
5062
+	timeLayout := "2006-01-02"
5063
+	loc, _ := time.LoadLocation("Local")
5064
+	var startTime int64
5065
+	if len(start_time) > 0 {
5066
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
5067
+		if err != nil {
5068
+			//fmt.Println(err)
5069
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5070
+			return
5071
+		}
5072
+		startTime = theTime.Unix()
5073
+	}
5074
+
5075
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
5076
+
5077
+	if config.IsOpen == 1 {
5078
+
5079
+		creater := this.GetAdminUserInfo().AdminUser.Id
5080
+		//查询未核对的医嘱
5081
+		advicelist, _ := service.GetHisCheckDoctorAdvice(orgId, recordIDStrs, startTime)
5082
+		for _, item := range advicelist {
5083
+			if item.ExecutionStaff == creater {
5084
+				this.ServeSuccessJSON(map[string]interface{}{
5085
+					"msg":    "2",
5086
+					"advice": item,
5087
+				})
5088
+				return
5089
+			}
5090
+
5091
+			service.CheckHisDoctorAdvice(item.ID, creater)
5092
+
5093
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
5094
+			redis := service.RedisClient()
5095
+			//清空key 值
5096
+			redis.Set(key, "", time.Second)
5097
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
5098
+			redis.Set(keyTwo, "", time.Second)
5099
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
5100
+			redis.Set(keyThree, "", time.Second)
5101
+			theTime := time.Now()
5102
+			recordDate := theTime.Format("2006-01-02")
5103
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
5104
+
5105
+			redis.Set(keyFour, "", time.Second)
5106
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
5107
+			redis.Set(keyFive, "", time.Second)
5108
+
5109
+		}
5110
+	} else {
5111
+
5112
+		//查询未核对的医嘱
5113
+		advicelist, _ := service.GetCheckDoctorAdvice(orgId, recordIDStrs, startTime)
5114
+		creater := this.GetAdminUserInfo().AdminUser.Id
5115
+		for _, item := range advicelist {
5116
+			if item.ExecutionStaff == creater {
5117
+				this.ServeSuccessJSON(map[string]interface{}{
5118
+					"msg":    "2",
5119
+					"advice": item,
5120
+				})
5121
+				return
5122
+			}
5123
+
5124
+			service.CheckDoctorAdvice(item.ID, creater)
5125
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
5126
+			redis := service.RedisClient()
5127
+			//清空key 值
5128
+			redis.Set(key, "", time.Second)
5129
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
5130
+			redis.Set(keyTwo, "", time.Second)
5131
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
5132
+			redis.Set(keyThree, "", time.Second)
5133
+			theTime := time.Now()
5134
+			recordDate := theTime.Format("2006-01-02")
5135
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
5136
+
5137
+			redis.Set(keyFour, "", time.Second)
5138
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
5139
+			redis.Set(keyFive, "", time.Second)
5140
+		}
5141
+	}
5142
+
5143
+	this.ServeSuccessJSON(map[string]interface{}{
5144
+		"msg": "1",
5145
+	})
5146
+	return
5147
+
5148
+}
5149
+
5150
+func (this *DialysisApiController) SettleNewDoctorAdvice() {
5151
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5152
+	is_open, _ := this.GetInt64("is_open")
5153
+	idsStr := this.GetString("str")
5154
+	recordIDStrs := strings.Split(idsStr, ",")
5155
+	start_time := this.GetString("advice_date")
5156
+	timeLayout := "2006-01-02"
5157
+	loc, _ := time.LoadLocation("Local")
5158
+	var startTime int64
5159
+	if len(start_time) > 0 {
5160
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
5161
+		if err != nil {
5162
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5163
+			return
5164
+		}
5165
+		startTime = theTime.Unix()
5166
+	}
5167
+
5168
+	if is_open == 1 {
5169
+		service.SettleHisNewDoctorAdvice(recordIDStrs, startTime, orgId)
5170
+	} else {
5171
+		service.SettleNewDoctorAdvice(recordIDStrs, startTime, orgId)
5172
+	}
5173
+
5174
+	this.ServeSuccessJSON(map[string]interface{}{
5175
+		"msg": "1",
5176
+	})
5177
+	return
5178
+}
5179
+
5180
+func (this *DialysisApiController) ExcutionDoctorAdviceById() {
5181
+
5182
+	advice_id, _ := this.GetInt64("advice_id")
5183
+	start_time := this.GetString("advice_date")
5184
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5185
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
5186
+	exec_time, _ := this.GetInt64("exec_time")
5187
+
5188
+	//his医嘱
5189
+	if config.IsOpen == 1 {
5190
+
5191
+		//查询医嘱
5192
+		advice, _ := service.GetHisDocById(advice_id, orgId)
5193
+		if advice.Checker == this.GetAdminUserInfo().AdminUser.Id {
5194
+			this.ServeSuccessJSON(map[string]interface{}{
5195
+				"msg": "3",
5196
+			})
5197
+			return
5198
+		}
5199
+		medical, _ := service.GetBaseDrugMedical(orgId)
5200
+		var prescribing_number int64
5201
+		stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
5202
+		parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5203
+		if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5204
+			prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5205
+		}
5206
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5207
+			prescribing_number = parseIntPrescribingNumber
5208
+		}
5209
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5210
+			prescribing_number = parseIntPrescribingNumber
5211
+		}
5212
+
5213
+		drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId)
5214
+		//库存不足
5215
+		if prescribing_number > drugStockOut.FlushCount {
5216
+			this.ServeSuccessJSON(map[string]interface{}{
5217
+				"msg":  "2",
5218
+				"drug": medical,
5219
+			})
5220
+			return
5221
+		}
5222
+		info := models.HisDoctorAdviceInfo{
5223
+			ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
5224
+			ExecutionTime:  exec_time,
5225
+			ExecutionState: 1,
5226
+			UpdatedTime:    time.Now().Unix(),
5227
+		}
5228
+		//执行医嘱
5229
+		service.UpdateHisDoctorAdviceExecution(info, advice.ID)
5230
+
5231
+		key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
5232
+		redis := service.RedisClient()
5233
+		//清空key 值
5234
+		redis.Set(key, "", time.Second)
5235
+		keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
5236
+
5237
+		redis.Set(keyTwo, "", time.Second)
5238
+		keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
5239
+		redis.Set(keyThree, "", time.Second)
5240
+		toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
5241
+		theTime := toTime.Format("2006-01-02")
5242
+
5243
+		fmt.Println("theTIME", theTime)
5244
+		keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
5245
+
5246
+		redis.Set(keyFour, "", time.Second)
5247
+		keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
5248
+		redis.Set(keyFive, "", time.Second)
5249
+
5250
+		//出库
5251
+		if prescribing_number <= drugStockOut.FlushCount {
5252
+			pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
5253
+			//执行出库逻辑
5254
+			hisadvice := &models.HisDoctorAdviceInfo{
5255
+				ID:                    advice.ID,
5256
+				UserOrgId:             advice.UserOrgId,
5257
+				PatientId:             advice.PatientId,
5258
+				AdviceType:            advice.AdviceType,
5259
+				AdviceDate:            advice.AdviceDate,
5260
+				StartTime:             advice.StartTime,
5261
+				AdviceName:            advice.AdviceName,
5262
+				AdviceDesc:            advice.AdviceDesc,
5263
+				ReminderDate:          advice.ReminderDate,
5264
+				SingleDose:            advice.SingleDose,
5265
+				SingleDoseUnit:        advice.SingleDoseUnit,
5266
+				DrugSpec:              advice.DrugSpec,
5267
+				DrugSpecUnit:          advice.DrugSpecUnit,
5268
+				PrescribingNumber:     advice.PrescribingNumber,
5269
+				PrescribingNumberUnit: advice.PrescribingNumberUnit,
5270
+				DeliveryWay:           advice.DeliveryWay,
5271
+				ExecutionFrequency:    advice.ExecutionFrequency,
5272
+				AdviceDoctor:          advice.AdviceDoctor,
5273
+				Status:                1,
5274
+				CreatedTime:           advice.CreatedTime,
5275
+				UpdatedTime:           advice.UpdatedTime,
5276
+				AdviceAffirm:          advice.AdviceAffirm,
5277
+				Remark:                advice.Remark,
5278
+				StopTime:              advice.StopTime,
5279
+				StopReason:            advice.StopReason,
5280
+				StopDoctor:            advice.StopDoctor,
5281
+				StopState:             advice.StopState,
5282
+				ParentId:              advice.ParentId,
5283
+				ExecutionTime:         advice.ExecutionTime,
5284
+				ExecutionStaff:        this.GetAdminUserInfo().AdminUser.Id,
5285
+				ExecutionState:        advice.ExecutionState,
5286
+				Checker:               advice.Checker,
5287
+				RecordDate:            advice.RecordDate,
5288
+				DialysisOrderId:       advice.DialysisOrderId,
5289
+				CheckTime:             advice.CheckTime,
5290
+				CheckState:            advice.CheckState,
5291
+				RemindType:            advice.RemindType,
5292
+				FrequencyType:         advice.FrequencyType,
5293
+				DayCount:              advice.DayCount,
5294
+				WeekDay:               advice.WeekDay,
5295
+				TemplateId:            advice.TemplateId,
5296
+				Modifier:              advice.Modifier,
5297
+				Way:                   advice.Way,
5298
+				DrugId:                advice.DrugId,
5299
+				ExecutionFrequencyId:  advice.ExecutionFrequencyId,
5300
+			}
5301
+			if medical.IsUse == 2 {
5302
+				if config.IsOpen != 1 {
5303
+					if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
5304
+						service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
5305
+
5306
+					}
5307
+					//不通过药房发药
5308
+					if pharmacyConfig.IsOpen != 1 {
5309
+						service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
5310
+					}
5311
+					//查询默认仓库
5312
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
5313
+					//查询默认仓库剩余多少库存
5314
+					var sum_count int64
5315
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
5316
+					for _, its := range stockInfo {
5317
+						if its.MaxUnit == medical.MaxUnit {
5318
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
5319
+						}
5320
+						sum_count += its.StockMaxNumber + its.StockMinNumber
5321
+					}
5322
+					service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
5323
+					service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5324
+				}
5325
+			}
5326
+		}
5327
+
5328
+		this.ServeSuccessJSON(map[string]interface{}{
5329
+			"msg": "1",
5330
+		})
5331
+		return
5332
+	}
5333
+
5334
+	if config.IsOpen == 2 || config.IsOpen == 0 {
5335
+
5336
+		advice, _ := service.GetBloodDocById(advice_id, orgId)
5337
+		medical, _ := service.GetBaseDrugMedical(orgId)
5338
+		pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
5339
+		storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
5340
+		var prescribing_number int64
5341
+		stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
5342
+		parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5343
+		if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5344
+			prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5345
+		}
5346
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5347
+			prescribing_number = parseIntPrescribingNumber
5348
+		}
5349
+		if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5350
+			prescribing_number = parseIntPrescribingNumber
5351
+		}
5352
+		drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId)
5353
+		//库存不足
5354
+		if prescribing_number > drugStockOut.FlushCount {
5355
+			this.ServeSuccessJSON(map[string]interface{}{
5356
+				"msg":  "2",
5357
+				"drug": medical,
5358
+			})
5359
+			return
5360
+		}
5361
+		info := models.DoctorAdvice{
5362
+			ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
5363
+			ExecutionTime:  exec_time,
5364
+			ExecutionState: 1,
5365
+			UpdatedTime:    time.Now().Unix(),
5366
+		}
5367
+		//执行医嘱
5368
+		service.UpdateDoctorAdviceExecution(info, advice.ID)
5369
+
5370
+		dadvice := &models.DoctorAdvice{
5371
+			ID:                    advice.ID,
5372
+			UserOrgId:             advice.UserOrgId,
5373
+			PatientId:             advice.PatientId,
5374
+			AdviceType:            advice.AdviceType,
5375
+			AdviceDate:            advice.AdviceDate,
5376
+			StartTime:             advice.StartTime,
5377
+			AdviceName:            advice.AdviceName,
5378
+			AdviceDesc:            advice.AdviceDesc,
5379
+			ReminderDate:          advice.ReminderDate,
5380
+			SingleDose:            advice.SingleDose,
5381
+			SingleDoseUnit:        advice.SingleDoseUnit,
5382
+			DrugSpec:              advice.DrugSpec,
5383
+			DrugSpecUnit:          advice.DrugSpecUnit,
5384
+			PrescribingNumber:     advice.PrescribingNumber,
5385
+			PrescribingNumberUnit: advice.PrescribingNumberUnit,
5386
+			DeliveryWay:           advice.DeliveryWay,
5387
+			ExecutionFrequency:    advice.ExecutionFrequency,
5388
+			AdviceDoctor:          advice.AdviceDoctor,
5389
+			Status:                1,
5390
+			CreatedTime:           advice.CreatedTime,
5391
+			UpdatedTime:           advice.UpdatedTime,
5392
+			AdviceAffirm:          advice.AdviceAffirm,
5393
+			Remark:                advice.Remark,
5394
+			StopTime:              advice.StopTime,
5395
+			StopReason:            advice.StopReason,
5396
+			StopDoctor:            advice.StopDoctor,
5397
+			StopState:             advice.StopState,
5398
+			ParentId:              advice.ParentId,
5399
+			ExecutionTime:         advice.ExecutionTime,
5400
+			ExecutionStaff:        advice.ExecutionStaff,
5401
+			ExecutionState:        advice.ExecutionState,
5402
+			Checker:               advice.Checker,
5403
+			RecordDate:            advice.ReminderDate,
5404
+			DialysisOrderId:       advice.DialysisOrderId,
5405
+			CheckTime:             advice.CheckTime,
5406
+			CheckState:            advice.CheckState,
5407
+			RemindType:            advice.RemindType,
5408
+			FrequencyType:         advice.FrequencyType,
5409
+			DayCount:              advice.DayCount,
5410
+			WeekDay:               advice.WeekDay,
5411
+			TemplateId:            advice.TemplateId,
5412
+			Modifier:              advice.Modifier,
5413
+			Way:                   advice.Way,
5414
+			DrugId:                advice.DrugId,
5415
+		}
5416
+		if medical.IsUse == 2 {
5417
+			if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
5418
+				service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
5419
+			}
5420
+			if pharmacyConfig.IsOpen != 1 {
5421
+				service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
5422
+			}
5423
+
5424
+			//更新字典里面的库存
5425
+			stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
5426
+			var sum_count int64
5427
+			for _, its := range stockInfo {
5428
+				baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
5429
+				if its.MaxUnit == baseDrug.MaxUnit {
5430
+					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
5431
+				}
5432
+				sum_count += its.StockMaxNumber + its.StockMinNumber
5433
+			}
5434
+			service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
5435
+			//剩余库存
5436
+			service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5437
+		}
5438
+	}
5439
+	this.ServeSuccessJSON(map[string]interface{}{
5440
+		"msg": "1",
5441
+	})
5442
+	return
5443
+
5444
+}

+ 27 - 4
controllers/dialysis_record_api_controller.go View File

@@ -787,7 +787,8 @@ func (this *DialysisRecordAPIController) StartDialysis() {
787 787
 	blood_access_id, _ := this.GetInt64("blood_access_id")
788 788
 	bedID, _ := this.GetInt64("bed")
789 789
 	nuclein_date := this.GetString("nuclein_date")
790
-
790
+	schedule_remark := this.GetString("schedule_remark")
791
+	order_remark := this.GetString("order_remark")
791 792
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
792 793
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
793 794
 		return
@@ -1001,9 +1002,13 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1001 1002
 		DialysisIrrigation:     dialysis_irrigation,
1002 1003
 		BloodAccessId:          blood_access_id,
1003 1004
 		NucleinDate:            theNucleinDate,
1005
+		ScheduleRemark:         schedule_remark,
1006
+		OrderRemark:            order_remark,
1004 1007
 	}
1005 1008
 
1006 1009
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
1010
+	//更新患者表排班备注
1011
+	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, patientID, schedule_remark)
1007 1012
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1008 1013
 	redis := service.RedisClient()
1009 1014
 	//清空key 值
@@ -1135,6 +1140,15 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1135 1140
 				record.TransmembranePressure = 60
1136 1141
 			}
1137 1142
 
1143
+			//针对兰溪人民医院的需求
1144
+			if adminUserInfo.CurrentOrgId == 10432 {
1145
+				befor, _ := service.GetAssessmentBefor(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1146
+				record.SystolicBloodPressure = befor.SystolicBloodPressure
1147
+				record.DiastolicBloodPressure = befor.DiastolicBloodPressure
1148
+				record.Temperature = befor.Temperature
1149
+				record.PulseFrequency = befor.PulseFrequency
1150
+			}
1151
+
1138 1152
 			err := service.CreateMonitor(&record)
1139 1153
 			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
1140 1154
 
@@ -1398,8 +1412,8 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1398 1412
 
1399 1413
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1400 1414
 
1401
-	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10340 || adminUserInfo.CurrentOrgId == 10414 {
1402
-		fmt.Println("进来2332233333333333333333333333333333333我的")
1415
+	if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10340 || adminUserInfo.CurrentOrgId == 10414 || adminUserInfo.CurrentOrgId == 10432 {
1416
+
1403 1417
 		evaluation, _ := service.MobileGetPredialysisEvaluationTwo(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
1404 1418
 		if evaluation.SystolicBloodPressure == 0 {
1405 1419
 			pre := models.PredialysisEvaluation{
@@ -1530,6 +1544,8 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1530 1544
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
1531 1545
 	blood_access_id, _ := this.GetInt64("blood_access_id")
1532 1546
 	nuclein_date := this.GetString("nuclein_date")
1547
+	schedule_remark := this.GetString("schedule_remark")
1548
+	order_remark := this.GetString("order_remark")
1533 1549
 	if record_id == 0 {
1534 1550
 		this.ErrorLog("id:%v", record_id)
1535 1551
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1671,7 +1687,7 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1671 1687
 		}
1672 1688
 
1673 1689
 	}
1674
-	fmt.Println("theNucleinDate", theNucleinDate)
1690
+
1675 1691
 	dialysisRecord := &models.DialysisOrder{
1676 1692
 		ID:                     record_id,
1677 1693
 		UserOrgId:              adminUserInfo.CurrentOrgId,
@@ -1693,9 +1709,16 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1693 1709
 		DialysisIrrigation:     dialysis_irrigation,
1694 1710
 		BloodAccessId:          blood_access_id,
1695 1711
 		NucleinDate:            theNucleinDate,
1712
+		ScheduleRemark:         schedule_remark,
1713
+		OrderRemark:            order_remark,
1696 1714
 	}
1697 1715
 
1698 1716
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1717
+
1718
+	order, _ := service.GetLastPatientOrder(record_id)
1719
+
1720
+	service.UpdateMobilePatient(adminUserInfo.CurrentOrgId, order.PatientId, schedule_remark)
1721
+
1699 1722
 	redis := service.RedisClient()
1700 1723
 	key := strconv.FormatInt(tempDialysisRecord.UserOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":dialysis_order"
1701 1724
 	redis.Set(key, "", time.Second)

+ 145 - 97
controllers/doctors_api_controller.go View File

@@ -29,6 +29,7 @@ func DoctorApiRegistRouters() {
29 29
 	beego.Router("/api/patients/modifydryweightdata", &DoctorsApiController{}, "Get:ModifydryWeightData")
30 30
 	beego.Router("/api/patient/deletedryweight", &DoctorsApiController{}, "Delete:DeleteDryWeight")
31 31
 	beego.Router("/api/schedule/advices", &DoctorsApiController{}, "Get:ScheduleAdvices")
32
+	beego.Router("/api/schedule/new/advices", &DoctorsApiController{}, "Get:GetScheduleAdvicesList")
32 33
 	beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
33 34
 	beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
34 35
 	beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
@@ -88,112 +89,67 @@ func (c *DoctorsApiController) ScheduleAdvices() {
88 89
 	adminUserInfo := c.GetAdminUserInfo()
89 90
 	orgID := adminUserInfo.CurrentOrgId
90 91
 
91
-	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way)
92
-	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way)
93
-
94
-	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
95
-	//project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
96
-	for _, item := range project {
97
-		index := 0
98
-		for _, subItem := range item.HisPrescriptionTeamProject {
99
-
100
-			if subItem.HisProject.CostClassify != 3 {
101
-				subItem.IsCheckTeam = 2
102
-				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
103
-			}
92
+	config, _ := service.GetHisDoctorConfig(orgID)
93
+	project_config, _ := service.GetHisProjectConfig(orgID)
104 94
 
105
-			if subItem.HisProject.CostClassify == 3 {
106
-				subItem.IsCheckTeam = 1
107
-				index = index + 1
108
-				if index == 1 {
109
-					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
95
+	if config.IsOpen == 0 || config.IsOpen == 2 {
96
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0)
97
+		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
98
+		if err != nil {
99
+			c.ErrorLog("获取排班信息失败:%v", err)
100
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
101
+		} else {
102
+			filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
103
+			for _, schedual := range scheduals {
104
+				if len(schedual.DoctorAdvices) > 0 {
105
+					filtedScheduals = append(filtedScheduals, schedual)
110 106
 				}
111 107
 			}
108
+			c.ServeSuccessJSON(map[string]interface{}{
109
+				"scheduals":      filtedScheduals,
110
+				"adminUser":      adminUser,
111
+				"config":         config,
112
+				"project_config": project_config,
113
+			})
112 114
 		}
113 115
 	}
114
-	//for _, item := range project {
115
-	//	index := 0
116
-	//	for _, subItem := range item.HisPrescriptionTeamProject {
117
-	//
118
-	//		//获取所有的患者
119
-	//		patients, _ := service.GetAllPatientListByListTwo(orgID)
120
-	//
121
-	//		//获取所有床位
122
-	//		numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
123
-	//
124
-	//		//获取透析处方
125
-	//		prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
126
-	//
127
-	//		//获取上机
128
-	//		dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
129
-	//		for key, item := range project {
130
-	//			for _, patient := range patients {
131
-	//				if item.PatientId == patient.ID {
132
-	//					project[key].SchedualPatient = patient
133
-	//					break
134
-	//				}
135
-	//			}
136
-	//			// 获取床位信息
137
-	//			for _, it := range numberList {
138
-	//				if item.BedId == it.ID {
139
-	//					project[key].DeviceNumber = it
140
-	//					break
141
-	//				}
142
-	//			}
143
-	//
144
-	//			// 获取处方
145
-	//			for _, it := range prescriptions {
146
-	//				if item.PatientId == it.PatientId {
147
-	//					project[key].Prescription = it
148
-	//					break
149
-	//				}
150
-	//			}
151
-	//
152
-	//			//获取上机
153
-	//			for _, it := range dialysisOrders {
154
-	//				if item.PatientId == it.PatientId {
155
-	//					project[key].DialysisOrder = it
156
-	//					break
157
-	//				}
158
-	//			}
159
-	//		}
160
-	//		if subItem.HisProject.CostClassify != 3 {
161
-	//			subItem.IsCheckTeam = 2
162
-	//			item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
163
-	//		}
164
-	//
165
-	//		if subItem.HisProject.CostClassify == 3 {
166
-	//			subItem.IsCheckTeam = 1
167
-	//			index = index + 1
168
-	//			if index == 1 {
169
-	//				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
170
-	//			}
171
-	//		}
172
-	//	}
173
-	//}
174
-	config, _ := service.GetHisDoctorConfig(orgID)
175
-	project_config, _ := service.GetHisProjectConfig(orgID)
116
+	if config.IsOpen == 1 {
117
+		hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0)
118
+		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
119
+		project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
120
+		for _, item := range project {
121
+			index := 0
122
+			for _, subItem := range item.HisPrescriptionTeamProject {
123
+
124
+				if subItem.HisProject.CostClassify != 3 {
125
+					subItem.IsCheckTeam = 2
126
+					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
127
+				}
176 128
 
177
-	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
178
-	if err != nil {
179
-		c.ErrorLog("获取排班信息失败:%v", err)
180
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
181
-	} else {
182
-		filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
183
-		for _, schedual := range scheduals {
184
-			if len(schedual.DoctorAdvices) > 0 {
185
-				filtedScheduals = append(filtedScheduals, schedual)
129
+				if subItem.HisProject.CostClassify == 3 {
130
+					subItem.IsCheckTeam = 1
131
+					index = index + 1
132
+					if index == 1 {
133
+						item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
134
+					}
135
+				}
186 136
 			}
187 137
 		}
188
-		c.ServeSuccessJSON(map[string]interface{}{
189
-			"scheduals":      filtedScheduals,
190
-			"adminUser":      adminUser,
191
-			"hisAdvices":     hisAdvices,
192
-			"config":         config,
193
-			"project_config": project_config,
194
-			"project":        project,
195
-		})
138
+
139
+		if err != nil {
140
+			c.ErrorLog("获取排班信息失败:%v", err)
141
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
142
+		} else {
143
+			c.ServeSuccessJSON(map[string]interface{}{
144
+				"adminUser":      adminUser,
145
+				"hisAdvices":     hisAdvices,
146
+				"config":         config,
147
+				"project_config": project_config,
148
+				"project":        project,
149
+			})
150
+		}
196 151
 	}
152
+
197 153
 }
198 154
 
199 155
 func (c *DoctorsApiController) GetAllDoctorAndNurse() {
@@ -1407,3 +1363,95 @@ func (this *DoctorsApiController) GetPatientInfo() {
1407 1363
 		return
1408 1364
 	}
1409 1365
 }
1366
+
1367
+func (c *DoctorsApiController) GetScheduleAdvicesList() {
1368
+
1369
+	schedualDate := c.GetString("date")
1370
+	adviceType, _ := c.GetInt("advice_type")
1371
+	patientType, _ := c.GetInt("patient_type")
1372
+	delivery_way := c.GetString("delivery_way")
1373
+	schedule_type, _ := c.GetInt64("schedule_type")
1374
+	partition_type, _ := c.GetInt64("partition_type")
1375
+	patient_id, _ := c.GetInt64("patient_id")
1376
+	excution_way, _ := c.GetInt64("excution_way")
1377
+	cost_type, _ := c.GetInt64("cost_type")
1378
+	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
1379
+		adviceType = 0
1380
+	}
1381
+
1382
+	if patientType != 1 && patientType != 2 {
1383
+
1384
+		patientType = 0
1385
+	}
1386
+
1387
+	date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
1388
+	if parseDateErr != nil {
1389
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1390
+		return
1391
+	}
1392
+
1393
+	adminUserInfo := c.GetAdminUserInfo()
1394
+	orgID := adminUserInfo.CurrentOrgId
1395
+
1396
+	config, _ := service.GetHisDoctorConfig(orgID)
1397
+	project_config, _ := service.GetHisProjectConfig(orgID)
1398
+
1399
+	if config.IsOpen == 0 || config.IsOpen == 2 {
1400
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type)
1401
+		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1402
+		if err != nil {
1403
+			c.ErrorLog("获取排班信息失败:%v", err)
1404
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1405
+		} else {
1406
+			filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
1407
+			for _, schedual := range scheduals {
1408
+				if len(schedual.DoctorAdvices) > 0 {
1409
+					filtedScheduals = append(filtedScheduals, schedual)
1410
+				}
1411
+			}
1412
+			c.ServeSuccessJSON(map[string]interface{}{
1413
+				"scheduals":      filtedScheduals,
1414
+				"adminUser":      adminUser,
1415
+				"config":         config,
1416
+				"project_config": project_config,
1417
+			})
1418
+		}
1419
+	}
1420
+	if config.IsOpen == 1 {
1421
+		hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type)
1422
+		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1423
+		project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
1424
+		for _, item := range project {
1425
+			index := 0
1426
+			for _, subItem := range item.HisPrescriptionTeamProject {
1427
+
1428
+				if subItem.HisProject.CostClassify != 3 {
1429
+					subItem.IsCheckTeam = 2
1430
+					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
1431
+				}
1432
+
1433
+				if subItem.HisProject.CostClassify == 3 {
1434
+					subItem.IsCheckTeam = 1
1435
+					index = index + 1
1436
+					if index == 1 {
1437
+						item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
1438
+					}
1439
+				}
1440
+			}
1441
+		}
1442
+
1443
+		if err != nil {
1444
+			c.ErrorLog("获取排班信息失败:%v", err)
1445
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1446
+		} else {
1447
+			c.ServeSuccessJSON(map[string]interface{}{
1448
+				"adminUser":      adminUser,
1449
+				"hisAdvices":     hisAdvices,
1450
+				"config":         config,
1451
+				"project_config": project_config,
1452
+				"project":        project,
1453
+			})
1454
+		}
1455
+	}
1456
+
1457
+}

+ 3 - 0
controllers/drug_pharmacy_management_controller.go View File

@@ -486,6 +486,9 @@ func (this *PharmacyApiController) SaveSetting() {
486 486
 		Ctime:     time.Now().Unix(),
487 487
 	}
488 488
 
489
+	if is_open == 1 {
490
+		service.UpdateSettleOpenConfigOne(orgId, 2)
491
+	}
489 492
 	//查找是否存在
490 493
 	_, errcode := service.GetConfigSettingIsExsit(orgId)
491 494
 	if errcode == gorm.ErrRecordNotFound {

+ 7 - 8
controllers/drug_stock_api_contorller.go View File

@@ -3760,7 +3760,6 @@ func (c *StockDrugApiController) CheckDrugOut() {
3760 3760
 	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
3761 3761
 
3762 3762
 	for _, it := range warehousingOutInfoList {
3763
-		fmt.Println("countunit23322332232323wo", it.CountUnit)
3764 3763
 		var total_count int64
3765 3764
 		var out_count int64
3766 3765
 		//查询剩余库存
@@ -3808,11 +3807,11 @@ func (c *StockDrugApiController) CheckDrugOut() {
3808 3807
 		medical, _ := service.GetBaseDrugMedical(it.DrugId)
3809 3808
 		////出库数量累加
3810 3809
 		var out_count_one int64
3811
-		fmt.Println("it.count", it.CountUnit)
3812
-		fmt.Println("MaxUnit", medical.MaxUnit)
3813
-		fmt.Println("MinUnit", medical.MinUnit)
3814
-		fmt.Println("count", it.Count)
3815
-		fmt.Println("number", medical.MinNumber)
3810
+		//fmt.Println("it.count", it.CountUnit)
3811
+		//fmt.Println("MaxUnit", medical.MaxUnit)
3812
+		//fmt.Println("MinUnit", medical.MinUnit)
3813
+		//fmt.Println("count", it.Count)
3814
+		//fmt.Println("number", medical.MinNumber)
3816 3815
 		if it.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3817 3816
 			out_count_one = it.Count * medical.MinNumber
3818 3817
 		}
@@ -3824,10 +3823,10 @@ func (c *StockDrugApiController) CheckDrugOut() {
3824 3823
 		if it.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3825 3824
 			out_count_one = it.Count
3826 3825
 		}
3827
-		fmt.Println("countone3232232323323232332332wo", out_count_one)
3826
+		//fmt.Println("countone3232232323323232332332wo", out_count_one)
3828 3827
 		//增加出库数量
3829 3828
 		service.AddDrugCount(it.DrugId, it.OrgId, storeHouseConfig.DrugStorehouseOut, out_count_one)
3830
-		fmt.Println("countunit23322332232323", it.CountUnit)
3829
+		//fmt.Println("countunit23322332232323", it.CountUnit)
3831 3830
 
3832 3831
 	}
3833 3832
 	warehousingOutInfoListThree, _ := service.GetDrugWarehouseOutListById(warehouse_out_id, orgId)

+ 42 - 1
controllers/gobal_config_api_controller.go View File

@@ -117,6 +117,8 @@ func GobalConfigRegistRouters() {
117 117
 	beego.Router("/api/changeprescriptionconfig", &GobalConfigApiController{}, "Get:ChangePrescriptionConfig")
118 118
 
119 119
 	beego.Router("/api/changedrugopenconfig", &GobalConfigApiController{}, "Get:ChangeDrugOpenConfig")
120
+
121
+	beego.Router("/api/changesettleopenconfig", &GobalConfigApiController{}, "Get:ChangeSettleOpenConfig")
120 122
 }
121 123
 
122 124
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -182,7 +184,9 @@ func (c *GobalConfigApiController) PostDrugStockConfig() {
182 184
 	}
183 185
 
184 186
 	errs, configs := service.FindDrugStockAutomaticReduceRecordByOrgId(org_id)
185
-
187
+	if is_open == 1 {
188
+		service.UpdateSettleOpenConfigOne(org_id, 2)
189
+	}
186 190
 	if errs == gorm.ErrRecordNotFound {
187 191
 		err := service.CreateDrugAutomaticReduceRecord(&config)
188 192
 		if err != nil {
@@ -1568,6 +1572,8 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1568 1572
 	prescriptionConfig, _ := service.FindPrescriptionConfigById(adminUserInfo.CurrentOrgId)
1569 1573
 
1570 1574
 	drugOutConfig, _ := service.FindDrugOutConfigById(adminUserInfo.CurrentOrgId)
1575
+
1576
+	drugSettleConfig, _ := service.FindeDrugSettleConfigById(adminUserInfo.CurrentOrgId)
1571 1577
 	c.ServeSuccessJSON(map[string]interface{}{
1572 1578
 		"is_open_xt_his":         config.IsOpen,
1573 1579
 		"is_open_xt_his_project": project_config.IsOpen,
@@ -1575,6 +1581,7 @@ func (c *GobalConfigApiController) GetAllIsOpenConfig() {
1575 1581
 		"is_open_advice":         adviceSetting.IsAdviceOpen,
1576 1582
 		"is_prescription_advice": prescriptionConfig.IsOpen,
1577 1583
 		"is_open":                drugOutConfig.IsOpen,
1584
+		"is_seetle_open":         drugSettleConfig.IsOpen,
1578 1585
 	})
1579 1586
 
1580 1587
 }
@@ -2499,6 +2506,11 @@ func (c *GobalConfigApiController) ChangeDrugOpenConfig() {
2499 2506
 
2500 2507
 	drug_out_open, _ := c.GetInt64("drug_out_open")
2501 2508
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2509
+	if drug_out_open == 1 {
2510
+		service.UpdateDrugStockAutomaticReduceRecordOne(orgId, 2)
2511
+		service.UpdatePharyConfig(orgId, 2)
2512
+		service.UpdateSettleOpenConfigOne(orgId, 2)
2513
+	}
2502 2514
 	_, errcode := service.GetDrugOpenConfig(orgId)
2503 2515
 	if errcode == gorm.ErrRecordNotFound {
2504 2516
 		config := models.DrugOutConfig{
@@ -2518,3 +2530,32 @@ func (c *GobalConfigApiController) ChangeDrugOpenConfig() {
2518 2530
 		})
2519 2531
 	}
2520 2532
 }
2533
+
2534
+func (this *GobalConfigApiController) ChangeSettleOpenConfig() {
2535
+
2536
+	drug_out_open, _ := this.GetInt64("drug_settle_open")
2537
+
2538
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2539
+	config := models.HisSettleStockConfig{
2540
+		UserOrgId: orgId,
2541
+		Ctime:     time.Now().Unix(),
2542
+		Mtime:     0,
2543
+		Status:    1,
2544
+		IsOpen:    drug_out_open,
2545
+	}
2546
+
2547
+	if drug_out_open == 1 {
2548
+		service.UpdateDrugOutConfig(orgId, 2)
2549
+		service.UpdateDrugStockAutomaticReduceRecordOne(orgId, 2)
2550
+		service.UpdatePharyConfig(orgId, 2)
2551
+	}
2552
+	openConfig, errcode := service.GetSettleOpenConfig(orgId)
2553
+	if errcode == gorm.ErrRecordNotFound {
2554
+		service.CreateSettleOpenConfig(config)
2555
+	} else if errcode == nil {
2556
+		service.UpdateSettleOpenConfig(openConfig.ID, config)
2557
+	}
2558
+	this.ServeSuccessJSON(map[string]interface{}{
2559
+		"msg": 1,
2560
+	})
2561
+}

+ 421 - 28
controllers/his_api_controller.go View File

@@ -1930,7 +1930,7 @@ func (c *HisApiController) CreateHisPrescription() {
1930 1930
 							s.PatientId = patient_id
1931 1931
 							s.HisPatientId = his_patient_id
1932 1932
 							s.StartTime = pTime
1933
-
1933
+							s.IsSettle = 2
1934 1934
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
1935 1935
 							if errcode > 0 {
1936 1936
 								c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -2832,14 +2832,26 @@ func (c *HisApiController) DeletePrescription() {
2832 2832
 
2833 2833
 		}
2834 2834
 	}
2835
-	if drugStockConfig.IsOpen == 1 {
2835
+	if c.GetAdminUserInfo().CurrentOrgId == 10387 {
2836
+
2836 2837
 		if len(advices) > 0 {
2837 2838
 			for _, item := range advices {
2838 2839
 				creater := c.GetAdminUserInfo().AdminUser.Id
2839 2840
 				service.DrugAutoAddCancelInfo(item, creater)
2840 2841
 			}
2841 2842
 		}
2843
+
2844
+	} else {
2845
+		if drugStockConfig.IsOpen == 1 {
2846
+			if len(advices) > 0 {
2847
+				for _, item := range advices {
2848
+					creater := c.GetAdminUserInfo().AdminUser.Id
2849
+					service.DrugAutoAddCancelInfo(item, creater)
2850
+				}
2851
+			}
2852
+		}
2842 2853
 	}
2854
+
2843 2855
 	c.ServeSuccessJSON(map[string]interface{}{
2844 2856
 		"msg": "删除成功",
2845 2857
 	})
@@ -2914,8 +2926,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2914 2926
 	defer redis.Close()
2915 2927
 
2916 2928
 	if err == nil {
2917
-		if drugStockConfig.IsOpen == 1 {
2918
-
2929
+		if c.GetAdminUserInfo().CurrentOrgId == 10387 {
2919 2930
 			//查询是否在处方中出库
2920 2931
 			openConfig, _ := service.GetDrugOpenConfigOne(c.GetAdminUserInfo().CurrentOrgId)
2921 2932
 
@@ -2925,16 +2936,37 @@ func (c *HisApiController) DeleteDoctorAdvice() {
2925 2936
 				if advice.ExecutionState == 1 {
2926 2937
 					creater := c.GetAdminUserInfo().AdminUser.Id
2927 2938
 					service.DrugAutoAddCancelInfo(&advice, creater)
2928
-
2929 2939
 				}
2930
-
2931 2940
 			}
2932 2941
 
2933 2942
 			//开启保存处方扣减功能
2934 2943
 			if openConfig.IsOpen == 1 {
2935 2944
 				creater := c.GetAdminUserInfo().AdminUser.Id
2936 2945
 				service.DrugAutoAddCancelInfo(&advice, creater)
2946
+			}
2947
+		} else {
2948
+			if drugStockConfig.IsOpen == 1 {
2949
+
2950
+				//查询是否在处方中出库
2951
+				openConfig, _ := service.GetDrugOpenConfigOne(c.GetAdminUserInfo().CurrentOrgId)
2952
+
2953
+				if openConfig.IsOpen != 1 {
2954
+
2955
+					//判断该医嘱是否执行了
2956
+					if advice.ExecutionState == 1 {
2957
+						creater := c.GetAdminUserInfo().AdminUser.Id
2958
+						service.DrugAutoAddCancelInfo(&advice, creater)
2959
+
2960
+					}
2961
+
2962
+				}
2963
+
2964
+				//开启保存处方扣减功能
2965
+				if openConfig.IsOpen == 1 {
2966
+					creater := c.GetAdminUserInfo().AdminUser.Id
2967
+					service.DrugAutoAddCancelInfo(&advice, creater)
2937 2968
 
2969
+				}
2938 2970
 			}
2939 2971
 		}
2940 2972
 
@@ -5101,7 +5133,8 @@ func (c *HisApiController) GetUploadInfo() {
5101 5133
 			tx.Commit()
5102 5134
 		}
5103 5135
 	}()
5104
-	if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
5136
+	fmt.Println("dec_way", dec_way)
5137
+	if (dec_way == "true" && tmp_decimal == "0") || (dec_way == "true" && tmp_decimal == "") {
5105 5138
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
5106 5139
 		return
5107 5140
 	}
@@ -5131,6 +5164,9 @@ func (c *HisApiController) GetUploadInfo() {
5131 5164
 	recordDateTime := theTime.Unix()
5132 5165
 	adminUser := c.GetAdminUserInfo()
5133 5166
 	var prescriptions []*models.HisPrescription
5167
+
5168
+	var prescriptionsOne []*models.HisPrescription
5169
+
5134 5170
 	var start_time int64
5135 5171
 	var end_time int64
5136 5172
 
@@ -5143,8 +5179,12 @@ func (c *HisApiController) GetUploadInfo() {
5143 5179
 			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
5144 5180
 
5145 5181
 				prescriptions, _ = service.GetPrescriptionByIdsTX(ids_arr, adminUser.CurrentOrgId, tx)
5182
+
5183
+				prescriptionsOne, _ = service.GetPrescriptionByIdsTxOne(ids_arr, adminUser.CurrentOrgId, tx)
5146 5184
 			} else {
5147 5185
 				prescriptions, _ = service.GetSettleHisPrescriptionTX(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
5186
+
5187
+				prescriptionsOne, _ = service.GetSettleHisPrescriptionTXOne(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
5148 5188
 			}
5149 5189
 		} else { //月结
5150 5190
 
@@ -5167,6 +5207,8 @@ func (c *HisApiController) GetUploadInfo() {
5167 5207
 			recordEndTime := theEndTime.Unix()
5168 5208
 			end_time = recordEndTime
5169 5209
 			prescriptions, _ = service.GetMonthHisPrescriptionTX(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type, tx)
5210
+
5211
+			prescriptionsOne, _ = service.GetMonthHisPrescriptionTXOne(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
5170 5212
 		}
5171 5213
 
5172 5214
 		timestamp := time.Now().Unix()
@@ -5298,6 +5340,137 @@ func (c *HisApiController) GetUploadInfo() {
5298 5340
 				customs = append(customs, cus)
5299 5341
 			}
5300 5342
 		}
5343
+
5344
+		var goods []*models.DialysisBeforePrepareGoods
5345
+		var newGoods []*models.NewDialysisBeforePrepareGoods
5346
+		var oldGoods []*models.OldDialysisBeforePrepareGoods
5347
+		var infos []*models.HisDoctorAdviceInfo
5348
+		var infoList []*models.HisDoctorAdviceInfo
5349
+		var hisAdvice []*models.HisDoctorAdviceInfo
5350
+		var newGoodOne []*models.NewDialysisBeforePrepareGoods
5351
+		houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5352
+
5353
+		settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5354
+		if settConfig.IsOpen == 1 {
5355
+			//判断库存的地方
5356
+			for _, info := range prescriptions {
5357
+				if info.Type == 1 {
5358
+					infos = append(infos, info.HisDoctorAdviceInfo...)
5359
+
5360
+				}
5361
+				if info.Type == 2 {
5362
+					for _, sumItem := range info.HisPrescriptionProject {
5363
+						if sumItem.Type == 3 {
5364
+							var good models.DialysisBeforePrepareGoods
5365
+							var newGood models.NewDialysisBeforePrepareGoods
5366
+							good.GoodId = sumItem.GoodInfo.ID
5367
+							good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5368
+							count, _ := strconv.Atoi(sumItem.Count)
5369
+							good.Count = int64(count)
5370
+							good.StorehouseId = houseConfig.StorehouseOutInfo
5371
+							good.ProjectId = sumItem.ID
5372
+							goods = append(goods, &good)
5373
+
5374
+							newGood.GoodId = sumItem.GoodInfo.ID
5375
+							newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5376
+							count2, _ := strconv.Atoi(sumItem.Count)
5377
+							newGood.Count = int64(count2)
5378
+							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5379
+							newGood.ProjectId = sumItem.ID
5380
+							newGoods = append(newGoods, &newGood)
5381
+						}
5382
+					}
5383
+				}
5384
+			}
5385
+
5386
+			for _, info := range prescriptionsOne {
5387
+				if info.Type == 1 {
5388
+					hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
5389
+				}
5390
+
5391
+				if info.Type == 2 {
5392
+					for _, sumItem := range info.HisPrescriptionProject {
5393
+						if sumItem.Type == 3 {
5394
+							var newGood models.NewDialysisBeforePrepareGoods
5395
+
5396
+							newGood.GoodId = sumItem.GoodInfo.ID
5397
+							newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5398
+							count2, _ := strconv.Atoi(sumItem.Count)
5399
+							newGood.Count = int64(count2)
5400
+							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5401
+							newGood.ProjectId = sumItem.ID
5402
+							newGoodOne = append(newGoodOne, &newGood)
5403
+						}
5404
+					}
5405
+				}
5406
+			}
5407
+
5408
+			//判断
5409
+			for _, itemOne := range infos {
5410
+				for _, itemTwo := range hisAdvice {
5411
+					if itemOne.DrugId == itemTwo.DrugId {
5412
+						itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
5413
+					}
5414
+				}
5415
+			}
5416
+
5417
+			for _, itemTwo := range hisAdvice {
5418
+				medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
5419
+				var sum_out_count int64
5420
+				for _, itemThree := range itemTwo.Child {
5421
+					var prescribing_number int64
5422
+					stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
5423
+					parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5424
+					if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5425
+						prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5426
+					}
5427
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5428
+						prescribing_number = parseIntPrescribingNumber
5429
+					}
5430
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5431
+						prescribing_number = parseIntPrescribingNumber
5432
+					}
5433
+					sum_out_count += prescribing_number
5434
+				}
5435
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId)
5436
+
5437
+				if sum_out_count > drugStockOut.FlushCount {
5438
+					c.ServeSuccessJSON(map[string]interface{}{
5439
+						"msg":  "2",
5440
+						"drug": medical,
5441
+					})
5442
+					return
5443
+				}
5444
+			}
5445
+
5446
+			for _, itemOne := range newGoods {
5447
+				for _, item := range newGoodOne {
5448
+					if itemOne.ProjectId == item.ProjectId {
5449
+						item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
5450
+					}
5451
+				}
5452
+			}
5453
+
5454
+			for _, item := range newGoodOne {
5455
+				var sum_out_count_one int64
5456
+				good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
5457
+
5458
+				for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
5459
+					sum_out_count_one += itemOne.Count
5460
+				}
5461
+				list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId)
5462
+				fmt.Println("sum_out_count_one", sum_out_count_one)
5463
+				fmt.Println("list.FlushCount", list.FlushCount)
5464
+				if sum_out_count_one > list.FlushCount {
5465
+					c.ServeSuccessJSON(map[string]interface{}{
5466
+						"msg":  "3",
5467
+						"good": good,
5468
+					})
5469
+					return
5470
+				}
5471
+			}
5472
+		}
5473
+
5301 5474
 		for _, item := range customs {
5302 5475
 			var advice_id int64 = 0
5303 5476
 			var project_id int64 = 0
@@ -5354,6 +5527,7 @@ func (c *HisApiController) GetUploadInfo() {
5354 5527
 		if dec_way == "true" {
5355 5528
 
5356 5529
 			tmpstring := strconv.FormatInt(order.ID, 10)
5530
+
5357 5531
 			//扣押金
5358 5532
 			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
5359 5533
 			order.Decimal = decimal
@@ -5364,21 +5538,18 @@ func (c *HisApiController) GetUploadInfo() {
5364 5538
 				return
5365 5539
 			}
5366 5540
 		}
5367
-		if err == nil {
5368
-			houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5369
-			var goods []*models.DialysisBeforePrepareGoods
5370
-			var newGoods []*models.NewDialysisBeforePrepareGoods
5371
-			var infos []*models.HisDoctorAdviceInfo
5372 5541
 
5542
+		if err == nil {
5373 5543
 			for _, info := range prescriptions {
5374 5544
 				if info.Type == 1 {
5375
-					infos = append(infos, info.HisDoctorAdviceInfo...)
5545
+					infoList = append(infoList, info.HisDoctorAdviceInfo...)
5376 5546
 				}
5377 5547
 				if info.Type == 2 {
5378 5548
 					for _, sumItem := range info.HisPrescriptionProject {
5379 5549
 						if sumItem.Type == 3 {
5380 5550
 							var good models.DialysisBeforePrepareGoods
5381 5551
 							var newGood models.NewDialysisBeforePrepareGoods
5552
+							var oldGood models.OldDialysisBeforePrepareGoods
5382 5553
 							good.GoodId = sumItem.GoodInfo.ID
5383 5554
 							good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5384 5555
 							count, _ := strconv.Atoi(sumItem.Count)
@@ -5394,18 +5565,80 @@ func (c *HisApiController) GetUploadInfo() {
5394 5565
 							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5395 5566
 							newGood.ProjectId = sumItem.ID
5396 5567
 							newGoods = append(newGoods, &newGood)
5568
+
5569
+							oldGood.GoodId = sumItem.GoodInfo.ID
5570
+							oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5571
+							count3, _ := strconv.Atoi(sumItem.Count)
5572
+							oldGood.Count = int64(count3)
5573
+							oldGood.StorehouseId = houseConfig.StorehouseOutInfo
5574
+							oldGood.ProjectId = sumItem.ID
5575
+							oldGood.RecordDate = sumItem.RecordDate
5576
+
5577
+							oldGoods = append(oldGoods, &oldGood)
5397 5578
 						}
5398 5579
 
5399 5580
 					}
5400 5581
 
5401 5582
 				}
5402 5583
 			}
5403
-			for _, item := range infos {
5404
-				service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5405
-				//service.DrugAutoAddCancelInfo(item, adminUser.AdminUser.Id)
5584
+			if settConfig.IsOpen == 1 {
5585
+				fmt.Println("infos23233232232323323233223wo", infoList)
5586
+				for _, item := range infoList {
5587
+					medical, _ := service.GetBaseDrugMedical(item.DrugId)
5588
+					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5589
+					//查询默认仓库
5590
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
5591
+					//查询默认仓库剩余多少库存
5592
+					var sum_count int64
5593
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
5594
+					for _, its := range stockInfo {
5595
+						if its.MaxUnit == medical.MaxUnit {
5596
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
5597
+						}
5598
+						sum_count += its.StockMaxNumber + its.StockMinNumber
5599
+					}
5600
+					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
5601
+					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5602
+				}
5603
+
5604
+				for _, item := range oldGoods {
5605
+					dialyPrepareOne := models.DialysisBeforePrepare{
5606
+						GoodTypeId:   item.GoodTypeId,
5607
+						GoodId:       item.GoodId,
5608
+						PatientId:    item.PatientId,
5609
+						RecordDate:   item.RecordDate,
5610
+						UserOrgId:    item.UserOrgId,
5611
+						Count:        item.Count,
5612
+						Ctime:        time.Now().Unix(),
5613
+						Creater:      adminUser.AdminUser.Id,
5614
+						CommdityCode: item.CommdityCode,
5615
+						Status:       1,
5616
+						StorehouseId: houseConfig.StorehouseOutInfo,
5617
+					}
5618
+					err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
5619
+				}
5406 5620
 
5621
+				service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5622
+				//查询默认仓库
5623
+				//storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5624
+				//stockList, _ := service.GetStockCountByGoodId(goods.GoodId, storeHouseConfig.StorehouseOutInfo,adminUser.CurrentOrgId)
5625
+				//var total_count int64
5626
+				//for _, it := range stockList {
5627
+				//  total_count += it.StockCount
5628
+				//}
5629
+				////基础库插入数据
5630
+				//service.UpdateGoodInfoReduceSumCount(goods.GoodId, total_count, adminUser.CurrentOrgId)
5631
+				//
5632
+				//////更新剩余库存
5633
+				//
5634
+				//goodList, _ := service.GetSumGoodList(adminUser.CurrentOrgId, storeHouseConfig.StorehouseOutInfo, goods.GoodId)
5635
+				//var flush_count int64
5636
+				//for _, it := range goodList {
5637
+				//  flush_count += it.StockCount
5638
+				//}
5639
+				//errs := service.UpdateSumGood(adminUser.CurrentOrgId, storeHouseConfig.StorehouseOutInfo, goods.GoodId, flush_count)
5640
+				//fmt.Println(errs)
5407 5641
 			}
5408
-			service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5409 5642
 
5410 5643
 			c.ServeSuccessJSON(map[string]interface{}{
5411 5644
 				"msg": "结算成功",
@@ -5438,12 +5671,14 @@ func (c *HisApiController) GetUploadInfo() {
5438 5671
 				return
5439 5672
 			}
5440 5673
 			if err == nil {
5441
-
5442 5674
 				houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5443 5675
 				var goods []*models.DialysisBeforePrepareGoods
5444 5676
 				var newGoods []*models.NewDialysisBeforePrepareGoods
5445 5677
 				var infos []*models.HisDoctorAdviceInfo
5446
-
5678
+				var hisAdvice []*models.HisDoctorAdviceInfo
5679
+				var newGoodOne []*models.NewDialysisBeforePrepareGoods
5680
+				var infolist []*models.HisDoctorAdviceInfo
5681
+				var oldGoods []*models.OldDialysisBeforePrepareGoods
5447 5682
 				for _, info := range prescriptions {
5448 5683
 					if info.Type == 1 {
5449 5684
 						infos = append(infos, info.HisDoctorAdviceInfo...)
@@ -5474,11 +5709,161 @@ func (c *HisApiController) GetUploadInfo() {
5474 5709
 
5475 5710
 					}
5476 5711
 				}
5477
-				for _, item := range infos {
5478
-					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5479 5712
 
5713
+				settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5714
+				if settConfig.IsOpen == 1 {
5715
+
5716
+					//判断库存的地方
5717
+					for _, info := range prescriptions {
5718
+						if info.Type == 1 {
5719
+							infolist = append(infolist, info.HisDoctorAdviceInfo...)
5720
+
5721
+						}
5722
+						if info.Type == 2 {
5723
+							for _, sumItem := range info.HisPrescriptionProject {
5724
+								if sumItem.Type == 3 {
5725
+									var good models.DialysisBeforePrepareGoods
5726
+									var newGood models.NewDialysisBeforePrepareGoods
5727
+									var oldGood models.OldDialysisBeforePrepareGoods
5728
+									good.GoodId = sumItem.GoodInfo.ID
5729
+									good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5730
+									count, _ := strconv.Atoi(sumItem.Count)
5731
+									good.Count = int64(count)
5732
+									good.StorehouseId = houseConfig.StorehouseOutInfo
5733
+									good.ProjectId = sumItem.ID
5734
+									goods = append(goods, &good)
5735
+
5736
+									newGood.GoodId = sumItem.GoodInfo.ID
5737
+									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5738
+									count2, _ := strconv.Atoi(sumItem.Count)
5739
+									newGood.Count = int64(count2)
5740
+									newGood.StorehouseId = houseConfig.StorehouseOutInfo
5741
+									newGood.ProjectId = sumItem.ID
5742
+									newGoods = append(newGoods, &newGood)
5743
+
5744
+									oldGood.GoodId = sumItem.GoodInfo.ID
5745
+									oldGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5746
+									count3, _ := strconv.Atoi(sumItem.Count)
5747
+									oldGood.Count = int64(count3)
5748
+									oldGood.StorehouseId = houseConfig.StorehouseOutInfo
5749
+									oldGood.ProjectId = sumItem.ID
5750
+									oldGood.RecordDate = sumItem.RecordDate
5751
+
5752
+									oldGoods = append(oldGoods, &oldGood)
5753
+								}
5754
+							}
5755
+						}
5756
+					}
5757
+
5758
+					for _, info := range prescriptionsOne {
5759
+						if info.Type == 1 {
5760
+							hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
5761
+						}
5762
+
5763
+						if info.Type == 2 {
5764
+							for _, sumItem := range info.HisPrescriptionProject {
5765
+								if sumItem.Type == 3 {
5766
+									var newGood models.NewDialysisBeforePrepareGoods
5767
+
5768
+									newGood.GoodId = sumItem.GoodInfo.ID
5769
+									newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5770
+									count2, _ := strconv.Atoi(sumItem.Count)
5771
+									newGood.Count = int64(count2)
5772
+									newGood.StorehouseId = houseConfig.StorehouseOutInfo
5773
+									newGood.ProjectId = sumItem.ID
5774
+									newGoodOne = append(newGoodOne, &newGood)
5775
+								}
5776
+							}
5777
+						}
5778
+					}
5779
+
5780
+					//判断
5781
+					for _, itemOne := range infos {
5782
+						for _, itemTwo := range hisAdvice {
5783
+							if itemOne.DrugId == itemTwo.DrugId {
5784
+								itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
5785
+							}
5786
+						}
5787
+					}
5788
+
5789
+					for _, itemTwo := range hisAdvice {
5790
+						medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
5791
+						var sum_out_count int64
5792
+						for _, itemThree := range itemTwo.Child {
5793
+							var prescribing_number int64
5794
+							stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
5795
+							parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5796
+							if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5797
+								prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5798
+							}
5799
+							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5800
+								prescribing_number = parseIntPrescribingNumber
5801
+							}
5802
+							if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5803
+								prescribing_number = parseIntPrescribingNumber
5804
+							}
5805
+							sum_out_count += prescribing_number
5806
+						}
5807
+						drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId)
5808
+
5809
+						if sum_out_count > drugStockOut.FlushCount {
5810
+							c.ServeSuccessJSON(map[string]interface{}{
5811
+								"msg":  "2",
5812
+								"drug": medical,
5813
+							})
5814
+							return
5815
+						}
5816
+					}
5817
+
5818
+					for _, itemOne := range newGoods {
5819
+						for _, item := range newGoodOne {
5820
+							if itemOne.ProjectId == item.ProjectId {
5821
+								item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
5822
+							}
5823
+						}
5824
+					}
5825
+
5826
+					for _, item := range newGoodOne {
5827
+						var sum_out_count_one int64
5828
+						good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
5829
+
5830
+						for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
5831
+							sum_out_count_one += itemOne.Count
5832
+						}
5833
+						list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId)
5834
+						fmt.Println("sum_out_count_one", sum_out_count_one)
5835
+						fmt.Println("list.FlushCount", list.FlushCount)
5836
+						if sum_out_count_one > list.FlushCount {
5837
+							c.ServeSuccessJSON(map[string]interface{}{
5838
+								"msg":  "3",
5839
+								"good": good,
5840
+							})
5841
+							return
5842
+						}
5843
+					}
5844
+
5845
+					fmt.Println("infos233232323223323232323232323232", infolist)
5846
+					for _, item := range infolist {
5847
+						service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5848
+					}
5849
+					for _, item := range oldGoods {
5850
+						dialyPrepareOne := models.DialysisBeforePrepare{
5851
+							GoodTypeId:   item.GoodTypeId,
5852
+							GoodId:       item.GoodId,
5853
+							PatientId:    item.PatientId,
5854
+							RecordDate:   item.RecordDate,
5855
+							UserOrgId:    item.UserOrgId,
5856
+							Count:        item.Count,
5857
+							Ctime:        time.Now().Unix(),
5858
+							Creater:      adminUser.AdminUser.Id,
5859
+							CommdityCode: item.CommdityCode,
5860
+							Status:       1,
5861
+							StorehouseId: houseConfig.StorehouseOutInfo,
5862
+						}
5863
+						err = service.CreateDialysisBeforePrepareOne(&dialyPrepareOne)
5864
+					}
5865
+					service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5480 5866
 				}
5481
-				service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5482 5867
 
5483 5868
 				c.ServeSuccessJSON(map[string]interface{}{
5484 5869
 					"msg": "结算成功",
@@ -5509,10 +5894,6 @@ func (c *HisApiController) Refund() {
5509 5894
 		}
5510 5895
 	}
5511 5896
 
5512
-	if order.ID == 0 {
5513
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5514
-		return
5515
-	}
5516 5897
 	orders, _ := service.GetHisOrderDetailByNumberThree(order.Number, order.UserOrgId)
5517 5898
 	houseConfig, _ := service.GetAllStoreHouseConfig(order.UserOrgId)
5518 5899
 	var goods []*models.DialysisBeforePrepareGoods
@@ -5533,6 +5914,7 @@ func (c *HisApiController) Refund() {
5533 5914
 				good.Count = int64(count)
5534 5915
 				good.StorehouseId = houseConfig.StorehouseOutInfo
5535 5916
 				good.ProjectId = info.HisPrescriptionProject.ID
5917
+
5536 5918
 				goods = append(goods, &good)
5537 5919
 
5538 5920
 				newGood.GoodId = info.HisPrescriptionProject.VMGoodInfo.ID
@@ -5541,12 +5923,23 @@ func (c *HisApiController) Refund() {
5541 5923
 				newGood.Count = int64(count2)
5542 5924
 				newGood.StorehouseId = houseConfig.StorehouseOutInfo
5543 5925
 				newGood.ProjectId = info.HisPrescriptionProject.ID
5926
+				newGood.RecordDate = order.SettleAccountsDate
5927
+				newGood.UserOrgId = order.UserOrgId
5544 5928
 				newGoods = append(newGoods, &newGood)
5545 5929
 			}
5546 5930
 		}
5547 5931
 	}
5548
-	for _, item := range infos {
5549
-		service.DrugAutoAddCancelInfo(item, order.Creator)
5932
+	settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5933
+	if settConfig.IsOpen == 1 {
5934
+		for _, item := range infos {
5935
+
5936
+			service.DrugAutoAddCancelInfo(item, adminUser.AdminUser.Id)
5937
+
5938
+		}
5939
+
5940
+		for _, item := range newGoods {
5941
+			service.GoodAutoAddCancelInfo(item, adminUser.AdminUser.Id)
5942
+		}
5550 5943
 	}
5551 5944
 
5552 5945
 	c.ServeSuccessJSON(map[string]interface{}{

+ 7 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -269,7 +269,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
269 269
 
270 270
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
271 271
 
272
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 53 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 {
272
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 53 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 || adminUserInfo.Org.Id == 10432 {
273 273
 		dewater_amount = dewater_amount * 1000
274 274
 	}
275 275
 
@@ -379,6 +379,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
379 379
 			newprescribe.Remark = dialysisSolution.Remark
380 380
 			if adminUserInfo.Org.Id == 10340 {
381 381
 				newprescribe.TargetUltrafiltration = 0
382
+				newprescribe.Sodium = 138
383
+				newprescribe.Bicarbonate = 31.1
384
+				newprescribe.DialysateFlow = 500
382 385
 			}
383 386
 			//插入透析处方
384 387
 			err := service.AddSigleRecord(&newprescribe)
@@ -659,6 +662,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
659 662
 				if adminUserInfo.Org.Id == 10318 {
660 663
 					evaluation.Remark = "患者已确认无发热,无流行病学接触史"
661 664
 				}
665
+				if adminUserInfo.Org.Id == 10340 {
666
+					evaluation.BreathingRate = "20"
667
+				}
662 668
 			}
663 669
 		} else {
664 670
 			evaluation.UpdatedTime = time.Now().Unix()

+ 578 - 31
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -88,7 +88,7 @@ func (this *DialysisAPIController) Scheduals() {
88 88
 
89 89
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
90 90
 	scheduals_json_str, _ := redis.Get(key).Result()
91
-	redis.Set(scheduals_json_str, "", time.Second)
91
+	redis.Set(key, "", time.Second)
92 92
 	patients, _ := service.GetAllPatientListSix(orgID)
93 93
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
94 94
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
@@ -105,8 +105,8 @@ func (this *DialysisAPIController) Scheduals() {
105 105
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
106 106
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
107 107
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
108
+				dobulecheck, _ := service.GetAllDobuleCheckList(orgID, date.Unix())
108 109
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
109
-
110 110
 				for key, item := range scheduals {
111 111
 					// 获取患者信息
112 112
 					for _, patient := range patients {
@@ -178,6 +178,13 @@ func (this *DialysisAPIController) Scheduals() {
178 178
 							break
179 179
 						}
180 180
 					}
181
+
182
+					for _, check := range dobulecheck {
183
+						if item.PatientId == check.PatientId {
184
+							scheduals[key].DoubleCheck = check
185
+							break
186
+						}
187
+					}
181 188
 				}
182 189
 				//缓存数据
183 190
 				scheduals_json, err := json.Marshal(&scheduals)
@@ -194,6 +201,8 @@ func (this *DialysisAPIController) Scheduals() {
194 201
 				project, _ = service.GetAllHisProjectPrescription(orgID, date.Unix())
195 202
 			}
196 203
 
204
+			//list, _ := service.GetZoneCountList(orgID, date.Unix())
205
+
197 206
 			this.ServeSuccessJSON(map[string]interface{}{
198 207
 				"scheduals": scheduals,
199 208
 				"project":   project,
@@ -554,7 +563,6 @@ func (this *DialysisAPIController) DialysisRecord() {
554 563
 	if is_advice_open.IsAdviceOpen == 1 {
555 564
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
556 565
 	}
557
-	fmt.Println("doctorAdvices23344334344433434334343434wode", doctorAdvices)
558 566
 
559 567
 	lastOrder, _ := service.GetLastDilysisOrder(adminInfo.Org.Id, patientID, date.Unix())
560 568
 	returnData := map[string]interface{}{
@@ -739,15 +747,6 @@ func (c *DialysisAPIController) PostDoubleCheck() {
739 747
 		return
740 748
 	}
741 749
 
742
-	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
743
-
744
-		list, _ := service.GetRoleList(adminUserInfo.Org.Id, modifier)
745
-		if employee_number != list.JobNumber {
746
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorEmployeeNumber)
747
-			return
748
-		}
749
-	}
750
-
751 750
 	if len(recordDateStr) == 0 {
752 751
 		recordDateStr = time.Now().Format("2006-01-02")
753 752
 	}
@@ -776,10 +775,31 @@ func (c *DialysisAPIController) PostDoubleCheck() {
776 775
 		firstCheckDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", firstCheckTimeStr)
777 776
 		firstCheckDate = firstCheckDateUnix.Unix()
778 777
 	}
779
-	//now := time.Now()
780
-	//year, month, day := now.Date()
781
-	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
782
-	//todayTimeStamp := today_time.Unix()
778
+
779
+	if adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10340 {
780
+
781
+		list, _ := service.GetRoleList(adminUserInfo.Org.Id, modifier)
782
+		_, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
783
+		if check.ID == 0 {
784
+			if employee_number != list.JobNumber {
785
+				c.ServeSuccessJSON(map[string]interface{}{
786
+					"doubleCheck": check,
787
+					"msg":         "2",
788
+				})
789
+				return
790
+			}
791
+		}
792
+		if check.ID > 0 {
793
+			if employee_number != list.JobNumber {
794
+				c.ServeSuccessJSON(map[string]interface{}{
795
+					"doubleCheck": check,
796
+					"msg":         "2",
797
+				})
798
+				return
799
+			}
800
+		}
801
+
802
+	}
783 803
 
784 804
 	doubleCheck := models.DoubleCheck{
785 805
 		UserOrgId:                  adminUserInfo.Org.Id,
@@ -837,6 +857,7 @@ func (c *DialysisAPIController) PostDoubleCheck() {
837 857
 		if err == nil {
838 858
 			c.ServeSuccessJSON(map[string]interface{}{
839 859
 				"doubleCheck": &doubleCheck,
860
+				"msg":         "1",
840 861
 			})
841 862
 		}
842 863
 
@@ -1107,6 +1128,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1107 1128
 		Complication:                 complications,
1108 1129
 		DialysisIntakes:              dialysateVolume,
1109 1130
 		CreatedTime:                  time.Now().Unix(),
1131
+		UpdatedTime:                  time.Now().Unix(),
1110 1132
 		Status:                       1,
1111 1133
 		Remark:                       remark,
1112 1134
 		BloodAccessPartId:            blood_access_part_id,
@@ -1361,6 +1383,8 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1361 1383
 	dry_water_hour := c.GetString("dry_water_hour")
1362 1384
 
1363 1385
 	water_machine := c.GetString("water_machine")
1386
+	add_amount, _ := c.GetFloat("add_amount")
1387
+	reduce_amount, _ := c.GetFloat("reduce_amount")
1364 1388
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1365 1389
 
1366 1390
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
@@ -1471,6 +1495,8 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1471 1495
 		DrhyWater:                  drhy_water,
1472 1496
 		DryWaterHour:               dry_water_hour,
1473 1497
 		WaterMachine:               water_machine,
1498
+		AddAmount:                  add_amount,
1499
+		ReduceAmount:               reduce_amount,
1474 1500
 	}
1475 1501
 
1476 1502
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1821,7 +1847,7 @@ func (c *DialysisAPIController) Finish() {
1821 1847
 
1822 1848
 	}
1823 1849
 
1824
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 {
1850
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10414 || adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10223 {
1825 1851
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1826 1852
 		if evaluation.SystolicBloodPressure == 0 {
1827 1853
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
@@ -2103,7 +2129,8 @@ func (this *DialysisAPIController) StartDialysis() {
2103 2129
 	zone_id, _ := this.GetInt64("zone_id")
2104 2130
 	elecsign := this.GetString("url")
2105 2131
 	nuclein_date_str := this.GetString("nuclein_date_str")
2106
-
2132
+	schedule_remark := this.GetString("schedule_remark")
2133
+	order_remark := this.GetString("order_remark")
2107 2134
 	if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
2108 2135
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2109 2136
 		return
@@ -2186,7 +2213,7 @@ func (this *DialysisAPIController) StartDialysis() {
2186 2213
 		}
2187 2214
 		theNucleinDate = theTime.Unix()
2188 2215
 	}
2189
-	fmt.Println("wo2o3o23o2o2323oo232o3swo", theNucleinDate)
2216
+
2190 2217
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
2191 2218
 
2192 2219
 	//查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
@@ -2303,13 +2330,15 @@ func (this *DialysisAPIController) StartDialysis() {
2303 2330
 		BloodAccessId:          blood_access_id,
2304 2331
 		Url:                    elecsign,
2305 2332
 		NucleinDate:            theNucleinDate,
2333
+		ScheduleRemark:         schedule_remark,
2334
+		OrderRemark:            order_remark,
2306 2335
 	}
2307 2336
 	//查询该床位是否有人用了
2308 2337
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
2309 2338
 	if errorscode == gorm.ErrRecordNotFound {
2310 2339
 
2311 2340
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2312
-
2341
+		service.UpdateMobilePatient(adminUserInfo.Org.Id, patientID, schedule_remark)
2313 2342
 		redis := service.RedisClient()
2314 2343
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2315 2344
 		redis.Set(key, "", time.Second)
@@ -2372,7 +2401,7 @@ func (this *DialysisAPIController) StartDialysis() {
2372 2401
 
2373 2402
 			//针对肇庆三鹤血液透析中心
2374 2403
 
2375
-			if template.TemplateId == 43 {
2404
+			if template.TemplateId == 43 || adminUserInfo.Org.Id == 10432 {
2376 2405
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2377 2406
 			}
2378 2407
 
@@ -2405,9 +2434,10 @@ func (this *DialysisAPIController) StartDialysis() {
2405 2434
 	}
2406 2435
 
2407 2436
 	//只针对广慈医院
2408
-	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 || adminUserInfo.Org.Id == 9918 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 {
2437
+	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 || adminUserInfo.Org.Id == 9918 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10432 {
2409 2438
 		// 查询病人是否有透前评估数据
2410 2439
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
2440
+
2411 2441
 		//如果有数据就插入
2412 2442
 		if errcode == nil {
2413 2443
 			record.SystolicBloodPressure = befor.SystolicBloodPressure
@@ -2430,7 +2460,17 @@ func (this *DialysisAPIController) StartDialysis() {
2430 2460
 			record.VenousPressure = 80
2431 2461
 			record.TransmembranePressure = 60
2432 2462
 		}
2463
+		//针对兰溪人民医院的需求
2464
+		if adminUserInfo.Org.Id == 10430 || adminUserInfo.Org.Id == 9671 {
2465
+			befor, _ := service.GetAssessmentBeforThrity(adminUserInfo.Org.Id, patientID, recordDate.Unix())
2466
+			record.SystolicBloodPressure = befor.SystolicBloodPressure
2467
+			record.DiastolicBloodPressure = befor.DiastolicBloodPressure
2468
+			record.Temperature = befor.Temperature
2469
+			record.PulseFrequency = befor.PulseFrequency
2470
+			record.BreathingRate = befor.BreathingRate
2471
+		}
2433 2472
 		err := service.CreateMonitor(&record)
2473
+
2434 2474
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2435 2475
 
2436 2476
 		redis := service.RedisClient()
@@ -2578,6 +2618,8 @@ func (c *DialysisAPIController) PostSolution() {
2578 2618
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2579 2619
 
2580 2620
 	is_water := c.GetString("is_water")
2621
+	add_amount, _ := c.GetFloat("add_amount")
2622
+	reduce_amount, _ := c.GetFloat("reduce_amount")
2581 2623
 	var is_war int64
2582 2624
 	if is_water == "是" {
2583 2625
 		is_war = 1
@@ -2702,6 +2744,8 @@ func (c *DialysisAPIController) PostSolution() {
2702 2744
 		DrhyWater:                  drhy_water,
2703 2745
 		DryWaterHour:               dry_water_hour,
2704 2746
 		WaterMachine:               water_machine,
2747
+		AddAmount:                  add_amount,
2748
+		ReduceAmount:               reduce_amount,
2705 2749
 	}
2706 2750
 
2707 2751
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -2799,6 +2843,7 @@ func (c *DialysisAPIController) PostSolution() {
2799 2843
 		EpoCount:                   epo_count,
2800 2844
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2801 2845
 		PreImpulse:                 impulse,
2846
+		SolutionStatus:             1,
2802 2847
 	}
2803 2848
 
2804 2849
 	//针对河间咸的
@@ -3028,9 +3073,8 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3028 3073
 				record.UltrafiltrationRate = ultrafiltration_rate
3029 3074
 			}
3030 3075
 
3031
-			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 {
3076
+			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 {
3032 3077
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3033
-				fmt.Println("ultrafiltration_rate2332323223322332q", ultrafiltration_rate)
3034 3078
 				record.UltrafiltrationRate = ultrafiltration_rate
3035 3079
 			}
3036 3080
 			//if template.TemplateId == 47 {
@@ -3058,7 +3102,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3058 3102
 		}
3059 3103
 	}
3060 3104
 
3061
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 {
3105
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 {
3062 3106
 
3063 3107
 		if ultrafiltration_rate > 0 {
3064 3108
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
@@ -3098,6 +3142,8 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
3098 3142
 	dialysis_irrigation := this.GetString("dialysis_irrigation")
3099 3143
 	blood_access_id, _ := this.GetInt64("blood_access_id")
3100 3144
 	nuclein_date_str := this.GetString("nuclein_date_str")
3145
+	order_remark := this.GetString("order_remark")
3146
+	schedule_remark := this.GetString("schedule_remark")
3101 3147
 	if record_id == 0 {
3102 3148
 		this.ErrorLog("id:%v", record_id)
3103 3149
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -3260,9 +3306,13 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
3260 3306
 		DialysisIrrigation:     dialysis_irrigation,
3261 3307
 		BloodAccessId:          blood_access_id,
3262 3308
 		NucleinDate:            theNucleinDate,
3309
+		OrderRemark:            order_remark,
3310
+		ScheduleRemark:         schedule_remark,
3263 3311
 	}
3264 3312
 
3265 3313
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
3314
+	order, _ := service.GetLastPatientOrder(record_id)
3315
+	service.UpdateMobilePatient(adminUserInfo.Org.Id, order.PatientId, schedule_remark)
3266 3316
 	redis := service.RedisClient()
3267 3317
 
3268 3318
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
@@ -3767,7 +3817,7 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
3767 3817
 		advice.UserOrgId = adminUserInfo.Org.Id
3768 3818
 		advice.PatientId = patient
3769 3819
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3770
-
3820
+		advice.IsSettle = 2
3771 3821
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
3772 3822
 			utils.ErrorLog("advice_name")
3773 3823
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -3894,7 +3944,7 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
3894 3944
 					child.UserOrgId = adminUserInfo.Org.Id
3895 3945
 					child.PatientId = patient
3896 3946
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
3897
-
3947
+					child.IsSettle = 1
3898 3948
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
3899 3949
 						utils.ErrorLog("child advice_name")
3900 3950
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -4084,15 +4134,16 @@ func (c *DialysisAPIController) GetSolution() {
4084 4134
 	solution, err := service.MobileGetDialysisSolutionByModeIdSeven(adminUserInfo.Org.Id, patient_id, mode_id)
4085 4135
 	prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSeven(adminUserInfo.Org.Id, patient_id, mode_id)
4086 4136
 	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSeven(adminUserInfo.Org.Id, mode_id)
4087
-
4137
+	dialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient_id, adminUserInfo.Org.Id)
4088 4138
 	if err != nil {
4089 4139
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
4090 4140
 		return
4091 4141
 	}
4092 4142
 	c.ServeSuccessJSON(map[string]interface{}{
4093
-		"solution":            solution,
4094
-		"prescription":        prescription,
4095
-		"system_prescription": system_prescription,
4143
+		"solution":             solution,
4144
+		"prescription":         prescription,
4145
+		"system_prescription":  system_prescription,
4146
+		"dialysisPrescription": dialysisPrescription,
4096 4147
 	})
4097 4148
 
4098 4149
 }
@@ -6978,6 +7029,502 @@ func (this *DialysisAPIController) GetDialysisRecordOrder() {
6978 7029
 	})
6979 7030
 }
6980 7031
 
7032
+func (this *DialysisAPIController) GetScheduleTypeByIdList() {
7033
+
7034
+	org_id := this.GetMobileAdminUserInfo().Org.Id
7035
+
7036
+	schedule_date := this.GetString("schedule_date")
7037
+	schedule_type, _ := this.GetInt64("schedule_type")
7038
+	timeLayout := "2006-01-02"
7039
+	loc, _ := time.LoadLocation("Local")
7040
+	var startdateunix int64
7041
+
7042
+	if len(schedule_date) > 0 {
7043
+		theTime, err := time.ParseInLocation(timeLayout+"15:04:05", schedule_date+"00:00:00", loc)
7044
+		if err != nil {
7045
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7046
+			return
7047
+		}
7048
+		startdateunix = theTime.Unix()
7049
+	}
7050
+
7051
+	list, _ := service.GetScheduleTypeById(org_id, startdateunix, schedule_type)
7052
+	scheduals, _ := service.MobileGetDialysisScheduals(org_id, startdateunix, schedule_type)
7053
+	devices, _ := service.GetAllDevicetByListSix(org_id)
7054
+	for key, item := range scheduals {
7055
+		// 床位信息
7056
+		for _, device := range devices {
7057
+			if item.BedId == device.ID {
7058
+				scheduals[key].DeviceNumber = device
7059
+				break
7060
+			}
7061
+		}
7062
+
7063
+	}
7064
+	this.ServeSuccessJSON(map[string]interface{}{
7065
+		"list":      list,
7066
+		"scheduals": scheduals,
7067
+	})
7068
+}
7069
+
7070
+func (this *DialysisAPIController) SavePatientPicture() {
7071
+
7072
+	patient_id, _ := this.GetInt64("patient_id")
7073
+	dialysis_date, _ := this.GetInt64("schedule_date")
7074
+	avatar := this.GetString("avatar")
7075
+	fmt.Println("patient_id", patient_id)
7076
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7077
+
7078
+	order := models.DialysisOrder{
7079
+		Url: avatar,
7080
+	}
7081
+	err := service.UpdatePatientSign(patient_id, dialysis_date, order, orgId)
7082
+	redis := service.RedisClient()
7083
+
7084
+	key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":dialysis_order"
7085
+	redis.Set(key, "", time.Second)
7086
+	keyOne := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":dialysis_orders_list_all"
7087
+	//清空key 值
7088
+	redis.Set(keyOne, "", time.Second)
7089
+	keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":doctor_advices"
7090
+	redis.Set(keyThree, "", time.Second)
7091
+	keyFour := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":monitor_records"
7092
+	redis.Set(keyFour, "", time.Second)
7093
+
7094
+	keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":patient_info"
7095
+	redis.Set(keyFive, "", time.Second)
7096
+
7097
+	keySix := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysis_date, 10) + ":his_doctor_advice"
7098
+	redis.Set(keySix, "", time.Second)
7099
+
7100
+	keySeven := strconv.FormatInt(orgId, 10) + ":" + ":device_list_all"
7101
+	redis.Set(keySeven, "", time.Second)
7102
+	if err != nil {
7103
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
7104
+		return
7105
+	}
7106
+	this.ServeSuccessJSON(map[string]interface{}{
7107
+		"order": order,
7108
+	})
7109
+}
7110
+
7111
+func (this *DialysisAPIController) ExectionMobileAdvice() {
7112
+
7113
+	ids := this.GetString("ids")
7114
+	idSplit := strings.Split(ids, ",")
7115
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7116
+
7117
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
7118
+	execution_time := this.GetString("exce_time")
7119
+	timeLayout2 := "2006-01-02 15:04:05"
7120
+	loc, _ := time.LoadLocation("Local")
7121
+
7122
+	theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
7123
+	if errs != nil {
7124
+		utils.ErrorLog(errs.Error())
7125
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7126
+		return
7127
+	}
7128
+	//his客户
7129
+	if config.IsOpen == 1 {
7130
+
7131
+		list, _ := service.GetHisMobileAdviceGroupList(orgId, idSplit)
7132
+		adviceList, _ := service.GetHisMobileAdviceList(orgId, idSplit)
7133
+		for _, item := range list {
7134
+			for _, it := range adviceList {
7135
+				if item.DrugId == it.DrugId {
7136
+					item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
7137
+				}
7138
+			}
7139
+		}
7140
+
7141
+		for _, item := range list {
7142
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
7143
+			var sum_out_count int64
7144
+			for _, itemThree := range item.ChildDoctorAdvice {
7145
+				var prescribing_number int64
7146
+				stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
7147
+				parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
7148
+				if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
7149
+					prescribing_number = parseIntPrescribingNumber * medical.MinNumber
7150
+				}
7151
+				if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
7152
+					prescribing_number = parseIntPrescribingNumber
7153
+				}
7154
+				if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
7155
+					prescribing_number = parseIntPrescribingNumber
7156
+				}
7157
+				sum_out_count += prescribing_number
7158
+			}
7159
+			drugStockOut, _ := service.GetDrugSumOutCountByDrugId(item.DrugId, orgId)
7160
+
7161
+			//库存不足
7162
+			if sum_out_count > drugStockOut.FlushCount {
7163
+				this.ServeSuccessJSON(map[string]interface{}{
7164
+					"msg":  "2",
7165
+					"drug": medical,
7166
+					"ids":  ids,
7167
+				})
7168
+				return
7169
+			}
7170
+		}
7171
+		creater := this.GetMobileAdminUserInfo().AdminUser.Id
7172
+		//执行医嘱
7173
+		errs := service.ExectionMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
7174
+		advices, _ := service.FindHisDoctorAdviceByIds(orgId, idSplit)
7175
+		for _, item := range advices {
7176
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7177
+			redis := service.RedisClient()
7178
+			//清空key 值
7179
+			redis.Set(key, "", time.Second)
7180
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7181
+			redis.Set(keyTwo, "", time.Second)
7182
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7183
+			redis.Set(keyThree, "", time.Second)
7184
+			recordDate := theTime.Format("2006-01-02")
7185
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7186
+
7187
+			redis.Set(keyFour, "", time.Second)
7188
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7189
+			redis.Set(keyFive, "", time.Second)
7190
+
7191
+			defer redis.Close()
7192
+		}
7193
+		if errs == nil {
7194
+
7195
+			//药品管理信息
7196
+			_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
7197
+			storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7198
+			if drugStockConfig.IsOpen == 1 {
7199
+				for _, item := range advices {
7200
+					advice, _ := service.FindHisDoctorAdviceById(orgId, item.ID)
7201
+					config, _ := service.GetDrugOpenConfigOne(orgId)
7202
+					if config.IsOpen != 1 {
7203
+						//查询该药品是否有库存
7204
+						medical, _ := service.GetBaseDrugMedical(item.DrugId)
7205
+						pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
7206
+						if medical.IsUse == 2 {
7207
+							if config.IsOpen != 1 {
7208
+								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7209
+									service.HisDrugsDelivery(orgId, creater, &advice)
7210
+								}
7211
+								if pharmacyConfig.IsOpen != 1 {
7212
+									service.HisDrugsDelivery(orgId, creater, &advice)
7213
+								}
7214
+
7215
+								//更新字典里面的库存
7216
+								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
7217
+								var sum_count int64
7218
+								for _, its := range stockInfo {
7219
+									if its.MaxUnit == medical.MaxUnit {
7220
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
7221
+									}
7222
+									sum_count += its.StockMaxNumber + its.StockMinNumber
7223
+								}
7224
+								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7225
+								//剩余库存
7226
+								service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7227
+							}
7228
+
7229
+						}
7230
+
7231
+					}
7232
+				}
7233
+			}
7234
+			this.ServeSuccessJSON(map[string]interface{}{
7235
+				"msg": "1",
7236
+				"ids": ids,
7237
+			})
7238
+			return
7239
+		} else {
7240
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
7241
+		}
7242
+	}
7243
+
7244
+	fmt.Println("config233322333223", config.IsOpen)
7245
+
7246
+	//血透客户
7247
+	if config.IsOpen == 2 || config.IsOpen == 0 {
7248
+
7249
+		//药品管理信息
7250
+		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
7251
+		if drugStockConfig.IsOpen == 1 {
7252
+			list, _ := service.GetBloodMobileAdviceGroupList(orgId, idSplit)
7253
+			adviceList, _ := service.GetBloodMobileAdviceList(orgId, idSplit)
7254
+			for _, item := range list {
7255
+				for _, it := range adviceList {
7256
+					if item.DrugId == it.DrugId {
7257
+						item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
7258
+					}
7259
+				}
7260
+			}
7261
+			for _, item := range list {
7262
+				medical, _ := service.GetBaseDrugMedical(item.DrugId)
7263
+				var sum_out_count int64
7264
+				for _, itemThree := range item.ChildDoctorAdvice {
7265
+					var prescribing_number int64
7266
+					stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
7267
+					parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
7268
+					if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
7269
+						prescribing_number = parseIntPrescribingNumber * medical.MinNumber
7270
+					}
7271
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
7272
+						prescribing_number = parseIntPrescribingNumber
7273
+					}
7274
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
7275
+						prescribing_number = parseIntPrescribingNumber
7276
+					}
7277
+					sum_out_count += prescribing_number
7278
+				}
7279
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(item.DrugId, orgId)
7280
+
7281
+				//库存不足
7282
+				if sum_out_count > drugStockOut.FlushCount {
7283
+					this.ServeSuccessJSON(map[string]interface{}{
7284
+						"msg":  "2",
7285
+						"drug": medical,
7286
+						"ids":  ids,
7287
+					})
7288
+					return
7289
+				}
7290
+			}
7291
+
7292
+			creater := this.GetMobileAdminUserInfo().AdminUser.Id
7293
+			fmt.Println("creater2332243244224242424", creater)
7294
+			//执行医嘱
7295
+			errs := service.ExectionBloodMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
7296
+			advices, _ := service.FindAllDoctorAdviceByIds(orgId, idSplit)
7297
+			for _, item := range advices {
7298
+				key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7299
+				redis := service.RedisClient()
7300
+				//清空key 值
7301
+				redis.Set(key, "", time.Second)
7302
+				keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7303
+				redis.Set(keyTwo, "", time.Second)
7304
+				keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7305
+				redis.Set(keyThree, "", time.Second)
7306
+				recordDate := theTime.Format("2006-01-02")
7307
+				keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7308
+
7309
+				redis.Set(keyFour, "", time.Second)
7310
+				keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7311
+				redis.Set(keyFive, "", time.Second)
7312
+
7313
+				defer redis.Close()
7314
+			}
7315
+			if errs == nil {
7316
+
7317
+				for _, item := range advices {
7318
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
7319
+					medical, _ := service.GetBaseDrugMedical(item.DrugId)
7320
+					//查询是否出库按钮开启
7321
+					adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
7322
+					if adviceSetting.IsAdviceOpen == 1 {
7323
+						//查询是否出库按钮开启
7324
+						prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
7325
+						pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
7326
+						if prescriptionConfig.IsOpen == 1 {
7327
+							if medical.IsUse == 2 {
7328
+								if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7329
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7330
+								}
7331
+								if pharmacyConfig.IsOpen != 1 {
7332
+									service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7333
+								}
7334
+
7335
+								//更新字典里面的库存
7336
+								stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
7337
+								var sum_count int64
7338
+								for _, its := range stockInfo {
7339
+									if its.MaxUnit == medical.MaxUnit {
7340
+										its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
7341
+									}
7342
+									sum_count += its.StockMaxNumber + its.StockMinNumber
7343
+								}
7344
+								service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7345
+								//剩余库存
7346
+								service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7347
+							}
7348
+						}
7349
+					} else {
7350
+						pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
7351
+						if medical.IsUse == 2 {
7352
+							if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
7353
+								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7354
+							}
7355
+							if pharmacyConfig.IsOpen != 1 {
7356
+								service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
7357
+							}
7358
+
7359
+							stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
7360
+							var sum_count int64
7361
+							for _, its := range stockInfo {
7362
+								if its.MaxUnit == medical.MaxUnit {
7363
+									its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
7364
+								}
7365
+								sum_count += its.StockMaxNumber + its.StockMinNumber
7366
+							}
7367
+							service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
7368
+							//剩余库存
7369
+							service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
7370
+						}
7371
+					}
7372
+				}
7373
+			}
7374
+			this.ServeSuccessJSON(map[string]interface{}{
7375
+				"msg": "1",
7376
+				"ids": ids,
7377
+			})
7378
+			return
7379
+
7380
+		} else {
7381
+
7382
+			creater := this.GetMobileAdminUserInfo().AdminUser.Id
7383
+			//执行医嘱
7384
+			service.ExectionBloodMobileAdvice(orgId, idSplit, theTime.Unix(), creater)
7385
+			advices, _ := service.FindAllDoctorAdviceByIds(orgId, idSplit)
7386
+			for _, item := range advices {
7387
+				key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7388
+				redis := service.RedisClient()
7389
+				//清空key 值
7390
+				redis.Set(key, "", time.Second)
7391
+				keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7392
+				redis.Set(keyTwo, "", time.Second)
7393
+				keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7394
+				redis.Set(keyThree, "", time.Second)
7395
+				recordDate := theTime.Format("2006-01-02")
7396
+				keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7397
+
7398
+				redis.Set(keyFour, "", time.Second)
7399
+				keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7400
+				redis.Set(keyFive, "", time.Second)
7401
+
7402
+				defer redis.Close()
7403
+			}
7404
+			this.ServeSuccessJSON(map[string]interface{}{
7405
+				"msg": "1",
7406
+				"ids": ids,
7407
+			})
7408
+			return
7409
+		}
7410
+
7411
+	}
7412
+
7413
+}
7414
+
7415
+func (this *DialysisAPIController) GetSettleMobileAdvice() {
7416
+
7417
+	ids := this.GetString("ids")
7418
+	idSplit := strings.Split(ids, ",")
7419
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7420
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
7421
+
7422
+	if config.IsOpen == 1 {
7423
+		service.UpdateSettleMobileHisAdvice(orgId, idSplit)
7424
+		this.ServeSuccessJSON(map[string]interface{}{
7425
+			"msg": "1",
7426
+			"ids": ids,
7427
+		})
7428
+		return
7429
+	}
7430
+
7431
+	if config.IsOpen == 0 || config.IsOpen == 2 {
7432
+
7433
+		service.UpdateSettleMobileBloodAdvice(orgId, idSplit)
7434
+		this.ServeSuccessJSON(map[string]interface{}{
7435
+			"msg": "1",
7436
+			"ids": ids,
7437
+		})
7438
+		return
7439
+	}
7440
+}
7441
+
7442
+func (this *DialysisAPIController) GetCheckMobileAdvice() {
7443
+
7444
+	ids := this.GetString("ids")
7445
+	idSplit := strings.Split(ids, ",")
7446
+	orgId := this.GetMobileAdminUserInfo().Org.Id
7447
+
7448
+	config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
7449
+
7450
+	//his
7451
+	if config.IsOpen == 1 {
7452
+		checker := this.GetMobileAdminUserInfo().AdminUser.Id
7453
+		theTime := time.Now()
7454
+
7455
+		advices := models.HisDoctorAdviceThirty{
7456
+			CheckTime:   theTime.Unix(),
7457
+			Checker:     checker,
7458
+			UpdatedTime: time.Now().Unix(),
7459
+		}
7460
+		service.CheckHisMobileDoctorAdvice(orgId, idSplit, advices)
7461
+
7462
+		list, _ := service.FindDoctorAdviceByIds(orgId, idSplit)
7463
+		for _, item := range list {
7464
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7465
+			redis := service.RedisClient()
7466
+			//清空key 值
7467
+			redis.Set(key, "", time.Second)
7468
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7469
+			redis.Set(keyTwo, "", time.Second)
7470
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7471
+			redis.Set(keyThree, "", time.Second)
7472
+			recordDate := theTime.Format("2006-01-02")
7473
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7474
+
7475
+			redis.Set(keyFour, "", time.Second)
7476
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7477
+			redis.Set(keyFive, "", time.Second)
7478
+			defer redis.Close()
7479
+		}
7480
+
7481
+		this.ServeSuccessJSON(map[string]interface{}{
7482
+			"msg": "1",
7483
+			"ids": ids,
7484
+		})
7485
+		return
7486
+	}
7487
+
7488
+	//血透
7489
+	if config.IsOpen == 0 || config.IsOpen == 2 {
7490
+
7491
+		checker := this.GetMobileAdminUserInfo().AdminUser.Id
7492
+		theTime := time.Now()
7493
+
7494
+		advices := models.DoctorAdvice{
7495
+			CheckTime:   theTime.Unix(),
7496
+			Checker:     checker,
7497
+			UpdatedTime: time.Now().Unix(),
7498
+		}
7499
+
7500
+		service.CheckBloodDoctorAdvice(orgId, idSplit, advices)
7501
+		list, _ := service.FindDoctorAdviceByIds(orgId, idSplit)
7502
+		for _, item := range list {
7503
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
7504
+			redis := service.RedisClient()
7505
+			//清空key 值
7506
+			redis.Set(key, "", time.Second)
7507
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
7508
+			redis.Set(keyTwo, "", time.Second)
7509
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
7510
+			redis.Set(keyThree, "", time.Second)
7511
+			recordDate := theTime.Format("2006-01-02")
7512
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
7513
+
7514
+			redis.Set(keyFour, "", time.Second)
7515
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
7516
+			redis.Set(keyFive, "", time.Second)
7517
+			defer redis.Close()
7518
+		}
7519
+		this.ServeSuccessJSON(map[string]interface{}{
7520
+			"msg": "1",
7521
+			"ids": ids,
7522
+		})
7523
+		return
7524
+	}
7525
+
7526
+}
7527
+
6981 7528
 func (this *DialysisAPIController) CheckSchedule() {
6982 7529
 
6983 7530
 	patientID, _ := this.GetInt64("patient_id")

+ 1 - 0
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -509,6 +509,7 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
509 509
 				Status:       1,
510 510
 				CreatedTime:  time.Now().Unix(),
511 511
 				UpdatedTime:  time.Now().Unix(),
512
+				IsExport:     5,
512 513
 			}
513 514
 			createErr := service.CreateSchedule(newSchedule)
514 515
 			redis := service.RedisClient()

+ 8 - 4
controllers/mobile_api_controllers/doctor_advice_api_controller.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"fmt"
8 9
 	"strconv"
9 10
 	"time"
10 11
 )
@@ -26,7 +27,7 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
26 27
 		adviceType = 0
27 28
 	}
28 29
 
29
-	if patientType != 1 && patientType != 2 {
30
+	if patientType != 1 && patientType != 2 && patientType != 3 && patientType != 4 {
30 31
 
31 32
 		patientType = 0
32 33
 	}
@@ -43,12 +44,14 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
43 44
 	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
44 45
 	redis.Set(key, "", time.Second)
45 46
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesTwo(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
47
+
48
+	fmt.Println("scheduals00923923999233223", scheduals)
46 49
 	//获取所有的患者
47 50
 	blood_patients, _ := service.GetAllPatientListByListSeven(orgID)
48 51
 	//获取透析处方
49 52
 	blood_prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
50 53
 	//获取上机
51
-	blood_dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
54
+	blood_dialysisOrders, _ := service.GetAllDialysisOrdersByListSeven(orgID, date.Unix())
52 55
 
53 56
 	for key, schedule := range scheduals {
54 57
 		for _, patient := range blood_patients {
@@ -78,6 +81,7 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
78 81
 	config, _ := service.GetHisDoctorConfig(orgID)
79 82
 	project_config, _ := service.GetHisProjectConfig(orgID)
80 83
 
84
+	fmt.Println("project_config23323232322323", project_config.IsOpen)
81 85
 	if project_config.IsOpen == 1 || project_config.IsOpen == 2 {
82 86
 		//获取his医嘱数据
83 87
 		project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
@@ -111,7 +115,7 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
111 115
 		prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
112 116
 
113 117
 		//获取上机
114
-		dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
118
+		dialysisOrders, _ := service.GetAllDialysisOrdersByListSeven(orgID, date.Unix())
115 119
 
116 120
 		for key, item := range project {
117 121
 			for _, patient := range patients {
@@ -153,7 +157,7 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
153 157
 		} else {
154 158
 			filtedScheduals := []*service.MScheduleDoctorAdviceVMOne{}
155 159
 			for _, schedual := range scheduals {
156
-				if len(schedual.DoctorAdvices) > 0 {
160
+				if len(schedual.DoctorAdvices) > 0 || len(hisAdvices) > 0 {
157 161
 					filtedScheduals = append(filtedScheduals, schedual)
158 162
 				}
159 163
 			}

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

@@ -178,4 +178,14 @@ func MobileAPIControllersRegisterRouters() {
178 178
 	beego.Router("/m/api/checksch/get", &DialysisAPIController{}, "Get:CheckSchedule")
179 179
 
180 180
 	//beego.Router("/m/api/getscheduletypebyidlist",&DialysisAPIController{},"Get:GetScheduleTypeByIdList")
181
+
182
+	beego.Router("/m/api/getscheduletypebyidlist", &DialysisAPIController{}, "Get:GetScheduleTypeByIdList")
183
+
184
+	beego.Router("/m/api/savepatientpicture", &DialysisAPIController{}, "Get:SavePatientPicture")
185
+
186
+	beego.Router("/m/api/exectionmobileadvice", &DialysisAPIController{}, "Get:ExectionMobileAdvice")
187
+
188
+	beego.Router("/m/api/settlemobileadvice", &DialysisAPIController{}, "Get:GetSettleMobileAdvice")
189
+
190
+	beego.Router("/m/api/checkmobileadvice", &DialysisAPIController{}, "Get:GetCheckMobileAdvice")
181 191
 }

+ 46 - 10
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -723,7 +723,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
723 723
 								total = list.Count*medical.MinNumber + list.StockMinNumber
724 724
 								prescribing_number_total = count
725 725
 							}
726
-							fmt.Println("meiddidididssddssddsdsds", medical.IsUse)
726
+
727 727
 							if medical.IsUse == 1 {
728 728
 								c.ServeSuccessJSON(map[string]interface{}{
729 729
 									"msg":    "1",
@@ -1686,6 +1686,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1686 1686
 	}
1687 1687
 	// 计算透析处方的相关超滤量
1688 1688
 	schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.Org.Id, patient.ID, theAssessmentDateTime)
1689
+	lastDialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient.ID, adminUserInfo.Org.Id)
1689 1690
 	var lastDialysisPrescribe *models.DialysisPrescription
1690 1691
 	var dialysisSolution *models.DialysisSolution
1691 1692
 	var dialysisPrescribe *models.DialysisPrescription
@@ -1766,11 +1767,16 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1766 1767
 		newprescribe.Status = 1
1767 1768
 		newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
1768 1769
 		newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
1770
+		newprescribe.Remark = lastDialysisPrescription.Remark
1769 1771
 		_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1770 1772
 		newprescribe.ID = dialysisPrescription.ID
1771 1773
 
1772 1774
 		if dialysisPrescription.ID == 0 {
1773
-			fmt.Println("处方11111111111")
1775
+			if adminUserInfo.Org.Id == 10340 {
1776
+				newprescribe.Sodium = 138
1777
+				newprescribe.Bicarbonate = 31.1
1778
+				newprescribe.DialysateFlow = 500
1779
+			}
1774 1780
 			err := service.AddSigleRecord(&newprescribe)
1775 1781
 			//获取key,清空redis
1776 1782
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -1796,6 +1802,11 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1796 1802
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1797 1803
 			}
1798 1804
 		} else {
1805
+			if adminUserInfo.Org.Id == 10340 {
1806
+				newprescribe.Sodium = 138
1807
+				newprescribe.Bicarbonate = 31.1
1808
+				newprescribe.DialysateFlow = 500
1809
+			}
1799 1810
 			err := service.UpDateDialysisPrescription(&newprescribe)
1800 1811
 			//获取key,清空redis
1801 1812
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -1874,9 +1885,15 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1874 1885
 			newprescribe.Status = 1
1875 1886
 			newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
1876 1887
 			newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
1888
+			newprescribe.Remark = lastDialysisPrescription.Remark
1877 1889
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1878 1890
 			newprescribe.ID = dialysisPrescription.ID
1879 1891
 			if dialysisPrescription.ID == 0 {
1892
+				if adminUserInfo.Org.Id == 10340 {
1893
+					newprescribe.Sodium = 138
1894
+					newprescribe.Bicarbonate = 31.1
1895
+					newprescribe.DialysateFlow = 500
1896
+				}
1880 1897
 				err := service.AddSigleRecord(&newprescribe)
1881 1898
 				//获取key,清空redis
1882 1899
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -1898,7 +1915,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1898 1915
 
1899 1916
 				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1900 1917
 				redis.Set(keySeven, "", time.Second)
1901
-				fmt.Println("处方2222222222")
1918
+
1902 1919
 				if err != nil {
1903 1920
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1904 1921
 				}
@@ -1981,12 +1998,17 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1981 1998
 			newprescribe.Status = 1
1982 1999
 			newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
1983 2000
 			newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
2001
+			newprescribe.Remark = lastDialysisPrescription.Remark
1984 2002
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1985 2003
 			newprescribe.ID = dialysisPrescription.ID
1986 2004
 			if dialysisPrescription.ID == 0 {
2005
+				if adminUserInfo.Org.Id == 10340 {
2006
+					newprescribe.Sodium = 138
2007
+					newprescribe.Bicarbonate = 31.1
2008
+					newprescribe.DialysateFlow = 500
2009
+				}
1987 2010
 				err := service.AddSigleRecord(&newprescribe)
1988 2011
 
1989
-				fmt.Println("处方2222222222")
1990 2012
 				//获取key,清空redis
1991 2013
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1992 2014
 				redis := service.RedisClient()
@@ -2011,6 +2033,11 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2011 2033
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2012 2034
 				}
2013 2035
 			} else {
2036
+				if adminUserInfo.Org.Id == 10340 {
2037
+					newprescribe.Sodium = 138
2038
+					newprescribe.Bicarbonate = 31.1
2039
+					newprescribe.DialysateFlow = 500
2040
+				}
2014 2041
 				err := service.UpDateDialysisPrescription(&newprescribe)
2015 2042
 				//获取key,清空redis
2016 2043
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -2055,8 +2082,13 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2055 2082
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2056 2083
 			newprescribe.ID = dialysisPrescription.ID
2057 2084
 			if dialysisPrescription.ID == 0 {
2085
+				if adminUserInfo.Org.Id == 10340 {
2086
+					newprescribe.Sodium = 138
2087
+					newprescribe.Bicarbonate = 31.1
2088
+					newprescribe.DialysateFlow = 500
2089
+				}
2058 2090
 				err := service.AddSigleRecord(&newprescribe)
2059
-				fmt.Println("处方44444444444")
2091
+
2060 2092
 				//获取key,清空redis
2061 2093
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2062 2094
 				redis := service.RedisClient()
@@ -2081,6 +2113,11 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
2081 2113
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2082 2114
 				}
2083 2115
 			} else {
2116
+				if adminUserInfo.Org.Id == 10340 {
2117
+					newprescribe.Sodium = 138
2118
+					newprescribe.Bicarbonate = 31.1
2119
+					newprescribe.DialysateFlow = 500
2120
+				}
2084 2121
 				err := service.UpDateDialysisPrescription(&newprescribe)
2085 2122
 				//获取key,清空redis
2086 2123
 				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -3247,7 +3284,7 @@ func (c *PatientApiController) GetPatientMonitor() {
3247 3284
 	//获取患者的透析次数
3248 3285
 	count, err := service.GetDialysisCount(orgID, partition)
3249 3286
 
3250
-	patients, err := service.GetAllpatient(orgID)
3287
+	patients, err := service.GetAllpatientThirty(orgID)
3251 3288
 	if err == nil {
3252 3289
 		c.ServeSuccessJSON(map[string]interface{}{
3253 3290
 			"monitor":      monitor,
@@ -3659,7 +3696,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
3659 3696
 			advice.UserOrgId = adminUserInfo.Org.Id
3660 3697
 			advice.PatientId = patientInfo.ID
3661 3698
 			advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3662
-
3699
+			advice.IsSettle = 2
3663 3700
 			//入口
3664 3701
 			errcode := c.setAdviceWithJSON(&advice, adviceNameM)
3665 3702
 			if errcode > 0 {
@@ -3685,7 +3722,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
3685 3722
 						s.UserOrgId = adminUserInfo.Org.Id
3686 3723
 						s.PatientId = patientInfo.ID
3687 3724
 						s.AdviceDoctor = adminUserInfo.AdminUser.Id
3688
-
3725
+						s.IsSettle = 2
3689 3726
 						errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
3690 3727
 						if errcode > 0 {
3691 3728
 							c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -3772,7 +3809,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
3772 3809
 		advice.UserOrgId = adminUserInfo.Org.Id
3773 3810
 		advice.PatientId = patient
3774 3811
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3775
-
3812
+		advice.IsSettle = 2
3776 3813
 		err := service.CreateDoctorAdvice(&advice)
3777 3814
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3778 3815
 		redis := service.RedisClient()
@@ -3780,7 +3817,6 @@ func (c *PatientApiController) CreateGroupAdvice() {
3780 3817
 		redis.Set(key, "", time.Second)
3781 3818
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
3782 3819
 		redis.Set(keyOne, "", time.Second)
3783
-		fmt.Println("key`2232333332233223233232", key)
3784 3820
 		defer redis.Close()
3785 3821
 		if err != nil {
3786 3822
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)

+ 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)

+ 20 - 16
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -249,6 +249,7 @@ func (this *StaffScheduleApiController) GetAllZone() {
249 249
 
250 250
 	id := this.GetMobileAdminUserInfo().Org.Id
251 251
 	zone, err := service.GetAllMobileZone(id)
252
+
252 253
 	if err != nil {
253 254
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
254 255
 		return
@@ -283,18 +284,21 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
283 284
 		//获取当天排班的病人情况
284 285
 		schedule, err := service.GetPatientSchedule(startTime, zoneid, classtype, orgid)
285 286
 
287
+		zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
286 288
 		if err != nil {
287 289
 			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
288 290
 			return
289 291
 		}
290 292
 		this.ServeSuccessJSON(map[string]interface{}{
291 293
 			"schedule": schedule,
294
+			"zonelist": zonelist,
292 295
 		})
293 296
 	}
294 297
 	if is_open == 1 {
295 298
 		//获取空床位的排班数据
296 299
 		list, err := service.GetPatientScheduleByBed(startTime, zoneid, orgid, classtype)
297 300
 		stockType, _ := service.GetStockType(orgid)
301
+		zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
298 302
 		if err != nil {
299 303
 			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
300 304
 			return
@@ -302,6 +306,7 @@ func (this *StaffScheduleApiController) GetPatientScheduleList() {
302 306
 		this.ServeSuccessJSON(map[string]interface{}{
303 307
 			"schedule":  list,
304 308
 			"stockType": stockType,
309
+			"zonelist":  zonelist,
305 310
 		})
306 311
 	}
307 312
 }
@@ -714,7 +719,6 @@ func (c *StaffScheduleApiController) GetSolutionSchedule() {
714 719
 	timeLayout := "2006-01-02"
715 720
 	loc, _ := time.LoadLocation("Local")
716 721
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
717
-	fmt.Println("时间错2332233323223", theTime.Unix())
718 722
 	schedule, _ := service.GetSolutionScheduleBySchedule(orgId, zoneid, classtype, theTime.Unix())
719 723
 	c.ServeSuccessJSON(map[string]interface{}{
720 724
 		"schedule": schedule,
@@ -752,17 +756,21 @@ func (c *StaffScheduleApiController) ChangeScheduleType() {
752 756
 	schedule_date, _ := c.GetInt64("schedule_date")
753 757
 	patient_id, _ := c.GetInt64("patient_id")
754 758
 	bed_id, _ := c.GetInt64("bed_id")
755
-	schedule_week, _ := c.GetInt64("schedule_week")
759
+	//schedule_week, _ := c.GetInt64("schedule_week")
756 760
 	mode_id, _ := c.GetInt64("mode_id")
757 761
 	id, _ := c.GetInt64("id")
758 762
 	org_id := c.GetMobileAdminUserInfo().Org.Id
759 763
 	//查询该班次该床位是否已经存在患者
760 764
 	schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
761 765
 	//查询该床位所属分区
762
-	numberlist, _ := service.GetPartionId(bed_id, org_id)
766
+	//numberlist, _ := service.GetPartionId(bed_id, org_id)
763 767
 	//存在
764 768
 	if schedule.ID > 0 {
765
-
769
+		order, _ := service.GetDialysisOrder(schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
770
+		if order.ID > 0 {
771
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSchedule)
772
+			return
773
+		}
766 774
 		//调换位置
767 775
 		sch := models.Schedule{
768 776
 			PatientId: schedule.PatientId,
@@ -778,20 +786,12 @@ func (c *StaffScheduleApiController) ChangeScheduleType() {
778 786
 
779 787
 	} else {
780 788
 		xtSchedule := models.Schedule{
781
-			UserOrgId:    org_id,
782
-			PartitionId:  numberlist.ZoneId,
783
-			BedId:        bed_id,
784
-			PatientId:    patient_id,
785 789
 			ScheduleDate: schedule_date,
786 790
 			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,
791
+			PatientId:    patient_id,
792
+			UserOrgId:    org_id,
793 793
 		}
794
-		service.CreateSchedule(&xtSchedule)
794
+		service.ChangeScheduleClass(xtSchedule)
795 795
 	}
796 796
 	c.ServeSuccessJSON(map[string]interface{}{
797 797
 		"msg": "ok",
@@ -800,7 +800,6 @@ func (c *StaffScheduleApiController) ChangeScheduleType() {
800 800
 
801 801
 func (c *StaffScheduleApiController) ChangeScheduleBed() {
802 802
 
803
-	fmt.Println("jin23323232233222323323232")
804 803
 	schedule_type, _ := c.GetInt64("schedule_type")
805 804
 	schedule_date, _ := c.GetInt64("schedule_date")
806 805
 	patient_id, _ := c.GetInt64("patient_id")
@@ -817,6 +816,11 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
817 816
 	//存在
818 817
 	if schedule.ID > 0 {
819 818
 
819
+		order, _ := service.GetDialysisOrder(schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
820
+		if order.ID > 0 {
821
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSchedule)
822
+			return
823
+		}
820 824
 		//调换位置
821 825
 		sch := models.Schedule{
822 826
 			PatientId: schedule.PatientId,

+ 10 - 5
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)
@@ -936,6 +937,7 @@ func (c *PatientApiController) UpdateDialysisSolution() {
936 937
 			OxygenFlow:                 solution.OxygenFlow,
937 938
 			OxygenTime:                 solution.OxygenTime,
938 939
 			MaxUltrafiltrationRate:     solution.MaxUltrafiltrationRate,
940
+			Amylaceum:                  solution.Amylaceum,
939 941
 		}
940 942
 		service.UpdatePatientDialysisSolutionOne(solution.PatientId, adminUserInfo.CurrentOrgId, &prescription, todayTime.Unix())
941 943
 	}
@@ -1313,7 +1315,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1313 1315
 		advice.UserOrgId = adminUserInfo.CurrentOrgId
1314 1316
 		advice.PatientId = patientInfo.ID
1315 1317
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1316
-
1318
+		advice.IsSettle = 2
1317 1319
 		if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
1318 1320
 			utils.ErrorLog("advice_name")
1319 1321
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1466,7 +1468,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1466 1468
 					child.UserOrgId = adminUserInfo.CurrentOrgId
1467 1469
 					child.PatientId = patientInfo.ID
1468 1470
 					child.AdviceDoctor = adminUserInfo.AdminUser.Id
1469
-
1471
+					child.IsSettle = 2
1470 1472
 					if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
1471 1473
 						utils.ErrorLog("child advice_name")
1472 1474
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -1542,13 +1544,12 @@ func (c *PatientApiController) CreateGroupAdvice() {
1542 1544
 
1543 1545
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
1544 1546
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
1545
-	//fmt.Println("key23323323232323223233223232323",key)
1547
+
1546 1548
 	redis := service.RedisClient()
1547 1549
 	defer redis.Close()
1548 1550
 	redis.Set(key, "", time.Second)
1549 1551
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
1550 1552
 	redis.Set(keyOne, "", time.Second)
1551
-	//fmt.Println("keyOne23322322323232323233232332",keyOne)
1552 1553
 	if err != nil {
1553 1554
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1554 1555
 		return
@@ -3877,6 +3878,11 @@ func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, met
3877 3878
 		max_ultrafiltration_rate, _ := strconv.ParseFloat(dataBody["max_ultrafiltration_rate"].(string), 64)
3878 3879
 		solution.MaxUltrafiltrationRate = max_ultrafiltration_rate
3879 3880
 	}
3881
+
3882
+	if dataBody["amylaceum"] != nil && reflect.TypeOf(dataBody["amylaceum"]).String() == "string" {
3883
+		amylaceum := dataBody["amylaceum"].(string)
3884
+		solution.Amylaceum = amylaceum
3885
+	}
3880 3886
 	return
3881 3887
 }
3882 3888
 
@@ -5235,7 +5241,6 @@ func (c *PatientApiController) GetPatientDialysisLongSolution() {
5235 5241
 	for _, item := range list {
5236 5242
 		//获取该模式最新的1条数据
5237 5243
 		solution, _ := service.GetNewPatientSolutionByModeId(patient_id, item.ModeId, adminUserInfo.CurrentOrgId)
5238
-
5239 5244
 		//更新状态值
5240 5245
 		service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, adminUserInfo.CurrentOrgId, patient_id)
5241 5246
 	}

+ 114 - 30
controllers/print_data_api_controller.go View File

@@ -36,43 +36,127 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
36 36
 
37 37
 	idStrs := strings.Split(schIDStr, ",")
38 38
 	adminUserInfo := this.GetAdminUserInfo()
39
-	schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
40
-	for _, item := range schedules {
41
-		list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
42
-		if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 {
43
-			item.Count = list.Count
39
+
40
+	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
41
+		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
42
+		for _, item := range schedules {
43
+
44
+			//获取透析上机
45
+			order, _ := service.GetBatchDialysisOrder(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
46
+			item.DialysisOrder = order
47
+
48
+			//获取透析处方
49
+			prescription, _ := service.GetBatchPrescription(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
50
+			item.Prescription = prescription
51
+			//接诊评估
52
+			receiveTreatmentAsses, _ := service.GetBatchReceiveTreatmentAsses(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
53
+			item.ReceiveAssessment = receiveTreatmentAsses
54
+
55
+			//透前评估
56
+			assessmentBeforeDislysisVM, _ := service.GetBatchAssessmentBeforeDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
57
+			item.AssessmentBeforeDislysis = assessmentBeforeDislysisVM
58
+
59
+			//透后评估
60
+			assessmentAfterDislysisVM, _ := service.GetBatchAssessmentAfterDislysisVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
61
+			item.AssessmentAfterDislysis = assessmentAfterDislysisVM
62
+
63
+			//上次透后体重
64
+			lastAfterWeight, _ := service.GetBatchLastAfterWeight(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
65
+			item.LastAfterWeight = lastAfterWeight
66
+
67
+			//透析监测
68
+			monitor, _ := service.GetBatchMonitor(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
69
+			item.MonitoringRecords = monitor
70
+
71
+			//透析医嘱
72
+			advice, _ := service.GetBatchDoctorAdvice(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
73
+			item.Advices = advice
74
+
75
+			//双人核对
76
+			dobuleCheck, _ := service.GetBatchDobuleCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
77
+			item.DoubleCheck = dobuleCheck
78
+
79
+			//透析小结
80
+			summerVM, _ := service.GetBatchSummerVM(this.GetAdminUserInfo().CurrentOrgId, item.PatientID, item.ScheduleDate)
81
+			item.Summer = summerVM
82
+
83
+			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
84
+			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 {
85
+				item.Count = list.Count
86
+			}
87
+			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
88
+				listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
89
+
90
+				item.Patient.TotalDialysis = listOne.Count
91
+				item.Count = listOne.Count
92
+			}
93
+		}
94
+		if getScheduleErr != nil {
95
+			this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
96
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
97
+			return
44 98
 		}
45
-		if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
46
-			listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
47 99
 
48
-			item.Patient.TotalDialysis = listOne.Count
49
-			item.Count = listOne.Count
100
+		medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
101
+		if getMedicalStaffErr != nil {
102
+			this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
103
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
104
+			return
50 105
 		}
51
-	}
52
-	if getScheduleErr != nil {
53
-		this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
54
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
55
-		return
56
-	}
57 106
 
58
-	medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
59
-	if getMedicalStaffErr != nil {
60
-		this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
61
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
62
-		return
107
+		adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
108
+		name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
109
+		templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
110
+
111
+		this.ServeSuccessJSON(map[string]interface{}{
112
+			"schedules":      schedules,
113
+			"medical_staffs": medicalStaffs,
114
+			"users":          adminUser,
115
+			"templateInfo":   templateInfo,
116
+			"name":           name,
117
+		})
63 118
 	}
64 119
 
65
-	adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
66
-	name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
67
-	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
120
+	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9671 {
121
+		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
122
+		for _, item := range schedules {
123
+			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
124
+			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 {
125
+				item.Count = list.Count
126
+			}
127
+			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 {
128
+				listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
129
+
130
+				item.Patient.TotalDialysis = listOne.Count
131
+				item.Count = listOne.Count
132
+			}
133
+		}
134
+		if getScheduleErr != nil {
135
+			this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
136
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
137
+			return
138
+		}
139
+
140
+		medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
141
+		if getMedicalStaffErr != nil {
142
+			this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
143
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
144
+			return
145
+		}
146
+
147
+		adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
148
+		name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
149
+		templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
150
+
151
+		this.ServeSuccessJSON(map[string]interface{}{
152
+			"schedules":      schedules,
153
+			"medical_staffs": medicalStaffs,
154
+			"users":          adminUser,
155
+			"templateInfo":   templateInfo,
156
+			"name":           name,
157
+		})
158
+	}
68 159
 
69
-	this.ServeSuccessJSON(map[string]interface{}{
70
-		"schedules":      schedules,
71
-		"medical_staffs": medicalStaffs,
72
-		"users":          adminUser,
73
-		"templateInfo":   templateInfo,
74
-		"name":           name,
75
-	})
76 160
 }
77 161
 
78 162
 func (this *PrintDataAPIController) StockRecordPrintData() {

+ 65 - 2
controllers/schedule_api_controller.go View File

@@ -41,6 +41,7 @@ func ScheduleApiRegistRouters() {
41 41
 
42 42
 	beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
43 43
 	beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
44
+	beego.Router("/api/schedule/getnextscheduleweekdayone", &ScheduleApiController{}, "Get:GetNextWeekDayScheduleOne")
44 45
 
45 46
 	beego.Router("/api/schedule/getthreeweeklist", &ScheduleApiController{}, "Get:GetThreeWeekList")
46 47
 
@@ -1261,6 +1262,7 @@ func (c *ScheduleApiController) CreateSchedule() {
1261 1262
 	schedule.UpdatedTime = time.Now().Unix()
1262 1263
 	schedule.Status = 1
1263 1264
 	schedule.UserOrgId = adminUserInfo.CurrentOrgId
1265
+	schedule.IsExport = 5
1264 1266
 
1265 1267
 	so, _ := service.GetDialysisSolutionTwo(adminUserInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
1266 1268
 	filedRecordOne, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器")
@@ -3128,17 +3130,59 @@ func (c *ScheduleApiController) CancelScheduleTemplate() {
3128 3130
 		return
3129 3131
 	}
3130 3132
 }
3133
+func (this *ScheduleApiController) GetNextWeekDayScheduleOne() {
3134
+	week_type, _ := this.GetInt64("week_type", -1)
3135
+	week_time, _ := this.GetInt64("week_time")
3136
+	record_date := this.GetString("record_date")
3137
+
3138
+	zons := this.GetString("zone")
3139
+	zone := strings.Split(zons, ",")
3140
+
3141
+	start_time, _ := this.GetInt64("start_time")
3142
+	end_time, _ := this.GetInt64("end_time")
3143
+	timeLayout := "2006-01-02"
3144
+	loc, _ := time.LoadLocation("Local")
3145
+	//theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
3146
+	//theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
3147
+
3148
+	adminUserInfo := this.GetAdminUserInfo()
3149
+	var theStartTIme int64
3150
+	if len(record_date) > 0 {
3151
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
3152
+		if err != nil {
3153
+			utils.ErrorLog(err.Error())
3154
+		}
3155
+		theStartTIme = theTime.Unix()
3156
+	}
3157
+
3158
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone, theStartTIme)
3159
+	for _, item := range schedule {
3160
+		order, _ := service.GetLastDialysisOrder(adminUserInfo.CurrentOrgId, item.PatientId, theStartTIme)
3161
+		item.XtDialysisOrderSix = order
3162
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
3163
+
3164
+			dialysisprescription, _ := service.GetLastDialysisSolution(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId, item.ScheduleDate)
3165
+			item.DialysisPrescription = dialysisprescription
3166
+		}
3167
+	}
3168
+	if err != nil {
3169
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3170
+		return
3171
+	}
3172
+	this.ServeSuccessJSON(map[string]interface{}{
3173
+		"schedule": schedule,
3174
+	})
3175
+}
3131 3176
 
3132 3177
 func (this *ScheduleApiController) GetNextWeekDaySchedule() {
3133 3178
 
3134 3179
 	week_type, _ := this.GetInt64("week_type", -1)
3135 3180
 	week_time, _ := this.GetInt64("week_time")
3136
-	//start_time, _ := this.GetInt64("start_time")
3137
-	//end_time, _ := this.GetInt64("end_time")
3138 3181
 	record_date := this.GetString("record_date")
3139 3182
 
3140 3183
 	zons := this.GetString("zone")
3141 3184
 	zone := strings.Split(zons, ",")
3185
+
3142 3186
 	start_time := this.GetString("start_time")
3143 3187
 	end_time := this.GetString("end_time")
3144 3188
 	timeLayout := "2006-01-02"
@@ -3578,7 +3622,16 @@ func (this *ScheduleApiController) GetBloodScheduleList() {
3578 3622
 	orgId := this.GetAdminUserInfo().CurrentOrgId
3579 3623
 	if week_type > 0 {
3580 3624
 		list, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone)
3625
+		for _, item := range list {
3626
+			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
3627
+			item.XtDialysisOrderSix = order
3628
+			if orgId == 9671 || orgId == 9675 || orgId == 10340 {
3581 3629
 
3630
+				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
3631
+				item.DialysisPrescription = solution
3632
+			}
3633
+
3634
+		}
3582 3635
 		if err != nil {
3583 3636
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3584 3637
 			return
@@ -3593,7 +3646,17 @@ func (this *ScheduleApiController) GetBloodScheduleList() {
3593 3646
 	if week_type == 0 {
3594 3647
 		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
3595 3648
 		list, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone)
3649
+		for _, item := range list {
3650
+
3651
+			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
3652
+			item.XtDialysisOrderSix = order
3653
+			if orgId == 9671 || orgId == 9675 || orgId == 10340 {
3596 3654
 
3655
+				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
3656
+				item.DialysisPrescription = solution
3657
+			}
3658
+
3659
+		}
3597 3660
 		if err != nil {
3598 3661
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3599 3662
 			return

+ 15 - 0
models/device_models.go View File

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

+ 171 - 19
models/dialysis.go View File

@@ -457,6 +457,7 @@ type DoctorAdvice struct {
457 457
 	DrugNameId            int64           `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
458 458
 	IsMedicine            int64           `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
459 459
 	PushStartTime         int64           `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
460
+	IsSettle              int64           `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
460 461
 }
461 462
 
462 463
 func (DoctorAdvice) TableName() string {
@@ -846,6 +847,8 @@ type DialysisOrder struct {
846 847
 	BloodAccessId              int64         `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
847 848
 	Mission                    string        `gorm:"column:mission" json:"mission" form:"mission"`
848 849
 	NucleinDate                int64         `gorm:"column:nuclein_date" json:"nuclein_date" form:"nuclein_date"`
850
+	ScheduleRemark             string        `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
851
+	OrderRemark                string        `gorm:"column:order_remark" json:"order_remark" form:"order_remark"`
849 852
 }
850 853
 
851 854
 func (DialysisOrder) TableName() string {
@@ -1095,14 +1098,36 @@ type DialysisBeforePrepareGoods struct {
1095 1098
 }
1096 1099
 
1097 1100
 type NewDialysisBeforePrepareGoods struct {
1098
-	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1099
-	Count             int64  `gorm:"column:count" json:"count" form:"count"`
1100
-	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1101
-	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1102
-	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1103
-	NewCount          int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1104
-	ProjectId         int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1105
-	StorehouseId      int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1101
+	GoodId                             int64                            `gorm:"column:good_id" json:"good_id" form:"good_id"`
1102
+	Count                              int64                            `gorm:"column:count" json:"count" form:"count"`
1103
+	GoodTypeId                         int64                            `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1104
+	TypeName                           string                           `gorm:"column:type_name" json:"type_name" form:"type_name"`
1105
+	SpecificationName                  string                           `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1106
+	NewCount                           int64                            `gorm:"column:new_count" json:"new_count" form:"new_count"`
1107
+	ProjectId                          int64                            `gorm:"column:project_id" json:"project_id" form:"project_id"`
1108
+	StorehouseId                       int64                            `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1109
+	RecordDate                         int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
1110
+	UserOrgId                          int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1111
+	ChildNewDialysisBeforePrepareGoods []*NewDialysisBeforePrepareGoods `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"child"`
1112
+}
1113
+
1114
+type OldDialysisBeforePrepareGoods struct {
1115
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
1116
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1117
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1118
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1119
+	GoodId       int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1120
+	GoodTypeId   int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1121
+	Count        int64  `gorm:"column:count" json:"count" form:"count"`
1122
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1123
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1124
+	Creater      int64  `gorm:"column:creater" json:"creater" form:"creater"`
1125
+	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
1126
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
1127
+	CommdityCode string `gorm:"column:commdity_code" json:"commdity_code" form:"commdity_code"`
1128
+	NewCount     int64  `gorm:"column:new_count" json:"new_count" form:"new_count"`
1129
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1130
+	StorehouseId int64  `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
1106 1131
 }
1107 1132
 
1108 1133
 type QueueCallConfig struct {
@@ -1207,17 +1232,18 @@ func (HisDoctorAdvice) TableName() string {
1207 1232
 }
1208 1233
 
1209 1234
 type DialysisScheduleSix struct {
1210
-	ID           int64  `gorm:"column:id" json:"id" form:"id"`
1211
-	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1212
-	PartitionId  int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1213
-	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1214
-	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1215
-	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1216
-	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1217
-	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1218
-	ModeId       int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1219
-	Status       int64  `gorm:"column:status" json:"status" form:"status"`
1220
-	Name         string `gorm:"column:name" json:"name" form:"name"`
1235
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
1236
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1237
+	PartitionId         int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1238
+	BedId               int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1239
+	PatientId           int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1240
+	ScheduleDate        int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1241
+	ScheduleType        int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1242
+	ScheduleWeek        int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1243
+	ModeId              int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1244
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
1245
+	Name                string `gorm:"column:name" json:"name" form:"name"`
1246
+	DialysisOrderTwenty `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"order"`
1221 1247
 }
1222 1248
 
1223 1249
 type DialysisScheduleSeven struct {
@@ -1231,3 +1257,129 @@ type DialysisScheduleSeven struct {
1231 1257
 func (DialysisScheduleSeven) TableName() string {
1232 1258
 	return "xt_schedule"
1233 1259
 }
1260
+
1261
+type DialysisOrderTwenty struct {
1262
+	ID                 int64        `gorm:"column:id" json:"id"`
1263
+	DialysisDate       int64        `gorm:"column:dialysis_date" json:"dialysis_date"`
1264
+	UserOrgId          int64        `gorm:"column:user_org_id" json:"user_org_id"`
1265
+	PatientId          int64        `gorm:"column:patient_id" json:"patient_id"`
1266
+	Stage              int64        `gorm:"column:stage" json:"stage"`
1267
+	Remark             string       `gorm:"column:remark" json:"remark"`
1268
+	BedID              int64        `gorm:"column:bed_id" json:"bed_id"`
1269
+	Status             int64        `gorm:"column:status" json:"status"`
1270
+	DeviceNumber       DeviceNumber `gorm:"ForeignKey:BedID"`
1271
+	StartTime          int64        `gorm:"column:start_time" json:"start_time"`
1272
+	SchedualType       int64        `gorm:"column:schedual_type" json:"schedual_type"`
1273
+	ZoneId             int64        `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1274
+	BloodAccessId      int64        `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
1275
+	DialysisIrrigation string       `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1276
+	DialysisDialyszers string       `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1277
+	OrderRemark        string       `gorm:"column:order_remark" json:"order_remark" form:"order_remark"`
1278
+	ScheduleRemark     string       `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
1279
+}
1280
+
1281
+func (DialysisOrderTwenty) TableName() string {
1282
+	return "xt_dialysis_order"
1283
+}
1284
+
1285
+type HisDoctorAdviceThirty struct {
1286
+	ID                    int64                    `gorm:"column:id" json:"id" form:"id"`
1287
+	UserOrgId             int64                    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1288
+	PatientId             int64                    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1289
+	AdviceDate            int64                    `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1290
+	StartTime             int64                    `gorm:"column:start_time" json:"start_time" form:"start_time"`
1291
+	AdviceName            string                   `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1292
+	PrescribingNumber     float64                  `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1293
+	PrescribingNumberUnit string                   `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1294
+	Status                int64                    `gorm:"column:status" json:"status" form:"status"`
1295
+	CreatedTime           int64                    `gorm:"column:created_time" json:"created_time" form:"created_time"`
1296
+	UpdatedTime           int64                    `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1297
+	ParentId              int64                    `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1298
+	ExecutionTime         int64                    `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1299
+	ExecutionStaff        int64                    `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1300
+	ExecutionState        int64                    `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1301
+	Checker               int64                    `gorm:"column:checker" json:"checker" form:"checker"`
1302
+	CheckTime             int64                    `gorm:"column:check_time" json:"check_time" form:"check_time"`
1303
+	CheckState            int64                    `gorm:"column:check_state" json:"check_state" form:"check_state"`
1304
+	ChildDoctorAdvice     []*HisDoctorAdviceThirty `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
1305
+	IsCheck               int64                    `gorm:"-" json:"is_check" form:"is_check"`
1306
+	Way                   int64                    `gorm:"column:way" json:"way" form:"way"`
1307
+	IsSettle              int64                    `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
1308
+}
1309
+
1310
+func (HisDoctorAdviceThirty) TableName() string {
1311
+	return "his_doctor_advice_info"
1312
+}
1313
+
1314
+type DoctorAdviceThrity struct {
1315
+	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
1316
+	GroupNo               int64                 `gorm:"column:groupno" json:"groupno" form:"groupno"`
1317
+	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1318
+	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1319
+	AdviceType            int64                 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1320
+	AdviceDate            int64                 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1321
+	StartTime             int64                 `gorm:"column:start_time" json:"start_time" form:"start_time"`
1322
+	AdviceName            string                `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1323
+	AdviceDesc            string                `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
1324
+	ReminderDate          int64                 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
1325
+	SingleDose            float64               `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1326
+	SingleDoseUnit        string                `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
1327
+	DrugSpec              float64               `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
1328
+	DrugSpecUnit          string                `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
1329
+	PrescribingNumber     float64               `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1330
+	PrescribingNumberUnit string                `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1331
+	DeliveryWay           string                `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1332
+	ExecutionFrequency    string                `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1333
+	AdviceDoctor          int64                 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
1334
+	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
1335
+	CreatedTime           int64                 `gorm:"column:created_time" json:"created_time" form:"created_time"`
1336
+	UpdatedTime           int64                 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1337
+	AdviceAffirm          string                `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
1338
+	Remark                string                `gorm:"column:remark" json:"remark" form:"remark"`
1339
+	StopTime              int64                 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
1340
+	StopReason            string                `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
1341
+	StopDoctor            int64                 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
1342
+	StopState             int64                 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
1343
+	ParentId              int64                 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1344
+	ExecutionTime         int64                 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1345
+	ExecutionStaff        int64                 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1346
+	ExecutionState        int64                 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1347
+	Checker               int64                 `gorm:"column:checker" json:"checker" form:"checker"`
1348
+	RecordDate            int64                 `gorm:"column:record_date" json:"record_date"`
1349
+	DialysisOrderId       int64                 `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
1350
+	CheckTime             int64                 `gorm:"column:check_time" json:"check_time" form:"check_time"`
1351
+	CheckState            int64                 `gorm:"column:check_state" json:"check_state" form:"check_state"`
1352
+	AdviceId              int64                 `gorm:"-"`
1353
+	RemindType            int64                 `gorm:"column:remind_type" json:"remind_type"`
1354
+	FrequencyType         int64                 `gorm:"column:frequency_type" json:"frequency_type"`
1355
+	DayCount              int64                 `gorm:"column:day_count" json:"day_count"`
1356
+	WeekDay               string                `gorm:"column:week_day" json:"week_day"`
1357
+	ChildDoctorAdvice     []*DoctorAdviceThrity `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
1358
+	TemplateId            string                `gorm:"column:template_id" json:"template_id"`
1359
+	Modifier              int64                 `gorm:"column:modifier" json:"modifier" form:"modifier"`
1360
+	IsCheck               int64                 `gorm:"-" json:"is_check" form:"is_check"`
1361
+	Way                   int64                 `gorm:"column:way" json:"way" form:"way"`
1362
+	DrugId                int64                 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1363
+	DrugNameId            int64                 `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
1364
+	IsMedicine            int64                 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1365
+	PushStartTime         int64                 `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
1366
+	IsSettle              int64                 `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
1367
+}
1368
+
1369
+func (DoctorAdviceThrity) TableName() string {
1370
+	return "xt_doctor_advice"
1371
+}
1372
+
1373
+type XtDialysisOrderSix struct {
1374
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
1375
+	DialysisDate       int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
1376
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1377
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1378
+	BloodAccessId      int64  `gorm:"column:blood_access_id" json:"blood_access_id" form:"blood_access_id"`
1379
+	DialysisIrrigation string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1380
+	DialysisDialyszers string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1381
+}
1382
+
1383
+func (XtDialysisOrderSix) TableName() string {
1384
+	return "xt_dialysis_order"
1385
+}

+ 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
 

+ 12 - 0
models/good_models.go View File

@@ -289,3 +289,15 @@ type GoodInformationThirty struct {
289 289
 func (GoodInformationThirty) TableName() string {
290 290
 	return "xt_good_information"
291 291
 }
292
+
293
+type GoodInformationFourty struct {
294
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
295
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
296
+	OrgId             int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
297
+	GoodName          string `gorm:"column:good_name" json:"good_name" form:"good_name"`
298
+	Status            int64  `gorm:"column:status" json:"status"`
299
+}
300
+
301
+func (GoodInformationFourty) TableName() string {
302
+	return "xt_good_information"
303
+}

+ 16 - 0
models/his_models.go View File

@@ -257,6 +257,8 @@ type HisDoctorAdviceInfo struct {
257 257
 	HisOrderInfo          HisOrderInfo           `gorm:"ForeignKey:AdviceId;AssociationForeignKey:ID" json:"order_info"`
258 258
 	IsMedicine            int64                  `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
259 259
 	ExecutionFrequencyId  int64                  `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
260
+	Child                 []*HisDoctorAdviceInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
261
+	IsSettle              int64                  `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
260 262
 }
261 263
 
262 264
 func (HisDoctorAdviceInfo) TableName() string {
@@ -860,6 +862,7 @@ type HisPrescriptionProject struct {
860 862
 	HisOrderInfo         HisOrderInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"order_info"`
861 863
 	ExecutionFrequencyId int64        `gorm:"column:execution_frequency_id" json:"execution_frequency_id" form:"execution_frequency_id"`
862 864
 	IsOut                int64        `gorm:"column:is_out" json:"is_out" form:"is_out"` //新增字段
865
+
863 866
 }
864 867
 
865 868
 func (HisPrescriptionProject) TableName() string {
@@ -2426,3 +2429,16 @@ type Item struct {
2426 2429
 	Vaf58  string `json:"vaf58"`
2427 2430
 	Vaf61  string `json:"vaf61"`
2428 2431
 }
2432
+
2433
+type HisSettleStockConfig struct {
2434
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
2435
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2436
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
2437
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
2438
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
2439
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
2440
+}
2441
+
2442
+func (HisSettleStockConfig) TableName() string {
2443
+	return "his_settle_stock_config"
2444
+}

+ 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 {

+ 46 - 0
models/patient_models.go View File

@@ -352,6 +352,8 @@ type DialysisPrescription struct {
352 352
 	DrhyWater                  string        `gorm:"column:drhy_water" json:"drhy_water" form:"drhy_water"`
353 353
 	DryWaterHour               string        `gorm:"column:dry_water_hour" json:"dry_water_hour" form:"dry_water_hour"`
354 354
 	WaterMachine               string        `gorm:"column:water_machine" json:"water_machine" form:"water_machine"`
355
+	AddAmount                  float64       `gorm:"column:add_amount" json:"add_amount" form:"add_amount"`
356
+	ReduceAmount               float64       `gorm:"column:reduce_amount" json:"reduce_amount" form:"reduce_amount"`
355 357
 }
356 358
 
357 359
 func (DialysisPrescription) TableName() string {
@@ -457,6 +459,7 @@ type DialysisPrescriptionList struct {
457 459
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
458 460
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
459 461
 	MaxUltrafiltrationRate     string  `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
462
+	WaterMachine               string  `gorm:"column:water_machine" json:"water_machine" form:"water_machine"`
460 463
 }
461 464
 
462 465
 func (DialysisPrescriptionList) TableName() string {
@@ -469,6 +472,7 @@ type DialysisAssesmentBefor struct {
469 472
 	PatientId              int64 `gorm:"column:patient_id" json:"patient_id"`
470 473
 	AssessmentDate         int64 `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
471 474
 	BloodAccessPartOperaId int64 `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id" form:"blood_access_part_opera_id"`
475
+	CreatedTime            int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
472 476
 }
473 477
 
474 478
 func (DialysisAssesmentBefor) TableName() string {
@@ -782,6 +786,7 @@ type XtPatientsNew struct {
782 786
 	TrobleShoot                  int64   `gorm:"column:troble_shoot" json:"troble_shoot" form:"troble_shoot"`
783 787
 	TreatmentPlan                string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
784 788
 	Doctor                       int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
789
+	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
785 790
 }
786 791
 
787 792
 func (XtPatientsNew) TableName() string {
@@ -1147,6 +1152,7 @@ type XtPatients struct {
1147 1152
 	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
1148 1153
 	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
1149 1154
 	SchRemark                    string  `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
1155
+	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
1150 1156
 }
1151 1157
 
1152 1158
 func (XtPatients) TableName() string {
@@ -1601,9 +1607,49 @@ type XtScheduleList struct {
1601 1607
 	ScheduleType     int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1602 1608
 	ScheduleWeek     int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1603 1609
 	ModeId           int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1610
+	IsExport         int64              `gorm:"column:is_export" json:"is_export" form:"is_export"`
1604 1611
 	DialysisSolution VmDialysisSolution `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"vmsolution"`
1605 1612
 }
1606 1613
 
1607 1614
 func (XtScheduleList) TableName() string {
1608 1615
 	return "xt_schedule"
1609 1616
 }
1617
+
1618
+type DialysisPrescriptionTwenty struct {
1619
+	ID                         int64  `gorm:"column:id" json:"id"`
1620
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id"`
1621
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id"`
1622
+	ModeId                     int64  `gorm:"column:mode_id" json:"mode_id"`
1623
+	Anticoagulant              int64  `gorm:"column:anticoagulant" json:"anticoagulant"`
1624
+	DialysateFormulation       int64  `gorm:"column:dialysate_formulation" json:"dialysate_formulation"`
1625
+	DialyzerPerfusionApparatus string `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
1626
+	DialysisDialyszers         string `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
1627
+	DialysisIrrigation         string `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
1628
+}
1629
+
1630
+func (DialysisPrescriptionTwenty) TableName() string {
1631
+	return "xt_dialysis_prescription"
1632
+}
1633
+
1634
+type DialysisPrescriptionThrity struct {
1635
+	ID        int64  `gorm:"column:id" json:"id"`
1636
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id"`
1637
+	PatientId int64  `gorm:"column:patient_id" json:"patient_id"`
1638
+	Remark    string `gorm:"column:remark" json:"remark" form:"remark"`
1639
+}
1640
+
1641
+func (DialysisPrescriptionThrity) TableName() string {
1642
+	return "xt_dialysis_prescription"
1643
+}
1644
+
1645
+type PatientsThirty struct {
1646
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
1647
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1648
+	DialysisNo    string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1649
+	Name          string `gorm:"column:name" json:"name" form:"name"`
1650
+	TotalDialysis int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
1651
+}
1652
+
1653
+func (PatientsThirty) TableName() string {
1654
+	return "xt_patients"
1655
+}

+ 84 - 16
models/schedule_models.go View File

@@ -200,6 +200,7 @@ type VmSchedulesRemind struct {
200 200
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId;"`
201 201
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
202 202
 	LastAfterWeight            AssessmentAfterDislysis    `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
203
+	XtDialysisOrderSix         XtDialysisOrderSix         `json:"dialysis_order" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
203 204
 }
204 205
 
205 206
 func (VmSchedulesRemind) TableName() string {
@@ -207,28 +208,32 @@ func (VmSchedulesRemind) TableName() string {
207 208
 }
208 209
 
209 210
 type WeekScheduleSix struct {
210
-	ID           int64 `gorm:"column:id" json:"id" form:"id"`
211
-	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
212
-	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
213
-	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
214
-	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
215
-	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
216
-	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
217
-	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
218
-	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
219
-	Status       int64 `gorm:"column:status" json:"status" form:"status"`
220
-	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
221
-	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
222
-	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
223
-
211
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
212
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
213
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
214
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
215
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
216
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
217
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
218
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
219
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
220
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
221
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
222
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
223
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
224
+	IdCardNo                   string                     `gorm:"-" json:"id_card_no" form:"id_card_no"`
225
+	Gender                     string                     `gorm:"-" json:"gender" form:"gender"`
226
+	Phone                      string                     `gorm:"-" json:"phone" form:"phone"`
227
+	DialysisNo                 string                     `gorm:"-" json:"dialysis_no" form:"dialysis_no"`
224 228
 	Patient                    string                     `gorm:"-" json:"patient" form:"patient"`
225 229
 	DeviceZone                 DeviceZone                 `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
226 230
 	DeviceNumber               DeviceNumber               `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
227
-	DialysisPrescription       DialysisSolution           `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
228 231
 	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
229 232
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
230 233
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
231 234
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate"`
235
+	XtDialysisOrderSix         XtDialysisOrderSix         `json:"dialysis_order" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
236
+	DialysisPrescription       DialysisPrescription       `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
232 237
 }
233 238
 
234 239
 func (WeekScheduleSix) TableName() string {
@@ -368,13 +373,36 @@ type VmBloodScheduleTwo struct {
368 373
 	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
369 374
 	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
370 375
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
371
-	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
376
+	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
372 377
 }
373 378
 
374 379
 func (VmBloodScheduleTwo) TableName() string {
375 380
 	return "xt_schedule"
376 381
 }
377 382
 
383
+type VmBloodScheduleThree struct {
384
+	ID                         int64                      `gorm:"column:id" json:"id" form:"id"`
385
+	UserOrgId                  int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
386
+	PartitionId                int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
387
+	BedId                      int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
388
+	PatientId                  int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
389
+	ScheduleDate               int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
390
+	ScheduleType               int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
391
+	ScheduleWeek               int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
392
+	ModeId                     int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
393
+	Status                     int64                      `gorm:"column:status" json:"status" form:"status"`
394
+	CreatedTime                int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
395
+	UpdatedTime                int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
396
+	IsExport                   int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
397
+	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
398
+	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
399
+	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
400
+}
401
+
402
+func (VmBloodScheduleThree) TableName() string {
403
+	return "xt_schedule"
404
+}
405
+
378 406
 type HisPrescriptionTemplateSix struct {
379 407
 	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
380 408
 	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -406,6 +434,7 @@ type HisPrescriptionInfoTemplateSix struct {
406 434
 	PType                               int64                                  `gorm:"column:p_type" json:"p_type" form:"p_type"`
407 435
 	PTemplateId                         int64                                  `gorm:"column:p_template_id" json:"p_template_id" form:"p_template_id"`
408 436
 	HisPrescriptionProjectTemplateSeven []*HisPrescriptionProjectTemplateSeven `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
437
+	HisPrescriptionAdviceTemplate       []*HisPrescriptionAdviceTemplate       `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"his_advice"`
409 438
 	MedType                             string                                 `gorm:"column:med_type" json:"med_type" form:"med_type"`
410 439
 }
411 440
 
@@ -455,3 +484,42 @@ type GoodInfoNight struct {
455 484
 func (GoodInfoNight) TableName() string {
456 485
 	return "xt_good_information"
457 486
 }
487
+
488
+type ScheduleTwenty struct {
489
+	ID                  int64               `gorm:"column:id" json:"id" form:"id"`
490
+	UserOrgId           int64               `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
491
+	PartitionId         int64               `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
492
+	BedId               int64               `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
493
+	PatientId           int64               `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
494
+	ScheduleDate        int64               `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
495
+	ScheduleType        int64               `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
496
+	ScheduleWeek        int64               `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
497
+	ModeId              int64               `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
498
+	Status              int64               `gorm:"column:status" json:"status" form:"status"`
499
+	CreatedTime         int64               `gorm:"column:created_time" json:"created_time" form:"created_time"`
500
+	UpdatedTime         int64               `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
501
+	IsExport            int64               `gorm:"column:is_export" json:"is_export" form:"is_export"`
502
+	Patient             string              `gorm:"-" json:"patient" form:"patient"`
503
+	DeviceZone          DeviceZone          `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
504
+	DeviceNumber        DeviceNumber        `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
505
+	TreatmentMode       TreatmentMode       `json:"mode" gorm:"foreignkey:ModeId"`
506
+	DialysisOrderTwenty DialysisOrderTwenty `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
507
+}
508
+
509
+func (ScheduleTwenty) TableName() string {
510
+	return "xt_schedule"
511
+}
512
+
513
+type ScheduleTwentyOne struct {
514
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
515
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
516
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
517
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
518
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
519
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
520
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
521
+}
522
+
523
+func (ScheduleTwentyOne) TableName() string {
524
+	return "xt_schedule"
525
+}

+ 176 - 0
service/dialysis_service.go View File

@@ -1862,3 +1862,179 @@ 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
+}
1888
+
1889
+func GetHisExcutionDoctorAdviceListGroupList(patients []string, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdvice, err error) {
1890
+
1891
+	err = XTReadDB().Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1 and execution_state = 2", patients, advice_date, user_org_id).Group("drug_id").Find(&advice).Error
1892
+	return advice, err
1893
+}
1894
+
1895
+func GetHisExcutionDoctorAdviceList(patients []string, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdvice, err error) {
1896
+
1897
+	err = XTReadDB().Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1 and execution_state = 2", patients, advice_date, user_org_id).Find(&advice).Error
1898
+	return advice, err
1899
+}
1900
+
1901
+func UpdateHisDoctorAdviceExecution(info models.HisDoctorAdviceInfo, id int64) error {
1902
+
1903
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Update(map[string]interface{}{"execution_staff": info.ExecutionStaff, "execution_state": info.ExecutionState, "execution_time": info.ExecutionTime, "updated_time": info.ExecutionTime}).Error
1904
+	return err
1905
+}
1906
+
1907
+func UpdateDoctorAdviceExecution(info models.DoctorAdvice, id int64) error {
1908
+
1909
+	err := XTWriteDB().Model(&models.DoctorAdvice{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"execution_staff": info.ExecutionStaff, "execution_state": info.ExecutionState, "execution_time": info.ExecutionTime, "updated_time": info.ExecutionTime}).Error
1910
+	return err
1911
+}
1912
+
1913
+func GetExcutionDoctorAdviceGroupList(patients []string, advice_date int64, user_org_id int64) (advice []*models.DoctorAdviceThrity, err error) {
1914
+
1915
+	err = XTReadDB().Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1 and execution_state = 2", patients, advice_date, user_org_id).Group("drug_id").Find(&advice).Error
1916
+	return advice, err
1917
+}
1918
+
1919
+func GetExcutionDoctorAdviceList(patients []string, advice_date int64, user_org_id int64) (advice []*models.DoctorAdviceThrity, err error) {
1920
+
1921
+	err = XTReadDB().Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1 and execution_state = 2", patients, advice_date, user_org_id).Find(&advice).Error
1922
+	return advice, err
1923
+}
1924
+
1925
+func GetHisCheckDoctorAdvice(orgid int64, patinentids []string, advice_date int64) (advice []*models.HisDoctorAdviceThirty, err error) {
1926
+
1927
+	err = XTReadDB().Where("user_org_id = ? and patient_id in(?) and advice_date = ? and status =1", orgid, patinentids, advice_date).Find(&advice).Error
1928
+	return advice, err
1929
+}
1930
+
1931
+func CheckDoctorAdvice(id int64, creater int64) (models.DoctorAdviceThrity, error) {
1932
+
1933
+	doctoradvice := models.DoctorAdviceThrity{}
1934
+	err := XTWriteDB().Model(&doctoradvice).Where("id = ? and status = 1", id).Update(map[string]interface{}{"checker": creater, "check_time": time.Now().Unix()}).Error
1935
+	return doctoradvice, err
1936
+}
1937
+
1938
+func CheckHisDoctorAdvice(id int64, creater int64) (models.HisDoctorAdviceThirty, error) {
1939
+
1940
+	doctoradvice := models.HisDoctorAdviceThirty{}
1941
+	err := XTWriteDB().Model(&doctoradvice).Where("id = ? and status = 1", id).Update(map[string]interface{}{"checker": creater, "check_time": time.Now().Unix()}).Error
1942
+	return doctoradvice, err
1943
+}
1944
+
1945
+func GetCheckDoctorAdvice(orgid int64, patinentids []string, advice_date int64) (advice []*models.DoctorAdviceThrity, err error) {
1946
+
1947
+	err = XTReadDB().Where("user_org_id = ? and patient_id in(?) and advice_date = ? and status=1", orgid, patinentids, advice_date).Find(&advice).Error
1948
+	return advice, err
1949
+}
1950
+
1951
+func SettleHisNewDoctorAdvice(patinentids []string, advice_date int64, orgid int64) (advice []*models.HisDoctorAdviceThirty, err error) {
1952
+
1953
+	err = XTWriteDB().Model(&advice).Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1", patinentids, advice_date, orgid).Update(map[string]interface{}{"is_settle": 1}).Error
1954
+	return advice, err
1955
+}
1956
+
1957
+func SettleNewDoctorAdvice(patinentids []string, advice_date int64, orgid int64) (advice []*models.DoctorAdviceThrity, err error) {
1958
+
1959
+	err = XTWriteDB().Model(&advice).Where("patient_id in(?) and advice_date = ? and user_org_id = ? and status = 1", patinentids, advice_date, orgid).Update(map[string]interface{}{"is_settle": 1}).Error
1960
+	return advice, err
1961
+}
1962
+
1963
+func GetHisMobileAdviceGroupList(orgid int64, ids []string) (advice []*models.HisDoctorAdvice, err error) {
1964
+
1965
+	err = XTReadDB().Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Group("drug_id").Find(&advice).Error
1966
+	return advice, err
1967
+}
1968
+
1969
+func GetHisMobileAdviceList(orgid int64, ids []string) (advice []*models.HisDoctorAdvice, err error) {
1970
+
1971
+	err = XTReadDB().Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Find(&advice).Error
1972
+	return advice, err
1973
+}
1974
+
1975
+func ExectionMobileAdvice(orgid int64, ids []string, execution_time int64, execution_staff int64) error {
1976
+
1977
+	advice := models.HisDoctorAdvice{}
1978
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1}).Error
1979
+	return err
1980
+}
1981
+
1982
+func GetBloodMobileAdviceGroupList(orgid int64, ids []string) (advice []*models.DoctorAdviceThrity, err error) {
1983
+
1984
+	err = XTReadDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Group("drug_id").Find(&advice).Error
1985
+	return advice, err
1986
+}
1987
+
1988
+func GetBloodMobileAdviceList(orgid int64, ids []string) (advice []*models.DoctorAdviceThrity, err error) {
1989
+
1990
+	err = XTReadDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Find(&advice).Error
1991
+	return advice, err
1992
+}
1993
+
1994
+func FindAllDoctorAdviceByIds(orgID int64, ids []string) (advice []models.DoctorAdvice, err error) {
1995
+	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id=?  AND id in(?)  AND status = 1", orgID, ids).Find(&advice).Error
1996
+	return
1997
+}
1998
+
1999
+func ExectionBloodMobileAdvice(orgid int64, ids []string, execution_time int64, execution_staff int64) error {
2000
+	fmt.Println("ids2323232323323223233223wode", ids)
2001
+	advice := models.DoctorAdviceThrity{}
2002
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_staff": execution_staff, "execution_state": 1}).Error
2003
+	return err
2004
+}
2005
+
2006
+func UpdateSettleMobileHisAdvice(orgid int64, ids []string) error {
2007
+
2008
+	advice := models.HisDoctorAdviceThirty{}
2009
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status =1", orgid, ids).Updates(map[string]interface{}{"is_settle": 1}).Error
2010
+	return err
2011
+}
2012
+
2013
+func UpdateSettleMobileBloodAdvice(orgid int64, ids []string) error {
2014
+
2015
+	advice := models.DoctorAdvice{}
2016
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status =1", orgid, ids).Updates(map[string]interface{}{"is_settle": 1}).Error
2017
+	return err
2018
+}
2019
+
2020
+func CheckBloodDoctorAdvice(orgid int64, ids []string, advice models.DoctorAdvice) error {
2021
+
2022
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"check_time": advice.CheckTime, "checker": advice.Checker, "check_state": 1}).Error
2023
+	return err
2024
+}
2025
+
2026
+func CheckHisMobileDoctorAdvice(orgid int64, ids []string, advice models.HisDoctorAdviceThirty) error {
2027
+	err := XTWriteDB().Model(&advice).Where("user_org_id = ? and id in(?) and status = 1", orgid, ids).Updates(map[string]interface{}{"check_time": advice.CheckTime, "checker": advice.Checker, "check_state": 1}).Error
2028
+	return err
2029
+}
2030
+
2031
+func GetLastOrder(user_org_id int64, patient_id int64, dialysis_date int64) (models.DialysisOrderTwenty, error) {
2032
+
2033
+	twenty := models.DialysisOrderTwenty{}
2034
+
2035
+	err := XTReadDB().Where("user_org_id = ? and patient_id =? and dialysis_date < ? and status = 1", user_org_id, patient_id, dialysis_date).Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
2036
+		return db.Preload("DeviceZone", "status =1").Where("org_id = ? AND status = 1", user_org_id)
2037
+	}).Order("id desc").First(&twenty).Error
2038
+
2039
+	return twenty, err
2040
+}

+ 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 + "%"

+ 20 - 3
service/doctor_schedule_service.go View File

@@ -588,7 +588,7 @@ func GetAllMobileZone(orgid int64) (zone []*models.DeviceZone, err error) {
588 588
 	return zone, err
589 589
 }
590 590
 
591
-func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int64) (schedule []*models.Schedule, err error) {
591
+func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int64) (schedule []*models.ScheduleTwenty, err error) {
592 592
 
593 593
 	db := XTReadDB().Table("xt_schedule as s")
594 594
 	if zoneid > 0 {
@@ -599,8 +599,8 @@ func GetPatientSchedule(startime int64, zoneid int64, classtype int64, orgid int
599 599
 	}
600 600
 	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
601 601
 		return XTReadDB().Model(&models.DeviceNumber{}).Where("status = 1 AND org_id = ?", orgid).Order("sort asc")
602
-	}).Preload("DialysisOrder", "status =1").Joins("JOIN xt_patients as p ON p.id = s.patient_id and p.lapseto = 1 and p.user_org_id =?", orgid).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
603
-		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
602
+	}).Preload("DialysisOrderTwenty", "status =1").Joins("JOIN xt_patients as p ON p.id = s.patient_id and p.lapseto = 1 and p.user_org_id =?", orgid).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
603
+		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,s.is_export,p.name as patient").Find(&schedule).Error
604 604
 	return schedule, err
605 605
 }
606 606
 
@@ -741,3 +741,20 @@ func UpdateDialysisPrescriptionOne(prescription models.DialysisPrescription, pat
741 741
 	err := XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and status = 1", patientid, recordate).Updates(map[string]interface{}{"dialysis_dialyszers": prescription.DialysisDialyszers, "mode_id": mode_id, "dialysis_irrigation": prescription.DialysisIrrigation}).Error
742 742
 	return err
743 743
 }
744
+
745
+func GetPatientScheduleListByZone(schedule_date int64, class_tye int64, orgid int64) (schedule []*models.ScheduleTwentyOne, err error) {
746
+
747
+	db := XTReadDB().Model(&schedule).Where("status = 1")
748
+
749
+	if schedule_date > 0 {
750
+		db = db.Where("schedule_date = ?", schedule_date)
751
+	}
752
+	if class_tye > 0 {
753
+		db = db.Where("schedule_type = ?", class_tye)
754
+	}
755
+	if orgid > 0 {
756
+		db = db.Where("user_org_id = ?", orgid)
757
+	}
758
+	err = db.Select("partition_id,Count(id) as id,user_org_id").Group("partition_id").Scan(&schedule).Error
759
+	return schedule, err
760
+}

+ 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
+}

+ 115 - 0
service/his_service.go View File

@@ -537,6 +537,22 @@ func GetSettleHisPrescriptionTX(org_id int64, patient_id int64, his_patient_id i
537 537
 	return
538 538
 }
539 539
 
540
+func GetSettleHisPrescriptionTXOne(org_id int64, patient_id int64, his_patient_id int64, record_date int64, med_type int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
541
+	err = tx.Model(&models.HisPrescription{}).
542
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
543
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
544
+		}).
545
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
546
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("drug_id").Preload("Drug", "status=1")
547
+		}).
548
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
549
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("project_id").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
550
+		}).
551
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND his_patient_id = ? AND p_type <> 1 AND med_type = ?", org_id, record_date, patient_id, his_patient_id, med_type).
552
+		Find(&prescription).Error
553
+	return
554
+}
555
+
540 556
 func GetMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64, med_type int64) (prescription []*models.HisPrescription, err error) {
541 557
 	err = readDb.Model(&models.HisPrescription{}).
542 558
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -568,6 +584,22 @@ func GetMonthHisPrescriptionTX(org_id int64, patient_id int64, start_date int64,
568 584
 	return
569 585
 }
570 586
 
587
+func GetMonthHisPrescriptionTXOne(org_id int64, patient_id int64, start_date int64, end_date int64, med_type int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
588
+	err = tx.Model(&models.HisPrescription{}).
589
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
590
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
591
+		}).
592
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
593
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("drug_id").Preload("Drug", "status=1")
594
+		}).
595
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
596
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("project_id").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
597
+		}).
598
+		Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 AND med_type = ?", org_id, start_date, end_date, patient_id, med_type).
599
+		Find(&prescription).Error
600
+	return
601
+}
602
+
571 603
 func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
572 604
 	err = readDb.Model(&models.HisPrescription{}).
573 605
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -2392,6 +2424,25 @@ func GetPrescriptionByIdsTX(ids []string, org_id int64, tx *gorm.DB) (prescripti
2392 2424
 	return
2393 2425
 }
2394 2426
 
2427
+func GetPrescriptionByIdsTxOne(ids []string, org_id int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
2428
+	err = tx.Model(&models.HisPrescription{}).
2429
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
2430
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
2431
+		}).
2432
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
2433
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("drug_id").Preload("Drug", "status=1")
2434
+		}).
2435
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
2436
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("project_id").Preload("HisProject").Preload("GoodInfo", "status=1")
2437
+		}).Preload("TempHisOrder", func(tx *gorm.DB) *gorm.DB {
2438
+		return tx.Where("status = 1 AND user_org_id = ?", org_id)
2439
+	}).
2440
+		Where("id in (?) AND user_org_id = ? AND status = 1", ids, org_id).
2441
+		Find(&prescription).Error
2442
+
2443
+	return
2444
+}
2445
+
2395 2446
 func GetNewAllUnChargeHisPatientListTwo(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
2396 2447
 	db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2397 2448
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
@@ -2590,3 +2641,67 @@ func GetHisPrescriptonProjectById(id int64) (models.HisPrescriptionProject, erro
2590 2641
 	err := XTReadDB().Where("id = ? and status = 1", id).Find(&project).Error
2591 2642
 	return project, err
2592 2643
 }
2644
+
2645
+type HisOrderInfoTwo struct {
2646
+	ID                     int64                      `gorm:"column:id" json:"id" form:"id"`
2647
+	OrderNumber            string                     `gorm:"column:order_number" json:"order_number" form:"order_number"`
2648
+	UploadDate             int64                      `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
2649
+	AdviceId               int64                      `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
2650
+	DetItemFeeSumamt       float64                    `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
2651
+	Cnt                    float64                    `gorm:"column:cnt" json:"cnt" form:"cnt"`
2652
+	Pric                   float64                    `gorm:"column:pric" json:"pric" form:"pric"`
2653
+	PatientId              int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2654
+	MedChrgitmType         string                     `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
2655
+	Status                 int64                      `gorm:"column:status" json:"status" form:"status"`
2656
+	FeedetlSn              string                     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
2657
+	ChldMedcFlag           string                     `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
2658
+	ChrgitmLv              string                     `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
2659
+	UserOrgId              int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2660
+	ProjectId              int64                      `gorm:"column:project_id" json:"project_id" form:"project_id"`
2661
+	ItemId                 int64                      `gorm:"column:item_id" json:"item_id" form:"item_id"`
2662
+	FulamtOwnpayAmt        float64                    `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
2663
+	HisPrescriptionProject HisPrescriptionProject     `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
2664
+	HisDoctorAdviceInfo    models.HisDoctorAdviceInfo `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
2665
+}
2666
+
2667
+func (HisOrderInfoTwo) TableName() string {
2668
+	return "his_order_info"
2669
+}
2670
+func GetHisOrderDetailByNumberTwo(order_number string, org_id int64) (order []*HisOrderInfoTwo, err error) {
2671
+	err = readDb.Model(&HisOrderInfoTwo{}).Where("order_number = ? AND status = 1", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2672
+		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)
2673
+	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2674
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
2675
+	}).Find(&order).Error
2676
+	return
2677
+}
2678
+
2679
+func GetHisOrderDetailByNumberThree(order_number string, org_id int64) (order []*HisOrderInfoTwo, err error) {
2680
+	err = readDb.Model(&HisOrderInfoTwo{}).Where("order_number = ?", order_number).Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2681
+		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)
2682
+	}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2683
+		return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status = 1 AND org_id = ?", org_id)
2684
+	}).Find(&order).Error
2685
+	return
2686
+}
2687
+
2688
+func GetHisOrderByIDThree(order_id int64) (order models.HisOrder, err error) {
2689
+	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
2690
+	return
2691
+}
2692
+
2693
+func GetDrugSumOutCountByDrugId(drug_id int64, user_org_id int64) (models.XtDrugStockCount, error) {
2694
+
2695
+	drug := models.XtDrugStockCount{}
2696
+
2697
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and status = 1", drug_id, user_org_id).Find(&drug).Error
2698
+
2699
+	return drug, err
2700
+}
2701
+
2702
+func GetStockGoodList(good_id int64, org_id int64) (models.XtGoodStockCount, error) {
2703
+
2704
+	stockCount := models.XtGoodStockCount{}
2705
+	err = XTReadDB().Where("good_id = ? and user_org_id = ? and status= 1", good_id, org_id).Find(&stockCount).Error
2706
+	return stockCount, err
2707
+}

+ 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
+}

+ 4 - 13
service/manage_service.go View File

@@ -914,19 +914,10 @@ func GetAllpatient(orgid int64) (patients []*models.Patients, err error) {
914 914
 	return patients, err
915 915
 }
916 916
 
917
-//func GetInformation(id int64, orgid int64) (*models.DeviceInformation, error) {
918
-////	var information models.DeviceInformation
919
-////	var err error
920
-////	err = UserReadDB().Model(&information).Where("id = ? and user_org_id = ? and status = ?", id, orgid, 1).Find(&information).Error
921
-////	fmt.Print("", err)
922
-////	if err == gorm.ErrRecordNotFound {
923
-////		return nil, err
924
-////	}
925
-////	if err != nil {
926
-////		return nil, err
927
-////	}
928
-////	return &information, nil
929
-////}
917
+func GetAllpatientThirty(orgid int64) (patients []*models.PatientsThirty, err error) {
918
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&patients).Error
919
+	return patients, err
920
+}
930 921
 
931 922
 func GetInformation(eid int64, startdate int64, orgid int64, classtype int64) (*models.DeviceInformation, error) {
932 923
 	var information models.DeviceInformation

File diff suppressed because it is too large
+ 1261 - 198
service/mobile_dialysis_service.go


+ 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
+}

+ 13 - 9
service/new_warehouse_service.go View File

@@ -1308,22 +1308,22 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1308 1308
 	// 将该批次的剩余库存数量转换为拆零数量
1309 1309
 	// 将该批次的剩余库存数量转换为拆零数量
1310 1310
 	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit != drup.MinUnit {
1311
-		fmt.Println("进来1")
1311
+		//fmt.Println("进来1")
1312 1312
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1313
-		fmt.Println("剩余库存1", stock_number)
1313
+		//fmt.Println("剩余库存1", stock_number)
1314 1314
 	}
1315 1315
 	if warehouse.MaxUnit == drup.MinUnit && drup.MaxUnit != drup.MinUnit {
1316
-		fmt.Println("进来2")
1316
+		//fmt.Println("进来2")
1317 1317
 		stock_number = warehouse.StockMaxNumber + warehouse.StockMinNumber
1318
-		fmt.Println("剩余库存2", stock_number)
1318
+		//fmt.Println("剩余库存2", stock_number)
1319 1319
 	}
1320 1320
 	if warehouse.MaxUnit == drup.MaxUnit && drup.MaxUnit == drup.MinUnit {
1321
-		fmt.Println("进来3")
1321
+		//fmt.Println("进来3")
1322 1322
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
1323
-		fmt.Println("剩余库存3", stock_number)
1323
+		//fmt.Println("剩余库存3", stock_number)
1324 1324
 	}
1325
-	fmt.Println("剩余库存23333333333333333333333333333wo", stock_number)
1326
-	fmt.Println("出库数量2333333333333333333333333333333333333wo", deliver_number)
1325
+	//fmt.Println("剩余库存23333333333333333333333333333wo", stock_number)
1326
+	//fmt.Println("出库数量2333333333333333333333333333333333333wo", deliver_number)
1327 1327
 
1328 1328
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
1329 1329
 	if stock_number >= deliver_number {
@@ -1366,10 +1366,13 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1366 1366
 		fmt.Println("minnU目标而332322323323233223323223我", minNumber)
1367 1367
 		fmt.Println("max_number232232332232322wo", maxNumber)
1368 1368
 		fmt.Println(" warehouse.StockMinNumber", warehouse.StockMinNumber)
1369
+
1369 1370
 		if warehouse.StockMinNumber < minNumber {
1370 1371
 
1371 1372
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
1372
-			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
1373
+			if warehouse.MaxUnit != warehouse.MinUnit {
1374
+				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
1375
+			}
1373 1376
 		} else {
1374 1377
 			if minNumber > 0 {
1375 1378
 				if (warehouse.StockMinNumber - minNumber) >= 0 {
@@ -1838,6 +1841,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1838 1841
 				OverCount:               sum_count,
1839 1842
 				AdviceId:                advice.ID,
1840 1843
 				LastPrice:               warehouse.Price,
1844
+				SystemTime:              advice.AdviceDate,
1841 1845
 			}
1842 1846
 
1843 1847
 			CreateDrugFlowOne(drugflow)

+ 125 - 78
service/patient_service.go View File

@@ -221,44 +221,50 @@ func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMD
221 221
 }
222 222
 
223 223
 func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
224
-	redis := RedisClient()
225
-	defer redis.Close()
226
-	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
227
-	prescriptions_list_all, _ := redis.Get(key).Result()
228
-
229
-	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
230
-		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
231
-		if err != nil {
232
-			if err == gorm.ErrRecordNotFound {
233
-				if len(prescriptions) <= 0 {
234
-					redis.Set(key, "null", time.Second*60*60*18)
235
-				}
236
-				return nil, nil
237
-			} else {
238
-				return nil, err
239
-			}
240
-		} else {
241
-			if len(prescriptions) > 0 {
242
-				//缓存数据
243
-				prescriptions_list_all, err := json.Marshal(&prescriptions)
244
-				if err == nil {
245
-					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
246
-				}
247
-			} else {
248
-				redis.Set(key, "null", time.Second*60*60*18)
249
-			}
250
-			return prescriptions, nil
251
-		}
252
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
253
-		if prescriptions_list_all == "null" {
254
-			return nil, nil
255
-		} else {
256
-			json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
257
-			return prescriptions, nil
258
-		}
259 224
 
260
-	}
261
-}
225
+	err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
226
+	return prescriptions, err
227
+}
228
+
229
+//func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
230
+//	redis := RedisClient()
231
+//	defer redis.Close()
232
+//	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
233
+//	prescriptions_list_all, _ := redis.Get(key).Result()
234
+//  redis.Set(prescriptions_list_all, "", time.Second)
235
+//	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
236
+//		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
237
+//		if err != nil {
238
+//			if err == gorm.ErrRecordNotFound {
239
+//				if len(prescriptions) <= 0 {
240
+//					redis.Set(key, "null", time.Second*60*60*18)
241
+//				}
242
+//				return nil, nil
243
+//			} else {
244
+//				return nil, err
245
+//			}
246
+//		} else {
247
+//			if len(prescriptions) > 0 {
248
+//				//缓存数据
249
+//				prescriptions_list_all, err := json.Marshal(&prescriptions)
250
+//				if err == nil {
251
+//					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
252
+//				}
253
+//			} else {
254
+//				redis.Set(key, "null", time.Second*60*60*18)
255
+//			}
256
+//			return prescriptions, nil
257
+//		}
258
+//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
259
+//		if prescriptions_list_all == "null" {
260
+//			return nil, nil
261
+//		} else {
262
+//			json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
263
+//			return prescriptions, nil
264
+//		}
265
+//
266
+//	}
267
+//}
262 268
 
263 269
 func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluationList, err error) {
264 270
 	redis := RedisClient()
@@ -300,43 +306,49 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
300 306
 }
301 307
 
302 308
 func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
303
-	redis := RedisClient()
304
-	defer redis.Close()
305
-	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
306
-	dialysis_orders_list_all, _ := redis.Get(key).Result()
307
-	redis.Set(dialysis_orders_list_all, "", time.Second)
308
-	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
309
-		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
310
-
311
-		if err != nil {
312
-			if err == gorm.ErrRecordNotFound {
313
-				return nil, nil
314
-			} else {
315
-				return nil, err
316
-			}
317
-		} else {
318
-			if len(dialysisOrders) > 0 {
319
-				//缓存数据
320
-				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
321
-				if err == nil {
322
-					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
323
-				}
324
-			} else {
325
-				redis.Set(key, "null", time.Second*60*60*18)
326
-			}
327
-			return dialysisOrders, nil
328
-		}
329
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
330
-		if dialysis_orders_list_all == "null" {
331
-			return nil, nil
332
-		} else {
333
-			json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
334
-			return dialysisOrders, nil
335
-		}
336 309
 
337
-	}
310
+	err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
311
+	return dialysisOrders, err
338 312
 }
339 313
 
314
+//func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
315
+//	redis := RedisClient()
316
+//	defer redis.Close()
317
+//	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
318
+//	dialysis_orders_list_all, _ := redis.Get(key).Result()
319
+//	redis.Set(dialysis_orders_list_all, "", time.Second)
320
+//	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
321
+//		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
322
+//
323
+//		if err != nil {
324
+//			if err == gorm.ErrRecordNotFound {
325
+//				return nil, nil
326
+//			} else {
327
+//				return nil, err
328
+//			}
329
+//		} else {
330
+//			if len(dialysisOrders) > 0 {
331
+//				//缓存数据
332
+//				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
333
+//				if err == nil {
334
+//					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
335
+//				}
336
+//			} else {
337
+//				redis.Set(key, "null", time.Second*60*60*18)
338
+//			}
339
+//			return dialysisOrders, nil
340
+//		}
341
+//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
342
+//		if dialysis_orders_list_all == "null" {
343
+//			return nil, nil
344
+//		} else {
345
+//			json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
346
+//			return dialysisOrders, nil
347
+//		}
348
+//
349
+//	}
350
+//}
351
+
340 352
 func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*models.VMTreatmentSummaryForList, err error) {
341 353
 	redis := RedisClient()
342 354
 	defer redis.Close()
@@ -416,6 +428,12 @@ func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (asses
416 428
 	}
417 429
 }
418 430
 
431
+func GetAllDobuleCheckList(orgID int64, scheduleDate int64) (dobulecheck []*models.DoubleCheck, err error) {
432
+
433
+	err = XTReadDB().Where("check_date = ? and user_org_id = ? and status = 1", scheduleDate, orgID).Find(&dobulecheck).Error
434
+	return dobulecheck, err
435
+}
436
+
419 437
 func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHisDoctorAdviceInfo, err error) {
420 438
 	redis := RedisClient()
421 439
 	defer redis.Close()
@@ -539,9 +557,8 @@ func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients
539 557
 	redis := RedisClient()
540 558
 	defer redis.Close()
541 559
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(id, 10) + ":patient_info"
542
-
543 560
 	patient_info_str, _ := redis.Get(key).Result()
544
-	fmt.Println("patient_info_stre223322323232323323223", patient_info_str)
561
+
545 562
 	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
546 563
 		err = readDb.Model(&models.Patients{}).Preload("Contagions", "status = 1").Preload("Diseases", "status = 1").Where("id = ? and user_org_id=? and status=1", id, orgID).First(&patient).Error
547 564
 		if err != nil {
@@ -830,7 +847,7 @@ func UpdatePatientLapseto(patientid int64, lapseto models.PatientLapseto) error
830 847
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
831 848
 
832 849
 	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
850
+		"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 851
 	return err
835 852
 }
836 853
 
@@ -1378,7 +1395,7 @@ func GetPatientDialysisRecord(orgID, patientID int64, page, limit, start, end, m
1378 1395
 		Preload("TreatmentSummary", "patient_id=? and user_org_id=? and status=1", patientID, orgID).
1379 1396
 		Preload("Device", "org_id=? and status=1", orgID).
1380 1397
 		Preload("UserAdminRole", func(db *gorm.DB) *gorm.DB {
1381
-			return readUserDb.Where("org_id=? and status = 1", orgID)
1398
+			return readUserDb.Where("org_id=?", orgID)
1382 1399
 		}).
1383 1400
 		Joins("JOIN xt_schedule as s ON s.patient_id=? and FROM_UNIXTIME(s.schedule_date, '%Y-%m-%d')=FROM_UNIXTIME(do.dialysis_date, '%Y-%m-%d')", patientID).
1384 1401
 		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
@@ -2268,6 +2285,11 @@ func GetAllDialysisOrdersByListTwo(orgID int64, scheduleDate int64) (dialysisOrd
2268 2285
 	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
2269 2286
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
2270 2287
 
2288
+	if scheduleDate < 1669132800 {
2289
+		fmt.Println("key233232232332323232", key)
2290
+		redis.Set(key, "", time.Second)
2291
+	}
2292
+	fmt.Println("dialysis_orders_list_all", dialysis_orders_list_all)
2271 2293
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2272 2294
 		err = readDb.Model(&MDialysisOrderVM{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2273 2295
 		if err != nil {
@@ -2322,6 +2344,12 @@ func GetAllZoneByList(orgID int64) (zone []*models.DeviceZone, err error) {
2322 2344
 	}
2323 2345
 }
2324 2346
 
2347
+func GetAllDialysisOrdersByListSeven(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVM, err error) {
2348
+
2349
+	err = readDb.Model(&MDialysisOrderVM{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2350
+	return dialysisOrders, err
2351
+}
2352
+
2325 2353
 func GetAllPrescriptionByList(orgID int64, scheduleDate int64) (prescriptions []*models.VMDialysisPrescription, err error) {
2326 2354
 
2327 2355
 	redis := RedisClient()
@@ -2459,7 +2487,7 @@ func GetAllMonitorList(orgID int64, scheduleDate int64) (monitor []*models.VMMon
2459 2487
 	monitor_record_list_all, _ := redis.Get(key).Result()
2460 2488
 	fmt.Println("monitor_recorde_list", len(monitor_record_list_all))
2461 2489
 	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
2490
+		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 2491
 		if err != nil {
2464 2492
 			if err == gorm.ErrRecordNotFound {
2465 2493
 				return nil, nil
@@ -2608,7 +2636,7 @@ func GetAllDeviceNumberByListOne(orgID int64) (number []*MDeviceNumberVM, err er
2608 2636
 	}
2609 2637
 }
2610 2638
 
2611
-func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
2639
+func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionTwenty, err error) {
2612 2640
 
2613 2641
 	redis := RedisClient()
2614 2642
 	defer redis.Close()
@@ -2617,7 +2645,7 @@ func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions
2617 2645
 	prescriptions_list_all, _ := redis.Get(key).Result()
2618 2646
 
2619 2647
 	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2620
-		err = readDb.Model(&models.DialysisPrescriptionList{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2648
+		err = readDb.Model(&models.DialysisPrescriptionTwenty{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2621 2649
 		if err != nil {
2622 2650
 			if err == gorm.ErrRecordNotFound {
2623 2651
 				return nil, nil
@@ -2645,6 +2673,19 @@ func GetAllHisProjectPrescription(orgid int64, recorddate int64) (project []*mod
2645 2673
 	return project, err
2646 2674
 }
2647 2675
 
2676
+func GetZoneCountList(orgid int64, schedule_date int64) (list []*models.XtScheduleSeven, err error) {
2677
+
2678
+	db := XTReadDB().Model(&list).Where("status = 1")
2679
+	if orgid > 0 {
2680
+		db = db.Where("user_org_id = ?", orgid)
2681
+	}
2682
+	if schedule_date > 0 {
2683
+		db = db.Where("schedule_date =?", schedule_date)
2684
+	}
2685
+	err = db.Select("partition_id,count(id) as count").Group("partition_id").Scan(&list).Error
2686
+	return list, err
2687
+}
2688
+
2648 2689
 func GetPatientDialysisLongSolution(patient_id int64, page int64, limit int64, orgid int64) (solution []*models.DialysisSolution, total int64, err error) {
2649 2690
 
2650 2691
 	db := XTReadDB().Model(&solution).Where("status = 1 and solution_status = 1")
@@ -2676,6 +2717,12 @@ func GetDialysisSolutionDetailList(orgid int64, patient_id int64, mode_id int64,
2676 2717
 	return solution, total, err
2677 2718
 }
2678 2719
 
2720
+func UpdateDialysisBefor(dislysis models.XtAssessmentBeforeDislysis, id int64) error {
2721
+
2722
+	err := XTWriteDB().Model(&models.XtAssessmentBeforeDislysis{}).Where("id = ? and status= 1", id).Update(map[string]interface{}{"systolic_blood_pressure": dislysis.SystolicBloodPressure, "diastolic_blood_pressure": dislysis.DiastolicBloodPressure}).Error
2723
+	return err
2724
+}
2725
+
2679 2726
 func GetAllSchedulesByPatientInfo(org_id int64, patient_id int64, mode_id int64) ([]Schedule, error) {
2680 2727
 	var record []Schedule
2681 2728
 	loc, _ := time.LoadLocation("Local")

+ 144 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -102,6 +102,7 @@ type DialysisOrderVM struct {
102 102
 	FinishModifier int64           `gorm:"column:finish_modifier" json:"finish_modifier"`
103 103
 	SchedualType   int64           `gorm:"column:schedual_type" json:"schedual_type"`
104 104
 	WashpipeNurse  int64           `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
105
+	UserOrgId      int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
105 106
 }
106 107
 
107 108
 func (DialysisOrderVM) TableName() string {
@@ -203,7 +204,7 @@ type PrescriptionVM struct {
203 204
 	ReplacementFlow            string  `gorm:"column:replacement_flow" json:"replacement_flow" form:"replacement_flow"`
204 205
 	PlasmaSeparator            string  `gorm:"column:plasma_separator" json:"plasma_separator" form:"plasma_separator"`
205 206
 	BilirubinAdsorptionColumn  string  `gorm:"column:bilirubin_adsorption_column" json:"bilirubin_adsorption_column" form:"bilirubin_adsorption_column"`
206
-
207
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
207 208
 	HemodialysisPipelines      string  `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
208 209
 	HemodialysisPipelinesCount float64 `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
209 210
 	PunctureNeedle             string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
@@ -288,6 +289,7 @@ type AssessmentBeforeDislysisVM struct {
288 289
 	PreDialysisDrugs               string  `gorm:"column:pre_dialysis_drugs" json:"pre_dialysis_drugs" form:"pre_dialysis_drugs"`
289 290
 	Period                         int64   `gorm:"column:period" json:"period" form:"period"`
290 291
 	EstimatedFoodIntake            string  `gorm:"column:estimated_food_intake" json:"estimated_food_intake" form:"estimated_food_intake"`
292
+	UserOrgId                      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
291 293
 }
292 294
 
293 295
 func (AssessmentBeforeDislysisVM) TableName() string {
@@ -370,6 +372,7 @@ type AssessmentAfterDislysisVM struct {
370 372
 	Lapse                           int64   `gorm:"column:lapse" json:"lapse" form:"lapse"`
371 373
 	Consciousness                   int64   `gorm:"column:consciousness" json:"consciousness" form:"consciousness"`
372 374
 	Fallrisk                        int64   `gorm:"column:fallrisk" json:"fallrisk" form:"fallrisk"`
375
+	UserOrgId                       int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
373 376
 }
374 377
 
375 378
 func (AssessmentAfterDislysisVM) TableName() string {
@@ -436,6 +439,7 @@ type XtAssessmentAfterDislysisVM struct {
436 439
 	CvcA                            float64 `gorm:"column:cvc_a" json:"cvc_a" form:"cvc_a"`
437 440
 	CvcV                            float64 `gorm:"column:cvc_v" json:"cvc_v" form:"cvc_v"`
438 441
 	Channel                         int64   `gorm:"column:channel" json:"channel" form:"channel"`
442
+	UserOrgId                       int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
439 443
 }
440 444
 
441 445
 func (XtAssessmentAfterDislysisVM) TableName() string {
@@ -464,6 +468,7 @@ type ReceiveAssessmentVM struct {
464 468
 	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
465 469
 	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
466 470
 	AdmissionNumber              string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
471
+	UserOrgId                    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
467 472
 }
468 473
 
469 474
 func (ReceiveAssessmentVM) TableName() string {
@@ -547,6 +552,7 @@ type MonitoringRecordVM struct {
547 552
 	BloodThickness              float64 `gorm:"column:blood_thickness" json:"blood_thickness" form:"blood_thickness"`
548 553
 	BloodMonitor                float64 `gorm:"column:blood_monitor" json:"blood_monitor" form:"blood_monitor"`
549 554
 	BloodPressureMonitoringSite int64   `gorm:"column:blood_pressure_monitoring_site" json:"blood_pressure_monitoring_site" form:"blood_pressure_monitoring_site"`
555
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
550 556
 }
551 557
 
552 558
 func (MonitoringRecordVM) TableName() string {
@@ -757,3 +763,140 @@ type SummerVM struct {
757 763
 func (SummerVM) TableName() string {
758 764
 	return "xt_treatment_summary"
759 765
 }
766
+
767
+type PatientVMOne struct {
768
+	ID                        int64  `gorm:"column:id" json:"id" form:"id"`
769
+	UserOrgId                 int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
770
+	UserId                    int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
771
+	Avatar                    string `gorm:"column:avatar" json:"avatar" form:"avatar"`
772
+	PatientType               int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
773
+	DialysisNo                string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
774
+	AdmissionNumber           string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
775
+	Source                    int64  `gorm:"column:source" json:"source" form:"source"`
776
+	Lapseto                   int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
777
+	PartitionId               int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
778
+	BedId                     int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
779
+	Name                      string `gorm:"column:name" json:"name" form:"name"`
780
+	Alias                     string `gorm:"column:alias" json:"alias" form:"alias"`
781
+	Gender                    int64  `gorm:"column:gender" json:"gender" form:"gender"`
782
+	Nation                    string `gorm:"column:nation" json:"nation" form:"nation"`
783
+	NativePlace               string `gorm:"column:native_place" json:"native_place" form:"native_place"`
784
+	IdCardNo                  string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
785
+	Birthday                  int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
786
+	Height                    int64  `gorm:"column:height" json:"height" form:"height"`
787
+	Rh                        int64  `gorm:"column:rh" json:"rh" form:"rh"`
788
+	HealthCareDueAlertDate    int64  `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
789
+	Phone                     string `gorm:"column:phone" json:"phone" form:"phone"`
790
+	HomeTelephone             string `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
791
+	RelativePhone             string `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
792
+	RelativeRelations         string `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
793
+	HomeAddress               string `gorm:"column:home_address" json:"home_address" form:"home_address"`
794
+	WorkUnit                  string `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
795
+	UnitAddress               string `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
796
+	ReceivingDate             int64  `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
797
+	IsHospitalFirstDialysis   int64  `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
798
+	FirstDialysisDate         int64  `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
799
+	FirstDialysisHospital     string `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
800
+	PredialysisCondition      string `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
801
+	HospitalFirstDialysisDate int64  `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
802
+	TotalDialysis             int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
803
+	Diagnose                  string `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
804
+	Remark                    string `gorm:"column:remark" json:"remark" form:"remark"`
805
+	PatientComplains          string `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
806
+	PresentHistory            string `gorm:"column:present_history" json:"present_history"`     // 现病史
807
+	PastHistory               string `gorm:"column:past_history" json:"past_history"`           // 既往史
808
+	Status                    int64  `gorm:"column:status" json:"status" form:"status"`
809
+	Age                       int64  `gorm:"column:age" json:"age"`
810
+	DialysisAge               int64  `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
811
+	TellPhone                 string `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
812
+	FirstTreatmentDate        int64  `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
813
+	UserSysBeforeCount        int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
814
+}
815
+
816
+func (PatientVMOne) TableName() string {
817
+	return "xt_patients"
818
+}
819
+
820
+type ScheduleVMSix struct {
821
+	ID                       int64                       `gorm:"column:id" json:"id"`
822
+	PatientID                int64                       `gorm:"column:patient_id" json:"patient_id"`
823
+	ScheduleDate             int64                       `gorm:"column:schedule_date" json:"schedule_date"`
824
+	BedID                    int64                       `gorm:"column:bed_id" json:"bed_id"`
825
+	PartitionId              int64                       `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
826
+	Patient                  *PatientVMSix               `gorm:"ForeignKey:PatientID" json:"patient"`
827
+	DialysisOrder            DialysisOrderVM             `gorm:"ForeignKey:DialysisDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"dialysis_order"`
828
+	Prescription             PrescriptionVM              `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"prescription"`
829
+	ReceiveAssessment        ReceiveAssessmentVM         `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"receive_assessment"`
830
+	XtReceiveTreatmentAsses  *XtReceiveTreatmentAsses    `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"xt_receive_assessment"`
831
+	AssessmentBeforeDislysis AssessmentBeforeDislysisVM  `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"assessment_before_dislysis"`
832
+	AssessmentAfterDislysis  AssessmentAfterDislysisVM   `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"assessment_after_dislysis"`
833
+	MonitoringRecords        []*MonitoringRecordVM       `gorm:"ForeignKey:MonitoringDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"monitor_records"`
834
+	DeviceNumber             *DeviceNumberVM             `gorm:"ForeignKey:BedID" json:"device_number"`
835
+	DeviceZone               *DeviceZoneVM               `gorm:"ForeignKey:PartitionId" json:"device_zone"`
836
+	Advices                  []*DoctorAdviceVM           `gorm:"ForeignKey:RecordDate,PatientID;AssociationForeignKey:ScheduleDate,PatientId" json:"advices"`
837
+	DoubleCheck              *DoubleCheckVM              `gorm:"ForeignKey:CheckDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"check"`
838
+	Summer                   *SummerVM                   `gorm:"ForeignKey:AssessmentDate,PatientID;AssociationForeignKey:ScheduleDate,PatientID" json:"summer"`
839
+	LastAfterWeight          XtAssessmentAfterDislysisVM `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
840
+	Count                    int64
841
+}
842
+
843
+func (ScheduleVMSix) TableName() string {
844
+	return "xt_schedule"
845
+}
846
+
847
+type PatientVMSix struct {
848
+	ID                        int64  `gorm:"column:id" json:"id" form:"id"`
849
+	UserOrgId                 int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
850
+	UserId                    int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
851
+	Avatar                    string `gorm:"column:avatar" json:"avatar" form:"avatar"`
852
+	PatientType               int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
853
+	DialysisNo                string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
854
+	AdmissionNumber           string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
855
+	Source                    int64  `gorm:"column:source" json:"source" form:"source"`
856
+	Lapseto                   int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
857
+	PartitionId               int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
858
+	BedId                     int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
859
+	Name                      string `gorm:"column:name" json:"name" form:"name"`
860
+	Alias                     string `gorm:"column:alias" json:"alias" form:"alias"`
861
+	Gender                    int64  `gorm:"column:gender" json:"gender" form:"gender"`
862
+	Nation                    string `gorm:"column:nation" json:"nation" form:"nation"`
863
+	IdCardNo                  string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
864
+	Birthday                  int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
865
+	Height                    int64  `gorm:"column:height" json:"height" form:"height"`
866
+	EducationLevel            int64  `gorm:"column:education_level" json:"education_level" form:"education_level"`
867
+	Profession                int64  `gorm:"column:profession" json:"profession" form:"profession"`
868
+	Phone                     string `gorm:"column:phone" json:"phone" form:"phone"`
869
+	HomeTelephone             string `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
870
+	RelativePhone             string `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
871
+	RelativeRelations         string `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
872
+	HomeAddress               string `gorm:"column:home_address" json:"home_address" form:"home_address"`
873
+	WorkUnit                  string `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
874
+	UnitAddress               string `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
875
+	Children                  int64  `gorm:"column:children" json:"children" form:"children"`
876
+	IsHospitalFirstDialysis   int64  `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
877
+	FirstDialysisDate         int64  `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
878
+	FirstDialysisHospital     string `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
879
+	PredialysisCondition      string `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
880
+	HospitalFirstDialysisDate int64  `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
881
+	TotalDialysis             int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
882
+	Evaluate                  string `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
883
+	Diagnose                  string `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
884
+	Remark                    string `gorm:"column:remark" json:"remark" form:"remark"`
885
+	RegistrarsId              int64  `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
886
+	Registrars                string `gorm:"column:registrars" json:"registrars" form:"registrars"`
887
+	PatientComplains          string `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
888
+	PresentHistory            string `gorm:"column:present_history" json:"present_history"`     // 现病史
889
+	PastHistory               string `gorm:"column:past_history" json:"past_history"`           // 既往史
890
+	Status                    int64  `gorm:"column:status" json:"status" form:"status"`
891
+	CreatedTime               int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
892
+	UpdatedTime               int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
893
+	Age                       int64  `gorm:"column:age" json:"age"`
894
+	DialysisAge               int64  `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
895
+	TellPhone                 string `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
896
+	FirstTreatmentDate        int64  `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
897
+	UserSysBeforeCount        int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
898
+}
899
+
900
+func (PatientVMSix) TableName() string {
901
+	return "xt_patients"
902
+}

+ 134 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -321,3 +321,137 @@ func GetWarehouseCancelPrintList(orgid int64, startime int64, endtime int64) (ca
321 321
 	err = db.Select("x.ctime,x.good_id,sum(x.count) as count,t.good_name,t.specification_name,t.packing_unit,t.retail_price,t.packing_price").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id").Scan(&cancel).Error
322 322
 	return cancel, err
323 323
 }
324
+
325
+func GetSchedulesSeven(orgID int64, schIDs []string) ([]*ScheduleVMSix, error) {
326
+	//recordDateStr := time.Now().Format("2006-01-02")
327
+	//recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
328
+	var schedules []*ScheduleVMSix
329
+	db := p_service.XTReadDB()
330
+	err := db.Model(&ScheduleVMSix{}).
331
+		Preload("Patient", "user_org_id = ? AND status = 1", orgID).
332
+		Preload("DeviceNumber", "org_id = ?", orgID).
333
+		Preload("DeviceZone", "org_id = ?", orgID).
334
+		Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).Order("schedule_date asc").
335
+		Find(&schedules).
336
+		Error
337
+	if err != nil {
338
+		return nil, err
339
+	}
340
+	for _, item := range schedules {
341
+		dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
342
+		item.Patient.TotalDialysis = dialysis_count
343
+	}
344
+	return schedules, nil
345
+}
346
+
347
+func GetSchedulesSix(orgID int64, schIDs []string) ([]*ScheduleVMSix, error) {
348
+	recordDateStr := time.Now().Format("2006-01-02")
349
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
350
+	var schedules []*ScheduleVMSix
351
+	db := p_service.XTReadDB()
352
+	err := db.Model(&ScheduleVMSix{}).
353
+		Preload("Patient", "user_org_id = ? AND status = 1", orgID).
354
+		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
355
+			return db.Where("user_org_id = ? AND status = 1", orgID).Preload("DeviceNumber", "org_id = ? AND status = 1", orgID)
356
+		}).
357
+		Preload("Prescription", "user_org_id = ? AND status = 1", orgID).
358
+		Preload("ReceiveAssessment", "user_org_id = ? AND status = 1", orgID).
359
+		Preload("XtReceiveTreatmentAsses", "user_org_id = ? AND status = 1", orgID).
360
+		Preload("AssessmentBeforeDislysis", func(db *gorm.DB) *gorm.DB {
361
+			return db.Where("user_org_id = ? AND status = 1", orgID)
362
+		}).
363
+		Preload("AssessmentAfterDislysis", "user_org_id = ? AND status = 1", orgID).
364
+		Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
365
+			return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgID, recordDate.Unix())
366
+		}).Preload("MonitoringRecords", func(db *gorm.DB) *gorm.DB {
367
+		return db.Where("user_org_id = ? AND status = 1", orgID).
368
+			Order("operate_time asc")
369
+	}).
370
+		Preload("DeviceNumber", "org_id = ?", orgID).
371
+		Preload("DeviceZone", "org_id = ?", orgID).
372
+		Preload("DoubleCheck", "user_org_id = ? AND status = 1", orgID).
373
+		Preload("Summer", "user_org_id = ? AND status = 1", orgID).
374
+		Preload("Advices", func(db *gorm.DB) *gorm.DB {
375
+			return db.Select("id, user_org_id, patient_id, advice_type, advice_date, record_date, start_time, drug_spec_unit,advice_name,advice_desc, reminder_date, drug_spec, drug_spec_unit, single_dose, single_dose_unit, prescribing_number, prescribing_number_unit, delivery_way, execution_frequency, advice_doctor, status, created_time,updated_time, advice_affirm, remark, stop_time, stop_reason, stop_doctor, stop_state, parent_id, execution_time, execution_staff, execution_state, checker, check_state, check_time, groupno, IF(parent_id > 0, parent_id, id) as advice_order").
376
+				Where("user_org_id = ? AND advice_type = 2 AND status = 1", orgID).
377
+				Order("start_time asc, groupno desc, advice_order desc, id asc")
378
+		}).Where("user_org_id = ? AND status = 1 AND id in (?)", orgID, schIDs).Order("schedule_date asc").
379
+		Find(&schedules).
380
+		Error
381
+	if err != nil {
382
+		return nil, err
383
+	}
384
+	for _, item := range schedules {
385
+		dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
386
+		item.Patient.TotalDialysis = dialysis_count
387
+	}
388
+	return schedules, nil
389
+}
390
+
391
+func GetBatchDialysisOrder(orgid int64, patient_id int64, dialysis_date int64) (DialysisOrderVM, error) {
392
+
393
+	orderVM := DialysisOrderVM{}
394
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date = ? and status = 1", orgid, patient_id, dialysis_date).Preload("DeviceNumber", "org_id = ? AND status = 1", orgid).Find(&orderVM).Error
395
+	return orderVM, err
396
+}
397
+
398
+func GetBatchPrescription(orgid int64, patient_id int64, record_date int64) (PrescriptionVM, error) {
399
+
400
+	prescriptionVM := PrescriptionVM{}
401
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patient_id, record_date).Find(&prescriptionVM).Error
402
+	return prescriptionVM, err
403
+}
404
+
405
+func GetBatchReceiveTreatmentAsses(orgid int64, patient_id int64, record_date int64) (ReceiveAssessmentVM, error) {
406
+
407
+	receiveAssessmentVM := ReceiveAssessmentVM{}
408
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and record_date = ? and status = 1", orgid, patient_id, record_date).Find(&receiveAssessmentVM).Error
409
+	return receiveAssessmentVM, err
410
+}
411
+
412
+func GetBatchAssessmentBeforeDislysisVM(orgid int64, patient_id int64, assessment_date int64) (AssessmentBeforeDislysisVM, error) {
413
+
414
+	AssessmentBeforeDislysisVM := AssessmentBeforeDislysisVM{}
415
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and assessment_date = ? and status = 1", orgid, patient_id, assessment_date).Find(&AssessmentBeforeDislysisVM).Error
416
+	return AssessmentBeforeDislysisVM, err
417
+}
418
+
419
+func GetBatchAssessmentAfterDislysisVM(orgid int64, patient_id int64, assessment_date int64) (AssessmentAfterDislysisVM, error) {
420
+
421
+	assessmentAfterDislysisVM := AssessmentAfterDislysisVM{}
422
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and assessment_date = ? and status = 1", orgid, patient_id, assessment_date).Find(&assessmentAfterDislysisVM).Error
423
+	return assessmentAfterDislysisVM, err
424
+}
425
+
426
+func GetBatchLastAfterWeight(orgid int64, patient_id int64, assessment_date int64) (XtAssessmentAfterDislysisVM, error) {
427
+
428
+	xtAssessmentAfterDislysisVM := XtAssessmentAfterDislysisVM{}
429
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and assessment_date < ? and status = 1", orgid, patient_id, assessment_date).Order("id desc").First(&xtAssessmentAfterDislysisVM).Error
430
+	return xtAssessmentAfterDislysisVM, err
431
+}
432
+
433
+func GetBatchMonitor(orgid int64, patient_id int64, monitoring_date int64) (MonitoringRecordVM []*MonitoringRecordVM, err error) {
434
+
435
+	err = p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and monitoring_date = ? and status = 1", orgid, patient_id, monitoring_date).Order("operate_time asc").Find(&MonitoringRecordVM).Error
436
+	return MonitoringRecordVM, err
437
+}
438
+
439
+func GetBatchDoctorAdvice(orgid int64, patient_id int64, advice_date int64) (DoctorAdviceVM []*DoctorAdviceVM, err error) {
440
+
441
+	err = p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and advice_date = ? and status = 1 and  advice_type = 2", orgid, patient_id, advice_date).Order("start_time asc, groupno desc, id asc").Find(&DoctorAdviceVM).Error
442
+	return DoctorAdviceVM, err
443
+}
444
+
445
+func GetBatchDobuleCheck(orgid int64, patient_id int64, check_date int64) (*DoubleCheckVM, error) {
446
+
447
+	doubleCheckVM := DoubleCheckVM{}
448
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and check_date =? and status = 1", orgid, patient_id, check_date).Find(&doubleCheckVM).Error
449
+	return &doubleCheckVM, err
450
+}
451
+
452
+func GetBatchSummerVM(orgid int64, patient_id int64, assessment_date int64) (*SummerVM, error) {
453
+
454
+	SummerVM := SummerVM{}
455
+	err := p_service.XTReadDB().Where("user_org_id = ? and patient_id = ? and assessment_date =? and status = 1", orgid, patient_id, assessment_date).Find(&SummerVM).Error
456
+	return &SummerVM, err
457
+}

+ 27 - 6
service/schedule_service.go View File

@@ -706,7 +706,7 @@ func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64,
706 706
 
707 707
 func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
708 708
 
709
-	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
709
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
710 710
 	if orgid > 0 {
711 711
 		db = db.Where("x.user_org_id = ?", orgid)
712 712
 	}
@@ -733,7 +733,7 @@ func GetWeekDayScheduleByIdThee(orgid int64, scheduleDate int64, scheduleType in
733 733
 
734 734
 func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone []string) (list []*models.VmSchedulesRemind, err error) {
735 735
 
736
-	db := readDb2.Table("xt_schedule as x").Where("x.status = 1")
736
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
737 737
 	if orgid > 0 {
738 738
 		db = db.Where("x.user_org_id = ?", orgid)
739 739
 	}
@@ -747,7 +747,7 @@ func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int
747 747
 		db = db.Where("x.partition_id in (?)", zone)
748 748
 	}
749 749
 
750
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
750
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export,x.mode_id").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
751 751
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
752 752
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
753 753
 		return db.Where("status =1").Order("id asc")
@@ -912,7 +912,7 @@ func UpdateNewScheduleTemplateStatus(id int64, org_id int64) (err error) {
912 912
 
913 913
 func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone []string, record_date int64) (schedules []*models.WeekScheduleSix, err error) {
914 914
 
915
-	db := readDb2.Table("xt_schedule as s ").Where("s.status =1")
915
+	db := XTReadDB().Table("xt_schedule as s ").Where("s.status =1")
916 916
 	if orgID > 0 {
917 917
 		db = db.Where("s.user_org_id = ?", orgID)
918 918
 	}
@@ -943,7 +943,7 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
943 943
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
944 944
 		return db.Where("status =1 and parent_id = 0 and advice_date = ?", record_date).Preload("ChildDoctorAdvice", "status = 1 and advice_date = ?", record_date)
945 945
 	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", record_date).Joins("JOIN xt_patients as p ON p.id = s.patient_id").
946
-		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
946
+		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient,p.id_card_no as id_card_no,p.dialysis_no as dialysis_no,p.gender as gender,p.phone as phone").
947 947
 		Order("s.partition_id desc").
948 948
 		Find(&schedules).Error
949 949
 	return schedules, err
@@ -1107,7 +1107,7 @@ func GetDataPrint(orgid int64) (models.XtDataPrint, error) {
1107 1107
 
1108 1108
 func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*models.XtSchedule, err error) {
1109 1109
 
1110
-	err = readDb2.Model(&schedule).Where("schedule_date >=? and schedule_date<=? and status = 1 and user_org_id = ?", startime, endtime, orgid).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1110
+	err = XTReadDB().Model(&schedule).Where("schedule_date >=? and schedule_date<=? and status = 1 and user_org_id = ?", startime, endtime, orgid).Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
1111 1111
 		return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgid, endtime)
1112 1112
 	}).Find(&schedule).Error
1113 1113
 	return schedule, err
@@ -1236,3 +1236,24 @@ func GetDialysisOrderByBedIdTwo(orgID, start, bed_id int64, schedule_type int64)
1236 1236
 	return order, nil
1237 1237
 
1238 1238
 }
1239
+
1240
+func ChangeScheduleClass(schedule models.Schedule) error {
1241
+
1242
+	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
1243
+	return err
1244
+}
1245
+
1246
+func GetLastDialysisOrder(org_id int64, patient_id int64, dialysis_date int64) (models.XtDialysisOrderSix, error) {
1247
+
1248
+	order := models.XtDialysisOrderSix{}
1249
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and dialysis_date < ? and status = 1", org_id, patient_id, dialysis_date).Order("id desc").First(&order).Error
1250
+	return order, err
1251
+}
1252
+
1253
+func GetLastDialysisSolution(org_id int64, patient_id int64, mode_id int64, schedule_date int64) (models.DialysisPrescription, error) {
1254
+
1255
+	dialysisprescription := models.DialysisPrescription{}
1256
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and mode_id = ? and status = 1 and record_date<?", org_id, patient_id, mode_id, schedule_date).Order("id desc").First(&dialysisprescription).Error
1257
+	return dialysisprescription, err
1258
+
1259
+}

+ 89 - 1
service/stock_service.go View File

@@ -4237,7 +4237,7 @@ func GetOrderDetialByOrderIdOne(id []string, orgid int64) (out []*models.Warehou
4237 4237
 		db = db.Where("x.org_id = ?", orgid)
4238 4238
 	}
4239 4239
 
4240
-	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4240
+	err = db.Select("x.id,x.warehouse_out_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,x.manufacturer,t.social_security_directory_code,x.is_sys,x.sys_record_time,n.number,x.remark,x.license_number,x.storehouse_id,x.admin_user_id,x.buy_price,x.stock_count,x.warehouse_info_id,x.remark,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit,t.packing_price,x.register_number").Joins("left join xt_warehouse_info as n on n.id=x.warehouse_info_id").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.warehouse_out_id,x.good_id").Order("x.ctime desc").Scan(&out).Error
4241 4241
 
4242 4242
 	return out, err
4243 4243
 }
@@ -7113,6 +7113,13 @@ func GetDrugOpenConfigOne(orgid int64) (models.DrugOutConfig, error) {
7113 7113
 	return config, err
7114 7114
 }
7115 7115
 
7116
+func FindXTHisRecordByOrgIdSix(org_id int64) (models.XtHisConfig, error) {
7117
+
7118
+	config := models.XtHisConfig{}
7119
+	err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
7120
+	return config, err
7121
+}
7122
+
7116 7123
 func CreateDrugOutConfig(config models.DrugOutConfig) error {
7117 7124
 
7118 7125
 	err := XTWriteDB().Create(&config).Error
@@ -7132,6 +7139,12 @@ func FindDrugOutConfigById(orgid int64) (models.DrugOutConfig, error) {
7132 7139
 	return config, err
7133 7140
 }
7134 7141
 
7142
+func FindeDrugSettleConfigById(orgid int64) (models.HisSettleStockConfig, error) {
7143
+	config := models.HisSettleStockConfig{}
7144
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
7145
+	return config, err
7146
+}
7147
+
7135 7148
 func UpdatedWarehouseOut(id int64) error {
7136 7149
 
7137 7150
 	err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
@@ -8075,3 +8088,78 @@ func GetInvetoryWarehouseInfoList(orgid int64, storehouse_id int64) (info []*mod
8075 8088
 	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id=? and is_check= 1 and org_id = ?", storehouse_id, orgid).Preload("GoodInfo", "status = 1").Find(&info).Error
8076 8089
 	return info, err
8077 8090
 }
8091
+
8092
+func GetSettleOpenConfig(user_org_id int64) (*models.HisSettleStockConfig, error) {
8093
+
8094
+	config := models.HisSettleStockConfig{}
8095
+	err := XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
8096
+	if err == gorm.ErrRecordNotFound {
8097
+		return nil, err
8098
+	}
8099
+	if err != nil {
8100
+		return nil, err
8101
+	}
8102
+	return &config, nil
8103
+}
8104
+
8105
+func CreateSettleOpenConfig(config models.HisSettleStockConfig) error {
8106
+
8107
+	err := XTReadDB().Create(&config).Error
8108
+	return err
8109
+}
8110
+
8111
+func UpdateSettleOpenConfig(id int64, config models.HisSettleStockConfig) error {
8112
+
8113
+	err := XTWriteDB().Model(&models.HisSettleStockConfig{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_open": config.IsOpen}).Error
8114
+	return err
8115
+}
8116
+
8117
+func UpdateDrugStockAutomaticReduceRecordOne(orgid int64, is_open int64) (models.DrugStockConfig, error) {
8118
+
8119
+	config := models.DrugStockConfig{}
8120
+	err := XTWriteDB().Model(&config).Where("org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": is_open}).Error
8121
+	return config, err
8122
+}
8123
+
8124
+func UpdatePharyConfig(orgid int64, is_open int64) (models.PharmacyConfig, error) {
8125
+
8126
+	stockConfig := models.PharmacyConfig{}
8127
+
8128
+	err := XTWriteDB().Model(&stockConfig).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": is_open}).Error
8129
+
8130
+	return stockConfig, err
8131
+}
8132
+
8133
+func UpdateSettleOpenConfigOne(id int64, is_open int64) error {
8134
+
8135
+	err := XTWriteDB().Model(&models.HisSettleStockConfig{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_open": is_open}).Error
8136
+	return err
8137
+}
8138
+
8139
+func GetSettleOpenConfigByOrgId(user_org_id int64) (models.HisSettleStockConfig, error) {
8140
+
8141
+	config := models.HisSettleStockConfig{}
8142
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
8143
+	return config, nil
8144
+}
8145
+
8146
+func GetGoodInformationByGoodIdOne(good_id int64) (models.GoodInformationFourty, error) {
8147
+
8148
+	info := models.GoodInformationFourty{}
8149
+	err := XTReadDB().Where("id = ? and status = 1", good_id).Find(&info).Error
8150
+	return info, err
8151
+}
8152
+
8153
+func GetHisDocById(id int64, orgid int64) (models.HisDoctorAdvice, error) {
8154
+
8155
+	advice := models.HisDoctorAdvice{}
8156
+	err := XTReadDB().Where("id = ? and user_org_id= ? and status = 1", id, orgid).Find(&advice).Error
8157
+	return advice, err
8158
+}
8159
+
8160
+func GetBloodDocById(id int64, orgid int64) (models.DoctorAdvice, error) {
8161
+
8162
+	advice := models.DoctorAdvice{}
8163
+	err := XTReadDB().Where("id = ? and user_org_id= ? and status = 1", id, orgid).Find(&advice).Error
8164
+	return advice, err
8165
+}

+ 1 - 1
service/user_service.go View File

@@ -51,7 +51,7 @@ func GetAllDoctorAndNurse(orgId, appid int64) (doctors []AdminUserList, nurses [
51 51
 func GetAllDoctorAndNurseSix(orgId, appid int64) (doctors []AdminUserList, nurses []AdminUserList, err error) {
52 52
 
53 53
 	var users []AdminUserList
54
-	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("org_id=? and app_id =? and uar.user_type IN (2,3) and ua.status=1", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&users).Error
54
+	err = readUserDb.Table("sgj_user_admin_role as uar").Joins("JOIN sgj_user_admin as ua ON ua.id = uar.admin_user_id").Where("org_id=? and app_id =? and uar.user_type IN (2,3)", orgId, appid).Select("ua.id, uar.user_name as name, uar.user_type,uar.status").Scan(&users).Error
55 55
 	if err != nil {
56 56
 		return
57 57
 	}

File diff suppressed because it is too large
+ 6091 - 8
service/warhouse_service.go