Browse Source

11月9日库存管理

XMLWAN 2 years ago
parent
commit
fea32019fd

+ 1 - 1
conf/app.conf View File

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

+ 412 - 4
controllers/dialysis_api_controller.go View File

@@ -99,6 +99,12 @@ func DialysisApiRegistRouters() {
99 99
 	beego.Router("/api/patient/getscheduleprintlist", &DialysisApiController{}, "Get:GetSchedulePrintList")
100 100
 
101 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")
102 108
 }
103 109
 
104 110
 func (c *DialysisApiController) GetQueueCall() {
@@ -311,6 +317,8 @@ func (c *DialysisApiController) PostPrescription() {
311 317
 	drhy_water := c.GetString("drhy_water")
312 318
 	dry_water_hour := c.GetString("dry_water_hour")
313 319
 	water_machine := c.GetString("water_machine")
320
+	add_amount, _ := c.GetFloat("add_amount")
321
+	reduce_amount, _ := c.GetFloat("reduce_amount")
314 322
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
315 323
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
316 324
 
@@ -416,6 +424,8 @@ func (c *DialysisApiController) PostPrescription() {
416 424
 		DrhyWater:                  drhy_water,
417 425
 		DryWaterHour:               dry_water_hour,
418 426
 		WaterMachine:               water_machine,
427
+		AddAmount:                  add_amount,
428
+		ReduceAmount:               reduce_amount,
419 429
 	}
420 430
 
421 431
 	if appRole.UserType == 2 || appRole.UserType == 1 {
@@ -645,6 +655,8 @@ func (c *DialysisApiController) PostSoulution() {
645 655
 	dry_water_hour := c.GetString("dry_water_hour")
646 656
 	drhy_water := c.GetString("drhy_water")
647 657
 	water_machine := c.GetString("water_machine")
658
+	add_amount, _ := c.GetFloat("add_amount")
659
+	reduce_amount, _ := c.GetFloat("reduce_amount")
648 660
 	var prescription_doctor int64
649 661
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
650 662
 
@@ -762,6 +774,8 @@ func (c *DialysisApiController) PostSoulution() {
762 774
 		DryWaterHour:               dry_water_hour,
763 775
 		DrhyWater:                  drhy_water,
764 776
 		WaterMachine:               water_machine,
777
+		AddAmount:                  add_amount,
778
+		ReduceAmount:               reduce_amount,
765 779
 	}
766 780
 
767 781
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -3692,15 +3706,16 @@ func (c *DialysisApiController) GetSolution() {
3692 3706
 	solution, err := service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3693 3707
 	prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3694 3708
 	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, mode_id)
3695
-
3709
+	dialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient_id, adminUserInfo.CurrentOrgId)
3696 3710
 	if err != nil {
3697 3711
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3698 3712
 		return
3699 3713
 	}
3700 3714
 	c.ServeSuccessJSON(map[string]interface{}{
3701
-		"solution":            solution,
3702
-		"prescription":        prescription,
3703
-		"system_prescription": system_prescription,
3715
+		"solution":             solution,
3716
+		"prescription":         prescription,
3717
+		"system_prescription":  system_prescription,
3718
+		"dialysisPrescription": dialysisPrescription,
3704 3719
 	})
3705 3720
 
3706 3721
 }
@@ -4722,3 +4737,396 @@ func (this *DialysisApiController) GetSolutionListByOrgId() {
4722 4737
 	})
4723 4738
 
4724 4739
 }
4740
+
4741
+func (this *DialysisApiController) ExcutionDoctorAdvice() {
4742
+
4743
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4744
+	is_open, _ := this.GetInt64("is_open")
4745
+	idsStr := this.GetString("str")
4746
+	recordIDStrs := strings.Split(idsStr, ",")
4747
+	start_time := this.GetString("advice_date")
4748
+	exec_time, _ := this.GetInt64("exec_time")
4749
+	timeLayout := "2006-01-02"
4750
+	loc, _ := time.LoadLocation("Local")
4751
+	var startTime int64
4752
+	if len(start_time) > 0 {
4753
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4754
+		if err != nil {
4755
+			//fmt.Println(err)
4756
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4757
+			return
4758
+		}
4759
+		startTime = theTime.Unix()
4760
+	}
4761
+	config, _ := service.GetDrugOpenConfigOne(orgId)
4762
+	pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
4763
+	storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
4764
+	//his医嘱
4765
+	if is_open == 1 {
4766
+
4767
+		groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
4768
+		//查找未执行医嘱
4769
+		list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
4770
+		for _, item := range groupList {
4771
+			for _, it := range list {
4772
+				if item.DrugId == it.DrugId {
4773
+					item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
4774
+				}
4775
+			}
4776
+		}
4777
+
4778
+		for _, item := range groupList {
4779
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4780
+			var sum_out_count int64
4781
+			for _, it := range item.ChildDoctorAdvice {
4782
+				var prescribing_number int64
4783
+				stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
4784
+				parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
4785
+				if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4786
+					prescribing_number = parseIntPrescribingNumber * medical.MinNumber
4787
+				}
4788
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4789
+					prescribing_number = parseIntPrescribingNumber
4790
+				}
4791
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4792
+					prescribing_number = parseIntPrescribingNumber
4793
+				}
4794
+				sum_out_count += prescribing_number
4795
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId)
4796
+				//库存不足
4797
+				if sum_out_count > drugStockOut.FlushCount {
4798
+					this.ServeSuccessJSON(map[string]interface{}{
4799
+						"msg":  "2",
4800
+						"drug": medical,
4801
+					})
4802
+					return
4803
+				}
4804
+			}
4805
+		}
4806
+
4807
+		//执行出库逻辑
4808
+		for _, item := range list {
4809
+			hisadvice := &models.HisDoctorAdviceInfo{
4810
+				ID:                    item.ID,
4811
+				UserOrgId:             item.UserOrgId,
4812
+				PatientId:             item.PatientId,
4813
+				AdviceType:            item.AdviceType,
4814
+				AdviceDate:            item.AdviceDate,
4815
+				StartTime:             item.StartTime,
4816
+				AdviceName:            item.AdviceName,
4817
+				AdviceDesc:            item.AdviceDesc,
4818
+				ReminderDate:          item.ReminderDate,
4819
+				SingleDose:            item.SingleDose,
4820
+				SingleDoseUnit:        item.SingleDoseUnit,
4821
+				DrugSpec:              item.DrugSpec,
4822
+				DrugSpecUnit:          item.DrugSpecUnit,
4823
+				PrescribingNumber:     item.PrescribingNumber,
4824
+				PrescribingNumberUnit: item.PrescribingNumberUnit,
4825
+				DeliveryWay:           item.DeliveryWay,
4826
+				ExecutionFrequency:    item.ExecutionFrequency,
4827
+				AdviceDoctor:          item.AdviceDoctor,
4828
+				Status:                1,
4829
+				CreatedTime:           item.CreatedTime,
4830
+				UpdatedTime:           item.UpdatedTime,
4831
+				AdviceAffirm:          item.AdviceAffirm,
4832
+				Remark:                item.Remark,
4833
+				StopTime:              item.StopTime,
4834
+				StopReason:            item.StopReason,
4835
+				StopDoctor:            item.StopDoctor,
4836
+				StopState:             item.StopState,
4837
+				ParentId:              item.ParentId,
4838
+				ExecutionTime:         item.ExecutionTime,
4839
+				ExecutionStaff:        item.ExecutionStaff,
4840
+				ExecutionState:        item.ExecutionState,
4841
+				Checker:               item.Checker,
4842
+				RecordDate:            item.ReminderDate,
4843
+				DialysisOrderId:       item.DialysisOrderId,
4844
+				CheckTime:             item.CheckTime,
4845
+				CheckState:            item.CheckState,
4846
+				RemindType:            item.RemindType,
4847
+				FrequencyType:         item.FrequencyType,
4848
+				DayCount:              item.DayCount,
4849
+				WeekDay:               item.WeekDay,
4850
+				TemplateId:            item.TemplateId,
4851
+				Modifier:              item.Modifier,
4852
+				Way:                   item.Way,
4853
+				DrugId:                item.DrugId,
4854
+				ExecutionFrequencyId:  item.ExecutionFrequencyId,
4855
+			}
4856
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4857
+			if medical.IsUse == 2 {
4858
+				if config.IsOpen != 1 {
4859
+					if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
4860
+						service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
4861
+
4862
+					}
4863
+					//不通过药房发药
4864
+					if pharmacyConfig.IsOpen != 1 {
4865
+						service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
4866
+					}
4867
+					//查询默认仓库
4868
+					storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
4869
+					//查询默认仓库剩余多少库存
4870
+					var sum_count int64
4871
+					stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
4872
+					for _, its := range stockInfo {
4873
+						if its.MaxUnit == medical.MaxUnit {
4874
+							its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
4875
+						}
4876
+						sum_count += its.StockMaxNumber + its.StockMinNumber
4877
+					}
4878
+					service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
4879
+					service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
4880
+				}
4881
+			}
4882
+
4883
+			info := models.HisDoctorAdviceInfo{
4884
+				ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
4885
+				ExecutionTime:  exec_time,
4886
+				ExecutionState: 1,
4887
+				UpdatedTime:    time.Now().Unix(),
4888
+			}
4889
+			//执行医嘱
4890
+			service.UpdateHisDoctorAdviceExecution(info, item.ID)
4891
+
4892
+			key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
4893
+			redis := service.RedisClient()
4894
+			//清空key 值
4895
+			redis.Set(key, "", time.Second)
4896
+			keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
4897
+
4898
+			redis.Set(keyTwo, "", time.Second)
4899
+			keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
4900
+			redis.Set(keyThree, "", time.Second)
4901
+			toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
4902
+			theTime := toTime.Format("2006-01-02")
4903
+
4904
+			fmt.Println("theTIME", theTime)
4905
+			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
4906
+
4907
+			redis.Set(keyFour, "", time.Second)
4908
+			keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
4909
+			redis.Set(keyFive, "", time.Second)
4910
+		}
4911
+
4912
+	} else {
4913
+
4914
+		groupList, _ := service.GetExcutionDoctorAdviceGroupList(recordIDStrs, startTime, orgId)
4915
+		//查找未执行医嘱
4916
+		list, _ := service.GetExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
4917
+		for _, item := range groupList {
4918
+			for _, it := range list {
4919
+				if item.DrugId == it.DrugId {
4920
+					item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
4921
+				}
4922
+			}
4923
+		}
4924
+
4925
+		for _, item := range groupList {
4926
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4927
+			var sum_out_count int64
4928
+			for _, it := range item.ChildDoctorAdvice {
4929
+				var prescribing_number int64
4930
+				stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
4931
+				parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
4932
+				if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
4933
+					prescribing_number = parseIntPrescribingNumber * medical.MinNumber
4934
+				}
4935
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
4936
+					prescribing_number = parseIntPrescribingNumber
4937
+				}
4938
+				if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
4939
+					prescribing_number = parseIntPrescribingNumber
4940
+				}
4941
+				sum_out_count += prescribing_number
4942
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId)
4943
+				//库存不足
4944
+				if sum_out_count > drugStockOut.FlushCount {
4945
+					this.ServeSuccessJSON(map[string]interface{}{
4946
+						"msg":  "2",
4947
+						"drug": medical,
4948
+					})
4949
+					return
4950
+				}
4951
+			}
4952
+		}
4953
+
4954
+		for _, item := range list {
4955
+			medical, _ := service.GetBaseDrugMedical(item.DrugId)
4956
+			dadvice := &models.DoctorAdvice{
4957
+				ID:                    item.ID,
4958
+				UserOrgId:             item.UserOrgId,
4959
+				PatientId:             item.PatientId,
4960
+				AdviceType:            item.AdviceType,
4961
+				AdviceDate:            item.AdviceDate,
4962
+				StartTime:             item.StartTime,
4963
+				AdviceName:            item.AdviceName,
4964
+				AdviceDesc:            item.AdviceDesc,
4965
+				ReminderDate:          item.ReminderDate,
4966
+				SingleDose:            item.SingleDose,
4967
+				SingleDoseUnit:        item.SingleDoseUnit,
4968
+				DrugSpec:              item.DrugSpec,
4969
+				DrugSpecUnit:          item.DrugSpecUnit,
4970
+				PrescribingNumber:     item.PrescribingNumber,
4971
+				PrescribingNumberUnit: item.PrescribingNumberUnit,
4972
+				DeliveryWay:           item.DeliveryWay,
4973
+				ExecutionFrequency:    item.ExecutionFrequency,
4974
+				AdviceDoctor:          item.AdviceDoctor,
4975
+				Status:                1,
4976
+				CreatedTime:           item.CreatedTime,
4977
+				UpdatedTime:           item.UpdatedTime,
4978
+				AdviceAffirm:          item.AdviceAffirm,
4979
+				Remark:                item.Remark,
4980
+				StopTime:              item.StopTime,
4981
+				StopReason:            item.StopReason,
4982
+				StopDoctor:            item.StopDoctor,
4983
+				StopState:             item.StopState,
4984
+				ParentId:              item.ParentId,
4985
+				ExecutionTime:         item.ExecutionTime,
4986
+				ExecutionStaff:        item.ExecutionStaff,
4987
+				ExecutionState:        item.ExecutionState,
4988
+				Checker:               item.Checker,
4989
+				RecordDate:            item.ReminderDate,
4990
+				DialysisOrderId:       item.DialysisOrderId,
4991
+				CheckTime:             item.CheckTime,
4992
+				CheckState:            item.CheckState,
4993
+				RemindType:            item.RemindType,
4994
+				FrequencyType:         item.FrequencyType,
4995
+				DayCount:              item.DayCount,
4996
+				WeekDay:               item.WeekDay,
4997
+				TemplateId:            item.TemplateId,
4998
+				Modifier:              item.Modifier,
4999
+				Way:                   item.Way,
5000
+				DrugId:                item.DrugId,
5001
+			}
5002
+			if medical.IsUse == 2 {
5003
+				if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
5004
+					service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
5005
+				}
5006
+				if pharmacyConfig.IsOpen != 1 {
5007
+					service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
5008
+				}
5009
+
5010
+				//更新字典里面的库存
5011
+				stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
5012
+				var sum_count int64
5013
+				for _, its := range stockInfo {
5014
+					baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
5015
+					if its.MaxUnit == baseDrug.MaxUnit {
5016
+						its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
5017
+					}
5018
+					sum_count += its.StockMaxNumber + its.StockMinNumber
5019
+				}
5020
+				service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
5021
+				//剩余库存
5022
+				service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
5023
+			}
5024
+
5025
+			info := models.DoctorAdvice{
5026
+				ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
5027
+				ExecutionTime:  exec_time,
5028
+				ExecutionState: 1,
5029
+				UpdatedTime:    time.Now().Unix(),
5030
+			}
5031
+			//执行医嘱
5032
+			service.UpdateDoctorAdviceExecution(info, item.ID)
5033
+		}
5034
+
5035
+	}
5036
+
5037
+	this.ServeSuccessJSON(map[string]interface{}{
5038
+		"msg": "1",
5039
+	})
5040
+	return
5041
+}
5042
+
5043
+func (this *DialysisApiController) CheckNewDoctorAdvice() {
5044
+
5045
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5046
+	is_open, _ := this.GetInt64("is_open")
5047
+	idsStr := this.GetString("str")
5048
+	recordIDStrs := strings.Split(idsStr, ",")
5049
+	start_time := this.GetString("advice_date")
5050
+	timeLayout := "2006-01-02"
5051
+	loc, _ := time.LoadLocation("Local")
5052
+	var startTime int64
5053
+	if len(start_time) > 0 {
5054
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
5055
+		if err != nil {
5056
+			//fmt.Println(err)
5057
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5058
+			return
5059
+		}
5060
+		startTime = theTime.Unix()
5061
+	}
5062
+
5063
+	if is_open == 1 {
5064
+
5065
+		creater := this.GetAdminUserInfo().AdminUser.Id
5066
+		//查询未核对的医嘱
5067
+		advicelist, _ := service.GetHisCheckDoctorAdvice(orgId, recordIDStrs, startTime)
5068
+		for _, item := range advicelist {
5069
+			if item.ExecutionStaff == creater {
5070
+				this.ServeSuccessJSON(map[string]interface{}{
5071
+					"msg":    "2",
5072
+					"advice": item,
5073
+				})
5074
+				return
5075
+			}
5076
+
5077
+			service.CheckHisDoctorAdvice(item.ID, creater)
5078
+		}
5079
+	} else {
5080
+
5081
+		//查询未核对的医嘱
5082
+		advicelist, _ := service.GetCheckDoctorAdvice(orgId, recordIDStrs, startTime)
5083
+		creater := this.GetAdminUserInfo().AdminUser.Id
5084
+		for _, item := range advicelist {
5085
+			if item.ExecutionStaff == creater {
5086
+				this.ServeSuccessJSON(map[string]interface{}{
5087
+					"msg":    "2",
5088
+					"advice": item,
5089
+				})
5090
+				return
5091
+			}
5092
+
5093
+			service.CheckHisDoctorAdvice(item.ID, creater)
5094
+		}
5095
+	}
5096
+
5097
+	this.ServeSuccessJSON(map[string]interface{}{
5098
+		"msg": "1",
5099
+	})
5100
+	return
5101
+
5102
+}
5103
+
5104
+func (this *DialysisApiController) SettleNewDoctorAdvice() {
5105
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5106
+	is_open, _ := this.GetInt64("is_open")
5107
+	idsStr := this.GetString("str")
5108
+	recordIDStrs := strings.Split(idsStr, ",")
5109
+	start_time := this.GetString("advice_date")
5110
+	timeLayout := "2006-01-02"
5111
+	loc, _ := time.LoadLocation("Local")
5112
+	var startTime int64
5113
+	if len(start_time) > 0 {
5114
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
5115
+		if err != nil {
5116
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5117
+			return
5118
+		}
5119
+		startTime = theTime.Unix()
5120
+	}
5121
+
5122
+	if is_open == 1 {
5123
+		service.SettleHisNewDoctorAdvice(recordIDStrs, startTime, orgId)
5124
+	} else {
5125
+		service.SettleNewDoctorAdvice(recordIDStrs, startTime, orgId)
5126
+	}
5127
+
5128
+	this.ServeSuccessJSON(map[string]interface{}{
5129
+		"msg": "1",
5130
+	})
5131
+	return
5132
+}

+ 92 - 0
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")
@@ -1362,3 +1363,94 @@ func (this *DoctorsApiController) GetPatientInfo() {
1362 1363
 		return
1363 1364
 	}
1364 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
+	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
1378
+		adviceType = 0
1379
+	}
1380
+
1381
+	if patientType != 1 && patientType != 2 {
1382
+
1383
+		patientType = 0
1384
+	}
1385
+
1386
+	date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
1387
+	if parseDateErr != nil {
1388
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1389
+		return
1390
+	}
1391
+
1392
+	adminUserInfo := c.GetAdminUserInfo()
1393
+	orgID := adminUserInfo.CurrentOrgId
1394
+
1395
+	config, _ := service.GetHisDoctorConfig(orgID)
1396
+	project_config, _ := service.GetHisProjectConfig(orgID)
1397
+
1398
+	if config.IsOpen == 0 || config.IsOpen == 2 {
1399
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way)
1400
+		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1401
+		if err != nil {
1402
+			c.ErrorLog("获取排班信息失败:%v", err)
1403
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1404
+		} else {
1405
+			filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
1406
+			for _, schedual := range scheduals {
1407
+				if len(schedual.DoctorAdvices) > 0 {
1408
+					filtedScheduals = append(filtedScheduals, schedual)
1409
+				}
1410
+			}
1411
+			c.ServeSuccessJSON(map[string]interface{}{
1412
+				"scheduals":      filtedScheduals,
1413
+				"adminUser":      adminUser,
1414
+				"config":         config,
1415
+				"project_config": project_config,
1416
+			})
1417
+		}
1418
+	}
1419
+	if config.IsOpen == 1 {
1420
+		hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way)
1421
+		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1422
+		project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
1423
+		for _, item := range project {
1424
+			index := 0
1425
+			for _, subItem := range item.HisPrescriptionTeamProject {
1426
+
1427
+				if subItem.HisProject.CostClassify != 3 {
1428
+					subItem.IsCheckTeam = 2
1429
+					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
1430
+				}
1431
+
1432
+				if subItem.HisProject.CostClassify == 3 {
1433
+					subItem.IsCheckTeam = 1
1434
+					index = index + 1
1435
+					if index == 1 {
1436
+						item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
1437
+					}
1438
+				}
1439
+			}
1440
+		}
1441
+
1442
+		if err != nil {
1443
+			c.ErrorLog("获取排班信息失败:%v", err)
1444
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1445
+		} else {
1446
+			c.ServeSuccessJSON(map[string]interface{}{
1447
+				"adminUser":      adminUser,
1448
+				"hisAdvices":     hisAdvices,
1449
+				"config":         config,
1450
+				"project_config": project_config,
1451
+				"project":        project,
1452
+			})
1453
+		}
1454
+	}
1455
+
1456
+}

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

+ 144 - 14
controllers/his_api_controller.go View File

@@ -5103,7 +5103,6 @@ func (c *HisApiController) GetUploadInfo() {
5103 5103
 	}()
5104 5104
 	fmt.Println("dec_way", dec_way)
5105 5105
 	if (dec_way == "true" && tmp_decimal == "0") || (dec_way == "true" && tmp_decimal == "") {
5106
-		fmt.Println("tru23332322323323232232332即那里")
5107 5106
 		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
5108 5107
 		return
5109 5108
 	}
@@ -5133,6 +5132,9 @@ func (c *HisApiController) GetUploadInfo() {
5133 5132
 	recordDateTime := theTime.Unix()
5134 5133
 	adminUser := c.GetAdminUserInfo()
5135 5134
 	var prescriptions []*models.HisPrescription
5135
+
5136
+	var prescriptionsOne []*models.HisPrescription
5137
+
5136 5138
 	var start_time int64
5137 5139
 	var end_time int64
5138 5140
 
@@ -5145,8 +5147,12 @@ func (c *HisApiController) GetUploadInfo() {
5145 5147
 			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
5146 5148
 
5147 5149
 				prescriptions, _ = service.GetPrescriptionByIdsTX(ids_arr, adminUser.CurrentOrgId, tx)
5150
+
5151
+				prescriptionsOne, _ = service.GetPrescriptionByIdsTxOne(ids_arr, adminUser.CurrentOrgId, tx)
5148 5152
 			} else {
5149 5153
 				prescriptions, _ = service.GetSettleHisPrescriptionTX(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
5154
+
5155
+				prescriptionsOne, _ = service.GetSettleHisPrescriptionTXOne(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
5150 5156
 			}
5151 5157
 		} else { //月结
5152 5158
 
@@ -5169,6 +5175,8 @@ func (c *HisApiController) GetUploadInfo() {
5169 5175
 			recordEndTime := theEndTime.Unix()
5170 5176
 			end_time = recordEndTime
5171 5177
 			prescriptions, _ = service.GetMonthHisPrescriptionTX(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type, tx)
5178
+
5179
+			prescriptionsOne, _ = service.GetMonthHisPrescriptionTXOne(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type, tx)
5172 5180
 		}
5173 5181
 
5174 5182
 		timestamp := time.Now().Unix()
@@ -5299,7 +5307,133 @@ func (c *HisApiController) GetUploadInfo() {
5299 5307
 			}
5300 5308
 		}
5301 5309
 
5302
-		//判断库存的地方
5310
+		var goods []*models.DialysisBeforePrepareGoods
5311
+		var newGoods []*models.NewDialysisBeforePrepareGoods
5312
+		var infos []*models.HisDoctorAdviceInfo
5313
+		var hisAdvice []*models.HisDoctorAdviceInfo
5314
+		var newGoodOne []*models.NewDialysisBeforePrepareGoods
5315
+		houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5316
+
5317
+		settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5318
+		if settConfig.IsOpen == 1 {
5319
+			//判断库存的地方
5320
+			for _, info := range prescriptions {
5321
+				if info.Type == 1 {
5322
+					infos = append(infos, info.HisDoctorAdviceInfo...)
5323
+
5324
+				}
5325
+				if info.Type == 2 {
5326
+					for _, sumItem := range info.HisPrescriptionProject {
5327
+						if sumItem.Type == 3 {
5328
+							var good models.DialysisBeforePrepareGoods
5329
+							var newGood models.NewDialysisBeforePrepareGoods
5330
+							good.GoodId = sumItem.GoodInfo.ID
5331
+							good.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5332
+							count, _ := strconv.Atoi(sumItem.Count)
5333
+							good.Count = int64(count)
5334
+							good.StorehouseId = houseConfig.StorehouseOutInfo
5335
+							good.ProjectId = sumItem.ID
5336
+							goods = append(goods, &good)
5337
+
5338
+							newGood.GoodId = sumItem.GoodInfo.ID
5339
+							newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5340
+							count2, _ := strconv.Atoi(sumItem.Count)
5341
+							newGood.Count = int64(count2)
5342
+							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5343
+							newGood.ProjectId = sumItem.ID
5344
+							newGoods = append(newGoods, &newGood)
5345
+						}
5346
+					}
5347
+				}
5348
+			}
5349
+
5350
+			for _, info := range prescriptionsOne {
5351
+				if info.Type == 1 {
5352
+					hisAdvice = append(hisAdvice, info.HisDoctorAdviceInfo...)
5353
+				}
5354
+
5355
+				if info.Type == 2 {
5356
+					for _, sumItem := range info.HisPrescriptionProject {
5357
+						if sumItem.Type == 3 {
5358
+							var newGood models.NewDialysisBeforePrepareGoods
5359
+
5360
+							newGood.GoodId = sumItem.GoodInfo.ID
5361
+							newGood.GoodTypeId = sumItem.GoodInfo.GoodTypeId
5362
+							count2, _ := strconv.Atoi(sumItem.Count)
5363
+							newGood.Count = int64(count2)
5364
+							newGood.StorehouseId = houseConfig.StorehouseOutInfo
5365
+							newGood.ProjectId = sumItem.ID
5366
+							newGoodOne = append(newGoodOne, &newGood)
5367
+						}
5368
+					}
5369
+				}
5370
+			}
5371
+
5372
+			//判断
5373
+			for _, itemOne := range infos {
5374
+				for _, itemTwo := range hisAdvice {
5375
+					if itemOne.DrugId == itemTwo.DrugId {
5376
+						itemTwo.Child = append(itemTwo.ChildDoctorAdvice, itemOne)
5377
+					}
5378
+				}
5379
+			}
5380
+
5381
+			for _, itemTwo := range hisAdvice {
5382
+				medical, _ := service.GetBaseDrugMedical(itemTwo.DrugId)
5383
+				var sum_out_count int64
5384
+				for _, itemThree := range itemTwo.Child {
5385
+					var prescribing_number int64
5386
+					stringPrescribingNumber := strconv.FormatFloat(itemThree.PrescribingNumber, 'f', -1, 64)
5387
+					parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
5388
+					if itemThree.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
5389
+						prescribing_number = parseIntPrescribingNumber * medical.MinNumber
5390
+					}
5391
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
5392
+						prescribing_number = parseIntPrescribingNumber
5393
+					}
5394
+					if itemThree.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
5395
+						prescribing_number = parseIntPrescribingNumber
5396
+					}
5397
+					sum_out_count += prescribing_number
5398
+				}
5399
+				drugStockOut, _ := service.GetDrugSumOutCountByDrugId(itemTwo.DrugId, adminUser.CurrentOrgId)
5400
+
5401
+				if sum_out_count > drugStockOut.FlushCount {
5402
+					c.ServeSuccessJSON(map[string]interface{}{
5403
+						"msg":  "2",
5404
+						"drug": medical,
5405
+					})
5406
+					return
5407
+				}
5408
+			}
5409
+
5410
+			for _, itemOne := range newGoods {
5411
+				for _, item := range newGoodOne {
5412
+					if itemOne.ProjectId == item.ProjectId {
5413
+						item.ChildNewDialysisBeforePrepareGoods = append(item.ChildNewDialysisBeforePrepareGoods, item)
5414
+					}
5415
+				}
5416
+			}
5417
+
5418
+			for _, item := range newGoodOne {
5419
+				var sum_out_count_one int64
5420
+				good, _ := service.GetGoodInformationByGoodIdOne(item.GoodId)
5421
+
5422
+				for _, itemOne := range item.ChildNewDialysisBeforePrepareGoods {
5423
+					sum_out_count_one += itemOne.Count
5424
+				}
5425
+				list, _ := service.GetStockGoodList(item.GoodId, adminUser.CurrentOrgId)
5426
+				fmt.Println("sum_out_count_one", sum_out_count_one)
5427
+				fmt.Println("list.FlushCount", list.FlushCount)
5428
+				if sum_out_count_one > list.FlushCount {
5429
+					c.ServeSuccessJSON(map[string]interface{}{
5430
+						"msg":  "3",
5431
+						"good": good,
5432
+					})
5433
+					return
5434
+				}
5435
+			}
5436
+		}
5303 5437
 
5304 5438
 		for _, item := range customs {
5305 5439
 			var advice_id int64 = 0
@@ -5357,7 +5491,7 @@ func (c *HisApiController) GetUploadInfo() {
5357 5491
 		if dec_way == "true" {
5358 5492
 
5359 5493
 			tmpstring := strconv.FormatInt(order.ID, 10)
5360
-			fmt.Println("tmpstring222222222", order.ID)
5494
+
5361 5495
 			//扣押金
5362 5496
 			errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
5363 5497
 			order.Decimal = decimal
@@ -5368,15 +5502,8 @@ func (c *HisApiController) GetUploadInfo() {
5368 5502
 				return
5369 5503
 			}
5370 5504
 		}
5371
-		fmt.Println("err233232233232323232wo", err)
5372 5505
 
5373 5506
 		if err == nil {
5374
-
5375
-			houseConfig, _ := service.GetAllStoreHouseConfig(adminUser.CurrentOrgId)
5376
-			var goods []*models.DialysisBeforePrepareGoods
5377
-			var newGoods []*models.NewDialysisBeforePrepareGoods
5378
-			var infos []*models.HisDoctorAdviceInfo
5379
-
5380 5507
 			for _, info := range prescriptions {
5381 5508
 				if info.Type == 1 {
5382 5509
 					infos = append(infos, info.HisDoctorAdviceInfo...)
@@ -5407,7 +5534,7 @@ func (c *HisApiController) GetUploadInfo() {
5407 5534
 
5408 5535
 				}
5409 5536
 			}
5410
-			if adminUser.CurrentOrgId == 9671 {
5537
+			if settConfig.IsOpen == 1 {
5411 5538
 				for _, item := range infos {
5412 5539
 					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5413 5540
 				}
@@ -5479,10 +5606,13 @@ func (c *HisApiController) GetUploadInfo() {
5479 5606
 
5480 5607
 					}
5481 5608
 				}
5482
-				for _, item := range infos {
5483
-					service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5609
+				settConfig, _ := service.GetSettleOpenConfigByOrgId(adminUser.CurrentOrgId)
5610
+				if settConfig.IsOpen == 1 {
5611
+					for _, item := range infos {
5612
+						service.HisDrugsDelivery(item.UserOrgId, adminUser.AdminUser.Id, item)
5613
+					}
5614
+					service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5484 5615
 				}
5485
-				service.ConsumablesDeliveryTotal(adminUser.CurrentOrgId, his.PatientId, his.RecordDate, goods, newGoods, adminUser.AdminUser.Id)
5486 5616
 
5487 5617
 				c.ServeSuccessJSON(map[string]interface{}{
5488 5618
 					"msg": "结算成功",

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

+ 9 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1111,6 +1111,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1111 1111
 		Complication:                 complications,
1112 1112
 		DialysisIntakes:              dialysateVolume,
1113 1113
 		CreatedTime:                  time.Now().Unix(),
1114
+		UpdatedTime:                  time.Now().Unix(),
1114 1115
 		Status:                       1,
1115 1116
 		Remark:                       remark,
1116 1117
 		BloodAccessPartId:            blood_access_part_id,
@@ -1365,6 +1366,8 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1365 1366
 	dry_water_hour := c.GetString("dry_water_hour")
1366 1367
 
1367 1368
 	water_machine := c.GetString("water_machine")
1369
+	add_amount, _ := c.GetFloat("add_amount")
1370
+	reduce_amount, _ := c.GetFloat("reduce_amount")
1368 1371
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1369 1372
 
1370 1373
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
@@ -1475,6 +1478,8 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1475 1478
 		DrhyWater:                  drhy_water,
1476 1479
 		DryWaterHour:               dry_water_hour,
1477 1480
 		WaterMachine:               water_machine,
1481
+		AddAmount:                  add_amount,
1482
+		ReduceAmount:               reduce_amount,
1478 1483
 	}
1479 1484
 
1480 1485
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -2594,6 +2599,8 @@ func (c *DialysisAPIController) PostSolution() {
2594 2599
 	admin_user_id, _ := c.GetInt64("admin_user_id")
2595 2600
 
2596 2601
 	is_water := c.GetString("is_water")
2602
+	add_amount, _ := c.GetFloat("add_amount")
2603
+	reduce_amount, _ := c.GetFloat("reduce_amount")
2597 2604
 	var is_war int64
2598 2605
 	if is_water == "是" {
2599 2606
 		is_war = 1
@@ -2718,6 +2725,8 @@ func (c *DialysisAPIController) PostSolution() {
2718 2725
 		DrhyWater:                  drhy_water,
2719 2726
 		DryWaterHour:               dry_water_hour,
2720 2727
 		WaterMachine:               water_machine,
2728
+		AddAmount:                  add_amount,
2729
+		ReduceAmount:               reduce_amount,
2721 2730
 	}
2722 2731
 
2723 2732
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)

+ 6 - 3
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,11 @@ 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")
1774 1775
 			err := service.AddSigleRecord(&newprescribe)
1775 1776
 			//获取key,清空redis
1776 1777
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -1874,6 +1875,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1874 1875
 			newprescribe.Status = 1
1875 1876
 			newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
1876 1877
 			newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
1878
+			newprescribe.Remark = lastDialysisPrescription.Remark
1877 1879
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1878 1880
 			newprescribe.ID = dialysisPrescription.ID
1879 1881
 			if dialysisPrescription.ID == 0 {
@@ -1981,6 +1983,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1981 1983
 			newprescribe.Status = 1
1982 1984
 			newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
1983 1985
 			newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
1986
+			newprescribe.Remark = lastDialysisPrescription.Remark
1984 1987
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1985 1988
 			newprescribe.ID = dialysisPrescription.ID
1986 1989
 			if dialysisPrescription.ID == 0 {
@@ -3247,7 +3250,7 @@ func (c *PatientApiController) GetPatientMonitor() {
3247 3250
 	//获取患者的透析次数
3248 3251
 	count, err := service.GetDialysisCount(orgID, partition)
3249 3252
 
3250
-	patients, err := service.GetAllpatient(orgID)
3253
+	patients, err := service.GetAllpatientThirty(orgID)
3251 3254
 	if err == nil {
3252 3255
 		c.ServeSuccessJSON(map[string]interface{}{
3253 3256
 			"monitor":      monitor,

+ 99 - 10
models/dialysis.go View File

@@ -1095,16 +1095,17 @@ type DialysisBeforePrepareGoods struct {
1095 1095
 }
1096 1096
 
1097 1097
 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"`
1106
-	RecordDate        int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1107
-	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
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"`
1106
+	RecordDate                         int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
1107
+	UserOrgId                          int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1108
+	ChildNewDialysisBeforePrepareGoods []*NewDialysisBeforePrepareGoods `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"child"`
1108 1109
 }
1109 1110
 
1110 1111
 type QueueCallConfig struct {
@@ -1252,3 +1253,91 @@ type DialysisOrderTwenty struct {
1252 1253
 func (DialysisOrderTwenty) TableName() string {
1253 1254
 	return "xt_dialysis_order"
1254 1255
 }
1256
+
1257
+type HisDoctorAdviceThirty struct {
1258
+	ID                    int64                    `gorm:"column:id" json:"id" form:"id"`
1259
+	UserOrgId             int64                    `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1260
+	PatientId             int64                    `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1261
+	AdviceDate            int64                    `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1262
+	StartTime             int64                    `gorm:"column:start_time" json:"start_time" form:"start_time"`
1263
+	AdviceName            string                   `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1264
+	PrescribingNumber     float64                  `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1265
+	PrescribingNumberUnit string                   `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1266
+	Status                int64                    `gorm:"column:status" json:"status" form:"status"`
1267
+	CreatedTime           int64                    `gorm:"column:created_time" json:"created_time" form:"created_time"`
1268
+	UpdatedTime           int64                    `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1269
+	ParentId              int64                    `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1270
+	ExecutionTime         int64                    `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1271
+	ExecutionStaff        int64                    `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1272
+	ExecutionState        int64                    `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1273
+	Checker               int64                    `gorm:"column:checker" json:"checker" form:"checker"`
1274
+	CheckTime             int64                    `gorm:"column:check_time" json:"check_time" form:"check_time"`
1275
+	CheckState            int64                    `gorm:"column:check_state" json:"check_state" form:"check_state"`
1276
+	ChildDoctorAdvice     []*HisDoctorAdviceThirty `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
1277
+	IsCheck               int64                    `gorm:"-" json:"is_check" form:"is_check"`
1278
+	Way                   int64                    `gorm:"column:way" json:"way" form:"way"`
1279
+	IsSettle              int64                    `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
1280
+}
1281
+
1282
+func (HisDoctorAdviceThirty) TableName() string {
1283
+	return "his_doctor_advice_info"
1284
+}
1285
+
1286
+type DoctorAdviceThrity struct {
1287
+	ID                    int64                 `gorm:"column:id" json:"id" form:"id"`
1288
+	GroupNo               int64                 `gorm:"column:groupno" json:"groupno" form:"groupno"`
1289
+	UserOrgId             int64                 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1290
+	PatientId             int64                 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1291
+	AdviceType            int64                 `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
1292
+	AdviceDate            int64                 `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
1293
+	StartTime             int64                 `gorm:"column:start_time" json:"start_time" form:"start_time"`
1294
+	AdviceName            string                `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
1295
+	AdviceDesc            string                `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
1296
+	ReminderDate          int64                 `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
1297
+	SingleDose            float64               `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
1298
+	SingleDoseUnit        string                `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
1299
+	DrugSpec              float64               `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
1300
+	DrugSpecUnit          string                `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
1301
+	PrescribingNumber     float64               `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
1302
+	PrescribingNumberUnit string                `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
1303
+	DeliveryWay           string                `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
1304
+	ExecutionFrequency    string                `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
1305
+	AdviceDoctor          int64                 `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
1306
+	Status                int64                 `gorm:"column:status" json:"status" form:"status"`
1307
+	CreatedTime           int64                 `gorm:"column:created_time" json:"created_time" form:"created_time"`
1308
+	UpdatedTime           int64                 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1309
+	AdviceAffirm          string                `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
1310
+	Remark                string                `gorm:"column:remark" json:"remark" form:"remark"`
1311
+	StopTime              int64                 `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
1312
+	StopReason            string                `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
1313
+	StopDoctor            int64                 `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
1314
+	StopState             int64                 `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
1315
+	ParentId              int64                 `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
1316
+	ExecutionTime         int64                 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
1317
+	ExecutionStaff        int64                 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
1318
+	ExecutionState        int64                 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
1319
+	Checker               int64                 `gorm:"column:checker" json:"checker" form:"checker"`
1320
+	RecordDate            int64                 `gorm:"column:record_date" json:"record_date"`
1321
+	DialysisOrderId       int64                 `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
1322
+	CheckTime             int64                 `gorm:"column:check_time" json:"check_time" form:"check_time"`
1323
+	CheckState            int64                 `gorm:"column:check_state" json:"check_state" form:"check_state"`
1324
+	AdviceId              int64                 `gorm:"-"`
1325
+	RemindType            int64                 `gorm:"column:remind_type" json:"remind_type"`
1326
+	FrequencyType         int64                 `gorm:"column:frequency_type" json:"frequency_type"`
1327
+	DayCount              int64                 `gorm:"column:day_count" json:"day_count"`
1328
+	WeekDay               string                `gorm:"column:week_day" json:"week_day"`
1329
+	ChildDoctorAdvice     []*DoctorAdviceThrity `gorm:"ForeignKey:DrugId;AssociationForeignKey:DrugId" json:"child"`
1330
+	TemplateId            string                `gorm:"column:template_id" json:"template_id"`
1331
+	Modifier              int64                 `gorm:"column:modifier" json:"modifier" form:"modifier"`
1332
+	IsCheck               int64                 `gorm:"-" json:"is_check" form:"is_check"`
1333
+	Way                   int64                 `gorm:"column:way" json:"way" form:"way"`
1334
+	DrugId                int64                 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1335
+	DrugNameId            int64                 `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
1336
+	IsMedicine            int64                 `gorm:"column:is_medicine" json:"is_medicine" form:"is_medicine"`
1337
+	PushStartTime         int64                 `gorm:"column:push_start_time" json:"push_start_time" form:"push_start_time"`
1338
+	IsSettle              int64                 `gorm:"column:is_settle" json:"is_settle" form:"is_settle"`
1339
+}
1340
+
1341
+func (DoctorAdviceThrity) TableName() string {
1342
+	return "xt_doctor_advice"
1343
+}

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

+ 15 - 0
models/his_models.go View File

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

+ 14 - 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 {
@@ -1634,3 +1636,15 @@ type DialysisPrescriptionThrity struct {
1634 1636
 func (DialysisPrescriptionThrity) TableName() string {
1635 1637
 	return "xt_dialysis_prescription"
1636 1638
 }
1639
+
1640
+type PatientsThirty struct {
1641
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
1642
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1643
+	DialysisNo    string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1644
+	Name          string `gorm:"column:name" json:"name" form:"name"`
1645
+	TotalDialysis int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
1646
+}
1647
+
1648
+func (PatientsThirty) TableName() string {
1649
+	return "xt_patients"
1650
+}

+ 67 - 0
service/dialysis_service.go View File

@@ -1885,3 +1885,70 @@ func GetScheduleTypeById(org_id int64, schedule_date int64, schedule_type int64)
1885 1885
 	err = db.Select("partition_id,count(id) as count").Group("partition_id").Scan(&list).Error
1886 1886
 	return list, err
1887 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().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().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 CheckHisDoctorAdvice(id int64, creater int64) (models.HisDoctorAdviceThirty, error) {
1932
+
1933
+	doctoradvice := models.HisDoctorAdviceThirty{}
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 GetCheckDoctorAdvice(orgid int64, patinentids []string, advice_date int64) (advice []*models.DoctorAdviceThrity, err error) {
1939
+
1940
+	err = XTReadDB().Where("user_org_id = ? and patient_id in(?) and advice_date = ? and status=1", orgid, patinentids, advice_date).Find(&advice).Error
1941
+	return advice, err
1942
+}
1943
+
1944
+func SettleHisNewDoctorAdvice(patinentids []string, advice_date int64, orgid int64) (advice []*models.HisDoctorAdviceThirty, err error) {
1945
+
1946
+	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
1947
+	return advice, err
1948
+}
1949
+
1950
+func SettleNewDoctorAdvice(patinentids []string, advice_date int64, orgid int64) (advice []*models.DoctorAdviceThrity, err error) {
1951
+
1952
+	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
1953
+	return advice, err
1954
+}

+ 67 - 0
service/his_service.go View File

@@ -535,6 +535,22 @@ func GetSettleHisPrescriptionTX(org_id int64, patient_id int64, his_patient_id i
535 535
 	return
536 536
 }
537 537
 
538
+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) {
539
+	err = tx.Model(&models.HisPrescription{}).
540
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
541
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
542
+		}).
543
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
544
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("drug_id").Preload("Drug", "status=1")
545
+		}).
546
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
547
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("project_id").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
548
+		}).
549
+		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).
550
+		Find(&prescription).Error
551
+	return
552
+}
553
+
538 554
 func GetMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64, med_type int64) (prescription []*models.HisPrescription, err error) {
539 555
 	err = readDb.Model(&models.HisPrescription{}).
540 556
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -566,6 +582,22 @@ func GetMonthHisPrescriptionTX(org_id int64, patient_id int64, start_date int64,
566 582
 	return
567 583
 }
568 584
 
585
+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) {
586
+	err = tx.Model(&models.HisPrescription{}).
587
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
588
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
589
+		}).
590
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
591
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("drug_id").Preload("Drug", "status=1")
592
+		}).
593
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
594
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("project_id").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
595
+		}).
596
+		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).
597
+		Find(&prescription).Error
598
+	return
599
+}
600
+
569 601
 func GetMonthHisPrescriptionTwo(org_id int64, patient_id int64, start_date int64, end_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
570 602
 	err = readDb.Model(&models.HisPrescription{}).
571 603
 		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
@@ -2390,6 +2422,25 @@ func GetPrescriptionByIdsTX(ids []string, org_id int64, tx *gorm.DB) (prescripti
2390 2422
 	return
2391 2423
 }
2392 2424
 
2425
+func GetPrescriptionByIdsTxOne(ids []string, org_id int64, tx *gorm.DB) (prescription []*models.HisPrescription, err error) {
2426
+	err = tx.Model(&models.HisPrescription{}).
2427
+		Preload("HisAdditionalCharge", func(tx *gorm.DB) *gorm.DB {
2428
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
2429
+		}).
2430
+		Preload("HisDoctorAdviceInfo", func(tx *gorm.DB) *gorm.DB {
2431
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("drug_id").Preload("Drug", "status=1")
2432
+		}).
2433
+		Preload("HisPrescriptionProject", func(tx *gorm.DB) *gorm.DB {
2434
+			return tx.Where("status = 1 AND user_org_id = ?", org_id).Group("project_id").Preload("HisProject").Preload("GoodInfo", "status=1")
2435
+		}).Preload("TempHisOrder", func(tx *gorm.DB) *gorm.DB {
2436
+		return tx.Where("status = 1 AND user_org_id = ?", org_id)
2437
+	}).
2438
+		Where("id in (?) AND user_org_id = ? AND status = 1", ids, org_id).
2439
+		Find(&prescription).Error
2440
+
2441
+	return
2442
+}
2443
+
2393 2444
 func GetNewAllUnChargeHisPatientListTwo(org_id int64, keywords string, record_date int64) (patients []*NewTempPatients, err error) {
2394 2445
 	db := readDb.Model(&NewTempPatients{}).Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
2395 2446
 	db = db.Preload("HisPatient", func(db *gorm.DB) *gorm.DB {
@@ -2588,3 +2639,19 @@ func GetHisOrderByIDThree(order_id int64) (order models.HisOrder, err error) {
2588 2639
 	err = readDb.Model(&models.HisOrder{}).Where("id = ?", order_id).First(&order).Error
2589 2640
 	return
2590 2641
 }
2642
+
2643
+func GetDrugSumOutCountByDrugId(drug_id int64, user_org_id int64) (models.XtDrugStockCount, error) {
2644
+
2645
+	drug := models.XtDrugStockCount{}
2646
+
2647
+	err := XTReadDB().Where("drug_id = ? and user_org_id = ? and status = 1", drug_id, user_org_id).Find(&drug).Error
2648
+
2649
+	return drug, err
2650
+}
2651
+
2652
+func GetStockGoodList(good_id int64, org_id int64) (models.XtGoodStockCount, error) {
2653
+
2654
+	stockCount := models.XtGoodStockCount{}
2655
+	err = XTReadDB().Where("good_id = ? and user_org_id = ? and status= 1", good_id, org_id).Find(&stockCount).Error
2656
+	return stockCount, err
2657
+}

+ 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

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

+ 67 - 0
service/stock_service.go View File

@@ -7132,6 +7132,12 @@ func FindDrugOutConfigById(orgid int64) (models.DrugOutConfig, error) {
7132 7132
 	return config, err
7133 7133
 }
7134 7134
 
7135
+func FindeDrugSettleConfigById(orgid int64) (models.HisSettleStockConfig, error) {
7136
+	config := models.HisSettleStockConfig{}
7137
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&config).Error
7138
+	return config, err
7139
+}
7140
+
7135 7141
 func UpdatedWarehouseOut(id int64) error {
7136 7142
 
7137 7143
 	err := XTWriteDB().Model(&models.WarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_check": 1}).Error
@@ -8075,3 +8081,64 @@ func GetInvetoryWarehouseInfoList(orgid int64, storehouse_id int64) (info []*mod
8075 8081
 	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 8082
 	return info, err
8077 8083
 }
8084
+
8085
+func GetSettleOpenConfig(user_org_id int64) (*models.HisSettleStockConfig, error) {
8086
+
8087
+	config := models.HisSettleStockConfig{}
8088
+	err := XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
8089
+	if err == gorm.ErrRecordNotFound {
8090
+		return nil, err
8091
+	}
8092
+	if err != nil {
8093
+		return nil, err
8094
+	}
8095
+	return &config, nil
8096
+}
8097
+
8098
+func CreateSettleOpenConfig(config models.HisSettleStockConfig) error {
8099
+
8100
+	err := XTReadDB().Create(&config).Error
8101
+	return err
8102
+}
8103
+
8104
+func UpdateSettleOpenConfig(id int64, config models.HisSettleStockConfig) error {
8105
+
8106
+	err := XTWriteDB().Model(&models.HisSettleStockConfig{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_open": config.IsOpen}).Error
8107
+	return err
8108
+}
8109
+
8110
+func UpdateDrugStockAutomaticReduceRecordOne(orgid int64, is_open int64) (models.DrugStockConfig, error) {
8111
+
8112
+	config := models.DrugStockConfig{}
8113
+	err := XTWriteDB().Model(&config).Where("org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": is_open}).Error
8114
+	return config, err
8115
+}
8116
+
8117
+func UpdatePharyConfig(orgid int64, is_open int64) (models.PharmacyConfig, error) {
8118
+
8119
+	stockConfig := models.PharmacyConfig{}
8120
+
8121
+	err := XTWriteDB().Model(&stockConfig).Where("user_org_id = ? and status = 1", orgid).Update(map[string]interface{}{"is_open": is_open}).Error
8122
+
8123
+	return stockConfig, err
8124
+}
8125
+
8126
+func UpdateSettleOpenConfigOne(id int64, is_open int64) error {
8127
+
8128
+	err := XTWriteDB().Model(&models.HisSettleStockConfig{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"is_open": is_open}).Error
8129
+	return err
8130
+}
8131
+
8132
+func GetSettleOpenConfigByOrgId(user_org_id int64) (models.HisSettleStockConfig, error) {
8133
+
8134
+	config := models.HisSettleStockConfig{}
8135
+	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&config).Error
8136
+	return config, nil
8137
+}
8138
+
8139
+func GetGoodInformationByGoodIdOne(good_id int64) (models.GoodInformationFourty, error) {
8140
+
8141
+	info := models.GoodInformationFourty{}
8142
+	err := XTReadDB().Where("id = ? and status = 1", good_id).Find(&info).Error
8143
+	return info, err
8144
+}

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