瀏覽代碼

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

test_user 2 年之前
父節點
當前提交
7f6f0d32ef
共有 31 個文件被更改,包括 3437 次插入6322 次删除
  1. 6 6
      controllers/base_api_controller.go
  2. 1 1
      controllers/data_api_controller.go
  3. 271 14
      controllers/dialysis_api_controller.go
  4. 1 1
      controllers/dialysis_record_api_controller.go
  5. 158 4
      controllers/doctors_api_controller.go
  6. 2 0
      controllers/gobal_config_api_controller.go
  7. 23 7
      controllers/his_api_controller.go
  8. 4 1
      controllers/manage_api_controller.go
  9. 6 3
      controllers/mobile_api_controllers/check_weight_api_controller.go
  10. 179 144
      controllers/mobile_api_controllers/dialysis_api_controller.go
  11. 20 4
      controllers/mobile_api_controllers/patient_api_controller.go
  12. 6 0
      controllers/patient_api_controller.go
  13. 2 1
      controllers/pharmacy_controller.go
  14. 7 4
      controllers/print_data_api_controller.go
  15. 1 1
      controllers/schedule_api_controller.go
  16. 1 0
      controllers/self_drug_api_congtroller.go
  17. 2 0
      controllers/stock_in_api_controller.go
  18. 3 2
      models/good_models.go
  19. 27 0
      models/patient_models.go
  20. 2 2
      service/auto_create_week_disinfection.go
  21. 106 9
      service/dialysis_solution_service.go
  22. 1943 2
      service/mobile_dialysis_service.go
  23. 5 1
      service/new_stock_service.go
  24. 587 1
      service/new_warehouse_service.go
  25. 1 1
      service/patient_service.go
  26. 44 0
      service/patientmanage_service.go
  27. 8 0
      service/pharmacy_service.go
  28. 1 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  29. 11 1
      service/self_drug_service.go
  30. 9 3
      service/stock_service.go
  31. 0 6109
      service/warhouse_service.go

+ 6 - 6
controllers/base_api_controller.go 查看文件

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

+ 1 - 1
controllers/data_api_controller.go 查看文件

@@ -400,7 +400,7 @@ func configFormData(dataconfig *models.Dataconfig, data []byte) (code int) {
400 400
 	}
401 401
 	dataconfig.Module = module
402 402
 
403
-	if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" || module == "special_treatment" || module == "template_summary" || module == "template_plan" || module == "admitting_diagnosis" || module == "discharge_diagnosis" || module == "diagnosis_admission" || module == "treatment" || module == "illness_discharge" || module == "discharge_advice" || module == "dialysis_remark" || module == "catheter_operation" {
403
+	if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" || module == "special_treatment" || module == "template_summary" || module == "template_plan" || module == "admitting_diagnosis" || module == "discharge_diagnosis" || module == "diagnosis_admission" || module == "treatment" || module == "illness_discharge" || module == "discharge_advice" || module == "dialysis_remark" || module == "catheter_operation" || module == "main_content" || module == "patient_case" || module == "tentative_diagnosis" || module == "diagnostic_basis" || module == "differential_diagnosis" || module == "treatment_plan" {
404 404
 		if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
405 405
 			utils.ErrorLog("title")
406 406
 			code = enums.ErrorCodeParamWrong

+ 271 - 14
controllers/dialysis_api_controller.go 查看文件

@@ -333,6 +333,8 @@ func (c *DialysisApiController) PostPrescription() {
333 333
 	sodium_curve := c.GetString("sodium_curve")
334 334
 	dialysis_fluid_flow := c.GetString("dialysis_fluid_flow")
335 335
 	sodium_bicarbonate_flow := c.GetString("sodium_bicarbonate_flow")
336
+	prescription_water, _ := c.GetFloat("prescription_water")
337
+	dialysis_strainer := c.GetString("dialysis_strainer")
336 338
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
337 339
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
338 340
 
@@ -448,6 +450,8 @@ func (c *DialysisApiController) PostPrescription() {
448 450
 		SodiumCurve:                sodium_curve,
449 451
 		DialysisFluidFlow:          dialysis_fluid_flow,
450 452
 		SodiumBicarbonateFlow:      sodium_bicarbonate_flow,
453
+		PrescriptionWater:          prescription_water,
454
+		DialysisStrainer:           dialysis_strainer,
451 455
 	}
452 456
 
453 457
 	//长沙南雅医院,自动生成抗凝剂的临时处方
@@ -578,7 +582,7 @@ func (c *DialysisApiController) PostPrescription() {
578 582
 			if filedConfig.ID > 0 {
579 583
 				str = dialyzerPerfusionApparatus
580 584
 			} else {
581
-				str = dialysis_dialyszers + "/" + dialysis_irrigation
585
+				str = dialysis_dialyszers + "/" + dialysis_irrigation + "/" + dialysis_strainer
582 586
 			}
583 587
 			service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
584 588
 		}
@@ -594,6 +598,9 @@ func (c *DialysisApiController) PostPrescription() {
594 598
 				prescription.DisplaceLiquiValue = 0
595 599
 			}
596 600
 		}
601
+		if adminUserInfo.CurrentOrgId == 10340 && prescription.AdminUserId == 0 {
602
+			prescription.AdminUserId = adminUserInfo.AdminUser.Id
603
+		}
597 604
 
598 605
 		err := service.AddSigleRecord(&prescription)
599 606
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
@@ -835,6 +842,8 @@ func (c *DialysisApiController) PostSoulution() {
835 842
 	sodium_curve := c.GetString("sodium_curve")
836 843
 	dialysis_fluid_flow := c.GetString("dialysis_fluid_flow")
837 844
 	sodium_bicarbonate_flow := c.GetString("sodium_bicarbonate_flow")
845
+	prescription_water, _ := c.GetFloat("prescription_water")
846
+	dialysis_strainer := c.GetString("dialysis_strainer")
838 847
 	var prescription_doctor int64
839 848
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
840 849
 
@@ -849,7 +858,7 @@ func (c *DialysisApiController) PostSoulution() {
849 858
 		if filedConfig.ID > 0 {
850 859
 			str = dialyzerPerfusionApparatus
851 860
 		} else {
852
-			str = dialysis_dialyszers + "/" + dialysis_irrigation
861
+			str = dialysis_dialyszers + "/" + dialysis_irrigation + "/" + dialysis_strainer
853 862
 		}
854 863
 		service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
855 864
 	}
@@ -970,6 +979,8 @@ func (c *DialysisApiController) PostSoulution() {
970 979
 		TreatmentRemark:            treatment_remark,
971 980
 		DialysisFluidFlow:          dialysis_fluid_flow,
972 981
 		SodiumBicarbonateFlow:      sodium_bicarbonate_flow,
982
+		PrescriptionWater:          prescription_water,
983
+		DialysisStrainer:           dialysis_strainer,
973 984
 	}
974 985
 
975 986
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1148,6 +1159,8 @@ func (c *DialysisApiController) PostSoulution() {
1148 1159
 		TreatmentRemark:            treatment_remark,
1149 1160
 		DialysisFluidFlow:          dialysis_fluid_flow,
1150 1161
 		SodiumBicarbonateFlow:      sodium_bicarbonate_flow,
1162
+		PrescriptionWater:          prescribing_number,
1163
+		DialysisStrainer:           dialysis_strainer,
1151 1164
 	}
1152 1165
 
1153 1166
 	//针对河间咸得
@@ -1169,6 +1182,10 @@ func (c *DialysisApiController) PostSoulution() {
1169 1182
 		}
1170 1183
 	}
1171 1184
 
1185
+	if adminUserInfo.CurrentOrgId == 10340 && prescription.AdminUserId == 0 {
1186
+		prescription.AdminUserId = adminUserInfo.AdminUser.Id
1187
+	}
1188
+
1172 1189
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
1173 1190
 
1174 1191
 	//获取最新1条
@@ -1959,6 +1976,211 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1959 1976
 		}
1960 1977
 
1961 1978
 		err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
1979
+
1980
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 {
1981
+			fmt.Println("进来--------------------------------------")
1982
+			fmt.Println("evaluation.WeightBefore", weight_before)
1983
+			fmt.Println(" evaluation.DryWeight", dry_weight)
1984
+			var dewater_amount float64
1985
+			dewater_amount = 0
1986
+			if dry_weight > 0 {
1987
+				dewater_amount = weight_before - dry_weight - additional_weight
1988
+
1989
+				dewater_amount = dewater_amount * 1000
1990
+
1991
+				if dewater_amount <= 0 {
1992
+					dewater_amount = 0
1993
+				}
1994
+			} else {
1995
+				dewater_amount = 0
1996
+			}
1997
+
1998
+			// 计算透析处方的相关超滤量
1999
+			schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
2000
+			var lastDialysisPrescribe *models.DialysisPrescription
2001
+			var dialysisSolution *models.DialysisSolution
2002
+			var dialysisPrescribe *models.DialysisPrescription
2003
+			var mode_id int64
2004
+			if schedual != nil {
2005
+				dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
2006
+				if dialysisPrescribe == nil {
2007
+					dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
2008
+				}
2009
+				lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
2010
+				// 获取透析模版
2011
+				dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
2012
+				mode_id = schedual.ModeId
2013
+			} else {
2014
+				//lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribe(adminUserInfo.Org.Id, id,schedual.ModeId)
2015
+				// 获取透析模版
2016
+				dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
2017
+				dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.CurrentOrgId, patient)
2018
+
2019
+				if dialysisPrescribe == nil && dialysisSolution != nil {
2020
+					mode_id = dialysisSolution.ModeId
2021
+				}
2022
+
2023
+				if dialysisPrescribe == nil && dialysisSolution == nil {
2024
+					mode_id = 0
2025
+				}
2026
+			}
2027
+
2028
+			// 插入透析处方
2029
+			if dialysisPrescribe == nil && dialysisSolution != nil {
2030
+				var newprescribe models.DialysisPrescription
2031
+				newprescribe.UserOrgId = dialysisSolution.UserOrgId
2032
+				newprescribe.PatientId = dialysisSolution.PatientId
2033
+				newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
2034
+				newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
2035
+				newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
2036
+				newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
2037
+				newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
2038
+				newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
2039
+				newprescribe.ModeId = dialysisSolution.ModeId
2040
+				newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
2041
+				newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
2042
+				newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
2043
+				newprescribe.BloodFilter = dialysisSolution.BloodFilter
2044
+				newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
2045
+				newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
2046
+				newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
2047
+				newprescribe.Glucose = dialysisSolution.Glucose
2048
+				newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
2049
+				newprescribe.Kalium = dialysisSolution.Kalium
2050
+				newprescribe.Sodium = dialysisSolution.Sodium
2051
+				newprescribe.Calcium = dialysisSolution.Calcium
2052
+				newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
2053
+				newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
2054
+				newprescribe.Conductivity = dialysisSolution.Conductivity
2055
+				newprescribe.BodyFluid = dialysisSolution.BodyFluid
2056
+				newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
2057
+				newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
2058
+				newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
2059
+				newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
2060
+				newprescribe.BloodAccess = dialysisSolution.BloodAccess
2061
+				newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
2062
+				newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
2063
+				newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
2064
+				newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
2065
+				newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
2066
+				newprescribe.Dialyzer = dialysisSolution.Dialyzer
2067
+				newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
2068
+				newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
2069
+				newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
2070
+				newprescribe.TargetKtv = dialysisSolution.TargetKtv
2071
+
2072
+				newprescribe.CreatedTime = time.Now().Unix()
2073
+				newprescribe.UpdatedTime = time.Now().Unix()
2074
+				newprescribe.RecordDate = recordDate.Unix()
2075
+				newprescribe.DewaterAmount = dewater_amount
2076
+				newprescribe.TargetUltrafiltration = dewater_amount
2077
+				newprescribe.Status = 1
2078
+
2079
+				err := service.AddSigleRecord(&newprescribe)
2080
+				if err != nil {
2081
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2082
+				}
2083
+			}
2084
+
2085
+			if dialysisPrescribe == nil && dialysisSolution == nil {
2086
+				if lastDialysisPrescribe != nil {
2087
+					var newprescribe models.DialysisPrescription
2088
+					newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
2089
+					newprescribe.PatientId = lastDialysisPrescribe.PatientId
2090
+					newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
2091
+					newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
2092
+					newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
2093
+					newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
2094
+					newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
2095
+					newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
2096
+					newprescribe.ModeId = lastDialysisPrescribe.ModeId
2097
+					newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
2098
+					newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
2099
+					newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
2100
+					newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
2101
+					newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
2102
+					newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
2103
+					newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
2104
+					newprescribe.Glucose = lastDialysisPrescribe.Glucose
2105
+					newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
2106
+					newprescribe.Kalium = lastDialysisPrescribe.Kalium
2107
+					newprescribe.Sodium = lastDialysisPrescribe.Sodium
2108
+					newprescribe.Calcium = lastDialysisPrescribe.Calcium
2109
+					newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
2110
+					newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
2111
+					newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
2112
+					newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
2113
+					newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
2114
+					newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
2115
+					newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
2116
+					newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
2117
+					newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
2118
+					newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
2119
+					newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
2120
+					newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
2121
+					newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
2122
+					newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
2123
+					newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
2124
+					newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
2125
+					newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
2126
+					newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
2127
+					newprescribe.CreatedTime = time.Now().Unix()
2128
+					newprescribe.UpdatedTime = time.Now().Unix()
2129
+					newprescribe.RecordDate = recordDate.Unix()
2130
+					newprescribe.DewaterAmount = dewater_amount
2131
+					newprescribe.TargetUltrafiltration = dewater_amount
2132
+					newprescribe.Status = 1
2133
+					newprescribe.Creater = adminUserInfo.AdminUser.Id
2134
+					newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
2135
+
2136
+					err := service.AddSigleRecord(&newprescribe)
2137
+					key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2138
+					redis := service.RedisClient()
2139
+					defer redis.Close()
2140
+					//清空key 值
2141
+					redis.Set(key, "", time.Second)
2142
+
2143
+					keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
2144
+					redis.Set(keyOne, "", time.Second)
2145
+					keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2146
+					redis.Set(keyThree, "", time.Second)
2147
+					if err != nil {
2148
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2149
+					}
2150
+				} else {
2151
+					var newprescribe models.DialysisPrescription
2152
+					newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
2153
+					newprescribe.PatientId = patient
2154
+					newprescribe.ModeId = mode_id
2155
+					newprescribe.CreatedTime = time.Now().Unix()
2156
+					newprescribe.UpdatedTime = time.Now().Unix()
2157
+					newprescribe.RecordDate = recordDate.Unix()
2158
+					newprescribe.DewaterAmount = dewater_amount
2159
+					newprescribe.TargetUltrafiltration = dewater_amount
2160
+					newprescribe.Status = 1
2161
+					newprescribe.Creater = adminUserInfo.AdminUser.Id
2162
+					newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
2163
+					newprescribe.Modifier = adminUserInfo.AdminUser.Id
2164
+
2165
+					err := service.AddSigleRecord(&newprescribe)
2166
+					key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2167
+					redis := service.RedisClient()
2168
+					defer redis.Close()
2169
+					//清空key 值
2170
+					redis.Set(key, "", time.Second)
2171
+
2172
+					keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
2173
+					redis.Set(keyOne, "", time.Second)
2174
+					keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2175
+					redis.Set(keyThree, "", time.Second)
2176
+					if err != nil {
2177
+						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2178
+					}
2179
+				}
2180
+			}
2181
+
2182
+		}
2183
+
1962 2184
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1963 2185
 		redis := service.RedisClient()
1964 2186
 
@@ -1971,6 +2193,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1971 2193
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1972 2194
 		redis.Set(keyTwo, "", time.Second)
1973 2195
 		defer redis.Close()
2196
+
1974 2197
 		if err == nil {
1975 2198
 			c.ServeSuccessJSON(map[string]interface{}{
1976 2199
 				"assessmentBeforeDislysis": &assessmentBeforeDislysis,
@@ -2164,6 +2387,17 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2164 2387
 				newprescribe.Status = 1
2165 2388
 
2166 2389
 				err := service.AddSigleRecord(&newprescribe)
2390
+
2391
+				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2392
+				redis := service.RedisClient()
2393
+				defer redis.Close()
2394
+				//清空key 值
2395
+				redis.Set(key, "", time.Second)
2396
+
2397
+				keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
2398
+				redis.Set(keyOne, "", time.Second)
2399
+				keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2400
+				redis.Set(keyThree, "", time.Second)
2167 2401
 				if err != nil {
2168 2402
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2169 2403
 				}
@@ -2180,6 +2414,16 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2180 2414
 				newprescribe.Status = 1
2181 2415
 
2182 2416
 				err := service.AddSigleRecord(&newprescribe)
2417
+				key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2418
+				redis := service.RedisClient()
2419
+				defer redis.Close()
2420
+				//清空key 值
2421
+				redis.Set(key, "", time.Second)
2422
+
2423
+				keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
2424
+				redis.Set(keyOne, "", time.Second)
2425
+				keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2426
+				redis.Set(keyThree, "", time.Second)
2183 2427
 				if err != nil {
2184 2428
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
2185 2429
 				}
@@ -2197,6 +2441,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2197 2441
 		defer redis.Close()
2198 2442
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2199 2443
 		redis.Set(keyTwo, "", time.Second)
2444
+
2200 2445
 		if err == nil {
2201 2446
 			c.ServeSuccessJSON(map[string]interface{}{
2202 2447
 				"assessmentBeforeDislysis": &assessmentBeforeDislysis,
@@ -2336,10 +2581,12 @@ func (c *DialysisApiController) GetAllDeviceZone() {
2336 2581
 	adminUserInfo := c.GetAdminUserInfo()
2337 2582
 	err, zone := service.GetAllDeviceZone(adminUserInfo.CurrentOrgId)
2338 2583
 	dics, _, err := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
2584
+	efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.CurrentOrgId)
2339 2585
 	if err == nil {
2340 2586
 		c.ServeSuccessJSON(map[string]interface{}{
2341 2587
 			"zone": zone,
2342 2588
 			"dics": dics,
2589
+			"efs":  efs,
2343 2590
 		})
2344 2591
 	}
2345 2592
 
@@ -4144,7 +4391,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
4144 4391
 			}
4145 4392
 
4146 4393
 			//长沙南雅
4147
-			if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 || adminInfo.CurrentOrgId == 9829 || adminInfo.CurrentOrgId == 10440 {
4394
+			if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 || adminInfo.CurrentOrgId == 9829 || adminInfo.CurrentOrgId == 10440 || adminInfo.CurrentOrgId == 10469 {
4148 4395
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
4149 4396
 
4150 4397
 				record.UltrafiltrationRate = ultrafiltration_rate
@@ -4173,7 +4420,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
4173 4420
 	}
4174 4421
 
4175 4422
 	//长沙南雅
4176
-	if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 {
4423
+	if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 || adminInfo.CurrentOrgId == 10469 {
4177 4424
 
4178 4425
 		if ultrafiltration_rate > 0 {
4179 4426
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
@@ -4880,14 +5127,20 @@ func (this *DialysisApiController) GetDialysisGoodTotalCount() {
4880 5127
 
4881 5128
 	schedule_type, _ := this.GetInt64("schedule_type")
4882 5129
 
4883
-	partion_type, _ := this.GetInt64("partion_type")
5130
+	//partion_type, _ := this.GetInt64("partion_type")
4884 5131
 
4885 5132
 	start_time := this.GetString("selected_date")
5133
+
5134
+	partion_type := this.GetString("partion_type")
5135
+	var ids []string
5136
+
5137
+	ids = strings.Split(partion_type, ",")
5138
+	fmt.Println("ids------------------------", ids)
4886 5139
 	timeLayout := "2006-01-02"
4887 5140
 	loc, _ := time.LoadLocation("Local")
4888 5141
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4889 5142
 
4890
-	list, err := service.GetDialysisGoodTotalCount(orgId, schedule_type, partion_type, startTime.Unix())
5143
+	list, err := service.GetDialysisGoodTotalCount(orgId, schedule_type, ids, startTime.Unix())
4891 5144
 	if err == nil {
4892 5145
 		this.ServeSuccessJSON(map[string]interface{}{
4893 5146
 			"list": list,
@@ -4906,16 +5159,19 @@ func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
4906 5159
 
4907 5160
 	schedule_type, _ := this.GetInt64("schedule_type")
4908 5161
 
4909
-	partion_type, _ := this.GetInt64("partion_type")
5162
+	//partion_type, _ := this.GetInt64("partion_type")
4910 5163
 
5164
+	partion_type := this.GetString("partion_type")
5165
+	var ids []string
5166
+	ids = strings.Split(partion_type, ",")
4911 5167
 	start_time := this.GetString("selected_date")
4912 5168
 	timeLayout := "2006-01-02"
4913 5169
 	loc, _ := time.LoadLocation("Local")
4914 5170
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4915 5171
 
4916
-	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
5172
+	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, ids, startTime.Unix())
4917 5173
 
4918
-	tablelist, _ := service.GetDialysisAdviceSchedulistTwo(orgId, schedule_type, partion_type, startTime.Unix())
5174
+	tablelist, _ := service.GetDialysisAdviceSchedulistTwo(orgId, schedule_type, ids, startTime.Unix())
4919 5175
 
4920 5176
 	//获取长期医嘱
4921 5177
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
@@ -4986,14 +5242,15 @@ func (this *DialysisApiController) GetHisDialysisGoodCount() {
4986 5242
 
4987 5243
 	schedule_type, _ := this.GetInt64("schedule_type")
4988 5244
 
4989
-	partion_type, _ := this.GetInt64("partion_type")
4990
-
5245
+	//partion_type, _ := this.GetInt64("partion_type")
5246
+	partion_type := this.GetString("partion_type")
5247
+	var ids []string
5248
+	ids = strings.Split(partion_type, ",")
4991 5249
 	start_time := this.GetString("selected_date")
4992 5250
 	timeLayout := "2006-01-02"
4993 5251
 	loc, _ := time.LoadLocation("Local")
4994 5252
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4995
-
4996
-	list, _ := service.GetHisDialysisGoodCount(orgId, schedule_type, partion_type, startTime.Unix())
5253
+	list, _ := service.GetHisDialysisGoodCountTwo(orgId, schedule_type, ids, startTime.Unix())
4997 5254
 
4998 5255
 	this.ServeSuccessJSON(map[string]interface{}{
4999 5256
 		"list": list,
@@ -5783,7 +6040,7 @@ func (this *DialysisApiController) GetDialysisAdviceToday() {
5783 6040
 	loc, _ := time.LoadLocation("Local")
5784 6041
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
5785 6042
 
5786
-	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
6043
+	list, err := service.GetDialysisAdviceSchedulistTen(orgId, schedule_type, partion_type, startTime.Unix())
5787 6044
 
5788 6045
 	drug, _ := service.GetAllBaseDrugListTwenty(orgId)
5789 6046
 	_, config := service.FindXTHisRecordByOrgId(orgId)

+ 1 - 1
controllers/dialysis_record_api_controller.go 查看文件

@@ -1124,7 +1124,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1124 1124
 				}
1125 1125
 
1126 1126
 				//针对肇庆三鹤血液透析中心
1127
-				if adminUserInfo.CurrentOrgId == 10215 || template.TemplateId == 43 || adminUserInfo.CurrentOrgId == 10441 || adminUserInfo.CurrentOrgId == 10445 {
1127
+				if adminUserInfo.CurrentOrgId == 10215 || template.TemplateId == 43 || adminUserInfo.CurrentOrgId == 10441 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10469 {
1128 1128
 
1129 1129
 					if evaluation.ID > 0 {
1130 1130
 						ultrafiltration_rate = math.Ceil(prescription.TargetUltrafiltration / float64(totalMin) * 60)

+ 158 - 4
controllers/doctors_api_controller.go 查看文件

@@ -60,6 +60,11 @@ func DoctorApiRegistRouters() {
60 60
 	beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
61 61
 	beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
62 62
 	beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
63
+	beego.Router("/api/patient/createfirstdisease", &DoctorsApiController{}, "Post:CreateFirstDisease")
64
+	beego.Router("/api/patient/getfirstdiseaselist", &DoctorsApiController{}, "Get:GetFirstDiseaseList")
65
+	beego.Router("/api/patient/getfirstdetailbyid", &DoctorsApiController{}, "Get:GetFirstDetailById")
66
+	beego.Router("/api/patient/updatefirstdisease", &DoctorsApiController{}, "Post:UpdateFirstDisease")
67
+	beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
63 68
 }
64 69
 
65 70
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -71,6 +76,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
71 76
 	partition_type, _ := c.GetInt64("partition_type")
72 77
 	patient_id, _ := c.GetInt64("patient_id")
73 78
 	excution_way, _ := c.GetInt64("excution_way")
79
+	execution_frequency := c.GetString("execution_frequency")
74 80
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
75 81
 		adviceType = 0
76 82
 	}
@@ -93,7 +99,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
93 99
 	project_config, _ := service.GetHisProjectConfig(orgID)
94 100
 
95 101
 	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)
102
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
97 103
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
98 104
 		if err != nil {
99 105
 			c.ErrorLog("获取排班信息失败:%v", err)
@@ -114,7 +120,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
114 120
 		}
115 121
 	}
116 122
 	if config.IsOpen == 1 {
117
-		hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0)
123
+		hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, 0, execution_frequency)
118 124
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
119 125
 		project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
120 126
 		for _, item := range project {
@@ -1375,6 +1381,7 @@ func (c *DoctorsApiController) GetScheduleAdvicesList() {
1375 1381
 	patient_id, _ := c.GetInt64("patient_id")
1376 1382
 	excution_way, _ := c.GetInt64("excution_way")
1377 1383
 	cost_type, _ := c.GetInt64("cost_type")
1384
+	execution_frequency := c.GetString("execution_frequency")
1378 1385
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
1379 1386
 		adviceType = 0
1380 1387
 	}
@@ -1397,7 +1404,7 @@ func (c *DoctorsApiController) GetScheduleAdvicesList() {
1397 1404
 	project_config, _ := service.GetHisProjectConfig(orgID)
1398 1405
 
1399 1406
 	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)
1407
+		scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
1401 1408
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1402 1409
 		if err != nil {
1403 1410
 			c.ErrorLog("获取排班信息失败:%v", err)
@@ -1418,7 +1425,7 @@ func (c *DoctorsApiController) GetScheduleAdvicesList() {
1418 1425
 		}
1419 1426
 	}
1420 1427
 	if config.IsOpen == 1 {
1421
-		hisAdvices, err := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type)
1428
+		hisAdvices, err := service.GetHisDoctorAdvicesTwentyOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
1422 1429
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1423 1430
 		project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
1424 1431
 		for _, item := range project {
@@ -1455,3 +1462,150 @@ func (c *DoctorsApiController) GetScheduleAdvicesList() {
1455 1462
 	}
1456 1463
 
1457 1464
 }
1465
+
1466
+func (c *DoctorsApiController) CreateFirstDisease() {
1467
+
1468
+	//timeLayout := "2006-01-02"
1469
+	//loc, _ := time.LoadLocation("Local")
1470
+	dataBody := make(map[string]interface{}, 0)
1471
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1472
+	fmt.Print("err", err)
1473
+
1474
+	doctor := int64(dataBody["doctor"].(float64))
1475
+	record_date := dataBody["record_date"].(string)
1476
+
1477
+	recordDates, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_date)
1478
+	recordtime := recordDates.Unix()
1479
+
1480
+	patient_id := int64(dataBody["patient_id"].(float64))
1481
+	title := dataBody["title"].(string)
1482
+	main_content := dataBody["main_content"].(string)
1483
+	patient_case := dataBody["patient_case"].(string)
1484
+	tentative_diagnosis := dataBody["tentative_diagnosis"].(string)
1485
+	diagnostic_basis := dataBody["diagnostic_basis"].(string)
1486
+	differential_diagnosis := dataBody["differential_diagnosis"].(string)
1487
+	treatment_plan := dataBody["treatment_plan"].(string)
1488
+
1489
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1490
+	firstdisease := models.XtPatientFirstDisease{
1491
+		Title:                 title,
1492
+		RecordDate:            recordtime,
1493
+		Doctor:                doctor,
1494
+		MainContent:           main_content,
1495
+		PatientCase:           patient_case,
1496
+		TentativeDiagnosis:    tentative_diagnosis,
1497
+		DiagnosticBasis:       diagnostic_basis,
1498
+		DifferentialDiagnosis: differential_diagnosis,
1499
+		TreatmentPlan:         treatment_plan,
1500
+		UserOrgId:             orgId,
1501
+		PatientId:             patient_id,
1502
+		Ctime:                 time.Now().Unix(),
1503
+		Mtime:                 0,
1504
+		Status:                1,
1505
+	}
1506
+
1507
+	error := service.CreatePatientFirstDisease(firstdisease)
1508
+
1509
+	if error == nil {
1510
+		c.ServeSuccessJSON(map[string]interface{}{
1511
+			"firstDisease": firstdisease,
1512
+		})
1513
+	}
1514
+}
1515
+
1516
+func (c *DoctorsApiController) GetFirstDiseaseList() {
1517
+
1518
+	timeLayout := "2006-01-02"
1519
+	loc, _ := time.LoadLocation("Local")
1520
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1521
+	patient_id, _ := c.GetInt64("patient_id")
1522
+	start_time := c.GetString("start_time")
1523
+
1524
+	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1525
+	startime := dischargeTimes.Unix()
1526
+
1527
+	end_time := c.GetString("end_time")
1528
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1529
+	endtime := endTimes.Unix()
1530
+	list, err := service.GetPatientDiseaseList(orgId, patient_id, startime, endtime)
1531
+	if err == nil {
1532
+		c.ServeSuccessJSON(map[string]interface{}{
1533
+			"list": list,
1534
+		})
1535
+		return
1536
+	}
1537
+}
1538
+
1539
+func (c *DoctorsApiController) GetFirstDetailById() {
1540
+
1541
+	id, _ := c.GetInt64("id")
1542
+	list, err := service.GetFirstDetailById(id)
1543
+	if err == nil {
1544
+		c.ServeSuccessJSON(map[string]interface{}{
1545
+			"detail": list,
1546
+		})
1547
+		return
1548
+	}
1549
+}
1550
+
1551
+func (c *DoctorsApiController) UpdateFirstDisease() {
1552
+
1553
+	//timeLayout := "2006-01-02"
1554
+	//loc, _ := time.LoadLocation("Local")
1555
+	dataBody := make(map[string]interface{}, 0)
1556
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1557
+	fmt.Print("err", err)
1558
+	id := int64(dataBody["id"].(float64))
1559
+	doctor := int64(dataBody["doctor"].(float64))
1560
+	record_date := dataBody["record_date"].(string)
1561
+	recordDates, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_date)
1562
+	recordtime := recordDates.Unix()
1563
+	patient_id := int64(dataBody["patient_id"].(float64))
1564
+	title := dataBody["title"].(string)
1565
+	main_content := dataBody["main_content"].(string)
1566
+	patient_case := dataBody["patient_case"].(string)
1567
+	tentative_diagnosis := dataBody["tentative_diagnosis"].(string)
1568
+	diagnostic_basis := dataBody["diagnostic_basis"].(string)
1569
+	differential_diagnosis := dataBody["differential_diagnosis"].(string)
1570
+	treatment_plan := dataBody["treatment_plan"].(string)
1571
+
1572
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1573
+	firstdisease := models.XtPatientFirstDisease{
1574
+		Title:                 title,
1575
+		RecordDate:            recordtime,
1576
+		Doctor:                doctor,
1577
+		MainContent:           main_content,
1578
+		PatientCase:           patient_case,
1579
+		TentativeDiagnosis:    tentative_diagnosis,
1580
+		DiagnosticBasis:       diagnostic_basis,
1581
+		DifferentialDiagnosis: differential_diagnosis,
1582
+		TreatmentPlan:         treatment_plan,
1583
+		UserOrgId:             orgId,
1584
+		PatientId:             patient_id,
1585
+		Ctime:                 time.Now().Unix(),
1586
+		Mtime:                 0,
1587
+		Status:                1,
1588
+		ID:                    id,
1589
+	}
1590
+
1591
+	error := service.UpdatePatientFirstDisease(firstdisease, id)
1592
+
1593
+	if error == nil {
1594
+		c.ServeSuccessJSON(map[string]interface{}{
1595
+			"firstDisease": firstdisease,
1596
+		})
1597
+	}
1598
+
1599
+}
1600
+
1601
+func (c *DoctorsApiController) DeleteFirstDisease() {
1602
+
1603
+	schIDStr := c.GetString("ids")
1604
+	idStrs := strings.Split(schIDStr, ",")
1605
+	err := service.DeleteFirstDisease(idStrs)
1606
+	fmt.Println(err)
1607
+	returnData := make(map[string]interface{}, 0)
1608
+	returnData["msg"] = "ok"
1609
+	c.ServeSuccessJSON(returnData)
1610
+	return
1611
+}

+ 2 - 0
controllers/gobal_config_api_controller.go 查看文件

@@ -2439,6 +2439,7 @@ func (c *GobalConfigApiController) GetDrugFlow() {
2439 2439
 	dealerList, _ := service.GetAllDealerList(orgId)
2440 2440
 	medical, _ := service.GetBaseDrugMedical(drug_id)
2441 2441
 	houseList, _ := service.GetAllStoreHouseList(orgId)
2442
+	patientList, _ := service.GetAllPatientListSix(orgId)
2442 2443
 	c.ServeSuccessJSON(map[string]interface{}{
2443 2444
 		"list":             list,
2444 2445
 		"total":            total,
@@ -2446,6 +2447,7 @@ func (c *GobalConfigApiController) GetDrugFlow() {
2446 2447
 		"dealerList":       dealerList,
2447 2448
 		"drug":             medical,
2448 2449
 		"houseList":        houseList,
2450
+		"patientList":      patientList,
2449 2451
 	})
2450 2452
 }
2451 2453
 

+ 23 - 7
controllers/his_api_controller.go 查看文件

@@ -1709,7 +1709,8 @@ func (c *HisApiController) CreateHisPrescription() {
1709 1709
 
1710 1710
 										//查找该耗材的出库记录
1711 1711
 										goodWarehouseInfo, _ := service.GetAutoRecordByGoodIdSevenEight(project_id, patient_id, recordDateTime)
1712
-										fmt.Println("goodWarehouseInfo---------------------------------------------", goodWarehouseInfo)
1712
+
1713
+										//没有出库记录
1713 1714
 										if len(goodWarehouseInfo) == 0 {
1714 1715
 											//查询耗材库存
1715 1716
 											list, _ := service.GetGoodWarehouseInfoSeven(project_id)
@@ -1753,10 +1754,13 @@ func (c *HisApiController) CreateHisPrescription() {
1753 1754
 												}
1754 1755
 
1755 1756
 											}
1757
+
1756 1758
 											//删除记录
1757 1759
 											service.DeleteAutoWarehouse(patient_id, recordDateTime)
1758 1760
 
1759 1761
 										}
1762
+
1763
+										//有出库记录
1760 1764
 										if len(goodWarehouseInfo) > 0 {
1761 1765
 											//查询该患者耗材的历史数据
1762 1766
 											ordProject, _ := service.GetHisProjectPrescriptionByPatientIdOne(id)
@@ -1805,7 +1809,6 @@ func (c *HisApiController) CreateHisPrescription() {
1805 1809
 													service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, item.OrgId)
1806 1810
 												}
1807 1811
 
1808
-												//删除记录
1809 1812
 												service.DeleteAutoWarehouse(patient_id, recordDateTime)
1810 1813
 
1811 1814
 											}
@@ -2869,16 +2872,16 @@ func (c *HisApiController) DeletePrescription() {
2869 2872
 						count, _ := strconv.ParseInt(item.Count, 10, 64)
2870 2873
 						total_count += count
2871 2874
 
2872
-						goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId)
2873
-						var flush_count int64
2874
-						for _, it := range goodList {
2875
-							flush_count += it.StockCount
2876
-						}
2877 2875
 						if info.ID > 0 {
2878 2876
 							if info.Count >= total_count {
2879 2877
 
2880 2878
 								//回退库存
2881 2879
 								service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, total_count, info.PatientId, info.SysRecordTime, item.ProjectId)
2880
+								goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId)
2881
+								var flush_count int64
2882
+								for _, it := range goodList {
2883
+									flush_count += it.StockCount
2884
+								}
2882 2885
 								cancelStockInfo := models.CancelStockInfo{
2883 2886
 									GoodId:          item.ProjectId,
2884 2887
 									CancelStockId:   cancel.ID,
@@ -2953,6 +2956,11 @@ func (c *HisApiController) DeletePrescription() {
2953 2956
 							if info.Count < total_count {
2954 2957
 								//回退库存
2955 2958
 								service.UpDateWarehouseInfoByStockDelete(info.WarehouseInfotId, info.Count, info.PatientId, info.SysRecordTime, item.ProjectId)
2959
+								goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId)
2960
+								var flush_count int64
2961
+								for _, it := range goodList {
2962
+									flush_count += it.StockCount
2963
+								}
2956 2964
 								cancelStockInfo := models.CancelStockInfo{
2957 2965
 									GoodId:          item.ProjectId,
2958 2966
 									CancelStockId:   cancel.ID,
@@ -3024,6 +3032,12 @@ func (c *HisApiController) DeletePrescription() {
3024 3032
 								service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId, info.Count)
3025 3033
 							}
3026 3034
 
3035
+							goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.ProjectId)
3036
+							var flush_count int64
3037
+							for _, it := range goodList {
3038
+								flush_count += it.StockCount
3039
+							}
3040
+
3027 3041
 							//查询已出库数量
3028 3042
 							dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(c.GetAdminUserInfo().CurrentOrgId, info.PatientId, info.SysRecordTime, item.ProjectId)
3029 3043
 
@@ -3694,6 +3708,8 @@ func (c *HisApiController) DeleteProject() {
3694 3708
 					//查询已出库数量
3695 3709
 					dialysisInfo, _ := service.GetGoodDialysisOutInfoSix(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId)
3696 3710
 
3711
+					fmt.Println("aiwohonguo --------------------", prescribingNumber)
3712
+					fmt.Println("aiwohonguo --------------------", dialysisInfo.Count)
3697 3713
 					if prescribingNumber < dialysisInfo.Count {
3698 3714
 						//改变数量
3699 3715
 						service.UpdateAutoGood(adminInfo.CurrentOrgId, info.PatientId, info.SysRecordTime, project.ProjectId, id, prescribingNumber)

+ 4 - 1
controllers/manage_api_controller.go 查看文件

@@ -1933,6 +1933,7 @@ func (this *MachineApiController) GetQuery() {
1933 1933
 	cultures, err := service.GetCultureData(bedid, start, end, OrgID)
1934 1934
 	fmt.Print(err)
1935 1935
 	dialysate, err := service.GetDialysateData(bedid, start, end, OrgID)
1936
+
1936 1937
 	ions, err := service.GetDeviceIonData(bedid, start, end, OrgID)
1937 1938
 
1938 1939
 	oxygenates, err := service.GetOxygenates(bedid, start, end, OrgID)
@@ -3542,12 +3543,14 @@ func (this *MachineApiController) GetAllDoctorList() {
3542 3543
 	orgId := adminUserInfo.CurrentOrgId
3543 3544
 	appId := this.GetAdminUserInfo().CurrentAppId
3544 3545
 	list, err := service.GetAllDoctorTwo(orgId, appId)
3546
+	operators, err := service.GetAdminUserEsOne(orgId)
3545 3547
 	if err != nil {
3546 3548
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
3547 3549
 		return
3548 3550
 	}
3549 3551
 	this.ServeSuccessJSON(map[string]interface{}{
3550
-		"list": list,
3552
+		"list":      list,
3553
+		"operators": operators,
3551 3554
 	})
3552 3555
 }
3553 3556
 

+ 6 - 3
controllers/mobile_api_controllers/check_weight_api_controller.go 查看文件

@@ -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 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10138 || adminUserInfo.Org.Id == 10278 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10440 {
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 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10138 || adminUserInfo.Org.Id == 10278 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 {
273 273
 		if adminUserInfo.Org.Id != 10447 {
274 274
 			dewater_amount = dewater_amount * 1000
275 275
 		}
@@ -681,12 +681,15 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
681 681
 					evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
682 682
 				}
683 683
 
684
-				if adminUserInfo.Org.Id == 9829 {
684
+				if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 {
685 685
 					evaluation.PulseFrequency = 80
686 686
 				}
687 687
 				if adminUserInfo.Org.Id == 10440 {
688 688
 					evaluation.Temperature = 36.5
689 689
 				}
690
+				if adminUserInfo.Org.Id == 10469 {
691
+					evaluation.Temperature = 36.5
692
+				}
690 693
 			}
691 694
 		} else {
692 695
 			evaluation.UpdatedTime = time.Now().Unix()
@@ -763,7 +766,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
763 766
 
764 767
 		//蓬安济民
765 768
 
766
-		if adminUserInfo.Org.Id == 9829 {
769
+		if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 {
767 770
 			afterevaluation.PulseFrequency = 80
768 771
 		}
769 772
 

+ 179 - 144
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

@@ -1464,6 +1464,8 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1464 1464
 	treatment_remark := c.GetString("treatment_remark")
1465 1465
 	dialysis_fluid_flow := c.GetString("dialysis_fluid_flow")
1466 1466
 	sodium_bicarbonate_flow := c.GetString("sodium_bicarbonate_flow")
1467
+	prescription_water, _ := c.GetFloat("prescription_water")
1468
+	dialysis_strainer := c.GetString("dialysis_strainer")
1467 1469
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1468 1470
 
1469 1471
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
@@ -1488,7 +1490,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1488 1490
 		if filedConfig.ID > 0 {
1489 1491
 			str = dialyzerPerfusionApparatus
1490 1492
 		} else {
1491
-			str = dialysis_dialyszers + "/" + dialysis_irrigation
1493
+			str = dialysis_dialyszers + "/" + dialysis_irrigation + "/" + dialysis_strainer
1492 1494
 		}
1493 1495
 		service.ModifyScheduleMode(mode_id, id, recordDate.Unix(), adminUserInfo.Org.Id, str)
1494 1496
 	}
@@ -1596,6 +1598,8 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1596 1598
 		PrescriptionSodium:         prescription_sodium,
1597 1599
 		DialysisFluidFlow:          dialysis_fluid_flow,
1598 1600
 		SodiumBicarbonateFlow:      sodium_bicarbonate_flow,
1601
+		PrescriptionWater:          prescription_water,
1602
+		DialysisStrainer:           dialysis_strainer,
1599 1603
 	}
1600 1604
 
1601 1605
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1681,7 +1685,9 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1681 1685
 				prescription.DisplaceLiquiValue = 0
1682 1686
 			}
1683 1687
 		}
1684
-
1688
+		if adminUserInfo.Org.Id == 10340 && prescription.AdminUserId == 0 {
1689
+			prescription.AdminUserId = adminUserInfo.AdminUser.Id
1690
+		}
1685 1691
 		err := service.AddSigleRecord(&prescription)
1686 1692
 
1687 1693
 		//长沙南雅医院,自动生成抗凝剂的临时处方
@@ -2097,7 +2103,7 @@ func (c *DialysisAPIController) Finish() {
2097 2103
 
2098 2104
 	}
2099 2105
 
2100
-	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 == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 {
2106
+	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 == 10445 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 {
2101 2107
 		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
2102 2108
 		if evaluation.SystolicBloodPressure == 0 {
2103 2109
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
@@ -2753,8 +2759,9 @@ func (this *DialysisAPIController) StartDialysis() {
2753 2759
 
2754 2760
 			//针对肇庆三鹤血液透析中心
2755 2761
 
2756
-			if template.TemplateId == 43 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10440 {
2762
+			if template.TemplateId == 43 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 {
2757 2763
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2764
+
2758 2765
 			}
2759 2766
 
2760 2767
 			if template.TemplateId == 20 || template.TemplateId == 22 { //adminUserInfo.Org.Id == 9538
@@ -2836,7 +2843,7 @@ func (this *DialysisAPIController) StartDialysis() {
2836 2843
 			record.BreathingRate = befor.BreathingRate
2837 2844
 		}
2838 2845
 
2839
-		if adminUserInfo.Org.Id == 9829 {
2846
+		if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 {
2840 2847
 			record.PulseFrequency = 80
2841 2848
 			record.Temperature = 36.5
2842 2849
 		}
@@ -3013,6 +3020,8 @@ func (c *DialysisAPIController) PostSolution() {
3013 3020
 	dialysis_remark := c.GetString("dialysis_remark")
3014 3021
 	dialysis_fluid_flow := c.GetString("dialysis_fluid_flow")
3015 3022
 	sodium_bicarbonate_flow := c.GetString("sodium_bicarbonate_flow")
3023
+	prescription_water, _ := c.GetFloat("prescription_water")
3024
+	dialysis_strainer := c.GetString("dialysis_strainer")
3016 3025
 	if mode_id > 0 {
3017 3026
 
3018 3027
 		var str string
@@ -3021,7 +3030,7 @@ func (c *DialysisAPIController) PostSolution() {
3021 3030
 		if filedConfig.ID > 0 {
3022 3031
 			str = dialyzerPerfusionApparatus
3023 3032
 		} else {
3024
-			str = dialysis_dialyszers + "/" + dialysis_irrigation
3033
+			str = dialysis_dialyszers + "/" + dialysis_irrigation + "/" + dialysis_strainer
3025 3034
 		}
3026 3035
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id, str)
3027 3036
 	}
@@ -3143,6 +3152,8 @@ func (c *DialysisAPIController) PostSolution() {
3143 3152
 		TreatmentRemark:            treatment_remark,
3144 3153
 		DialysisFluidFlow:          dialysis_fluid_flow,
3145 3154
 		SodiumBicarbonateFlow:      sodium_bicarbonate_flow,
3155
+		PrescriptionWater:          prescription_water,
3156
+		DialysisStrainer:           dialysis_strainer,
3146 3157
 	}
3147 3158
 
3148 3159
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -3156,7 +3167,9 @@ func (c *DialysisAPIController) PostSolution() {
3156 3167
 
3157 3168
 	if dialysisPrescription.ID == 0 { //新增
3158 3169
 		prescription.Creater = adminUserInfo.AdminUser.Id
3159
-
3170
+		if adminUserInfo.Org.Id == 10340 && prescription.AdminUserId == 0 {
3171
+			prescription.AdminUserId = adminUserInfo.AdminUser.Id
3172
+		}
3160 3173
 	} else { //修改
3161 3174
 		if dialysisPrescription.Creater == 0 {
3162 3175
 			prescription.Creater = adminUserInfo.AdminUser.Id
@@ -3164,6 +3177,10 @@ func (c *DialysisAPIController) PostSolution() {
3164 3177
 			prescription.Creater = dialysisPrescription.Creater
3165 3178
 		}
3166 3179
 
3180
+		if adminUserInfo.Org.Id == 10340 && prescription.AdminUserId == 0 {
3181
+			prescription.AdminUserId = adminUserInfo.AdminUser.Id
3182
+		}
3183
+
3167 3184
 		//if/**/
3168 3185
 		//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
3169 3186
 
@@ -3249,6 +3266,8 @@ func (c *DialysisAPIController) PostSolution() {
3249 3266
 		TreatmentRemark:            treatment_remark,
3250 3267
 		SodiumBicarbonateFlow:      sodium_bicarbonate_flow,
3251 3268
 		DialysisFluidFlow:          dialysis_fluid_flow,
3269
+		PrescriptionWater:          prescription_water,
3270
+		DialysisStrainer:           dialysis_strainer,
3252 3271
 	}
3253 3272
 
3254 3273
 	//针对河间咸的
@@ -3593,8 +3612,10 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3593 3612
 				record.UltrafiltrationRate = ultrafiltration_rate
3594 3613
 			}
3595 3614
 
3596
-			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 {
3615
+			fmt.Println("adminiNof2323323232", adminInfo.Org.Id)
3616
+			if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10340 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 9829 || adminInfo.Org.Id == 10440 || adminInfo.Org.Id == 10469 {
3597 3617
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
3618
+				fmt.Println("ooooooooooo", ultrafiltration_rate)
3598 3619
 				record.UltrafiltrationRate = ultrafiltration_rate
3599 3620
 			}
3600 3621
 			//if template.TemplateId == 47 {
@@ -3623,11 +3644,11 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
3623 3644
 	}
3624 3645
 
3625 3646
 	//长沙南雅
3626
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 {
3627
-
3647
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 {
3648
+		fmt.Println("ultrafiltration_rate-------", ultrafiltration_rate)
3628 3649
 		if ultrafiltration_rate > 0 {
3629 3650
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3630
-
3651
+			fmt.Println("ultrafiltration_volume=======", ultrafiltration_volume)
3631 3652
 			record.UltrafiltrationVolume = ultrafiltration_volume
3632 3653
 		}
3633 3654
 
@@ -5664,9 +5685,6 @@ func (c *DialysisAPIController) EditConsumables() {
5664 5685
 
5665 5686
 				}
5666 5687
 
5667
-				fmt.Println("退库长度", len(cancelbefor))
5668
-				fmt.Println("出库长度", len(outbefor))
5669
-
5670 5688
 				//退库
5671 5689
 				for _, item := range cancelbefor {
5672 5690
 					warehouseOut, _ := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
@@ -5681,8 +5699,33 @@ func (c *DialysisAPIController) EditConsumables() {
5681 5699
 
5682 5700
 					delete_count = warehouseOutInfos.Count - item.Count
5683 5701
 
5702
+					//增加库存数量
5703
+					service.ModifyGoodAddInformation(item.GoodId, delete_count, adminInfo.Org.Id)
5704
+
5705
+					//增加出库库存数量
5706
+					service.ModifyReduceGoodSumCount(houseConfig.StorehouseOutInfo, delete_count, adminInfo.Org.Id, item.GoodId)
5707
+
5708
+					// 删除出库完成后,要增加对应批次的库存数量
5709
+
5710
+					service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count, patient_id, record_time, item.GoodId)
5711
+
5684 5712
 					houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5685 5713
 
5714
+					//更新剩余库存
5715
+					goodListOne, _ := service.GetSumGoodList(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId)
5716
+					var flush_count int64
5717
+					for _, it := range goodListOne {
5718
+						flush_count += it.StockCount
5719
+					}
5720
+					service.UpdateSumGood(adminInfo.Org.Id, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
5721
+
5722
+					//查询剩余库存
5723
+					goodList, _ := service.GetAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo)
5724
+					var sum_count int64
5725
+					for _, item := range goodList {
5726
+						sum_count += item.StockCount
5727
+					}
5728
+
5686 5729
 					// 在出库记录表里记录退库详情
5687 5730
 					warehouseOutInfo := &models.WarehouseOutInfo{
5688 5731
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -5699,6 +5742,7 @@ func (c *DialysisAPIController) EditConsumables() {
5699 5742
 						ConsumableType:          2,
5700 5743
 						StorehouseId:            houseConfig.StorehouseOutInfo,
5701 5744
 						IsCheck:                 1,
5745
+						OverCount:               sum_count,
5702 5746
 					}
5703 5747
 					warehouseOutInfo.Count = item.Count
5704 5748
 
@@ -5782,6 +5826,15 @@ func (c *DialysisAPIController) EditConsumables() {
5782 5826
 
5783 5827
 					} else if errcod == nil {
5784 5828
 						service.UpdatedWarehouseOutInfo(warehouseOutInfo, item.GoodId, patient_id, record_time, 0)
5829
+
5830
+						fmt.Println("进来-------------------------------------------------")
5831
+
5832
+						//查询剩余库存
5833
+						goodList, _ := service.GetAllGoodSumCount(item.GoodId, adminInfo.Org.Id, houseConfig.StorehouseOutInfo)
5834
+						var sum_count int64
5835
+						for _, item := range goodList {
5836
+							sum_count += item.StockCount
5837
+						}
5785 5838
 						//插入详情明细表
5786 5839
 						stockFlow := models.VmStockFlow{
5787 5840
 							WarehousingId:           warehouseOutInfos.WarehouseInfotId,
@@ -5809,6 +5862,7 @@ func (c *DialysisAPIController) EditConsumables() {
5809 5862
 							PatientId:               patient_id,
5810 5863
 							ReturnCount:             delete_count,
5811 5864
 							StorehouseId:            houseConfig.StorehouseOutInfo,
5865
+							OverCount:               sum_count,
5812 5866
 						}
5813 5867
 						exsit, errflows := service.GetStockFlowIsExsit(warehouseOutInfos.WarehouseInfotId, patient_id, record_time, item.GoodId)
5814 5868
 
@@ -5843,8 +5897,10 @@ func (c *DialysisAPIController) EditConsumables() {
5843 5897
 								PatientId:               patient_id,
5844 5898
 								ReturnCount:             delete_count,
5845 5899
 								StorehouseId:            houseConfig.StorehouseOutInfo,
5900
+								OverCount:               exsit.OverCount + delete_count,
5846 5901
 							}
5847
-							service.UpdatedStockFlowOne(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
5902
+							fmt.Println("stockFlow--------------------", stockFlow.OverCount)
5903
+							service.UpdatedStockFlowFive(stockFlow, warehouseOut.ID, patient_id, record_time, item.GoodId)
5848 5904
 						}
5849 5905
 
5850 5906
 					}
@@ -5876,16 +5932,8 @@ func (c *DialysisAPIController) EditConsumables() {
5876 5932
 
5877 5933
 					}
5878 5934
 
5879
-					service.ModifyGoodAddInformation(item.GoodId, delete_count, adminInfo.Org.Id)
5880
-
5881
-					//增加出库库存数量
5882
-					service.ModifyReduceGoodSumCount(houseConfig.StorehouseOutInfo, delete_count, adminInfo.Org.Id, item.GoodId)
5883
-
5884
-					errOne := service.UpDateWarehouStockFlowByStockDelete(warehouseOutInfos.WarehouseInfotId, record_time, item.GoodId, delete_count, patient_id)
5885
-					fmt.Println("errOne", errOne)
5886
-					// 删除出库完成后,要增加对应批次的库存数量
5887
-
5888
-					service.UpDateWarehouseInfoByStockDelete(warehouseOutInfos.WarehouseInfotId, delete_count, patient_id, record_time, item.GoodId)
5935
+					//errOne := service.UpDateWarehouStockFlowByStockDelete(warehouseOutInfos.WarehouseInfotId, record_time, item.GoodId, delete_count, patient_id)
5936
+					//fmt.Println("errOne", errOne)
5889 5937
 
5890 5938
 					//查询默认仓库
5891 5939
 					storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
@@ -5896,31 +5944,42 @@ func (c *DialysisAPIController) EditConsumables() {
5896 5944
 					}
5897 5945
 					//基础库插入数据
5898 5946
 					service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
5899
-					//更新剩余库存
5900
-					goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
5901
-					var flush_count int64
5902
-					for _, it := range goodList {
5903
-						flush_count += it.StockCount
5904
-					}
5905
-					service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
5947
+
5906 5948
 				}
5907 5949
 
5908
-				//出库
5909
-				for _, item := range outbefor {
5910
-					fmt.Println("出库ID", item.GoodId)
5911
-					var last_total int64
5912
-					//1.查看该患者该耗材型号最后一次出库数量
5913
-					goodInfoOne, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
5914
-					//计算当前出库和最后一次出库数据相差数据
5915
-					last_total = item.Count - goodInfoOne.Count
5950
+				fmt.Println("lnet---------------------------", len(outbefor))
5951
+				if len(outbefor) > 0 {
5952
+					//出库
5953
+					for _, item := range outbefor {
5954
+						fmt.Println("出库ID", item.GoodId)
5955
+						var last_total int64
5956
+						//1.查看该患者该耗材型号最后一次出库数量
5957
+						goodInfoOne, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
5958
+						//计算当前出库和最后一次出库数据相差数据
5959
+						last_total = item.Count - goodInfoOne.Count
5960
+
5961
+						//查询该批次剩余库存
5962
+						lastInfo, _ := service.GetLastStockOut(goodInfoOne.WarehouseInfotId)
5963
+
5964
+						if lastInfo.StockCount == 0 {
5965
+							//查询该耗材的总库存
5966
+							wareinfo, _ := service.GetStockGoodCount(item.GoodId)
5967
+							if wareinfo.StockCount == 0 {
5968
+								goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
5969
+								c.ServeSuccessJSON(map[string]interface{}{
5970
+									"message":            "1",
5971
+									"good_name":          goodObj.GoodName,
5972
+									"specification_name": goodObj.SpecificationName,
5973
+								})
5974
+								return
5975
+							}
5916 5976
 
5917
-					//查询该批次剩余库存
5918
-					lastInfo, _ := service.GetLastStockOut(goodInfoOne.WarehouseInfotId)
5977
+						}
5919 5978
 
5920
-					if lastInfo.StockCount == 0 {
5921 5979
 						//查询该耗材的总库存
5922 5980
 						wareinfo, _ := service.GetStockGoodCount(item.GoodId)
5923
-						if wareinfo.StockCount == 0 {
5981
+						// 如果库存差大于剩余库存则提示库存不足
5982
+						if last_total > wareinfo.StockCount {
5924 5983
 							goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
5925 5984
 							c.ServeSuccessJSON(map[string]interface{}{
5926 5985
 								"message":            "1",
@@ -5928,101 +5987,85 @@ func (c *DialysisAPIController) EditConsumables() {
5928 5987
 								"specification_name": goodObj.SpecificationName,
5929 5988
 							})
5930 5989
 							return
5931
-						}
5932
-
5933
-					}
5934
-
5935
-					//查询该耗材的总库存
5936
-					wareinfo, _ := service.GetStockGoodCount(item.GoodId)
5937
-					// 如果库存差大于剩余库存则提示库存不足
5938
-					if last_total > wareinfo.StockCount {
5939
-						goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
5940
-						c.ServeSuccessJSON(map[string]interface{}{
5941
-							"message":            "1",
5942
-							"good_name":          goodObj.GoodName,
5943
-							"specification_name": goodObj.SpecificationName,
5944
-						})
5945
-						return
5946
-					} else {
5990
+						} else {
5991
+
5992
+							out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
5993
+							houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5994
+							if err == gorm.ErrRecordNotFound {
5995
+								//没有记录,则创建出库单
5996
+								timeStr := time.Now().Format("2006-01-02")
5997
+								timeArr := strings.Split(timeStr, "-")
5998
+								total, _ := service.FindAllWarehouseOut(adminInfo.Org.Id)
5999
+								total = total + 1
6000
+								warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
6001
+								number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
6002
+								number = number + total
6003
+								warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
6004
+								warehouseOut := models.WarehouseOut{
6005
+									WarehouseOutOrderNumber: warehousing_out_order,
6006
+									OperationTime:           time.Now().Unix(),
6007
+									OrgId:                   adminInfo.Org.Id,
6008
+									Creater:                 adminInfo.AdminUser.Id,
6009
+									Ctime:                   time.Now().Unix(),
6010
+									Status:                  1,
6011
+									WarehouseOutTime:        record_time,
6012
+									Dealer:                  0,
6013
+									Manufacturer:            0,
6014
+									Type:                    1,
6015
+									IsSys:                   1,
6016
+									StorehouseId:            houseConfig.StorehouseOutInfo,
6017
+									IsCheck:                 1,
6018
+								}
6019
+								service.AddSigleWarehouseOut(&warehouseOut)
5947 6020
 
5948
-						fmt.Println("出库2o2o2o2o2oo2o2o2o2o2o2o", item.GoodId)
5949
-
5950
-						out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
5951
-						houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5952
-						if err == gorm.ErrRecordNotFound {
5953
-							//没有记录,则创建出库单
5954
-							timeStr := time.Now().Format("2006-01-02")
5955
-							timeArr := strings.Split(timeStr, "-")
5956
-							total, _ := service.FindAllWarehouseOut(adminInfo.Org.Id)
5957
-							total = total + 1
5958
-							warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
5959
-							number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
5960
-							number = number + total
5961
-							warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
5962
-							warehouseOut := models.WarehouseOut{
5963
-								WarehouseOutOrderNumber: warehousing_out_order,
5964
-								OperationTime:           time.Now().Unix(),
5965
-								OrgId:                   adminInfo.Org.Id,
5966
-								Creater:                 adminInfo.AdminUser.Id,
5967
-								Ctime:                   time.Now().Unix(),
5968
-								Status:                  1,
5969
-								WarehouseOutTime:        record_time,
5970
-								Dealer:                  0,
5971
-								Manufacturer:            0,
5972
-								Type:                    1,
5973
-								IsSys:                   1,
5974
-								StorehouseId:            houseConfig.StorehouseOutInfo,
5975
-								IsCheck:                 1,
5976 6021
 							}
5977
-							service.AddSigleWarehouseOut(&warehouseOut)
6022
+							//出库
6023
+							//err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, outbefor, newBeforePrepares, adminInfo.AdminUser.Id)
6024
+							//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6025
+							//1.查看该患者该耗材型号最后一次出库数量
6026
+							goodInfoTwo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
5978 6027
 
5979
-						}
5980
-						//出库
5981
-						//err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, outbefor, newBeforePrepares, adminInfo.AdminUser.Id)
5982
-						//houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
5983
-						//1.查看该患者该耗材型号最后一次出库数量
5984
-						goodInfoTwo, _ := service.GetLastGoodListByPatientIdOne(record_time, patient_id, item.GoodId, item.GoodTypeId)
6028
+							fmt.Println("count2323323222323wi", item.Count)
6029
+							prepare := models.DialysisBeforePrepare{
6030
+								UserOrgId:    adminInfo.Org.Id,
6031
+								PatientId:    patient_id,
6032
+								RecordDate:   record_time,
6033
+								GoodId:       item.GoodId,
6034
+								GoodTypeId:   item.GoodTypeId,
6035
+								Count:        item.Count - goodInfoTwo.Count,
6036
+								Ctime:        time.Now().Unix(),
6037
+								Mtime:        0,
6038
+								Creater:      adminInfo.AdminUser.Id,
6039
+								Modifier:     adminInfo.AdminUser.Id,
6040
+								Status:       1,
6041
+								CommdityCode: "",
6042
+								NewCount:     0,
6043
+								ProjectId:    0,
6044
+								StorehouseId: houseConfig.StorehouseOutInfo,
6045
+							}
6046
+							//fmt.Println("prepare", prepare.Count)
6047
+							//fmt.Println("count", item.Count)
6048
+							service.ConsumablesGoodDelivery(adminInfo.Org.Id, patient_id, record_time, &prepare, &out, item.Count)
6049
+							//增加出库数量
6050
+							service.ModifyGoodSumCount(houseConfig.StorehouseOutInfo, prepare.Count, adminInfo.Org.Id, item.GoodId)
6051
+
6052
+							storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6053
+							stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
6054
+							var total_count int64
6055
+							for _, it := range stockList {
6056
+								total_count += it.StockCount
6057
+							}
6058
+							//基础库插入数据
6059
+							service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
6060
+							//剩余库存
5985 6061
 
5986
-						fmt.Println("count2323323222323wi", item.Count)
5987
-						prepare := models.DialysisBeforePrepare{
5988
-							UserOrgId:    adminInfo.Org.Id,
5989
-							PatientId:    patient_id,
5990
-							RecordDate:   record_time,
5991
-							GoodId:       item.GoodId,
5992
-							GoodTypeId:   item.GoodTypeId,
5993
-							Count:        item.Count - goodInfoTwo.Count,
5994
-							Ctime:        time.Now().Unix(),
5995
-							Mtime:        0,
5996
-							Creater:      adminInfo.AdminUser.Id,
5997
-							Modifier:     adminInfo.AdminUser.Id,
5998
-							Status:       1,
5999
-							CommdityCode: "",
6000
-							NewCount:     0,
6001
-							ProjectId:    0,
6002
-							StorehouseId: houseConfig.StorehouseOutInfo,
6003
-						}
6004
-						fmt.Println("prepare", prepare.Count)
6005
-						fmt.Println("count", item.Count)
6006
-						service.ConsumablesGoodDelivery(adminInfo.Org.Id, patient_id, record_time, &prepare, &out, item.Count)
6007
-						//增加出库数量
6008
-						service.ModifyGoodSumCount(houseConfig.StorehouseOutInfo, prepare.Count, adminInfo.Org.Id, item.GoodId)
6009
-
6010
-						storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
6011
-						stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, adminInfo.Org.Id)
6012
-						var total_count int64
6013
-						for _, it := range stockList {
6014
-							total_count += it.StockCount
6015
-						}
6016
-						//基础库插入数据
6017
-						service.UpdateGoodInfoReduceSumCount(item.GoodId, total_count, adminInfo.Org.Id)
6018
-						//剩余库存
6019
-
6020
-						goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
6021
-						var flush_count int64
6022
-						for _, it := range goodList {
6023
-							flush_count += it.StockCount
6062
+							goodList, _ := service.GetSumGoodList(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId)
6063
+							var flush_count int64
6064
+							for _, it := range goodList {
6065
+								flush_count += it.StockCount
6066
+							}
6067
+							service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
6024 6068
 						}
6025
-						service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, item.GoodId, flush_count)
6026 6069
 					}
6027 6070
 				}
6028 6071
 
@@ -6062,15 +6105,7 @@ func (c *DialysisAPIController) EditConsumables() {
6062 6105
 						flush_count += it.StockCount
6063 6106
 					}
6064 6107
 					service.UpdateSumGood(adminInfo.Org.Id, storeHouseConfig.StorehouseOutInfo, it.GoodId, flush_count)
6065
-					//if err != nil {
6066
-					//	goodObj, _ := service.GetGoodInformationByGoodId(it.GoodId)
6067
-					//	c.ServeSuccessJSON(map[string]interface{}{
6068
-					//		"message":            "2",
6069
-					//		"good_name":          goodObj.GoodName,
6070
-					//		"specification_name": goodObj.SpecificationName,
6071
-					//	})
6072
-					//	return
6073
-					//}
6108
+
6074 6109
 				}
6075 6110
 			}
6076 6111
 		}
@@ -8237,7 +8272,7 @@ func (this *DialysisAPIController) GetNewDoctorListToday() {
8237 8272
 	timeLayout := "2006-01-02"
8238 8273
 	loc, _ := time.LoadLocation("Local")
8239 8274
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
8240
-	list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
8275
+	list, err := service.GetDialysisAdviceSchedulistSeven(orgId, schedule_type, partion_type, startTime.Unix())
8241 8276
 	_, config := service.FindXTHisRecordByOrgId(orgId)
8242 8277
 	appId := this.GetMobileAdminUserInfo().App.Id
8243 8278
 	doctorList, _ := service.GetAllAdminUsers(orgId, appId)

+ 20 - 4
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

@@ -1200,8 +1200,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1200 1200
 						}
1201 1201
 
1202 1202
 						if prescribing_number_total <= total {
1203
-							pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
1204 1203
 
1204
+							pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
1205
+							//判断药品是否零用
1205 1206
 							if medical.IsUse == 2 {
1206 1207
 
1207 1208
 								if config.IsOpen != 1 {
@@ -1678,7 +1679,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1678 1679
 	if evaluation.DryWeight > 0 {
1679 1680
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
1680 1681
 
1681
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 {
1682
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 {
1682 1683
 			dewater_amount = dewater_amount * 1000
1683 1684
 
1684 1685
 		}
@@ -3579,6 +3580,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
3579 3580
 
3580 3581
 func (c *PatientApiController) CreateGroupAdvice() {
3581 3582
 	is_child, _ := c.GetInt64("is_child", 0)
3583
+
3582 3584
 	if is_child == 1 {
3583 3585
 		patient, _ := c.GetInt64("id", 0)
3584 3586
 		if patient <= 0 {
@@ -3637,6 +3639,20 @@ func (c *PatientApiController) CreateGroupAdvice() {
3637 3639
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3638 3640
 			return
3639 3641
 		}
3642
+		advice_date, _ := dataBody["advice_date"].(string)
3643
+		fmt.Println("advice_date----------------------------------", advice_date)
3644
+
3645
+		var advicedateunix int64
3646
+		if len(advice_date) > 0 {
3647
+			theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", advice_date+" 00:00:00", loc)
3648
+			if err != nil {
3649
+				fmt.Println(err)
3650
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3651
+				return
3652
+			}
3653
+			advicedateunix = theTime.Unix()
3654
+		}
3655
+
3640 3656
 		adviceDate := startTime2
3641 3657
 		if len(adviceDate) == 0 {
3642 3658
 			utils.ErrorLog("len(adviceDate) == 0")
@@ -3649,8 +3665,8 @@ func (c *PatientApiController) CreateGroupAdvice() {
3649 3665
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
3650 3666
 			return
3651 3667
 		}
3652
-		AdviceDate := theTime.Unix()
3653
-		RecordDate := theTime.Unix()
3668
+		AdviceDate := advicedateunix
3669
+		RecordDate := advicedateunix
3654 3670
 
3655 3671
 		if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
3656 3672
 			utils.ErrorLog("start_time")

+ 6 - 0
controllers/patient_api_controller.go 查看文件

@@ -938,6 +938,7 @@ func (c *PatientApiController) UpdateDialysisSolution() {
938 938
 			OxygenTime:                 solution.OxygenTime,
939 939
 			MaxUltrafiltrationRate:     solution.MaxUltrafiltrationRate,
940 940
 			Amylaceum:                  solution.Amylaceum,
941
+			DialysisStrainer:           solution.DialysisStrainer,
941 942
 		}
942 943
 		service.UpdatePatientDialysisSolutionOne(solution.PatientId, adminUserInfo.CurrentOrgId, &prescription, todayTime.Unix())
943 944
 	}
@@ -3849,6 +3850,11 @@ func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, met
3849 3850
 		solution.DialysisIrrigation = dialysisIrrigation
3850 3851
 	}
3851 3852
 
3853
+	if dataBody["dialysis_strainer"] != nil && reflect.TypeOf(dataBody["dialysis_strainer"]).String() == "string" {
3854
+		dialysis_strainer := dataBody["dialysis_strainer"].(string)
3855
+		solution.DialysisStrainer = dialysis_strainer
3856
+	}
3857
+
3852 3858
 	if dataBody["plasma_separator"] != nil && reflect.TypeOf(dataBody["plasma_separator"]).String() == "string" {
3853 3859
 		plasmaSeparator := dataBody["plasma_separator"].(string)
3854 3860
 		solution.PlasmaSeparator = plasmaSeparator

+ 2 - 1
controllers/pharmacy_controller.go 查看文件

@@ -289,6 +289,7 @@ func (this *PharmacyController) DispensingMedicine() {
289 289
 		stime = stmp.Unix()
290 290
 		etime = stime + 86399
291 291
 	}
292
+
292 293
 	err = service.DispensingMedicine(orgid, patient_id, stime, etime, creater)
293 294
 	if err != nil {
294 295
 		utils.ErrorLog(err.Error())
@@ -564,7 +565,7 @@ func (this *PharmacyController) GetPatientsWithDrugs() {
564 565
 		return
565 566
 	}
566 567
 	total, err := service.CalculateTheTotalAmount(listll, drug_id)
567
-	fmt.Println("total2322332232323232332322wo", total)
568
+
568 569
 	if err != nil {
569 570
 		utils.ErrorLog(err.Error())
570 571
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)

+ 7 - 4
controllers/print_data_api_controller.go 查看文件

@@ -37,7 +37,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
37 37
 	idStrs := strings.Split(schIDStr, ",")
38 38
 	adminUserInfo := this.GetAdminUserInfo()
39 39
 
40
-	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 {
40
+	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 {
41 41
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
42 42
 		for _, item := range schedules {
43 43
 
@@ -136,7 +136,7 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
136 136
 		})
137 137
 	}
138 138
 
139
-	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 {
139
+	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 {
140 140
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
141 141
 		for _, item := range schedules {
142 142
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
@@ -257,13 +257,16 @@ func (this *PrintDataAPIController) CourseRecordPrintData() {
257 257
 
258 258
 	//patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
259 259
 	patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)
260
+
261
+	adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
260 262
 	if err != nil {
261 263
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
262 264
 		return
263 265
 	} else {
264 266
 		this.ServeSuccessJSON(map[string]interface{}{
265
-			"record":  record,
266
-			"patient": patient,
267
+			"record":    record,
268
+			"patient":   patient,
269
+			"adminUser": adminUser,
267 270
 		})
268 271
 	}
269 272
 }

+ 1 - 1
controllers/schedule_api_controller.go 查看文件

@@ -3870,7 +3870,7 @@ func (this *ScheduleApiController) GetBloodScheduleList() {
3870 3870
 		for _, item := range list {
3871 3871
 			order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
3872 3872
 			item.XtDialysisOrderSix = order
3873
-			if orgId == 9671 || orgId == 9675 || orgId == 10340 {
3873
+			if orgId == 10340 {
3874 3874
 
3875 3875
 				solution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
3876 3876
 				item.DialysisPrescription = solution

+ 1 - 0
controllers/self_drug_api_congtroller.go 查看文件

@@ -2766,6 +2766,7 @@ func (this *SelfDrugApiController) GetGoodNewQuery() {
2766 2766
 	for _, it := range manufacturerList {
2767 2767
 		ids = append(ids, it.ID)
2768 2768
 	}
2769
+
2769 2770
 	infoList, _ := service.GetGoodWarehouseInfoByOrgId(orgId, storehouse_id)
2770 2771
 	for _, it := range infoList {
2771 2772
 		goodIds = append(goodIds, it.GoodId)

+ 2 - 0
controllers/stock_in_api_controller.go 查看文件

@@ -5134,12 +5134,14 @@ func (this *StockManagerApiController) GetStockFlow() {
5134 5134
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
5135 5135
 	good, _ := service.GetGoodInformationByGoodId(good_id)
5136 5136
 	houseList, _ := service.GetAllStoreHouseList(adminUserInfo.CurrentOrgId)
5137
+	patients, _ := service.GetAllPatientListSix(adminUserInfo.CurrentOrgId)
5137 5138
 	this.ServeSuccessJSON(map[string]interface{}{
5138 5139
 		"list":             list,
5139 5140
 		"total":            total,
5140 5141
 		"manufacturerList": manufacturerList,
5141 5142
 		"good":             good,
5142 5143
 		"houseList":        houseList,
5144
+		"patients":         patients,
5143 5145
 	})
5144 5146
 }
5145 5147
 

+ 3 - 2
models/good_models.go 查看文件

@@ -137,8 +137,9 @@ func (GoodInfo) TableName() string {
137 137
 }
138 138
 
139 139
 type GoodInfoSeven struct {
140
-	ID       int64  `gorm:"column:id" json:"id" form:"id"`
141
-	GoodName string `gorm:"column:good_name" json:"good_name" form:"good_name"`
140
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
141
+	GoodName   string `gorm:"column:good_name" json:"good_name" form:"good_name"`
142
+	GoodStatus string `gorm:"column:good_status" json:"good_status" form:"good_status"`
142 143
 }
143 144
 
144 145
 func (GoodInfoSeven) TableName() string {

+ 27 - 0
models/patient_models.go 查看文件

@@ -364,6 +364,8 @@ type DialysisPrescription struct {
364 364
 	SodiumCurve                string        `gorm:"column:sodium_curve" json:"sodium_curve" form:"sodium_curve"`
365 365
 	DialysisFluidFlow          string        `gorm:"column:dialysis_fluid_flow" json:"dialysis_fluid_flow" form:"dialysis_fluid_flow"`
366 366
 	SodiumBicarbonateFlow      string        `gorm:"column:sodium_bicarbonate_flow" json:"sodium_bicarbonate_flow" form:"sodium_bicarbonate_flow"`
367
+	PrescriptionWater          float64       `gorm:"column:prescription_water" json:"prescription_water" form:"prescription_water"`
368
+	DialysisStrainer           string        `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
367 369
 }
368 370
 
369 371
 func (DialysisPrescription) TableName() string {
@@ -470,6 +472,7 @@ type DialysisPrescriptionList struct {
470 472
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
471 473
 	MaxUltrafiltrationRate     string  `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
472 474
 	WaterMachine               string  `gorm:"column:water_machine" json:"water_machine" form:"water_machine"`
475
+	DialysisStrainer           string  `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
473 476
 }
474 477
 
475 478
 func (DialysisPrescriptionList) TableName() string {
@@ -578,6 +581,8 @@ type DialysisSolution struct {
578 581
 	SodiumCurve                string  `gorm:"column:sodium_curve" json:"sodium_curve" form:"sodium_curve"`
579 582
 	DialysisFluidFlow          string  `gorm:"column:dialysis_fluid_flow" json:"dialysis_fluid_flow" form:"dialysis_fluid_flow"`
580 583
 	SodiumBicarbonateFlow      string  `gorm:"column:sodium_bicarbonate_flow" json:"sodium_bicarbonate_flow" form:"sodium_bicarbonate_flow"`
584
+	PrescriptionWater          float64 `gorm:"column:prescription_water" json:"prescription_water" form:"prescription_water"`
585
+	DialysisStrainer           string  `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
581 586
 }
582 587
 
583 588
 func (DialysisSolution) TableName() string {
@@ -1795,3 +1800,25 @@ type NewDialysisSolutionOne struct {
1795 1800
 func (NewDialysisSolutionOne) TableName() string {
1796 1801
 	return "xt_dialysis_solution"
1797 1802
 }
1803
+
1804
+type XtPatientFirstDisease struct {
1805
+	ID                    int64  `gorm:"column:id" json:"id" form:"id"`
1806
+	Title                 string `gorm:"column:title" json:"title" form:"title"`
1807
+	RecordDate            int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1808
+	Doctor                int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
1809
+	MainContent           string `gorm:"column:main_content" json:"main_content" form:"main_content"`
1810
+	PatientCase           string `gorm:"column:patient_case" json:"patient_case" form:"patient_case"`
1811
+	TentativeDiagnosis    string `gorm:"column:tentative_diagnosis" json:"tentative_diagnosis" form:"tentative_diagnosis"`
1812
+	DiagnosticBasis       string `gorm:"column:diagnostic_basis" json:"diagnostic_basis" form:"diagnostic_basis"`
1813
+	DifferentialDiagnosis string `gorm:"column:differential_diagnosis" json:"differential_diagnosis" form:"differential_diagnosis"`
1814
+	TreatmentPlan         string `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
1815
+	UserOrgId             int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1816
+	PatientId             int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1817
+	Ctime                 int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1818
+	Mtime                 int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1819
+	Status                int64  `gorm:"column:status" json:"status" form:"status"`
1820
+}
1821
+
1822
+func (XtPatientFirstDisease) TableName() string {
1823
+	return "xt_patient_first_disease"
1824
+}

+ 2 - 2
service/auto_create_week_disinfection.go 查看文件

@@ -15,9 +15,9 @@ var createWeekDisinfectionCronJob *cron.Cron
15 15
 
16 16
 func init() {
17 17
 	createWeekDisinfectionCronJob = cron.New()
18
-	spec := "0 50 23 * * ?" // 每天23点执行一次
18
+	//spec := "0 50 23 * * ?" // 每天23点执行一次
19 19
 	//spec := "0 55 23 * * ?" // 每天23点55执行一次
20
-	//spec := "0 0 5 * * ?" // 每天23点55执行一次
20
+	spec := "0 0 5 * * ?" // 每天23点55执行一次
21 21
 	//spec := "0 */1 * * * ?" // 每1分钟执行一次
22 22
 	createWeekDisinfectionCronJob.AddFunc(spec, func() {
23 23
 

+ 106 - 9
service/dialysis_solution_service.go 查看文件

@@ -190,7 +190,7 @@ func GetDialysisParameterList(keywords string, limit int64, page int64, partitio
190 190
 	return schedule, total, err
191 191
 }
192 192
 
193
-func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
193
+func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id []string, scheduleDate int64) (schedule []*models.VmBloodSchedule, err error) {
194 194
 
195 195
 	db := XTReadDB().Model(&models.VmBloodSchedule{}).Where("status = 1")
196 196
 
@@ -200,8 +200,12 @@ func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id in
200 200
 	if schedule_type > 0 {
201 201
 		db = db.Where("schedule_type = ?", schedule_type)
202 202
 	}
203
-	if partition_id > 0 {
204
-		db = db.Where("partition_id = ?", partition_id)
203
+	//if partition_id > 0 {
204
+	//	db = db.Where("partition_id = ?", partition_id)
205
+	//}
206
+	fmt.Println("len-------------", len(partition_id))
207
+	if len(partition_id) > 0 {
208
+		db = db.Where("partition_id in(?)", partition_id)
205 209
 	}
206 210
 	if orgID > 0 {
207 211
 		db = db.Where("user_org_id  = ?", orgID)
@@ -216,7 +220,7 @@ func GetDialysisGoodTotalCount(orgID int64, schedule_type int64, partition_id in
216 220
 
217 221
 }
218 222
 
219
-func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleOne, err error) {
223
+func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id []string, scheduleDate int64) (schedule []*models.VmBloodScheduleOne, err error) {
220 224
 
221 225
 	db := XTReadDB().Model(&models.VmBloodScheduleOne{}).Where("status = 1")
222 226
 
@@ -226,8 +230,11 @@ func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id
226 230
 	if schedule_type > 0 {
227 231
 		db = db.Where("schedule_type = ?", schedule_type)
228 232
 	}
229
-	if partition_id > 0 {
230
-		db = db.Where("partition_id = ?", partition_id)
233
+	//if partition_id > 0 {
234
+	//	db = db.Where("partition_id = ?", partition_id)
235
+	//}
236
+	if len(partition_id) > 0 {
237
+		db = db.Where("partition_id in(?)", partition_id)
231 238
 	}
232 239
 	if orgID > 0 {
233 240
 		db = db.Where("user_org_id  = ?", orgID)
@@ -243,7 +250,7 @@ func GetDialysisAdviceSchedulist(orgID int64, schedule_type int64, partition_id
243 250
 
244 251
 }
245 252
 
246
-func GetDialysisAdviceSchedulistTwo(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleTwo, err error) {
253
+func GetDialysisAdviceSchedulistTwo(orgID int64, schedule_type int64, partition_id []string, scheduleDate int64) (schedule []*models.VmBloodScheduleTwo, err error) {
247 254
 
248 255
 	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("status = 1")
249 256
 
@@ -253,8 +260,11 @@ func GetDialysisAdviceSchedulistTwo(orgID int64, schedule_type int64, partition_
253 260
 	if schedule_type > 0 {
254 261
 		db = db.Where("schedule_type = ?", schedule_type)
255 262
 	}
256
-	if partition_id > 0 {
257
-		db = db.Where("partition_id = ?", partition_id)
263
+	//if partition_id > 0 {
264
+	//	db = db.Where("partition_id = ?", partition_id)
265
+	//}
266
+	if len(partition_id) > 0 {
267
+		db = db.Where("partition_id in(?)", partition_id)
258 268
 	}
259 269
 	if orgID > 0 {
260 270
 		db = db.Where("user_org_id  = ?", orgID)
@@ -456,3 +466,90 @@ func GetHisAdviceListToday(user_org_id int64, advice_date int64) (advice []*mode
456 466
 	err = XTReadDB().Where("user_org_id = ? and status = 1 and advice_date = ?", user_org_id, advice_date).Preload("Drug", "org_id = ? and status=1", user_org_id).Find(&advice).Error
457 467
 	return advice, err
458 468
 }
469
+
470
+func GetDialysisAdviceSchedulistSeven(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleOne, err error) {
471
+
472
+	db := XTReadDB().Model(&models.VmBloodScheduleOne{}).Where("status = 1")
473
+
474
+	if scheduleDate > 0 {
475
+		db = db.Where("schedule_date = ?", scheduleDate)
476
+	}
477
+	if schedule_type > 0 {
478
+		db = db.Where("schedule_type = ?", schedule_type)
479
+	}
480
+	if partition_id > 0 {
481
+		db = db.Where("partition_id = ?", partition_id)
482
+	}
483
+
484
+	if orgID > 0 {
485
+		db = db.Where("user_org_id  = ?", orgID)
486
+	}
487
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
488
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
489
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ? and advice_type = 2", orgID, scheduleDate).
490
+		Preload("HisDoctorAdvice", func(db *gorm.DB) *gorm.DB {
491
+			return db.Where("user_org_id = ? and status = 1 and advice_date = ?", orgID, scheduleDate).Preload("Drug", "org_id =? and status = 1", orgID)
492
+		}).Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
493
+
494
+	return schedule, err
495
+
496
+}
497
+
498
+func GetDialysisAdviceSchedulistTen(orgID int64, schedule_type int64, partition_id int64, scheduleDate int64) (schedule []*models.VmBloodScheduleOne, err error) {
499
+
500
+	db := XTReadDB().Model(&models.VmBloodScheduleOne{}).Where("status = 1")
501
+
502
+	if scheduleDate > 0 {
503
+		db = db.Where("schedule_date = ?", scheduleDate)
504
+	}
505
+	if schedule_type > 0 {
506
+		db = db.Where("schedule_type = ?", schedule_type)
507
+	}
508
+	if partition_id > 0 {
509
+		db = db.Where("partition_id = ?", partition_id)
510
+	}
511
+
512
+	if orgID > 0 {
513
+		db = db.Where("user_org_id  = ?", orgID)
514
+	}
515
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
516
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
517
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ? and advice_date = ? and advice_type = 2", orgID, scheduleDate).
518
+		Preload("HisDoctorAdvice", func(db *gorm.DB) *gorm.DB {
519
+			return db.Where("user_org_id = ? and status = 1 and advice_date = ?", orgID, scheduleDate).Preload("Drug", "org_id =? and status = 1", orgID)
520
+		}).Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
521
+
522
+	return schedule, err
523
+
524
+}
525
+
526
+func GetHisDialysisGoodCountTwo(orgID int64, schedule_type int64, partition_id []string, scheduleDate int64) (schedule []*models.VmBloodScheduleTwo, err error) {
527
+
528
+	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
529
+	if scheduleDate > 0 {
530
+		db = db.Where("xt_schedule.schedule_date = ?", scheduleDate)
531
+	}
532
+	if schedule_type > 0 {
533
+		db = db.Where("xt_schedule.schedule_type = ?", schedule_type)
534
+	}
535
+	if len(partition_id) > 0 {
536
+		db = db.Where("xt_schedule.partition_id in (?)", partition_id)
537
+	}
538
+	if orgID > 0 {
539
+		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
540
+	}
541
+
542
+	err = db.
543
+		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
544
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
545
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
546
+		Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
547
+			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
548
+				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
549
+					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
550
+				})
551
+			})
552
+		}).Find(&schedule).Error
553
+
554
+	return schedule, err
555
+}

文件差異過大導致無法顯示
+ 1943 - 2
service/mobile_dialysis_service.go


+ 5 - 1
service/new_stock_service.go 查看文件

@@ -80,12 +80,16 @@ func GetGoodStockList(orgId int64, storehouse_id int64, good_type int64, keyword
80 80
 	offset := (page - 1) * limit
81 81
 	likeKey := "%" + keyword + "%"
82 82
 
83
-	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1  and x.org_id =?", orgId)
83
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1  and x.org_id =? and find_in_set('停用',x.good_status) = 0", orgId)
84 84
 
85 85
 	if good_type == 2 {
86 86
 		db = db.Where(" x.total_count<=x.stock_warn_count")
87 87
 	}
88 88
 
89
+	if good_type == 3 {
90
+		db = db.Where("x.sum_count = 0")
91
+	}
92
+
89 93
 	if len(keyword) > 0 {
90 94
 		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
91 95
 	}

+ 587 - 1
service/new_warehouse_service.go 查看文件

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"XT_New/utils"
5 6
 	"errors"
6 7
 	"fmt"
7 8
 	"github.com/jinzhu/gorm"
@@ -11,7 +12,7 @@ import (
11 12
 	"time"
12 13
 )
13 14
 
14
-//耗材出库
15
+// 耗材出库
15 16
 func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
16 17
 
17 18
 	//开事务
@@ -2962,3 +2963,588 @@ func HisSettleDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseo
2962 2963
 
2963 2964
 	return
2964 2965
 }
2966
+
2967
+// 耗材出库
2968
+func ConsumablesGoodDeliveryFivety(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, count int64) (err error) {
2969
+
2970
+	//开事务
2971
+	tx := XTWriteDB().Begin()
2972
+	defer func() {
2973
+		if err != nil {
2974
+			utils.ErrorLog("事务失败,原因为: %v", err)
2975
+			tx.Rollback()
2976
+		} else {
2977
+			tx.Commit()
2978
+		}
2979
+	}()
2980
+
2981
+	var deliver_number int64 = 0
2982
+	var stock_number int64 = 0
2983
+	var maxNumber int64 = 0
2984
+
2985
+	deliver_number = goods.Count
2986
+
2987
+	// 根据先进先出原则,查询最先入库的批次,进行出库
2988
+	// 如果没有对应的库存,则报错
2989
+
2990
+	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId, goods.StorehouseId)
2991
+	if err != nil {
2992
+		return errors.New("库存数量不足")
2993
+	}
2994
+
2995
+	stock_number = warehouse.StockCount
2996
+
2997
+	// 当库存数量大于或等于出库数量的话,则正常出库该批次
2998
+	if stock_number >= deliver_number {
2999
+
3000
+		maxNumber = goods.Count
3001
+		//出库
3002
+		warehouse.StockCount = warehouse.StockCount - maxNumber
3003
+		warehouse.Mtime = time.Now().Unix()
3004
+		if warehouse.StockCount < 0 {
3005
+			return errors.New("库存数量不足")
3006
+		}
3007
+		err := tx.Save(&warehouse).Error
3008
+		if err != nil {
3009
+			return err
3010
+		}
3011
+		//更新his_prescripton_project出库状态值
3012
+		project := models.HisPrescriptionProject{}
3013
+		err = tx.Model(&project).Where("project_id  = ? and record_date = ? and user_org_id = ? and patient_id = ? and status = 1", goods.GoodId, record_time, orgID, patient_id).Update(map[string]interface{}{"is_out": 1}).Error
3014
+		if err != nil {
3015
+			return err
3016
+		}
3017
+		//查询剩余库存
3018
+		goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID, goods.StorehouseId)
3019
+		var sum_count int64
3020
+		for _, item := range goodList {
3021
+			sum_count += item.StockCount
3022
+		}
3023
+
3024
+		warehouseOutInfo := &models.WarehouseOutInfo{
3025
+			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
3026
+			WarehouseOutId:          warehouseOut.ID,
3027
+			WarehouseInfotId:        warehouse.ID,
3028
+			Status:                  1,
3029
+			Ctime:                   time.Now().Unix(),
3030
+			Remark:                  warehouse.Remark,
3031
+			OrgId:                   orgID,
3032
+			Type:                    1,
3033
+			Manufacturer:            warehouse.Manufacturer,
3034
+			Dealer:                  warehouse.Dealer,
3035
+			IsSys:                   1,
3036
+			SysRecordTime:           record_time,
3037
+			GoodTypeId:              goods.GoodTypeId,
3038
+			GoodId:                  goods.GoodId,
3039
+			PatientId:               patient_id,
3040
+			Number:                  warehouse.Number,
3041
+			LicenseNumber:           warehouse.LicenseNumber,
3042
+			Price:                   warehouse.PackingPrice,
3043
+			ExpiryDate:              warehouse.ExpiryDate,
3044
+			ProductDate:             warehouse.ProductDate,
3045
+			ProjectId:               goods.ProjectId,
3046
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
3047
+			StorehouseId:            goods.StorehouseId,
3048
+			IsCheck:                 1,
3049
+			OverCount:               sum_count,
3050
+			RegisterNumber:          warehouse.RegisterNumber,
3051
+		}
3052
+		warehouseOutInfo.Count = count
3053
+		if orgID == 9671 || orgID == 10265 {
3054
+			goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3055
+			warehouseOutInfo.Price = goodsInfo.PackingPrice
3056
+		}
3057
+		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
3058
+		if errcodes == gorm.ErrRecordNotFound {
3059
+			err := tx.Create(&warehouseOutInfo).Error
3060
+			if err != nil {
3061
+				return err
3062
+			}
3063
+		} else if errcodes == nil {
3064
+
3065
+			outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
3066
+			if count != outInfoOne.Count {
3067
+				outInfo := models.WarehouseOutInfo{}
3068
+				err := tx.Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time  =? and status = 1", goods.GoodId, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": warehouseOutInfo.WarehouseOutId, "WarehouseOutOrderNumber": warehouseOutInfo.WarehouseOutOrderNumber, "sys_record_time": warehouseOutInfo.SysRecordTime, "good_type_id": warehouseOutInfo.GoodTypeId, "patient_id": warehouseOutInfo.PatientId, "consumable_type": warehouseOutInfo.ConsumableType, "count": warehouseOutInfo.Count, "price": warehouseOutInfo.Price, "dealer": warehouseOutInfo.Dealer, "manufacturer": warehouseOutInfo.Manufacturer, "number": warehouseOutInfo.Number, "license_number": warehouseOutInfo.LicenseNumber, "over_count": warehouseOutInfo.OverCount}).Error
3069
+				if err != nil {
3070
+					return err
3071
+				}
3072
+			}
3073
+
3074
+		}
3075
+		lastOut, _ := FindWarehouseOutInfoByPatientId(patient_id, record_time, goods.GoodId, orgID)
3076
+
3077
+		//查询已经出库的数据
3078
+		flowGood, _ := GetStockFlowIsBatchNumber(warehouse.ID, patient_id, record_time, goods.GoodId)
3079
+		var out_count int64
3080
+		var out_count_one int64
3081
+		for _, item := range flowGood {
3082
+			out_count += item.Count
3083
+		}
3084
+
3085
+		//查询退库数据
3086
+		flowGoodTwo, _ := GetStockFlowIsBatchNumberThree(patient_id, record_time, goods.GoodId)
3087
+		for _, item := range flowGoodTwo {
3088
+			out_count_one += item.Count
3089
+		}
3090
+		//如果本次出库数据大于历史出库数据 新增1条流水
3091
+		if count > (out_count - out_count_one) {
3092
+
3093
+			flow := models.VmStockFlow{
3094
+				WarehouseOutId:          warehouseOut.ID,
3095
+				WarehousingId:           warehouse.ID,
3096
+				GoodId:                  goods.GoodId,
3097
+				Number:                  warehouse.Number,
3098
+				ProductDate:             warehouse.ProductDate,
3099
+				ExpireDate:              warehouse.ExpiryDate,
3100
+				Count:                   count - out_count + out_count_one,
3101
+				Price:                   warehouse.PackingPrice,
3102
+				Status:                  1,
3103
+				Ctime:                   time.Now().Unix(),
3104
+				UserOrgId:               orgID,
3105
+				Manufacturer:            warehouse.Manufacturer,
3106
+				Dealer:                  warehouse.Dealer,
3107
+				LicenseNumber:           warehouse.LicenseNumber,
3108
+				IsEdit:                  2,
3109
+				Creator:                 warehouseOut.Creater,
3110
+				SystemTime:              record_time,
3111
+				ConsumableType:          3,
3112
+				WarehouseOutDetailId:    lastOut.ID,
3113
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
3114
+				IsSys:                   1,
3115
+				PatientId:               patient_id,
3116
+				ProjectId:               goods.ProjectId,
3117
+				SupplyWarehouseId:       warehouse.SupplyWarehouseId,
3118
+				StorehouseId:            goods.StorehouseId,
3119
+				OverCount:               sum_count,
3120
+				BuyPrice:                warehouse.Price,
3121
+				RegisterNumber:          warehouse.RegisterNumber,
3122
+			}
3123
+			if orgID == 9671 || orgID == 10265 {
3124
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3125
+				flow.Price = goodsInfo.PackingPrice
3126
+				flow.BuyPrice = goodsInfo.BuyPrice
3127
+			}
3128
+			err := tx.Create(&flow).Error
3129
+			if err != nil {
3130
+				return err
3131
+			}
3132
+
3133
+		}
3134
+
3135
+		//如果本次出库数据小于历史出库数据 新增1条退库流水
3136
+
3137
+		if count < (out_count - out_count_one) {
3138
+
3139
+			operation_time := time.Now().Unix()
3140
+
3141
+			//创建退库单
3142
+			timeStr := time.Now().Format("2006-01-02")
3143
+			timeArr := strings.Split(timeStr, "-")
3144
+			total, _ := FindAllCancelStockTotal(orgID)
3145
+			total = total + 1
3146
+			orderNumber := "CKTKD" + strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
3147
+
3148
+			cancelStock := models.CancelStock{
3149
+				OrderNumber:  orderNumber,
3150
+				OperaTime:    operation_time,
3151
+				OrgId:        orgID,
3152
+				Creater:      warehouseOut.Creater,
3153
+				Ctime:        time.Now().Unix(),
3154
+				Status:       1,
3155
+				ReturnTime:   record_time,
3156
+				Type:         1,
3157
+				StorehouseId: goods.StorehouseId,
3158
+				IsCheck:      1,
3159
+			}
3160
+			_, msgerrkonde := GetCancelStockDetailByOrderNumberOne(record_time, orgID)
3161
+			if msgerrkonde == gorm.ErrRecordNotFound {
3162
+
3163
+				err := tx.Create(&cancelStock).Error
3164
+				if err != nil {
3165
+					return err
3166
+				}
3167
+			}
3168
+
3169
+			cancel, _ := GetLastCancelStockById(orgID)
3170
+
3171
+			manufacturer, _ := GetManufactureById(warehouse.Manufacturer)
3172
+			deaerler, _ := GetDealerById(warehouse.Dealer)
3173
+			cancelStockInfo := models.CancelStockInfo{
3174
+				GoodId:          goods.GoodId,
3175
+				CancelStockId:   cancel.ID,
3176
+				GoodTypeId:      goods.GoodTypeId,
3177
+				Count:           out_count - out_count_one - count,
3178
+				Price:           warehouse.PackingPrice,
3179
+				Total:           0,
3180
+				ProductDate:     warehouse.ProductDate,
3181
+				ExpiryDate:      warehouse.ExpiryDate,
3182
+				Ctime:           time.Now().Unix(),
3183
+				Status:          1,
3184
+				OrgId:           orgID,
3185
+				OrderNumber:     cancel.OrderNumber,
3186
+				Type:            0,
3187
+				Dealer:          deaerler.DealerName,
3188
+				Manufacturer:    manufacturer.ManufacturerName,
3189
+				Number:          warehouse.Number,
3190
+				RegisterAccount: "",
3191
+				Remark:          "",
3192
+				WarehouseInfoId: warehouse.ID,
3193
+				PatientId:       patient_id,
3194
+				RecordDate:      record_time,
3195
+				StorehouseId:    goods.StorehouseId,
3196
+				IsCheck:         1,
3197
+			}
3198
+			if orgID == 9671 || orgID == 10265 {
3199
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3200
+				cancelStockInfo.Price = goodsInfo.PackingPrice
3201
+			}
3202
+
3203
+			err := tx.Create(&cancelStockInfo).Error
3204
+			if err != nil {
3205
+				return err
3206
+			}
3207
+
3208
+			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
3209
+
3210
+			flow := models.VmStockFlow{
3211
+				WarehousingId:           warehouse.ID,
3212
+				GoodId:                  goods.GoodId,
3213
+				Number:                  warehouse.Number,
3214
+				LicenseNumber:           warehouse.LicenseNumber,
3215
+				Count:                   out_count - out_count_one - count,
3216
+				UserOrgId:               orgID,
3217
+				PatientId:               patient_id,
3218
+				SystemTime:              record_time,
3219
+				ConsumableType:          7,
3220
+				IsSys:                   1,
3221
+				WarehousingOrder:        "",
3222
+				WarehouseOutId:          lastOut.WarehouseOutId,
3223
+				WarehouseOutOrderNumber: lastOut.WarehouseOutOrderNumber,
3224
+				IsEdit:                  0,
3225
+				CancelStockId:           cancel.ID,
3226
+				CancelOrderNumber:       cancel.OrderNumber,
3227
+				Manufacturer:            manufacturer.ID,
3228
+				Dealer:                  0,
3229
+				Creator:                 warehouseOut.Creater,
3230
+				UpdateCreator:           0,
3231
+				Status:                  1,
3232
+				Ctime:                   time.Now().Unix(),
3233
+				Mtime:                   0,
3234
+				Price:                   warehouse.PackingPrice,
3235
+				WarehousingDetailId:     warehouse.ID,
3236
+				WarehouseOutDetailId:    lastOut.ID,
3237
+				CancelOutDetailId:       cancelInfo.ID,
3238
+				ProductDate:             warehouse.ProductDate,
3239
+				ExpireDate:              warehouse.ExpiryDate,
3240
+				StorehouseId:            goods.StorehouseId,
3241
+				BuyPrice:                warehouse.Price,
3242
+				ProjectId:               goods.ProjectId,
3243
+				OverCount:               sum_count,
3244
+				RegisterNumber:          warehouse.RegisterNumber,
3245
+			}
3246
+			if orgID == 9671 || orgID == 10265 {
3247
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3248
+				flow.Price = goodsInfo.PackingPrice
3249
+				flow.BuyPrice = goodsInfo.BuyPrice
3250
+			}
3251
+
3252
+			err = tx.Create(&flow).Error
3253
+			if err != nil {
3254
+				return err
3255
+			}
3256
+		}
3257
+
3258
+		details := models.BloodAutomaticReduceDetail{
3259
+			WarehouseOutId:          lastOut.ID,
3260
+			WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
3261
+			PatientId:               patient_id,
3262
+			Ctime:                   time.Now().Unix(),
3263
+			Mtime:                   time.Now().Unix(),
3264
+			Status:                  1,
3265
+			RecordTime:              record_time,
3266
+			OrgId:                   orgID,
3267
+			GoodId:                  goods.GoodId,
3268
+			GoodTypeId:              goods.GoodTypeId,
3269
+			Count:                   count,
3270
+			ProjectId:               goods.ProjectId,
3271
+			StorehouseId:            goods.StorehouseId,
3272
+		}
3273
+
3274
+		////查询该耗材已经出库的数量
3275
+		_, errcode := GetAutoMaticReduceDetailTwenty(orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId)
3276
+		if errcode == gorm.ErrRecordNotFound {
3277
+
3278
+			err := tx.Create(&details).Error
3279
+			if err != nil {
3280
+				return err
3281
+			}
3282
+
3283
+		} else if errcode == nil {
3284
+
3285
+			detail := models.BloodAutomaticReduceDetail{}
3286
+			err := tx.Model(&detail).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ? and good_type_id = ?", orgID, patient_id, record_time, goods.GoodId, goods.GoodTypeId).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3287
+			if err != nil {
3288
+				return err
3289
+			}
3290
+
3291
+			err = tx.Create(&detail).Error
3292
+			if err != nil {
3293
+				return err
3294
+			}
3295
+
3296
+		}
3297
+
3298
+		return err
3299
+	} else {
3300
+
3301
+		// 当刚批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
3302
+		warehouse.StockCount = 0
3303
+		warehouse.Mtime = time.Now().Unix()
3304
+		errThree := UpDateWarehouseInfoByStock(&warehouse)
3305
+		if errThree != nil {
3306
+			return errThree
3307
+		}
3308
+		goodList, _ := GetAllGoodSumCount(goods.GoodId, orgID, goods.StorehouseId)
3309
+		var sum_count int64
3310
+		for _, item := range goodList {
3311
+			sum_count += item.StockCount
3312
+		}
3313
+		warehouseOutInfo := &models.WarehouseOutInfo{
3314
+			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
3315
+			WarehouseOutId:          warehouseOut.ID,
3316
+			WarehouseInfotId:        warehouse.ID,
3317
+			Status:                  1,
3318
+			Ctime:                   time.Now().Unix(),
3319
+			Remark:                  warehouse.Remark,
3320
+			OrgId:                   orgID,
3321
+			Type:                    1,
3322
+			Manufacturer:            warehouse.Manufacturer,
3323
+			Dealer:                  warehouse.Dealer,
3324
+			IsSys:                   1,
3325
+			SysRecordTime:           record_time,
3326
+			GoodTypeId:              goods.GoodTypeId,
3327
+			GoodId:                  goods.GoodId,
3328
+			PatientId:               patient_id,
3329
+			Number:                  warehouse.Number,
3330
+			LicenseNumber:           warehouse.LicenseNumber,
3331
+			Price:                   warehouse.PackingPrice,
3332
+			ExpiryDate:              warehouse.ExpiryDate,
3333
+			ProductDate:             warehouse.ProductDate,
3334
+			ProjectId:               goods.ProjectId,
3335
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
3336
+			StorehouseId:            goods.StorehouseId,
3337
+			IsCheck:                 1,
3338
+			OverCount:               sum_count,
3339
+			RegisterNumber:          warehouse.RegisterNumber,
3340
+		}
3341
+		warehouseOutInfo.Count = stock_number
3342
+		if orgID == 9671 || orgID == 10265 {
3343
+			goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3344
+			warehouseOutInfo.Price = goodsInfo.PackingPrice
3345
+		}
3346
+		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
3347
+
3348
+		if errcodes == gorm.ErrRecordNotFound {
3349
+
3350
+			outInfo := models.WarehouseOutInfo{}
3351
+			err := tx.Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time  =? and status = 1", goods.GoodId, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": warehouseOutInfo.WarehouseOutId, "WarehouseOutOrderNumber": warehouseOutInfo.WarehouseOutOrderNumber, "sys_record_time": warehouseOutInfo.SysRecordTime, "good_type_id": warehouseOutInfo.GoodTypeId, "patient_id": warehouseOutInfo.PatientId, "consumable_type": warehouseOutInfo.ConsumableType, "count": warehouseOutInfo.Count, "price": warehouseOutInfo.Price, "dealer": warehouseOutInfo.Dealer, "manufacturer": warehouseOutInfo.Manufacturer, "number": warehouseOutInfo.Number, "license_number": warehouseOutInfo.LicenseNumber, "over_count": warehouseOutInfo.OverCount}).Error
3352
+			if err != nil {
3353
+				return err
3354
+			}
3355
+
3356
+		} else if errcodes == nil {
3357
+			goods.Count = deliver_number - stock_number
3358
+			//更新数量为  该批次剩余数量  + 还有未出的数量
3359
+			warehouseOutInfo.Count = stock_number
3360
+			outInfoOne, _ := GetWarehouseOutInfoIsExistTwo(goods.GoodId, patient_id, record_time, goods.ProjectId)
3361
+			if count != outInfoOne.Count {
3362
+				outInfo := models.WarehouseOutInfo{}
3363
+				err := tx.Model(&outInfo).Where("good_id = ? and patient_id = ? and sys_record_time  =? and status = 1", goods.GoodId, patient_id, record_time).Updates(map[string]interface{}{"warehouse_out_id": warehouseOutInfo.WarehouseOutId, "WarehouseOutOrderNumber": warehouseOutInfo.WarehouseOutOrderNumber, "sys_record_time": warehouseOutInfo.SysRecordTime, "good_type_id": warehouseOutInfo.GoodTypeId, "patient_id": warehouseOutInfo.PatientId, "consumable_type": warehouseOutInfo.ConsumableType, "count": warehouseOutInfo.Count, "price": warehouseOutInfo.Price, "dealer": warehouseOutInfo.Dealer, "manufacturer": warehouseOutInfo.Manufacturer, "number": warehouseOutInfo.Number, "license_number": warehouseOutInfo.LicenseNumber, "over_count": warehouseOutInfo.OverCount}).Error
3364
+				if err != nil {
3365
+					return err
3366
+				}
3367
+			}
3368
+
3369
+		}
3370
+		lastOut, _ := FindWarehouseOutInfoByPatientId(patient_id, record_time, goods.GoodId, orgID)
3371
+		//查询该该批次已经出库的数据
3372
+		flowGood, _ := GetStockFlowIsBatchNumber(warehouse.ID, patient_id, record_time, goods.GoodId)
3373
+		var out_count int64
3374
+		var out_count_one int64
3375
+		for _, item := range flowGood {
3376
+			out_count += item.Count
3377
+		}
3378
+		flowGoodTwo, _ := GetStockFlowIsBatchNumberThree(patient_id, record_time, goods.GoodId)
3379
+		for _, item := range flowGoodTwo {
3380
+			out_count_one += item.Count
3381
+		}
3382
+		//如果出库数量 大于 历史出库数据 新增1条流水
3383
+		if count > out_count-out_count_one {
3384
+			flow := models.VmStockFlow{
3385
+				WarehouseOutId:          warehouseOut.ID,
3386
+				WarehousingId:           warehouse.ID,
3387
+				GoodId:                  goods.GoodId,
3388
+				Number:                  warehouse.Number,
3389
+				ProductDate:             warehouse.ProductDate,
3390
+				ExpireDate:              warehouse.ExpiryDate,
3391
+				Count:                   stock_number,
3392
+				Price:                   warehouse.PackingPrice,
3393
+				Status:                  1,
3394
+				Ctime:                   time.Now().Unix(),
3395
+				UserOrgId:               orgID,
3396
+				Manufacturer:            warehouse.Manufacturer,
3397
+				Dealer:                  warehouse.Dealer,
3398
+				LicenseNumber:           warehouse.LicenseNumber,
3399
+				IsEdit:                  2,
3400
+				Creator:                 warehouseOut.Creater,
3401
+				SystemTime:              record_time,
3402
+				ConsumableType:          3,
3403
+				WarehouseOutDetailId:    lastOut.ID,
3404
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
3405
+				IsSys:                   1,
3406
+				PatientId:               patient_id,
3407
+				ProjectId:               goods.ProjectId,
3408
+				SupplyWarehouseId:       warehouse.SupplyWarehouseId,
3409
+				StorehouseId:            goods.StorehouseId,
3410
+				OverCount:               sum_count,
3411
+				BuyPrice:                warehouse.Price,
3412
+				RegisterNumber:          warehouse.RegisterNumber,
3413
+			}
3414
+			if orgID == 9671 || orgID == 10265 {
3415
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3416
+				flow.Price = goodsInfo.PackingPrice
3417
+				flow.BuyPrice = goodsInfo.BuyPrice
3418
+			}
3419
+			err := tx.Create(&flow).Error
3420
+			if err != nil {
3421
+				return err
3422
+			}
3423
+		}
3424
+		//退库
3425
+		if count < out_count-out_count_one {
3426
+			operation_time := time.Now().Unix()
3427
+
3428
+			//创建退库单
3429
+			timeStr := time.Now().Format("2006-01-02")
3430
+			timeArr := strings.Split(timeStr, "-")
3431
+			total, _ := FindAllCancelStockTotal(orgID)
3432
+			total = total + 1
3433
+			orderNumber := "CKTKD" + strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
3434
+
3435
+			cancelStock := models.CancelStock{
3436
+				OrderNumber:  orderNumber,
3437
+				OperaTime:    operation_time,
3438
+				OrgId:        orgID,
3439
+				Creater:      warehouseOut.Creater,
3440
+				Ctime:        time.Now().Unix(),
3441
+				Status:       1,
3442
+				ReturnTime:   record_time,
3443
+				Type:         1,
3444
+				StorehouseId: goods.StorehouseId,
3445
+				IsCheck:      1,
3446
+			}
3447
+			_, msgerrkonde := GetCancelStockDetailByOrderNumberOne(record_time, orgID)
3448
+			if msgerrkonde == gorm.ErrRecordNotFound {
3449
+				err := tx.Create(&cancelStock).Error
3450
+				if err != nil {
3451
+					return err
3452
+				}
3453
+			}
3454
+
3455
+			cancel, _ := GetLastCancelStockById(orgID)
3456
+
3457
+			manufacturer, _ := GetManufactureById(warehouse.Manufacturer)
3458
+			deaerler, _ := GetDealerById(warehouse.Dealer)
3459
+			cancelStockInfo := models.CancelStockInfo{
3460
+				GoodId:          goods.GoodId,
3461
+				CancelStockId:   cancel.ID,
3462
+				GoodTypeId:      goods.GoodTypeId,
3463
+				Count:           out_count - out_count_one - count,
3464
+				Price:           warehouse.PackingPrice,
3465
+				Total:           0,
3466
+				ProductDate:     warehouse.ProductDate,
3467
+				ExpiryDate:      warehouse.ExpiryDate,
3468
+				Ctime:           time.Now().Unix(),
3469
+				Status:          1,
3470
+				OrgId:           orgID,
3471
+				OrderNumber:     cancel.OrderNumber,
3472
+				Type:            0,
3473
+				Dealer:          deaerler.DealerName,
3474
+				Manufacturer:    manufacturer.ManufacturerName,
3475
+				Number:          warehouse.Number,
3476
+				RegisterAccount: "",
3477
+				Remark:          "",
3478
+				WarehouseInfoId: warehouse.ID,
3479
+				PatientId:       patient_id,
3480
+				RecordDate:      record_time,
3481
+				StorehouseId:    goods.StorehouseId,
3482
+				IsCheck:         1,
3483
+			}
3484
+			if orgID == 9671 || orgID == 10265 {
3485
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3486
+				cancelStockInfo.Price = goodsInfo.PackingPrice
3487
+			}
3488
+			err := tx.Create(&cancelStockInfo).Error
3489
+			if err != nil {
3490
+				return err
3491
+			}
3492
+
3493
+			cancelInfo, _ := GetLastCancelStockInfoByGoodId(goods.GoodId)
3494
+
3495
+			flow := models.VmStockFlow{
3496
+				WarehousingId:           warehouse.ID,
3497
+				GoodId:                  goods.GoodId,
3498
+				Number:                  warehouse.Number,
3499
+				LicenseNumber:           warehouse.LicenseNumber,
3500
+				Count:                   out_count - count,
3501
+				UserOrgId:               orgID,
3502
+				PatientId:               patient_id,
3503
+				SystemTime:              record_time,
3504
+				ConsumableType:          7,
3505
+				IsSys:                   1,
3506
+				WarehousingOrder:        "",
3507
+				WarehouseOutId:          lastOut.WarehouseOutId,
3508
+				WarehouseOutOrderNumber: lastOut.WarehouseOutOrderNumber,
3509
+				IsEdit:                  0,
3510
+				CancelStockId:           cancel.ID,
3511
+				CancelOrderNumber:       cancel.OrderNumber,
3512
+				Manufacturer:            manufacturer.ID,
3513
+				Dealer:                  0,
3514
+				Creator:                 warehouseOut.Creater,
3515
+				UpdateCreator:           0,
3516
+				Status:                  1,
3517
+				Ctime:                   time.Now().Unix(),
3518
+				Mtime:                   0,
3519
+				Price:                   warehouse.PackingPrice,
3520
+				WarehousingDetailId:     warehouse.ID,
3521
+				WarehouseOutDetailId:    lastOut.ID,
3522
+				CancelOutDetailId:       cancelInfo.ID,
3523
+				ProductDate:             warehouse.ProductDate,
3524
+				ExpireDate:              warehouse.ExpiryDate,
3525
+				StorehouseId:            goods.StorehouseId,
3526
+				BuyPrice:                warehouse.Price,
3527
+				ProjectId:               goods.ProjectId,
3528
+				OverCount:               sum_count,
3529
+				RegisterNumber:          warehouse.RegisterNumber,
3530
+			}
3531
+			if orgID == 9671 || orgID == 10265 {
3532
+				goodsInfo, _ := FindeGoodInfo(orgID, goods.ProjectId)
3533
+				flow.Price = goodsInfo.PackingPrice
3534
+				flow.BuyPrice = goodsInfo.BuyPrice
3535
+			}
3536
+
3537
+			err = tx.Create(&flow).Error
3538
+			if err != nil {
3539
+				return err
3540
+			}
3541
+		}
3542
+
3543
+		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
3544
+		goods.Count = deliver_number - stock_number
3545
+
3546
+		ConsumablesGoodDelivery(orgID, patient_id, record_time, goods, warehouseOut, count)
3547
+
3548
+	}
3549
+	return err
3550
+}

+ 1 - 1
service/patient_service.go 查看文件

@@ -1923,7 +1923,7 @@ func GetDialysisCount(orgid int64, partitionid int64) (order []*models.BloodDial
1923 1923
 
1924 1924
 func UpdatePatientDialysisSolutionOne(patientid int64, orgid int64, prescription *models.DialysisPrescription, timenow int64) error {
1925 1925
 
1926
-	err = XTWriteDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and record_date = ? ", patientid, orgid, timenow).Updates(map[string]interface{}{"dialyzer": prescription.Dialyzer, "anticoagulant": prescription.Anticoagulant, "mode_id": prescription.ModeId, "dialysis_duration_hour": prescription.DialysisDurationHour, "anticoagulant_shouji": prescription.AnticoagulantShouji, "anticoagulant_weichi": prescription.AnticoagulantWeichi, "anticoagulant_zongliang": prescription.AnticoagulantZongliang, "kalium": prescription.Kalium, "sodium": prescription.Sodium, "calcium": prescription.Calcium, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus, "blood_access": prescription.BloodAccess, "dialysate_flow": prescription.DialysateFlow, "dialysate_temperature": prescription.DialysateTemperature, "dialysis_dialyszers": prescription.DialysisDialyszers, "dialysis_irrigation": prescription.DialysisIrrigation, "plasma_separator": prescription.PlasmaSeparator, "bilirubin_adsorption_column": prescription.BilirubinAdsorptionColumn, "oxygen_uptake": prescription.OxygenUptake, "oxygen_flow": prescription.OxygenFlow, "oxygen_time": prescription.OxygenTime}).Error
1926
+	err = XTWriteDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and record_date = ? ", patientid, orgid, timenow).Updates(map[string]interface{}{"dialyzer": prescription.Dialyzer, "anticoagulant": prescription.Anticoagulant, "mode_id": prescription.ModeId, "dialysis_duration_hour": prescription.DialysisDurationHour, "anticoagulant_shouji": prescription.AnticoagulantShouji, "anticoagulant_weichi": prescription.AnticoagulantWeichi, "anticoagulant_zongliang": prescription.AnticoagulantZongliang, "kalium": prescription.Kalium, "sodium": prescription.Sodium, "calcium": prescription.Calcium, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus, "blood_access": prescription.BloodAccess, "dialysate_flow": prescription.DialysateFlow, "dialysate_temperature": prescription.DialysateTemperature, "dialysis_dialyszers": prescription.DialysisDialyszers, "dialysis_irrigation": prescription.DialysisIrrigation, "plasma_separator": prescription.PlasmaSeparator, "bilirubin_adsorption_column": prescription.BilirubinAdsorptionColumn, "oxygen_uptake": prescription.OxygenUptake, "oxygen_flow": prescription.OxygenFlow, "oxygen_time": prescription.OxygenTime, "dialysis_strainer": prescription.DialysisStrainer}).Error
1927 1927
 	return err
1928 1928
 }
1929 1929
 

+ 44 - 0
service/patientmanage_service.go 查看文件

@@ -1912,3 +1912,47 @@ func UpdateDialysisOrderSix(patient_id int64, dialysis_date int64, user_org_id i
1912 1912
 
1913 1913
 	return order, err
1914 1914
 }
1915
+
1916
+func CreatePatientFirstDisease(firstdisease models.XtPatientFirstDisease) error {
1917
+
1918
+	err := XTWriteDB().Create(&firstdisease).Error
1919
+	return err
1920
+}
1921
+
1922
+func GetPatientDiseaseList(org_id int64, patient_id int64, start_time int64, end_time int64) (disease []*models.XtPatientFirstDisease, err error) {
1923
+
1924
+	db := XTReadDB().Model(&disease).Where("status=1")
1925
+
1926
+	if org_id > 0 {
1927
+		db = db.Where("user_org_id =?", org_id)
1928
+	}
1929
+	if patient_id > 0 {
1930
+		db = db.Where("patient_id = ?", patient_id)
1931
+	}
1932
+	if start_time > 0 {
1933
+		db = db.Where("record_date >=?", start_time)
1934
+	}
1935
+	if end_time > 0 {
1936
+		db = db.Where("record_date<=?", end_time)
1937
+	}
1938
+	err = db.Find(&disease).Error
1939
+	return disease, err
1940
+}
1941
+
1942
+func GetFirstDetailById(id int64) (models.XtPatientFirstDisease, error) {
1943
+
1944
+	disease := models.XtPatientFirstDisease{}
1945
+	err = XTReadDB().Where("id = ? and status= 1", id).Find(&disease).Error
1946
+	return disease, err
1947
+}
1948
+
1949
+func UpdatePatientFirstDisease(disease models.XtPatientFirstDisease, id int64) error {
1950
+
1951
+	err := XTWriteDB().Model(&models.XtPatientFirstDisease{}).Where("id =? and status = 1", id).Update(map[string]interface{}{"title": disease.Title, "doctor": disease.Doctor, "record_date": disease.RecordDate, "main_content": disease.MainContent, "patient_case": disease.PatientCase, "tentative_diagnosis": disease.TentativeDiagnosis, "diagnostic_basis": disease.DiagnosticBasis, "differential_diagnosis": disease.DifferentialDiagnosis, "treatment_plan": disease.TreatmentPlan}).Error
1952
+	return err
1953
+}
1954
+
1955
+func DeleteFirstDisease(id []string) error {
1956
+	err := XTWriteDB().Model(models.XtPatientFirstDisease{}).Where("id in (?) and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
1957
+	return err
1958
+}

+ 8 - 0
service/pharmacy_service.go 查看文件

@@ -601,6 +601,7 @@ func DispensingMedicine(orgid, patient_id, stime, etime, creater int64) (err err
601 601
 			if PettyCash(v.DrugId) {
602 602
 				continue
603 603
 			}
604
+			//判断药品库存是否充足
604 605
 			kou := FenDrugInventory(v, orgid)
605 606
 			if !kou {
606 607
 				err = fmt.Errorf(FindDrugsName(v.DrugId) + "库存不足")
@@ -757,6 +758,9 @@ func DrugWithdrawal(orgid, patient_id, stime, etime, creater int64) (err error)
757 758
 		}
758 759
 
759 760
 		UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
761
+		//扣减库存
762
+		UpdateDrugStockCount(v.DrugId, v.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
763
+
760 764
 	}
761 765
 
762 766
 	err = tx.Raw("select id,dispensing_time from xt_doctor_advice where status = 1 and (advice_type = 2 or advice_type = 3) and created_time >= ? and created_time <= ? and "+
@@ -808,6 +812,8 @@ func DrugWithdrawal(orgid, patient_id, stime, etime, creater int64) (err error)
808 812
 			sum_count += its.StockMaxNumber + its.StockMinNumber
809 813
 		}
810 814
 		UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
815
+		//扣减库存
816
+		UpdateDrugStockCount(v.DrugId, v.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
811 817
 	}
812 818
 
813 819
 	//删除掉发药明细
@@ -1107,6 +1113,8 @@ func FenStock(orgid, creater int64, v *models.HisDoctorAdviceInfo) (err error) {
1107 1113
 		sum_count += its.StockMaxNumber + its.StockMinNumber
1108 1114
 	}
1109 1115
 	UpdateBaseDrugSumTwo(v.DrugId, sum_count, orgid)
1116
+	//扣减库存
1117
+	UpdateDrugStockCount(v.DrugId, v.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
1110 1118
 	return
1111 1119
 }
1112 1120
 

+ 1 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go 查看文件

@@ -220,6 +220,7 @@ type PrescriptionVM struct {
220 220
 	DialysisFluidFlow          string  `gorm:"column:dialysis_fluid_flow" json:"dialysis_fluid_flow" form:"dialysis_fluid_flow"`
221 221
 	SodiumBicarbonateFlow      string  `gorm:"column:sodium_bicarbonate_flow" json:"sodium_bicarbonate_flow" form:"sodium_bicarbonate_flow"`
222 222
 	DisplaceSpeed              string  `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
223
+	DialysisStrainer           string  `gorm:"column:dialysis_strainer" json:"dialysis_strainer" form:"dialysis_strainer"`
223 224
 }
224 225
 
225 226
 func (PrescriptionVM) TableName() string {

+ 11 - 1
service/self_drug_service.go 查看文件

@@ -1241,6 +1241,7 @@ func GetGoodWarehouseInfoByOrgId(orgid int64, storehouse_id int64) (info []*mode
1241 1241
 	if orgid > 0 {
1242 1242
 		db = db.Where("org_id = ?", orgid)
1243 1243
 	}
1244
+
1244 1245
 	if storehouse_id > 0 {
1245 1246
 		db = db.Where("storehouse_id = ?", storehouse_id)
1246 1247
 	}
@@ -1808,10 +1809,13 @@ func GetDrugStockCountList(orgId int64, storehouse_id int64, good_type int64, ke
1808 1809
 
1809 1810
 	offset := (page - 1) * limit
1810 1811
 	likeKey := "%" + keyword + "%"
1811
-	db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
1812
+	db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1 AND find_in_set('停用',x.drug_status) = 0")
1812 1813
 	if good_type == 2 {
1813 1814
 		db = db.Where("x.total_count<=x.drug_stock_limit")
1814 1815
 	}
1816
+	if good_type == 3 {
1817
+		db = db.Where("x.sum_count = 0")
1818
+	}
1815 1819
 	if storehouse_id > 0 {
1816 1820
 		db = db.Preload("DrugWarehouseInfo", "org_id = ? and status = 1 and storehouse_id = ? and is_check = 1", orgId, storehouse_id)
1817 1821
 
@@ -1876,6 +1880,12 @@ func GetAllGoodListSeven(orgid int64) (good []*models.GoodInfoSeven, err error)
1876 1880
 	return good, err
1877 1881
 }
1878 1882
 
1883
+func GetAllGoodListEight(orgid int64) (good []*models.GoodInfoSeven, err error) {
1884
+
1885
+	err = XTReadDB().Where("org_id = ? and status = 1  AND find_in_set('停用',good_status) = 0", orgid).Find(&good).Error
1886
+	return good, err
1887
+}
1888
+
1879 1889
 func GetGoodInformationWarehouseInfo(good_id int64, orgid int64) (info []*models.WarehousingInfoTen, err error) {
1880 1890
 
1881 1891
 	err = XTReadDB().Where("good_id = ? and org_id = ? and status = 1 and is_check = 1 and stock_count > 0", good_id, orgid).Find(&info).Error

+ 9 - 3
service/stock_service.go 查看文件

@@ -3392,7 +3392,7 @@ func PostSearchStock(keyword string, orgid int64) (goods []*models.GoodsType, er
3392 3392
 }
3393 3393
 
3394 3394
 func GetStockType(orgid int64) (goodstype []*models.GoodsTypeOne, err error) {
3395
-	err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3)", orgid).
3395
+	err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3 or stock_attribute = 4)", orgid).
3396 3396
 		Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&goodstype).Error
3397 3397
 	return goodstype, err
3398 3398
 }
@@ -3878,8 +3878,8 @@ func UpdateAutoGood(orgid int64, patient_id int64, recordtime int64, goodid int6
3878 3878
 	err = XTWriteDB().Model(models.BloodAutomaticReduceDetail{}).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ?", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3879 3879
 	err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3880 3880
 	//err = XTWriteDB().Model(models.WarehouseOutInfo{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("over_count", gorm.Expr("over_count + ?", count)).Error
3881
-	err = XTWriteDB().Model(&models.DialysisBeforePrepare{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3882
-	err = XTWriteDB().Model(&models.VmStockFlow{}).Where("org_id = ? and patient_id = ? and sys_record_time = ? and good_id = ? and status = 1 and project_id = ?", orgid, patient_id, recordtime, goodid, project_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3881
+	err = XTWriteDB().Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? and patient_id = ? and record_date = ? and good_id = ? and status = 1", orgid, patient_id, recordtime, goodid).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3882
+	//err = XTWriteDB().Model(&models.VmStockFlow{}).Where("user_org_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1 and project_id = ?", orgid, patient_id, recordtime, goodid, project_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3883 3883
 	return err
3884 3884
 }
3885 3885
 
@@ -5068,6 +5068,12 @@ func UpdatedStockFlowOne(flow models.VmStockFlow, warehousing_id int64, patient_
5068 5068
 	return err
5069 5069
 }
5070 5070
 
5071
+func UpdatedStockFlowFive(flow models.VmStockFlow, warehouse_out_id int64, patient_id int64, record_time int64, good_id int64) error {
5072
+
5073
+	err = XTWriteDB().Model(&flow).Where("warehouse_out_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehouse_out_id, patient_id, record_time, good_id).Updates(map[string]interface{}{"number": flow.Number, "license_number": flow.LicenseNumber, "count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer, "over_count": flow.OverCount}).Error
5074
+	return err
5075
+}
5076
+
5071 5077
 func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (*models.VmStockFlow, error) {
5072 5078
 
5073 5079
 	stock := models.VmStockFlow{}

文件差異過大導致無法顯示
+ 0 - 6109
service/warhouse_service.go