28169 4 viikkoa sitten
vanhempi
commit
daecf606fc

+ 4 - 4
controllers/base_api_controller.go Näytä tiedosto

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 11
84
-		subscibe.OrgId = 10489 //机构id 10344
84
+		subscibe.OrgId = 10480 //机构id 10344
85 85
 		subscibe.PeriodStart = 1547447814
86 86
 		subscibe.PeriodEnd = 1550039814
87 87
 		subscibe.State = 1
@@ -91,7 +91,7 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 10489 //机构id小英9675或4
94
+		adminUserInfo.CurrentOrgId = 10480 //机构id小英9675或4
95 95
 		adminUserInfo.CurrentAppId = 3467  //4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 11
329
-		subscibe.OrgId = 10489 //机构id小英10344或4
329
+		subscibe.OrgId = 10480 //机构id小英10344或4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -336,7 +336,7 @@ func (this *BaseServeAPIController) Prepare() {
336 336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337 337
 		subscibes[4] = &subscibe
338 338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 10489 //机构id小英9675或4
339
+		adminUserInfo.CurrentOrgId = 10480 //机构id小英9675或4
340 340
 		adminUserInfo.CurrentAppId = 3467  //4
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes

+ 53 - 3
controllers/common_api_controller.go Näytä tiedosto

@@ -2119,9 +2119,6 @@ func (this *CommonApiController) GetCountModeId() {
2119 2119
 	mode_id, _ := this.GetInt64("mode_id")
2120 2120
 	adminUserInfo := this.GetAdminUserInfo()
2121 2121
 	orgId := adminUserInfo.CurrentOrgId
2122
-	fmt.Println("start_time", start_time)
2123
-	fmt.Println("end_time", end_time)
2124
-	fmt.Println("mode_id", mode_id)
2125 2122
 
2126 2123
 	modeCount, err := service.GetCountModeId(start_time, end_time, mode_id, orgId)
2127 2124
 	if err != nil {
@@ -2167,3 +2164,56 @@ func (this *CommonApiController) GetCheckExamine() {
2167 2164
 	//cfydb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 6)  //c反应蛋白
2168 2165
 	//
2169 2166
 }
2167
+
2168
+func (this *CommonApiController) GetPatientInspectionList() {
2169
+
2170
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2171
+
2172
+	list, _ := service.GetAllPatientListMap(orgId)
2173
+	if len(list) > 0 {
2174
+		for _, item := range list {
2175
+			befor, _ := service.GetLastBefor(item.ID)
2176
+			item.BeforSystolicBloodPressure = befor.SystolicBloodPressure
2177
+			item.BeforDiastolicBloodPressure = befor.DiastolicBloodPressure
2178
+
2179
+			after, _ := service.GetLastRecordAfter(item.ID)
2180
+			item.AfterSystolicBloodPressure = after.SystolicBloodPressure
2181
+			item.AfterDiastolicBloodPressure = after.DiastolicBloodPressure
2182
+			item.KTV = after.Ktv
2183
+			item.URR = after.Urr
2184
+
2185
+			list, _ := service.GetInspectionByPatientId(item.ID, 169)
2186
+			item.XueLin = list.InspectValue
2187
+			listOne, _ := service.GetInspectionByPatientId(item.ID, 17)
2188
+			item.XueHongDanBai = listOne.InspectValue
2189
+			listTwo, _ := service.GetInspectionByPatientId(item.ID, 54)
2190
+			item.XueHongDanBai = listTwo.InspectValue
2191
+
2192
+			listThree, _ := service.GetInspectionByPatientId(item.ID, 111215)
2193
+			item.JiaoZhengGai = listThree.InspectValue
2194
+
2195
+			listFour, _ := service.GetInspectionByPatientId(item.ID, 170)
2196
+			item.JiaPanSu = listFour.InspectValue
2197
+
2198
+			listFive, _ := service.GetInspectionByPatientId(item.ID, 176)
2199
+			item.YiTieDanBai = listFive.InspectValue
2200
+
2201
+			listSix, _ := service.GetInspectionByPatientId(item.ID, 1506)
2202
+			item.TieDanBai = listSix.InspectValue
2203
+
2204
+			listSeven, _ := service.GetInspectionByPatientId(item.ID, 183)
2205
+			item.TieDanBai = listSeven.InspectValue
2206
+
2207
+			listEight, _ := service.GetInspectionByPatientId(item.ID, 182)
2208
+			item.Crp = listEight.InspectValue
2209
+
2210
+			listNight, _ := service.GetInspectionByPatientId(item.ID, 42)
2211
+			item.Mg = listNight.InspectValue
2212
+
2213
+		}
2214
+	}
2215
+
2216
+	this.ServeSuccessJSON(map[string]interface{}{
2217
+		"list": list,
2218
+	})
2219
+}

+ 2 - 0
controllers/common_api_router.go Näytä tiedosto

@@ -64,4 +64,6 @@ func CommonApiControllersRegisterRouters() {
64 64
 
65 65
 	beego.Router("/com/api/getcheckexamine", &CommonApiController{}, "Get:GetCheckExamine")
66 66
 
67
+	beego.Router("/com/api/getpatientinspectionlist", &CommonApiController{}, "Get:GetPatientInspectionList")
68
+
67 69
 }

+ 6 - 9
controllers/dialysis_api_controller.go Näytä tiedosto

@@ -5934,20 +5934,17 @@ func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
5934 5934
 	//获取长期医嘱
5935 5935
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
5936 5936
 
5937
-	longHisAdviceList, _ := service.GetAllHisAdviceTemplateList(orgId)
5938
-
5939 5937
 	_, config := service.FindXTHisRecordByOrgId(orgId)
5940 5938
 
5941 5939
 	drugList, _ := service.GetAllBaseDrugListTwenty(orgId)
5942 5940
 	if err == nil {
5943 5941
 		this.ServeSuccessJSON(map[string]interface{}{
5944
-			"list":              list,
5945
-			"total":             total,
5946
-			"adviceList":        adviceList,
5947
-			"config":            config,
5948
-			"drugList":          drugList,
5949
-			"tablelist":         tablelist,
5950
-			"longHisAdviceList": longHisAdviceList,
5942
+			"list":       list,
5943
+			"total":      total,
5944
+			"adviceList": adviceList,
5945
+			"config":     config,
5946
+			"drugList":   drugList,
5947
+			"tablelist":  tablelist,
5951 5948
 		})
5952 5949
 		return
5953 5950
 

File diff suppressed because it is too large
+ 641 - 328
controllers/his_api_controller.go


+ 1 - 1
controllers/mobile_api_controllers/dialysis_api_controller.go Näytä tiedosto

@@ -8353,7 +8353,7 @@ func (c *DialysisAPIController) GetPatientDialysisRecordList() {
8353 8353
 	//	})
8354 8354
 	//	return
8355 8355
 	//}
8356
-	if org_id == 9538 || org_id == 10101 || org_id == 10353 {
8356
+	if org_id == 9538 || org_id == 10101 || org_id == 10353 || org_id == 9946 {
8357 8357
 		list, _ := service.GetPatientDialysisRecordList(id, startdateunix, enddateunix)
8358 8358
 		c.ServeSuccessJSON(map[string]interface{}{
8359 8359
 			"list": list,

+ 5 - 6
controllers/mobile_api_controllers/patient_api_controller.go Näytä tiedosto

@@ -659,7 +659,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
659 659
 
660 660
 			for _, item := range advices {
661 661
 				//恒泰中医院
662
-				if item.UserOrgId == 10490 {
662
+				if item.UserOrgId == 10490 || item.UserOrgId == 10602 {
663 663
 					if item.DrugId == 0 || item.DrugNameId == 0 {
664 664
 						//从字典里面查找
665 665
 						drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
@@ -692,7 +692,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
692 692
 			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
693 693
 			for _, item := range advices {
694 694
 				//恒泰中医院
695
-				if item.UserOrgId == 10490 {
695
+				if item.UserOrgId == 10490 || item.UserOrgId == 10602 {
696 696
 					if item.DrugId == 0 || item.DrugNameId == 0 {
697 697
 						//从字典里面查找
698 698
 						drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
@@ -1269,7 +1269,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1269 1269
 		})
1270 1270
 		return
1271 1271
 	} else if origin == 2 {
1272
-		fmt.Println("缉拿咯喔我我哦我我")
1272
+
1273 1273
 		adminInfo := c.GetMobileAdminUserInfo()
1274 1274
 		creater := c.GetMobileAdminUserInfo().AdminUser.Id
1275 1275
 		var ids []string
@@ -1457,6 +1457,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1457 1457
 						drug_count += its.Count
1458 1458
 					}
1459 1459
 				}
1460
+
1460 1461
 				if total_count == drug_count {
1461 1462
 
1462 1463
 					advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
@@ -1664,9 +1665,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1664 1665
 				}
1665 1666
 
1666 1667
 				//
1667
-				fmt.Println("config.IsOpen", config.IsOpen)
1668
-				fmt.Println("config.IsOpen", item.UserOrgId)
1669
-				if config.IsOpen == 1 && item.UserOrgId == 10375 {
1668
+				if config.IsOpen == 1 && item.UserOrgId == 10210 {
1670 1669
 
1671 1670
 					service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1672 1671
 					//更新字典里面的库存

File diff suppressed because it is too large
+ 418 - 743
controllers/patient_dataconfig_api_controller.go


+ 3 - 2
controllers/self_drug_api_congtroller.go Näytä tiedosto

@@ -4109,8 +4109,9 @@ func (this *SelfDrugApiController) GetDrugFlowDetailById() {
4109 4109
 
4110 4110
 	drug_id, _ := this.GetInt64("drug_id")
4111 4111
 
4112
-	list, _ := service.GetDrugFlowDetailById(drug_id)
4113
-
4112
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4113
+	list, _ := service.GetDrugFlowDetailById(drug_id, orgId)
4114
+	fmt.Println("list====================", list)
4114 4115
 	drugMedical, _ := service.GetBaseDrugMedical(drug_id)
4115 4116
 
4116 4117
 	for index, _ := range list {

+ 2 - 0
models/device_models.go Näytä tiedosto

@@ -993,6 +993,8 @@ type XtAssessmentAfterDislysis struct {
993 993
 	CvcV                            float64 `gorm:"column:cvc_v" json:"cvc_v" form:"cvc_v"`
994 994
 	Channel                         int64   `gorm:"column:channel" json:"channel" form:"channel"`
995 995
 	SealingFluidDispose             string  `gorm:"column:sealing_fluid_dispose" json:"sealing_fluid_dispose" form:"sealing_fluid_dispose"`
996
+	Ktv                             string  `gorm:"column:ktv" json:"ktv" form:"ktv"`
997
+	Urr                             string  `gorm:"column:urr" json:"urr" form:"urr"`
996 998
 }
997 999
 
998 1000
 func (XtAssessmentAfterDislysis) TableName() string {

+ 126 - 271
models/patient_models.go Näytä tiedosto

@@ -2549,283 +2549,54 @@ func (XtMedicalHistory) TableName() string {
2549 2549
 
2550 2550
 // 评分系统
2551 2551
 type XtPatientFallassessment struct {
2552
-	ID               int64 `gorm:"column:id" json:"id" form:"id"`
2553
-	PatientId        int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2554
-	UserOrgId        int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2555
-	RecordDate       int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
2556
-	PingDate         int64 `gorm:"column:ping_date" json:"ping_date" form:"ping_date"`
2557
-	AdminUserId      int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2558
-	Status           int64 `gorm:"column:status" json:"status" form:"status"`
2559
-	IsCheck          int64 `gorm:"column:is_check" json:"is_check" form:"is_check"`
2560
-	IsCheckOne       int64 `gorm:"column:is_check_one" json:"is_check_one" form:"is_check_one"`
2561
-	IsCheckTwo       int64 `gorm:"column:is_check_two" json:"is_check_two" form:"is_check_two"`
2562
-	IsCheckThree     int64 `gorm:"column:is_check_three" json:"is_check_three" form:"is_check_three"`
2563
-	IsCheckFour      int64 `gorm:"column:is_check_four" json:"is_check_four" form:"is_check_four"`
2564
-	IsCheckFive      int64 `gorm:"column:is_check_five" json:"is_check_five" form:"is_check_five"`
2565
-	IsCheckSix       int64 `gorm:"column:is_check_six" json:"is_check_six" form:"is_check_six"`
2566
-	IsCheckSeven     int64 `gorm:"column:is_check_seven" json:"is_check_seven" form:"is_check_seven"`
2567
-	IsCheckEight     int64 `gorm:"column:is_check_eight" json:"is_check_eight" form:"is_check_eight"`
2568
-	IsCheckNight     int64 `gorm:"column:is_check_night" json:"is_check_night" form:"is_check_night"`
2569
-	IsCheckTen       int64 `gorm:"column:is_check_ten" json:"is_check_ten" form:"is_check_ten"`
2570
-	IsCheckEleven    int64 `gorm:"column:is_check_eleven" json:"is_check_eleven" form:"is_check_eleven"`
2571
-	IsCheckTwelve    int64 `gorm:"column:is_check_twelve" json:"is_check_twelve" form:"is_check_twelve"`
2572
-	IsCheckThirteen  int64 `gorm:"column:is_check_thirteen" json:"is_check_thirteen" form:"is_check_thirteen"`
2573
-	IsCheckFourteen  int64 `gorm:"column:is_check_fourteen" json:"is_check_fourteen" form:"is_check_fourteen"`
2574
-	IsCheckFifteen   int64 `gorm:"column:is_check_fifteen" json:"is_check_fifteen" form:"is_check_fifteen"`
2575
-	IsCheckSixteen   int64 `gorm:"column:is_check_sixteen" json:"is_check_sixteen" form:"is_check_sixteen"`
2576
-	IsCheckSeventeen int64 `gorm:"column:is_check_seventeen" json:"is_check_seventeen" form:"is_check_seventeen"`
2577
-	IsCheckEighteen  int64 `gorm:"column:is_check_eighteen" json:"is_check_eighteen" form:"is_check_eighteen"`
2578
-	IsCheckNineteen  int64 `gorm:"column:is_check_nineteen" json:"is_check_nineteen" form:"is_check_nineteen"`
2579
-	Ctime            int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
2580
-	Mtime            int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
2581
-	Total            int64 `gorm:"column:total" json:"total" form:"total"`
2552
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
2553
+	PatientId        int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2554
+	UserOrgId        int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2555
+	RecordDate       int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2556
+	PingDate         int64  `gorm:"column:ping_date" json:"ping_date" form:"ping_date"`
2557
+	AdminUserId      int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2558
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
2559
+	IsCheck          int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
2560
+	IsCheckOne       int64  `gorm:"column:is_check_one" json:"is_check_one" form:"is_check_one"`
2561
+	IsCheckTwo       int64  `gorm:"column:is_check_two" json:"is_check_two" form:"is_check_two"`
2562
+	IsCheckThree     int64  `gorm:"column:is_check_three" json:"is_check_three" form:"is_check_three"`
2563
+	IsCheckFour      int64  `gorm:"column:is_check_four" json:"is_check_four" form:"is_check_four"`
2564
+	IsCheckFive      int64  `gorm:"column:is_check_five" json:"is_check_five" form:"is_check_five"`
2565
+	IsCheckSix       int64  `gorm:"column:is_check_six" json:"is_check_six" form:"is_check_six"`
2566
+	IsCheckSeven     int64  `gorm:"column:is_check_seven" json:"is_check_seven" form:"is_check_seven"`
2567
+	IsCheckEight     int64  `gorm:"column:is_check_eight" json:"is_check_eight" form:"is_check_eight"`
2568
+	IsCheckNight     int64  `gorm:"column:is_check_night" json:"is_check_night" form:"is_check_night"`
2569
+	IsCheckTen       int64  `gorm:"column:is_check_ten" json:"is_check_ten" form:"is_check_ten"`
2570
+	IsCheckEleven    int64  `gorm:"column:is_check_eleven" json:"is_check_eleven" form:"is_check_eleven"`
2571
+	IsCheckTwelve    int64  `gorm:"column:is_check_twelve" json:"is_check_twelve" form:"is_check_twelve"`
2572
+	IsCheckThirteen  int64  `gorm:"column:is_check_thirteen" json:"is_check_thirteen" form:"is_check_thirteen"`
2573
+	IsCheckFourteen  int64  `gorm:"column:is_check_fourteen" json:"is_check_fourteen" form:"is_check_fourteen"`
2574
+	IsCheckFifteen   int64  `gorm:"column:is_check_fifteen" json:"is_check_fifteen" form:"is_check_fifteen"`
2575
+	IsCheckSixteen   int64  `gorm:"column:is_check_sixteen" json:"is_check_sixteen" form:"is_check_sixteen"`
2576
+	IsCheckSeventeen int64  `gorm:"column:is_check_seventeen" json:"is_check_seventeen" form:"is_check_seventeen"`
2577
+	IsCheckEighteen  int64  `gorm:"column:is_check_eighteen" json:"is_check_eighteen" form:"is_check_eighteen"`
2578
+	IsCheckNineteen  int64  `gorm:"column:is_check_nineteen" json:"is_check_nineteen" form:"is_check_nineteen"`
2579
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2580
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2581
+	Total            int64  `gorm:"column:total" json:"total" form:"total"`
2582
+	Content          string `gorm:"column:content" json:"content" form:"content"`
2583
+	ContentOne       string `gorm:"column:content_one" json:"content_one" form:"content_one"`
2584
+	ContentTwo       string `gorm:"column:content_two" json:"content_two" form:"content_two"`
2585
+	ContentThree     string `gorm:"column:content_three" json:"content_three" form:"content_three"`
2586
+	ContentFour      string `gorm:"column:content_four" json:"content_four" form:"content_four"`
2587
+	ContentFive      string `gorm:"column:content_five" json:"content_five" form:"content_five"`
2588
+	ContentSix       string `gorm:"column:content_six" json:"content_six" form:"content_six"`
2589
+	ContentSeven     string `gorm:"column:content_seven" json:"content_seven" form:"content_seven"`
2590
+	ContentEight     string `gorm:"column:content_eight" json:"content_eight" form:"content_eight"`
2591
+	ContentNight     string `gorm:"column:content_night" json:"content_night" form:"content_night"`
2592
+	ContentAdd       string `gorm:"column:content_add" json:"content_add" form:"content_add"`
2593
+	ContentAddOne    string `gorm:"column:content_add_one" json:"content_add_one" form:"content_add_one"`
2582 2594
 }
2583 2595
 
2584 2596
 func (XtPatientFallassessment) TableName() string {
2585 2597
 	return "xt_patient_fallassessment"
2586 2598
 }
2587 2599
 
2588
-type VmXtPatientFallassessment struct {
2589
-	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
2590
-	PatientId                      int64                             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2591
-	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2592
-	RecordDate                     int64                             `gorm:"column:record_date" json:"record_date" form:"record_date"`
2593
-	PingDate                       int64                             `gorm:"column:ping_date" json:"ping_date" form:"ping_date"`
2594
-	AdminUserId                    int64                             `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2595
-	Status                         int64                             `gorm:"column:status" json:"status" form:"status"`
2596
-	IsCheck                        int64                             `gorm:"column:is_check" json:"is_check" form:"is_check"`
2597
-	IsCheckOne                     int64                             `gorm:"column:is_check_one" json:"is_check_one" form:"is_check_one"`
2598
-	IsCheckTwo                     int64                             `gorm:"column:is_check_two" json:"is_check_two" form:"is_check_two"`
2599
-	IsCheckThree                   int64                             `gorm:"column:is_check_three" json:"is_check_three" form:"is_check_three"`
2600
-	IsCheckFour                    int64                             `gorm:"column:is_check_four" json:"is_check_four" form:"is_check_four"`
2601
-	IsCheckFive                    int64                             `gorm:"column:is_check_five" json:"is_check_five" form:"is_check_five"`
2602
-	IsCheckSix                     int64                             `gorm:"column:is_check_six" json:"is_check_six" form:"is_check_six"`
2603
-	IsCheckSeven                   int64                             `gorm:"column:is_check_seven" json:"is_check_seven" form:"is_check_seven"`
2604
-	IsCheckEight                   int64                             `gorm:"column:is_check_eight" json:"is_check_eight" form:"is_check_eight"`
2605
-	IsCheckNight                   int64                             `gorm:"column:is_check_night" json:"is_check_night" form:"is_check_night"`
2606
-	IsCheckTen                     int64                             `gorm:"column:is_check_ten" json:"is_check_ten" form:"is_check_ten"`
2607
-	IsCheckEleven                  int64                             `gorm:"column:is_check_eleven" json:"is_check_eleven" form:"is_check_eleven"`
2608
-	IsCheckTwelve                  int64                             `gorm:"column:is_check_twelve" json:"is_check_twelve" form:"is_check_twelve"`
2609
-	IsCheckThirteen                int64                             `gorm:"column:is_check_thirteen" json:"is_check_thirteen" form:"is_check_thirteen"`
2610
-	IsCheckFourteen                int64                             `gorm:"column:is_check_fourteen" json:"is_check_fourteen" form:"is_check_fourteen"`
2611
-	IsCheckFifteen                 int64                             `gorm:"column:is_check_fifteen" json:"is_check_fifteen" form:"is_check_fifteen"`
2612
-	IsCheckSixteen                 int64                             `gorm:"column:is_check_sixteen" json:"is_check_sixteen" form:"is_check_sixteen"`
2613
-	IsCheckSeventeen               int64                             `gorm:"column:is_check_seventeen" json:"is_check_seventeen" form:"is_check_seventeen"`
2614
-	IsCheckEighteen                int64                             `gorm:"column:is_check_eighteen" json:"is_check_eighteen" form:"is_check_eighteen"`
2615
-	IsCheckNineteen                int64                             `gorm:"column:is_check_nineteen" json:"is_check_nineteen" form:"is_check_nineteen"`
2616
-	Ctime                          int64                             `gorm:"column:ctime" json:"ctime" form:"ctime"`
2617
-	Mtime                          int64                             `gorm:"column:mtime" json:"mtime" form:"mtime"`
2618
-	Total                          int64                             `gorm:"column:total" json:"total" form:"total"`
2619
-	XtPatientFallassessmentAdd     []*XtPatientFallassessmentAdd     `json:"PatientFallassessmentAdd" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2620
-	XtPatientFallassessmentAddCopy []*XtPatientFallassessmentAddCopy `json:"PatientFallassessmentAddCopy" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2621
-	XtPatientFallassessmentAge     []*XtPatientFallassessmentAge     `json:"PatientFallassessmentAge" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2622
-	XtPatientFallassessmentBody    []*XtPatientFallassessmentBody    `json:"XtPatientFallassessmentBody" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2623
-	XtPatientFallassessmentCare    []*XtPatientFallassessmentCare    `json:"XtPatientFallassessmentCare" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2624
-	XtPatientFallassessmentExcrete []*XtPatientFallassessmentExcrete `json:"XtPatientFallassessmentExcrete" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2625
-	XtPatientFallassessmentFall    []*XtPatientFallassessmentFall    `json:"XtPatientFallassessmentFall" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2626
-	XtPatientFallassessmentHistory []*XtPatientFallassessmentHistory `json:"XtPatientFallassessmentHistory" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2627
-	XtPatientFallassessmentMedical []*XtPatientFallassessmentMedical `json:"XtPatientFallassessmentMedical" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2628
-	XtPatientFallassessmentOrgan   []*XtPatientFallassessmentOrgan   `json:"XtPatientFallassessmentOrgan" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2629
-	XtPatientFallassessmentPrevent []*XtPatientFallassessmentPrevent `json:"XtPatientFallassessmentPrevent" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2630
-	XtPatientFallassessmentRealize []*XtPatientFallassessmentRealize `json:"XtPatientFallassessmentRealize" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2631
-}
2632
-
2633
-func (VmXtPatientFallassessment) TableName() string {
2634
-	return "xt_patient_fallassessment"
2635
-}
2636
-
2637
-type XtPatientFallassessmentAdd struct {
2638
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2639
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2640
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2641
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2642
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2643
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2644
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2645
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2646
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2647
-}
2648
-
2649
-func (XtPatientFallassessmentAdd) TableName() string {
2650
-	return "xt_patient_fallassessment_add"
2651
-}
2652
-
2653
-type XtPatientFallassessmentAddCopy struct {
2654
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2655
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2656
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2657
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2658
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2659
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2660
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2661
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2662
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2663
-}
2664
-
2665
-func (XtPatientFallassessmentAddCopy) TableName() string {
2666
-	return "xt_patient_fallassessment_add_copy"
2667
-}
2668
-
2669
-type XtPatientFallassessmentAge struct {
2670
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2671
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2672
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2673
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2674
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2675
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2676
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2677
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2678
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2679
-}
2680
-
2681
-func (XtPatientFallassessmentAge) TableName() string {
2682
-	return "xt_patient_fallassessment_age"
2683
-}
2684
-
2685
-type XtPatientFallassessmentBody struct {
2686
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2687
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2688
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2689
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2690
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2691
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2692
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2693
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2694
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2695
-}
2696
-
2697
-func (XtPatientFallassessmentBody) TableName() string {
2698
-	return "xt_patient_fallassessment_body"
2699
-}
2700
-
2701
-type XtPatientFallassessmentCare struct {
2702
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2703
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2704
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2705
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2706
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2707
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2708
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2709
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2710
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2711
-}
2712
-
2713
-func (XtPatientFallassessmentCare) TableName() string {
2714
-	return "xt_patient_fallassessment_care"
2715
-}
2716
-
2717
-type XtPatientFallassessmentExcrete struct {
2718
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2719
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2720
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2721
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2722
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2723
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2724
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2725
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2726
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2727
-}
2728
-
2729
-func (XtPatientFallassessmentExcrete) TableName() string {
2730
-	return "xt_patient_fallassessment_excrete"
2731
-}
2732
-
2733
-type XtPatientFallassessmentFall struct {
2734
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2735
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2736
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2737
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2738
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2739
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2740
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2741
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2742
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2743
-}
2744
-
2745
-func (XtPatientFallassessmentFall) TableName() string {
2746
-	return "xt_patient_fallassessment_fall"
2747
-}
2748
-
2749
-type XtPatientFallassessmentHistory struct {
2750
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2751
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2752
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2753
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2754
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2755
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2756
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2757
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2758
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2759
-}
2760
-
2761
-func (XtPatientFallassessmentHistory) TableName() string {
2762
-	return "xt_patient_fallassessment_history"
2763
-}
2764
-
2765
-type XtPatientFallassessmentMedical struct {
2766
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2767
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2768
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2769
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2770
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2771
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2772
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2773
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2774
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2775
-}
2776
-
2777
-func (XtPatientFallassessmentMedical) TableName() string {
2778
-	return "xt_patient_fallassessment_medical"
2779
-}
2780
-
2781
-type XtPatientFallassessmentOrgan struct {
2782
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2783
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2784
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2785
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2786
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2787
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2788
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2789
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2790
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2791
-}
2792
-
2793
-func (XtPatientFallassessmentOrgan) TableName() string {
2794
-	return "xt_patient_fallassessment_organ"
2795
-}
2796
-
2797
-type XtPatientFallassessmentPrevent struct {
2798
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2799
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2800
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2801
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2802
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2803
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2804
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2805
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2806
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2807
-}
2808
-
2809
-func (XtPatientFallassessmentPrevent) TableName() string {
2810
-	return "xt_patient_fallassessment_prevent"
2811
-}
2812
-
2813
-type XtPatientFallassessmentRealize struct {
2814
-	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2815
-	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2816
-	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2817
-	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2818
-	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2819
-	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2820
-	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2821
-	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2822
-	Content       string `gorm:"column:content" json:"content" form:"content"`
2823
-}
2824
-
2825
-func (XtPatientFallassessmentRealize) TableName() string {
2826
-	return "xt_patient_fallassessment_realize"
2827
-}
2828
-
2829 2600
 type XtPatientPedFallssessment struct {
2830 2601
 	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2831 2602
 	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
@@ -2876,3 +2647,87 @@ type XtPatientCriticalOne struct {
2876 2647
 func (XtPatientCriticalOne) TableName() string {
2877 2648
 	return "xt_patient_critical_one"
2878 2649
 }
2650
+
2651
+type XtPatientBraden struct {
2652
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
2653
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2654
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2655
+	AdminUserId  int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2656
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2657
+	Total        int64  `gorm:"column:total" json:"total" form:"total"`
2658
+	FirstPingfen int64  `gorm:"column:first_pingfen" json:"first_pingfen" form:"first_pingfen"`
2659
+	TwoPingfen   int64  `gorm:"column:two_pingfen" json:"two_pingfen" form:"two_pingfen"`
2660
+	ThreePingfen int64  `gorm:"column:three_pingfen" json:"three_pingfen" form:"three_pingfen"`
2661
+	FourPingfen  int64  `gorm:"column:four_pingfen" json:"four_pingfen" form:"four_pingfen"`
2662
+	FivePingfen  int64  `gorm:"column:five_pingfen" json:"five_pingfen" form:"five_pingfen"`
2663
+	SixPingfen   int64  `gorm:"column:six_pingfen" json:"six_pingfen" form:"six_pingfen"`
2664
+	FamaliySign  string `gorm:"column:famaliy_sign" json:"famaliy_sign" form:"famaliy_sign"`
2665
+	PingDate     int64  `gorm:"column:ping_date" json:"ping_date" form:"ping_date"`
2666
+	FirstLapeso  int64  `gorm:"column:first_lapeso" json:"first_lapeso" form:"first_lapeso"`
2667
+	PingSign     string `gorm:"column:ping_sign" json:"ping_sign" form:"ping_sign"`
2668
+	LeaderSign   string `gorm:"column:leader_sign" json:"leader_sign" form:"leader_sign"`
2669
+	LeaderDate   int64  `gorm:"column:leader_date" json:"leader_date" form:"leader_date"`
2670
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2671
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2672
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
2673
+	FirstCheck   int64  `gorm:"column:first_check" json:"first_check" form:"first_check"`
2674
+	TwoCheck     int64  `gorm:"column:two_check" json:"two_check" form:"two_check"`
2675
+	ThreeCheck   int64  `gorm:"column:three_check" json:"three_check" form:"three_check"`
2676
+	FourCheck    int64  `gorm:"column:four_check" json:"four_check" form:"four_check"`
2677
+	FiveCheck    int64  `gorm:"column:five_check" json:"five_check" form:"five_check"`
2678
+	SixCheck     int64  `gorm:"column:six_check" json:"six_check" form:"six_check"`
2679
+	TwoLapeso    int64  `gorm:"column:two_lapeso" json:"two_lapeso" form:"two_lapeso"`
2680
+	ThreeLapeso  int64  `gorm:"column:three_lapeso" json:"three_lapeso" form:"three_lapeso"`
2681
+	Content      string `gorm:"column:content" json:"content" form:"content"`
2682
+}
2683
+
2684
+func (XtPatientBraden) TableName() string {
2685
+	return "xt_patient_braden"
2686
+}
2687
+
2688
+type XtPatientBradenChild struct {
2689
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2690
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2691
+	IsCheckStatus int64  `gorm:"column:is_check_status" json:"is_check_status" form:"is_check_status"`
2692
+	FassementId   int64  `gorm:"column:fassement_id" json:"fassement_id" form:"fassement_id"`
2693
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2694
+	Content       string `gorm:"column:content" json:"content" form:"content"`
2695
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
2696
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2697
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2698
+}
2699
+
2700
+func (XtPatientBradenChild) TableName() string {
2701
+	return "xt_patient_braden_child"
2702
+}
2703
+
2704
+type XtAgePatients struct {
2705
+	ID                          int64  `gorm:"column:id" json:"id" form:"id"`
2706
+	UserOrgId                   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2707
+	Name                        string `gorm:"column:name" json:"name" form:"name"`
2708
+	Status                      int64  `gorm:"column:status" json:"status" form:"status"`
2709
+	Age                         int64  `gorm:"column:age" json:"age" form:"age"`
2710
+	Lapseto                     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
2711
+	DialysisNo                  string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
2712
+	BeforSystolicBloodPressure  float64
2713
+	BeforDiastolicBloodPressure float64
2714
+	AfterSystolicBloodPressure  float64
2715
+	AfterDiastolicBloodPressure float64
2716
+	XueLin                      string
2717
+	XueHongDanBai               string
2718
+	XueGai                      string
2719
+	JiaoZhengGai                string
2720
+	JiaPanSu                    string
2721
+	YiTieDanBai                 string
2722
+	TieDanBai                   string
2723
+	QianBaiDanBai               string
2724
+	Crp                         string
2725
+	Mg                          string
2726
+	URR                         string
2727
+	KTV                         string
2728
+}
2729
+
2730
+func (XtAgePatients) TableName() string {
2731
+
2732
+	return "xt_patients"
2733
+}

+ 1 - 0
models/schedule_models.go Näytä tiedosto

@@ -448,6 +448,7 @@ type VmBloodScheduleTwo struct {
448 448
 	DeviceNumber               *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
449 449
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
450 450
 	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
451
+	HisPrescriptionProject     []*HisPrescriptionProject  `gorm:"ForeignKey:PatientId,schedule_date;AssociationForeignKey:PatientId,RecordDate" json:"his_prescription_project"`
451 452
 }
452 453
 
453 454
 func (VmBloodScheduleTwo) TableName() string {

+ 7 - 0
service/common_service.go Näytä tiedosto

@@ -3617,3 +3617,10 @@ func GetAllPatientCount(orgid int64) (total int64, err error) {
3617 3617
 	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
3618 3618
 	return
3619 3619
 }
3620
+
3621
+func GetPatientInspectionList(user_org_id int64) (inspection []*models.XtInspection, err error) {
3622
+
3623
+	err = XTReadDB().Where("inspect_date>=? and inspect_date<=? and org_id = ? and status=1", 1704038400, 1711814400, user_org_id).Group("patient_id").Find(&inspection).Error
3624
+
3625
+	return inspection, err
3626
+}

+ 29 - 15
service/dialysis_solution_service.go Näytä tiedosto

@@ -94,7 +94,6 @@ func GetDialysisAdviceTemplateList(keywords string, limit int64, page int64, par
94 94
 	if orgID > 0 {
95 95
 		db = db.Where("xt_schedule.user_org_id  = ?", orgID)
96 96
 	}
97
-
98 97
 	if len(idArray) >= 1 {
99 98
 		db = db.Where("xt_schedule.id in(?)", idArray)
100 99
 	}
@@ -126,10 +125,16 @@ func GetHisLongAdviceList(user_org_id int64) (advice []*models.HisDoctorAdviceTe
126 125
 	return advice, err
127 126
 }
128 127
 
129
-func GetAllHisAdviceTemplateList(user_org_id int64) (advice []*models.HisPrescriptionAdviceTemplate, err error) {
128
+func GetAllHisAdviceTemplateList(user_org_id int64, keywords string) (advice []*models.HisPrescriptionAdviceTemplate, err error) {
129
+	keywords = "%" + keywords + "%"
130
+	if len(keywords) > 0 {
131
+		err = XTReadDB().Where("user_org_id = ? and status = 1 and advice_name like ?", user_org_id, keywords).Find(&advice).Error
132
+		return advice, err
133
+	} else {
134
+		err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&advice).Error
135
+		return advice, err
136
+	}
130 137
 
131
-	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&advice).Error
132
-	return advice, err
133 138
 }
134 139
 
135 140
 func SaveDialysisSetting(setting models.XtDialysisSetting) error {
@@ -296,6 +301,7 @@ func GetDialysisAdviceSchedulistTwo(orgID int64, schedule_type int64, partition_
296 301
 }
297 302
 
298 303
 func GetDialysisAdviceSchedulistSix(keywords string, limit int64, page int64, partition_id int64, schedule_type int64, scheduleDate int64, orgID int64, idArray []string) (schedule []*models.VmBloodScheduleTwo, total int64, err error) {
304
+
299 305
 	db := XTReadDB().Model(&models.VmBloodScheduleTwo{}).Where("xt_schedule.status = 1")
300 306
 	offset := (page - 1) * limit
301 307
 	if scheduleDate > 0 {
@@ -409,13 +415,17 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
409 415
 		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
410 416
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
411 417
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
412
-			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
413
-				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
414
-					return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
415
-						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)
416
-					})
418
+			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
419
+				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
420
+					return db.Where("org_id = ? and status = 1", orgID)
421
+				})
422
+			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
423
+			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
424
+				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
425
+					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)
417 426
 				})
418 427
 			})
428
+		})
419 429
 		db = db.Joins("JOIN xt_patients AS patient ON patient.id=xt_schedule.patient_id AND patient.status = 1 AND patient.user_org_id = ? AND patient.name Like ?", orgID, keywords)
420 430
 		err = db.Count(&total).Offset(offset).Limit(limit).Find(&schedule).Error
421 431
 	} else {
@@ -423,13 +433,17 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
423 433
 			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
424 434
 			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
425 435
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
426
-			Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
427
-				return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
428
-					return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
429
-						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)
430
-					})
436
+			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
437
+				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
438
+					return db.Where("org_id = ? and status = 1", orgID)
431 439
 				})
432
-			}).Find(&schedule).Error
440
+			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
441
+			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
442
+				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
443
+					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)
444
+				})
445
+			})
446
+		}).Find(&schedule).Error
433 447
 	}
434 448
 
435 449
 	return schedule, total, err

+ 2 - 1
service/gobal_config_service.go Näytä tiedosto

@@ -846,7 +846,8 @@ func GetDrugCountList(startime int64, endtime int64, orgid int64) (info []*model
846 846
 }
847 847
 
848 848
 func GetMinCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
849
-	db := readDb2.Table("xt_drug_warehouse_info as x").Where("x.status = 1")
849
+
850
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
850 851
 
851 852
 	if startime > 0 {
852 853
 		db = db.Where("x.ctime >=?", startime)

+ 31 - 15
service/his_service.go Näytä tiedosto

@@ -403,7 +403,9 @@ func UpdatePatientCaseHistory(patient_id int64, record_date int64, user_org_id i
403 403
 }
404 404
 
405 405
 func SaveHisPrescription(tx *gorm.DB, prescription *models.HisPrescription) (err error) {
406
-	if err = tx.Model(&models.HisPrescription{}).Save(prescription).Error; err != nil {
406
+
407
+	err = tx.Model(&models.HisPrescription{}).Save(prescription).Error
408
+	if err != nil {
407 409
 		tx.Rollback()
408 410
 		return
409 411
 	}
@@ -886,12 +888,13 @@ func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err
886 888
 }
887 889
 
888 890
 func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
889
-	if err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error; err != nil {
891
+
892
+	err = tx.Model(&models.HisDoctorAdviceInfo{}).Save(s).Error
893
+
894
+	if err != nil {
890 895
 		tx.Rollback()
891 896
 		return
892 897
 	}
893
-	tx.Commit()
894
-
895 898
 	return
896 899
 }
897 900
 
@@ -907,23 +910,33 @@ func CreateHisDoctorAdviceTwo(s *models.HisDoctorAdviceInfo) (err error) {
907 910
 }
908 911
 
909 912
 func CreateHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err error) {
910
-	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
913
+	err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error
914
+	if err != nil {
911 915
 		tx.Rollback()
912 916
 		return
913 917
 	}
914
-	tx.Commit()
915
-
916 918
 	return
917 919
 }
918 920
 
921
+func GetLastHisProject(patient_id int64, user_org_id int64, record_date int64, tx *gorm.DB) (models.HisPrescriptionProject, error) {
922
+
923
+	prescriptionProject := models.HisPrescriptionProject{}
924
+	err := tx.Where("patient_id = ? and user_org_id = ? and record_date = ? and status=1", patient_id, user_org_id, record_date).Find(&prescriptionProject).Error
925
+	if err != gorm.ErrRecordNotFound {
926
+		if err != nil {
927
+			tx.Rollback()
928
+			return prescriptionProject, err
929
+		}
930
+	}
931
+	return prescriptionProject, err
932
+}
933
+
919 934
 func CreateHisProjectThree(project *models.HisPrescriptionProject) (err error) {
920 935
 	tx := writeDb.Begin()
921 936
 	if err = tx.Model(&models.HisPrescriptionProject{}).Save(project).Error; err != nil {
922 937
 		tx.Rollback()
923 938
 		return
924 939
 	}
925
-	tx.Commit()
926
-
927 940
 	return
928 941
 }
929 942
 
@@ -933,8 +946,6 @@ func SaveHisProjectTwo(project *models.HisPrescriptionProject, tx *gorm.DB) (err
933 946
 		tx.Rollback()
934 947
 		return
935 948
 	}
936
-	tx.Commit()
937
-
938 949
 	return
939 950
 }
940 951
 
@@ -2090,18 +2101,24 @@ type CustomAccountFormData struct {
2090 2101
 	HifesPay           float64 `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
2091 2102
 	MayPay             float64 `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
2092 2103
 	SetlDetail         string  `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
2104
+	SettleStartTime    int64   `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
2105
+	SettleEndTime      int64   `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
2093 2106
 }
2094 2107
 
2095 2108
 func GetCheckAccountFormData(start_time int64, end_time int64, org_id int64, insutype string, clr_type string) (cus []*CustomAccountFormData, err error) {
2096 2109
 	if clr_type == "9903" {
2097
-		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type = ? Group by o.id", org_id, start_time, end_time, insutype, clr_type).Scan(&cus).Error
2110
+		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay, o.settle_start_time as settle_start_time, o.settle_end_time as settle_end_time  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type = ?   Group by o.id", org_id, start_time, end_time, insutype, clr_type).Scan(&cus).Error
2098 2111
 	} else {
2099
-		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type <> 9903 Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
2112
+		err = readDb.Raw("select o.setl_detail as setl_detail, o.maf_pay as maf_pay,  o.hifmi_pay  as hifmi_pay, o.hifob_pay as hifob_pay, o.cvlserv_pay as cvlserv_pay, o.hifes_pay as hifes_pay, o.patient_id as patient_id, p.diagnosis as diagnosis_id, p.iinfo as iinfo, o.medfee_sumamt as medfee_sumamt ,o.psn_name as psn_name ,p.id_card_no as id_card_no ,o.psn_no as psn_no, o.mdtrt_id as mdtrt_id, o.settle_accounts_date as settle_accounts_date,o.act_pay_dedc as act_pay_dedc,O.fund_pay_sumamt as fund_pay_sumamt,o.psn_cash_pay as psn_cash_pay ,o.acct_pay as acct_pay,o.psn_cash_pay as cash_pay,o.medfee_sumamt as sumamt,o.hifp_pay as hifp_pay,o.settle_start_time as settle_start_time, o.settle_end_time as settle_end_time  from his_order o  Join his_patient p On o.patient_id = p.patient_id AND o.settle_accounts_date = p.record_date where o.user_org_id = ? AND o.status = 1 AND o.order_status = 2  AND o.settle_accounts_date >= ? AND o.settle_accounts_date <= ? AND o.insutype = ? AND o.clr_type <> 9903 Group by o.id", org_id, start_time, end_time, insutype).Scan(&cus).Error
2100 2113
 	}
2101 2114
 
2102 2115
 	for _, item := range cus {
2103 2116
 		var total int64
2104
-		readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? AND status = 1 AND stage = 2 AND dialysis_date <= ? AND  dialysis_date >= ?", item.PatientId, end_time, start_time).Count(&total)
2117
+		if item.SettleStartTime == 0 && item.SettleEndTime == 0 {
2118
+			readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? AND status = 1 AND stage = 2 AND dialysis_date <= ? AND  dialysis_date >= ?", item.PatientId, item.SettleAccountsDate, item.SettleAccountsDate).Count(&total)
2119
+		} else {
2120
+			readDb.Model(&models.DialysisOrder{}).Where("patient_id = ? AND status = 1 AND stage = 2 AND dialysis_date <= ? AND  dialysis_date >= ?", item.PatientId, item.SettleEndTime, item.SettleStartTime).Count(&total)
2121
+		}
2105 2122
 		fmt.Println(total)
2106 2123
 		item.DialysisCount = total
2107 2124
 		fmt.Println(item.DialysisCount)
@@ -2627,7 +2644,6 @@ func CreateHisLabelRecord(label *models.HisLabelPrintInfo, tx *gorm.DB) (err err
2627 2644
 		tx.Rollback()
2628 2645
 		return
2629 2646
 	}
2630
-	tx.Commit()
2631 2647
 	return
2632 2648
 }
2633 2649
 

+ 7 - 5
service/manage_center_service.go Näytä tiedosto

@@ -176,12 +176,14 @@ func FindBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err
176 176
 }
177 177
 
178 178
 func FindNewBaseDrugLibRecord(org_id int64, id int64, tx *gorm.DB) (lib models.BaseDrugLib, err error) {
179
-	err = readDb.Model(&models.BaseDrugLib{}).Where("id = ? AND org_id = ?  AND status = 1", id, org_id).First(&lib).Error
180
-	if err != nil {
181
-		tx.Rollback()
182
-		return
179
+	err = tx.Model(&models.BaseDrugLib{}).Where("id = ? AND org_id = ?  AND status = 1", id, org_id).First(&lib).Error
180
+	if err != gorm.ErrRecordNotFound {
181
+		if err != nil {
182
+			tx.Rollback()
183
+			return
184
+		}
183 185
 	}
184
-	tx.Commit()
186
+
185 187
 	return lib, err
186 188
 }
187 189
 

+ 10 - 0
service/new_stock_service.go Näytä tiedosto

@@ -357,6 +357,16 @@ func AddCancelSumCountOne(storehouse_id int64, drug_id int64, user_org_id int64,
357 357
 	return err
358 358
 }
359 359
 
360
+func AddNewCancelSumCountOne(storehouse_id int64, drug_id int64, user_org_id int64, cancel_count int64, tx *gorm.DB) error {
361
+
362
+	err = tx.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_cancel_count", gorm.Expr("sum_cancel_count + ?", cancel_count)).Error
363
+	if err != nil {
364
+		tx.Rollback()
365
+		return err
366
+	}
367
+	return err
368
+}
369
+
360 370
 func ReduceCancelSumCount(storehouse_id int64, drug_id int64, user_org_id int64, cancel_count int64, over_count int64) error {
361 371
 	db := writeDb.Begin()
362 372
 	err = db.Model(&models.XtDrugStockCount{}).Where("user_org_id = ? and storehouse_id  = ? and drug_id = ? and status = 1", user_org_id, storehouse_id, drug_id).UpdateColumn("sum_cancel_count", gorm.Expr("sum_cancel_count - ?", cancel_count)).Error

File diff suppressed because it is too large
+ 1097 - 1275
service/new_warehouse_service.go


+ 116 - 286
service/patient_service.go Näytä tiedosto

@@ -3749,242 +3749,6 @@ func SavePatientFallassessment(tx *gorm.DB, patientFallassessment models.XtPatie
3749 3749
 	return
3750 3750
 }
3751 3751
 
3752
-func GetLastPatientFallassessment(tx *gorm.DB, patient_id int64, user_org_id int64) (patientFallassessment models.XtPatientFallassessment, err error) {
3753
-
3754
-	err = tx.Where("patient_id = ? and user_org_id = ? and status=1", patient_id, user_org_id).Last(&patientFallassessment).Error
3755
-	if err == gorm.ErrRecordNotFound {
3756
-		tx.Rollback()
3757
-		return
3758
-	}
3759
-
3760
-	return
3761
-
3762
-}
3763
-
3764
-func CreateFallassessmentAge(tx *gorm.DB, patientAge models.XtPatientFallassessmentAge) (err error) {
3765
-
3766
-	err = tx.Create(&patientAge).Error
3767
-	if err == gorm.ErrRecordNotFound {
3768
-		tx.Rollback()
3769
-		return
3770
-	}
3771
-
3772
-	return
3773
-}
3774
-
3775
-func SaveFallassessmentAge(tx *gorm.DB, patientAge models.XtPatientFallassessmentAge) (err error) {
3776
-
3777
-	err = tx.Create(&patientAge).Error
3778
-	if err == gorm.ErrRecordNotFound {
3779
-		tx.Rollback()
3780
-		return
3781
-	}
3782
-
3783
-	return
3784
-}
3785
-
3786
-func CreateFallassessmentOrgan(tx *gorm.DB, organ models.XtPatientFallassessmentOrgan) (err error) {
3787
-
3788
-	err = tx.Create(&organ).Error
3789
-	if err == gorm.ErrRecordNotFound {
3790
-		tx.Rollback()
3791
-		return
3792
-	}
3793
-
3794
-	return
3795
-
3796
-}
3797
-
3798
-func SaveFallassessmentOrgan(tx *gorm.DB, organ models.XtPatientFallassessmentOrgan) (err error) {
3799
-
3800
-	err = tx.Create(&organ).Error
3801
-	if err == gorm.ErrRecordNotFound {
3802
-		tx.Rollback()
3803
-		return
3804
-	}
3805
-
3806
-	return
3807
-
3808
-}
3809
-
3810
-func CreateFallassessmentHistory(tx *gorm.DB, history models.XtPatientFallassessmentHistory) (err error) {
3811
-
3812
-	err = tx.Create(&history).Error
3813
-	if err == gorm.ErrRecordNotFound {
3814
-		tx.Rollback()
3815
-		return
3816
-	}
3817
-
3818
-	return
3819
-}
3820
-
3821
-func SaveFallassessmentHistory(tx *gorm.DB, history models.XtPatientFallassessmentHistory) (err error) {
3822
-
3823
-	err = tx.Save(&history).Error
3824
-	if err == gorm.ErrRecordNotFound {
3825
-		tx.Rollback()
3826
-		return
3827
-	}
3828
-
3829
-	return
3830
-}
3831
-
3832
-func CreateFallassessmentExcrete(tx *gorm.DB, excrete models.XtPatientFallassessmentExcrete) (err error) {
3833
-
3834
-	err = tx.Create(&excrete).Error
3835
-	if err == gorm.ErrRecordNotFound {
3836
-		tx.Rollback()
3837
-		return
3838
-	}
3839
-
3840
-	return
3841
-
3842
-}
3843
-
3844
-func SaveFallassessmentExcrete(tx *gorm.DB, excrete models.XtPatientFallassessmentExcrete) (err error) {
3845
-
3846
-	err = tx.Save(&excrete).Error
3847
-	if err == gorm.ErrRecordNotFound {
3848
-		tx.Rollback()
3849
-		return
3850
-	}
3851
-
3852
-	return
3853
-
3854
-}
3855
-
3856
-func CreateFallassessmentBody(tx *gorm.DB, body models.XtPatientFallassessmentBody) (err error) {
3857
-
3858
-	err = tx.Create(&body).Error
3859
-	if err == gorm.ErrRecordNotFound {
3860
-		tx.Rollback()
3861
-		return
3862
-	}
3863
-
3864
-	return
3865
-}
3866
-
3867
-func SaveFallassessmentBody(tx *gorm.DB, body models.XtPatientFallassessmentBody) (err error) {
3868
-
3869
-	err = tx.Save(&body).Error
3870
-	if err == gorm.ErrRecordNotFound {
3871
-		tx.Rollback()
3872
-		return
3873
-	}
3874
-
3875
-	return
3876
-}
3877
-
3878
-func CreateFallassessmentMedical(tx *gorm.DB, medical models.XtPatientFallassessmentMedical) (err error) {
3879
-
3880
-	err = tx.Create(&medical).Error
3881
-	if err == gorm.ErrRecordNotFound {
3882
-		tx.Rollback()
3883
-		return
3884
-	}
3885
-
3886
-	return
3887
-}
3888
-
3889
-func SaveFallassessmentMedical(tx *gorm.DB, medical models.XtPatientFallassessmentMedical) (err error) {
3890
-
3891
-	err = tx.Save(&medical).Error
3892
-	if err == gorm.ErrRecordNotFound {
3893
-		tx.Rollback()
3894
-		return
3895
-	}
3896
-
3897
-	return
3898
-}
3899
-
3900
-func CreateFallassessmentFall(tx *gorm.DB, fall models.XtPatientFallassessmentFall) (err error) {
3901
-
3902
-	err = tx.Create(&fall).Error
3903
-	if err == gorm.ErrRecordNotFound {
3904
-		tx.Rollback()
3905
-		return
3906
-	}
3907
-
3908
-	return
3909
-}
3910
-
3911
-func SaveFallassessmentFall(tx *gorm.DB, fall models.XtPatientFallassessmentFall) (err error) {
3912
-
3913
-	err = tx.Save(&fall).Error
3914
-	if err == gorm.ErrRecordNotFound {
3915
-		tx.Rollback()
3916
-		return
3917
-	}
3918
-
3919
-	return
3920
-}
3921
-
3922
-func CreateFallassessmentPrevent(tx *gorm.DB, excrete models.XtPatientFallassessmentPrevent) (err error) {
3923
-
3924
-	err = tx.Create(&excrete).Error
3925
-	if err == gorm.ErrRecordNotFound {
3926
-		tx.Rollback()
3927
-		return
3928
-	}
3929
-
3930
-	return
3931
-}
3932
-
3933
-func SaveFallassessmentPrevent(tx *gorm.DB, excrete models.XtPatientFallassessmentPrevent) (err error) {
3934
-
3935
-	err = tx.Save(&excrete).Error
3936
-	if err == gorm.ErrRecordNotFound {
3937
-		tx.Rollback()
3938
-		return
3939
-	}
3940
-
3941
-	return
3942
-}
3943
-
3944
-func CreateFallassessmentPealize(tx *gorm.DB, realize models.XtPatientFallassessmentRealize) (err error) {
3945
-
3946
-	err = tx.Create(&realize).Error
3947
-	if err == gorm.ErrRecordNotFound {
3948
-		tx.Rollback()
3949
-		return
3950
-	}
3951
-
3952
-	return
3953
-}
3954
-
3955
-func SaveFallassessmentPealize(tx *gorm.DB, realize models.XtPatientFallassessmentRealize) (err error) {
3956
-
3957
-	err = tx.Create(&realize).Error
3958
-	if err == gorm.ErrRecordNotFound {
3959
-		tx.Rollback()
3960
-		return
3961
-	}
3962
-
3963
-	return
3964
-}
3965
-
3966
-func CreateFallassessmentCare(tx *gorm.DB, care models.XtPatientFallassessmentCare) (err error) {
3967
-
3968
-	err = tx.Create(&care).Error
3969
-	if err == gorm.ErrRecordNotFound {
3970
-		tx.Rollback()
3971
-		return
3972
-	}
3973
-
3974
-	return
3975
-}
3976
-
3977
-func SaveFallassessmentCare(tx *gorm.DB, care models.XtPatientFallassessmentCare) (err error) {
3978
-
3979
-	err = tx.Save(&care).Error
3980
-	if err == gorm.ErrRecordNotFound {
3981
-		tx.Rollback()
3982
-		return
3983
-	}
3984
-
3985
-	return
3986
-}
3987
-
3988 3752
 func GetPatientFallsessMentList(patient_id int64, user_org_id int64, limit int64, page int64) (list []*models.XtPatientFallassessment, total int64, err error) {
3989 3753
 
3990 3754
 	offset := (page - 1) * limit
@@ -4002,51 +3766,26 @@ func GetPatientFallsessMentList(patient_id int64, user_org_id int64, limit int64
4002 3766
 	return list, total, err
4003 3767
 }
4004 3768
 
4005
-func CreateFallassessmentAdd(tx *gorm.DB, care models.XtPatientFallassessmentAdd) (err error) {
3769
+func GetPatientFallsessMentListOne(ids []string, user_org_id int64) (list []*models.XtPatientFallassessment, err error) {
4006 3770
 
4007
-	err = tx.Create(&care).Error
4008
-	if err == gorm.ErrRecordNotFound {
4009
-		tx.Rollback()
4010
-		return
4011
-	}
4012
-	return
4013
-}
4014
-
4015
-func SaveFallassessmentAdd(tx *gorm.DB, care models.XtPatientFallassessmentAdd) (err error) {
3771
+	db := XTReadDB().Model(&list).Where("status =1")
4016 3772
 
4017
-	err = tx.Save(&care).Error
4018
-	if err == gorm.ErrRecordNotFound {
4019
-		tx.Rollback()
4020
-		return
3773
+	if len(ids) > 0 {
3774
+		db = db.Where("id in(?)", ids)
4021 3775
 	}
4022
-	return
4023
-}
4024
-
4025
-func XtPatientFallassessmentAddCopy(tx *gorm.DB, care models.XtPatientFallassessmentAddCopy) (err error) {
4026
-
4027
-	err = tx.Create(&care).Error
4028
-	if err == gorm.ErrRecordNotFound {
4029
-		tx.Rollback()
4030
-		return
3776
+	if user_org_id > 0 {
3777
+		db = db.Where("user_org_id = ?", user_org_id)
4031 3778
 	}
4032
-	return
4033
-}
3779
+	err = db.Find(&list).Error
4034 3780
 
4035
-func SavePatientFallassessmentAddCopy(tx *gorm.DB, care models.XtPatientFallassessmentAddCopy) (err error) {
4036
-
4037
-	err = tx.Create(&care).Error
4038
-	if err == gorm.ErrRecordNotFound {
4039
-		tx.Rollback()
4040
-		return
4041
-	}
4042
-	return
3781
+	return list, err
4043 3782
 }
4044 3783
 
4045
-func GetPatientFallsessmentById(id int64, user_org_id int64) (models.VmXtPatientFallassessment, error) {
3784
+func GetPatientFallsessmentById(id int64, user_org_id int64) (models.XtPatientFallassessment, error) {
4046 3785
 
4047
-	fallassessment := models.VmXtPatientFallassessment{}
3786
+	fallassessment := models.XtPatientFallassessment{}
4048 3787
 
4049
-	err := XTReadDB().Where("id = ? and user_org_id = ?", id, user_org_id).Preload("XtPatientFallassessmentAdd", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentAge", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentAddCopy", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentBody", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentCare", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentExcrete", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentFall", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentHistory", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentMedical", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentOrgan", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentPrevent", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentRealize", "status=1 and user_org_id =?", user_org_id).Find(&fallassessment).Error
3788
+	err := XTReadDB().Where("id = ? and user_org_id = ?", id, user_org_id).Find(&fallassessment).Error
4050 3789
 
4051 3790
 	return fallassessment, err
4052 3791
 }
@@ -4054,20 +3793,7 @@ func GetPatientFallsessmentById(id int64, user_org_id int64) (models.VmXtPatient
4054 3793
 func DeletePatientFallsessment(id int64, user_org_id int64) (models.XtPatientFallassessment, error) {
4055 3794
 
4056 3795
 	fallassessment := models.XtPatientFallassessment{}
4057
-	err := XTWriteDB().Where("id =? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4058
-
4059
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentAdd{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4060
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentAddCopy{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4061
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentAge{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4062
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentBody{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4063
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentCare{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4064
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentExcrete{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4065
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentFall{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4066
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentHistory{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4067
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentMedical{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4068
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentOrgan{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4069
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentPrevent{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4070
-	err = XTWriteDB().Model(&models.XtPatientFallassessmentRealize{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
3796
+	err := XTWriteDB().Model(&fallassessment).Where("id =? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4071 3797
 	return fallassessment, err
4072 3798
 }
4073 3799
 
@@ -4185,3 +3911,107 @@ func UpdatePatientPedList(fallssessment models.XtPatientPedFallssessment) error
4185 3911
 
4186 3912
 	return err
4187 3913
 }
3914
+
3915
+func GetPatientFallsessMentListTwo(ids []string, user_org_id int64) (list []*models.XtPatientFallassessment, err error) {
3916
+
3917
+	db := XTReadDB().Model(&list).Where("status =1")
3918
+
3919
+	if len(ids) > 0 {
3920
+		db = db.Where("id in(?)", ids)
3921
+	}
3922
+	if user_org_id > 0 {
3923
+		db = db.Where("user_org_id = ?", user_org_id)
3924
+	}
3925
+	err = db.Find(&list).Error
3926
+	return list, err
3927
+}
3928
+
3929
+func CeatePatientSign(braden models.XtPatientBraden) error {
3930
+
3931
+	err := XTWriteDB().Create(&braden).Error
3932
+
3933
+	return err
3934
+}
3935
+
3936
+func GetPatientBradenList(patient_id int64, limit int64, page int64, user_org_id int64) (list []*models.XtPatientBraden, total int64, err error) {
3937
+
3938
+	offset := (page - 1) * limit
3939
+
3940
+	db := XTReadDB().Model(&list).Where("status =1")
3941
+	if patient_id > 0 {
3942
+		db = db.Where("patient_id = ?", patient_id)
3943
+	}
3944
+	if user_org_id > 0 {
3945
+		db = db.Where("user_org_id = ?", user_org_id)
3946
+	}
3947
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&list).Error
3948
+
3949
+	return list, total, err
3950
+}
3951
+
3952
+func GetPatientBradenById(id int64) (models.XtPatientBraden, error) {
3953
+
3954
+	patientBraden := models.XtPatientBraden{}
3955
+
3956
+	err := XTReadDB().Where("id = ? and status=1", id).Find(&patientBraden).Error
3957
+
3958
+	return patientBraden, err
3959
+}
3960
+
3961
+func SavePatientBraden(braden models.XtPatientBraden) error {
3962
+
3963
+	err := XTWriteDB().Save(&braden).Error
3964
+
3965
+	return err
3966
+}
3967
+
3968
+func DeletePatientBraden(id int64) error {
3969
+
3970
+	patientBraden := models.XtPatientBraden{}
3971
+	err := XTWriteDB().Model(&patientBraden).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
3972
+	return err
3973
+}
3974
+
3975
+func GetBatchPatientBraden(ids []string, user_org_id int64) (list []*models.XtPatientBraden, err error) {
3976
+
3977
+	db := XTReadDB().Model(&list).Where("status=1")
3978
+
3979
+	if len(ids) > 0 {
3980
+		db = db.Where("id in(?)", ids)
3981
+	}
3982
+	if user_org_id > 0 {
3983
+		db = db.Where("user_org_id =?", user_org_id)
3984
+	}
3985
+	err = db.Find(&list).Error
3986
+	return list, err
3987
+}
3988
+
3989
+func GetAllPatientListMap(user_org_id int64) (list []*models.XtAgePatients, err error) {
3990
+
3991
+	err = XTReadDB().Where("user_org_id =? and status=1 and lapseto = 1", user_org_id).Find(&list).Error
3992
+
3993
+	return list, err
3994
+}
3995
+
3996
+func GetLastBefor(patient_id int64) (models.XtAssessmentBeforeDislysis, error) {
3997
+
3998
+	beforeDislysis := models.XtAssessmentBeforeDislysis{}
3999
+
4000
+	err := XTReadDB().Where("patient_id = ? and status=1 AND  assessment_date>=1704038400  AND  assessment_date<=1711814400", patient_id).Order("id asc").Last(&beforeDislysis).Limit(1).Error
4001
+	return beforeDislysis, err
4002
+}
4003
+
4004
+func GetLastRecordAfter(patient_id int64) (models.XtAssessmentAfterDislysis, error) {
4005
+
4006
+	afterDislysis := models.XtAssessmentAfterDislysis{}
4007
+	err := XTReadDB().Where("patient_id = ? and status=1 AND assessment_date>=1704038400 AND assessment_date<=1711814400", patient_id).Order("id asc").Last(&afterDislysis).Limit(1).Error
4008
+	return afterDislysis, err
4009
+}
4010
+
4011
+func GetInspectionByPatientId(patient_id int64, item_id int64) (models.XtInspection, error) {
4012
+
4013
+	inspection := models.XtInspection{}
4014
+
4015
+	err := XTReadDB().Where("patient_id =? and status =1 and inspect_date>=1704038400 and inspect_date<=1711814400 and item_id =?", patient_id, item_id).Order("id asc").Last(&inspection).Limit(1).Error
4016
+	return inspection, err
4017
+}

+ 1 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Näytä tiedosto

@@ -28,7 +28,7 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
28 28
 		}).
29 29
 		Preload("AssessmentAfterDislysis", "user_org_id = ? AND status = 1", orgID).
30 30
 		Preload("LastAfterWeight", func(db *gorm.DB) *gorm.DB {
31
-			return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgID, recordDate.Unix())
31
+			return db.Where("user_org_id = ? and status = 1 and assessment_date < ?", orgID, recordDate.Unix()).Limit(1)
32 32
 		}).Preload("MonitoringRecords", func(db *gorm.DB) *gorm.DB {
33 33
 		return db.Where("user_org_id = ? AND status = 1", orgID).
34 34
 			Order("operate_time asc")

+ 14 - 0
service/secondary_service.go Näytä tiedosto

@@ -1185,3 +1185,17 @@ func GetLastDrugOverCount(id int64) (models.DrugFlow, error) {
1185 1185
 
1186 1186
 	return stockFlow, err
1187 1187
 }
1188
+
1189
+func GetNewAllStoreHouseConfig(orgid int64, tx *gorm.DB) (models.XtStorehouseConfig, error) {
1190
+
1191
+	config := models.XtStorehouseConfig{}
1192
+	err := tx.Where("user_org_id = ? and status = 1", orgid).First(&config).Error
1193
+	if err != gorm.ErrRecordNotFound {
1194
+		if err != nil {
1195
+			tx.Rollback()
1196
+			return config, err
1197
+		}
1198
+	}
1199
+
1200
+	return config, err
1201
+}

+ 13 - 0
service/self_drug_service.go Näytä tiedosto

@@ -136,6 +136,19 @@ func GetBaseDrugMedical(id int64) (models.XtBaseDrug, error) {
136 136
 	return drug, err
137 137
 }
138 138
 
139
+func GetNewBaseDrugMedical(id int64, tx *gorm.DB) (models.XtBaseDrug, error) {
140
+	drug := models.XtBaseDrug{}
141
+	err := tx.Model(&drug).Where("id = ? and status = 1", id).Find(&drug).Error
142
+	if err != gorm.ErrRecordNotFound {
143
+		if err != nil {
144
+			tx.Rollback()
145
+			return drug, err
146
+		}
147
+
148
+	}
149
+	return drug, err
150
+}
151
+
139 152
 func ModifyDrugWarehouseByInfoId(id int64, stock_max_number int64) error {
140 153
 	info := models.DrugWarehouseInfo{}
141 154
 	err := XTWriteDB().Model(&info).Where("id = ?", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number - ?", stock_max_number)).Error

File diff suppressed because it is too large
+ 489 - 147
service/stock_service.go


+ 2 - 2
service/user_service.go Näytä tiedosto

@@ -215,9 +215,9 @@ func GetAllHisDoctor(orgid int64) (appRole []*models.App_Role, err error) {
215 215
 	return appRole, err
216 216
 }
217 217
 
218
-func GetDrugFlowDetailById(drug_id int64) (flow []*models.DrugFlow, err error) {
218
+func GetDrugFlowDetailById(drug_id int64, org_id int64) (flow []*models.DrugFlow, err error) {
219 219
 
220
-	err = XTReadDB().Model(&flow).Where("drug_id = ? and status =1 and user_org_id =10402", drug_id).Order("id asc").Find(&flow).Error
220
+	err = XTReadDB().Model(&flow).Where("drug_id = ? and status =1 and user_org_id =?", drug_id, org_id).Order("id asc").Find(&flow).Error
221 221
 
222 222
 	return flow, err
223 223
 }

+ 828 - 4
service/warhouse_service.go Näytä tiedosto

@@ -6124,11 +6124,32 @@ func UpdateGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64,
6124 6124
 	return err
6125 6125
 }
6126 6126
 
6127
+func UpdateNewGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64, over_count int64, tx *gorm.DB) error {
6128
+
6129
+	err := tx.Model(models.WarehouseOutInfo{}).Where("id = ?  and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count}).Error
6130
+	if err != nil {
6131
+		tx.Rollback()
6132
+		return err
6133
+	}
6134
+	return err
6135
+}
6136
+
6127 6137
 func ChangeMaxNumber(id int64, count int64) error {
6128 6138
 
6129 6139
 	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1 and is_check = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
6130 6140
 	return err
6131 6141
 
6142
+}
6143
+
6144
+func ChangeNewMaxNumber(id int64, count int64, tx *gorm.DB) error {
6145
+
6146
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1 and is_check = 1", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
6147
+	if err != nil {
6148
+		tx.Rollback()
6149
+		return err
6150
+	}
6151
+	return err
6152
+
6132 6153
 }
6133 6154
 func ChangeMaxNumberOne(id int64, count int64) error {
6134 6155
 
@@ -6137,24 +6158,68 @@ func ChangeMaxNumberOne(id int64, count int64) error {
6137 6158
 
6138 6159
 }
6139 6160
 
6161
+func ChangeNewMaxNumberOne(id int64, count int64, tx *gorm.DB) error {
6162
+
6163
+	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1 and is_check = 1", id).Updates(map[string]interface{}{"stock_max_number": count, "stock_min_number": 0}).Error
6164
+	if err != nil {
6165
+		tx.Rollback()
6166
+		return err
6167
+	}
6168
+	return err
6169
+
6170
+}
6171
+
6140 6172
 func UpdateMinNumber(id int64, count int64) error {
6141 6173
 
6142 6174
 	err := XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1 and is_check = 1", id).Update(map[string]interface{}{"stock_min_number": count}).Error
6143 6175
 	return err
6144 6176
 }
6145 6177
 
6178
+func UpdateNewMinNumber(id int64, count int64, tx *gorm.DB) error {
6179
+
6180
+	err := tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and status = 1 and is_check = 1", id).Update(map[string]interface{}{"stock_min_number": count}).Error
6181
+	if err != nil {
6182
+		tx.Rollback()
6183
+		return err
6184
+	}
6185
+	return err
6186
+}
6187
+
6146 6188
 func FindLastDrugWarehouseOutInfo(orgid int64) (models.DrugWarehouseOutInfo, error) {
6147 6189
 	info := models.DrugWarehouseOutInfo{}
6148 6190
 	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&info).Error
6149 6191
 	return info, err
6150 6192
 }
6151 6193
 
6194
+func FindNewLastDrugWarehouseOutInfo(orgid int64, tx *gorm.DB) (models.DrugWarehouseOutInfo, error) {
6195
+	info := models.DrugWarehouseOutInfo{}
6196
+	err := tx.Where("org_id = ? and status = 1", orgid).Last(&info).Error
6197
+	if err != nil {
6198
+		tx.Rollback()
6199
+		return info, err
6200
+	}
6201
+	tx.Rollback()
6202
+	return info, err
6203
+}
6204
+
6152 6205
 func GetAllGoodSumCount(goodid int64, orgid int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
6153 6206
 
6154 6207
 	err = XTReadDB().Where("good_id = ? and org_id = ? and is_check =1 and status= 1 and stock_count > 0 and storehouse_id = ?", goodid, orgid, storehouse_id).Find(&info).Error
6155 6208
 	return info, err
6156 6209
 }
6157 6210
 
6211
+func GetNewAllGoodSumCount(goodid int64, orgid int64, storehouse_id int64, tx *gorm.DB) (info []*models.WarehousingInfo, err error) {
6212
+
6213
+	err = tx.Where("good_id = ? and org_id = ? and is_check =1 and status= 1 and stock_count > 0 and storehouse_id = ?", goodid, orgid, storehouse_id).Find(&info).Error
6214
+	if err != gorm.ErrRecordNotFound {
6215
+		if err != nil {
6216
+			tx.Rollback()
6217
+			return info, err
6218
+		}
6219
+	}
6220
+	return info, err
6221
+}
6222
+
6158 6223
 func CreatedFlushInfo(info models.XtWarehouseFlushInfo) error {
6159 6224
 	ut := writeDb.Begin()
6160 6225
 	err := ut.Create(&info).Error
@@ -6333,6 +6398,23 @@ func ModifyGoodSumCount(storehouse_id int64, count int64, user_org_id int64, goo
6333 6398
 	return err
6334 6399
 }
6335 6400
 
6401
+func ModifyNewGoodSumCount(storehouse_id int64, count int64, user_org_id int64, good_id int64, tx *gorm.DB) error {
6402
+
6403
+	err = tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count + ?", count)).Error
6404
+	if err != nil {
6405
+		tx.Rollback()
6406
+		return err
6407
+	}
6408
+
6409
+	err = tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_act_out_count", gorm.Expr("stock_act_out_count + ?", count)).Error
6410
+	if err != nil {
6411
+		tx.Rollback()
6412
+		return err
6413
+	}
6414
+
6415
+	return err
6416
+}
6417
+
6336 6418
 func ModifyReduceGoodSumCount(storehouse_id int64, count int64, user_org_id int64, good_id int64) error {
6337 6419
 
6338 6420
 	ut := XTWriteDB().Begin()
@@ -6378,6 +6460,17 @@ func ModifyAddGoodSumCount(storehouse_id int64, count int64, user_org_id int64,
6378 6460
 	return err
6379 6461
 }
6380 6462
 
6463
+func ModifyNewAddGoodSumCount(storehouse_id int64, count int64, user_org_id int64, good_id int64, tx *gorm.DB) error {
6464
+
6465
+	err = tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id  = ? and good_id =?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_out_count", gorm.Expr("stock_out_count - ?", count)).Error
6466
+	if err != nil {
6467
+		tx.Rollback()
6468
+		return err
6469
+	}
6470
+
6471
+	return err
6472
+}
6473
+
6381 6474
 func UpdateSumAddCancelCount(user_org_id int64, good_id int64, storehouse_id int64, count int64) error {
6382 6475
 
6383 6476
 	ut := XTWriteDB().Begin()
@@ -6390,6 +6483,16 @@ func UpdateSumAddCancelCount(user_org_id int64, good_id int64, storehouse_id int
6390 6483
 	return err
6391 6484
 }
6392 6485
 
6486
+func UpdateNewSumAddCancelCount(user_org_id int64, good_id int64, storehouse_id int64, count int64, tx *gorm.DB) error {
6487
+
6488
+	err := tx.Model(&models.XtGoodStockCount{}).Where("storehouse_id = ? and status = 1 and user_org_id = ? and good_id = ?", storehouse_id, user_org_id, good_id).UpdateColumn("stock_cancel_count", gorm.Expr("stock_cancel_count + ?", count)).Error
6489
+	if err != nil {
6490
+		tx.Rollback()
6491
+		return err
6492
+	}
6493
+	return err
6494
+}
6495
+
6393 6496
 func UpdateSumReduceCancelCount(user_org_id int64, good_id int64, storehouse_id int64, count int64) error {
6394 6497
 
6395 6498
 	ut := XTWriteDB().Begin()
@@ -7673,12 +7776,32 @@ func CreateAutoDetail(detail models.AutomaticReduceDetail) error {
7673 7776
 	return err
7674 7777
 }
7675 7778
 
7779
+func CreateNewAutoDetail(detail models.AutomaticReduceDetail, tx *gorm.DB) error {
7780
+
7781
+	err := tx.Create(&detail).Error
7782
+	if err != nil {
7783
+		tx.Rollback()
7784
+		return err
7785
+	}
7786
+	return err
7787
+}
7788
+
7676 7789
 func UpdateAutomaticReduce(patient_id int64, record_date int64, good_id int64, project_id int64) error {
7677 7790
 
7678 7791
 	err := XTWriteDB().Model(&models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time =? and good_id = ? and project_id = ? and status = 1", patient_id, record_date, good_id, project_id).Update(map[string]interface{}{"status": 0}).Error
7679 7792
 	return err
7680 7793
 }
7681 7794
 
7795
+func UpdateNewAutomaticReduce(patient_id int64, record_date int64, good_id int64, project_id int64, tx *gorm.DB) error {
7796
+
7797
+	err := tx.Model(&models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time =? and good_id = ? and project_id = ? and status = 1", patient_id, record_date, good_id, project_id).Update(map[string]interface{}{"status": 0}).Error
7798
+	if err != nil {
7799
+		tx.Rollback()
7800
+		return err
7801
+	}
7802
+	return err
7803
+}
7804
+
7682 7805
 func GetDrugFLowByAdviceById(drug_id int64, patient_id int64, user_org_id int64, advice_date int64) (outInfo []*models.DrugWarehouseOutInfo, err error) {
7683 7806
 
7684 7807
 	err = XTReadDB().Where("drug_id = ? and patient_id = ? and org_id = ? and sys_record_time = ? and status= 1", drug_id, patient_id, user_org_id, advice_date).Find(&outInfo).Error
@@ -7717,7 +7840,7 @@ func NewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdv
7717 7840
 	if isHasWay {
7718 7841
 		//判断当天当前机构有没有创建出库单,没有则创建
7719 7842
 		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
7720
-
7843
+		fmt.Println(out)
7721 7844
 		houseConfig, _ := GetAllStoreHouseConfig(orgID)
7722 7845
 		if err == gorm.ErrRecordNotFound {
7723 7846
 			timeStr := time.Now().Format("2006-01-02")
@@ -7753,13 +7876,13 @@ func NewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdv
7753 7876
 			}
7754 7877
 		}
7755 7878
 
7756
-		// 出库流程
7757
-		// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
7879
+		//出库流程
7880
+		//1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
7758 7881
 		drup, _ := FindNewBaseDrugLibRecord(orgID, advice.DrugId, tx)
7759 7882
 		if drup.ID > 0 {
7760 7883
 			prescribingNumber := advice.PrescribingNumber
7761 7884
 
7762
-			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber, advice.PrescribingNumberUnit)
7885
+			NewBloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber, advice.PrescribingNumberUnit, tx)
7763 7886
 
7764 7887
 		} else {
7765 7888
 			return errors.New("药品信息不存在")
@@ -7769,3 +7892,704 @@ func NewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdv
7769 7892
 
7770 7893
 	return
7771 7894
 }
7895
+
7896
+// 保存处方出库
7897
+func ConsumableNewPrescriptionDelivery(orgID int64, patient_id int64, record_time int64, goods *models.DialysisBeforePrepare, warehouseOut *models.WarehouseOut, creator int64, count int64, tx *gorm.DB) (err error) {
7898
+
7899
+	var deliver_number int64 = 0
7900
+	var stock_number int64 = 0
7901
+	var maxNumber int64 = 0
7902
+
7903
+	deliver_number = goods.Count
7904
+
7905
+	// 根据先进先出原则,查询最先入库的批次,进行出库
7906
+
7907
+	// 如果没有对应的库存,则报错
7908
+	warehouse, err := FindNewFirstWarehousingInfoByStock(goods.GoodId, goods.GoodTypeId, goods.StorehouseId, tx)
7909
+	if err != nil {
7910
+		goodErrcode := models.XtGoodErrcode{
7911
+			UserOrgId:      goods.UserOrgId,
7912
+			Errcode:        "查询库存信息报错",
7913
+			GoodId:         goods.GoodId,
7914
+			Status:         1,
7915
+			Ctime:          time.Now().Unix(),
7916
+			Mtime:          0,
7917
+			Count:          0,
7918
+			StockCount:     0,
7919
+			Creater:        creator,
7920
+			BatchNumberId:  warehouse.ID,
7921
+			WarehouseOutId: 0,
7922
+		}
7923
+		CreateGoodErrcode(goodErrcode)
7924
+		return err
7925
+	}
7926
+
7927
+	stock_number = warehouse.StockCount
7928
+
7929
+	// 当库存数量大于或等于出库数量的话,则正常出库该批次
7930
+	if stock_number >= deliver_number {
7931
+		maxNumber = goods.Count
7932
+		warehouse.StockCount = warehouse.StockCount - maxNumber
7933
+		warehouse.Mtime = time.Now().Unix()
7934
+
7935
+		//扣减库存
7936
+		errThree := UpDateNewWarehouseInfoByStock(&warehouse, tx)
7937
+		if errThree != nil {
7938
+			goodErrcode := models.XtGoodErrcode{
7939
+				UserOrgId:      goods.UserOrgId,
7940
+				Errcode:        "扣减库存失败",
7941
+				GoodId:         goods.GoodId,
7942
+				Status:         1,
7943
+				Ctime:          time.Now().Unix(),
7944
+				Mtime:          0,
7945
+				Count:          0,
7946
+				StockCount:     0,
7947
+				Creater:        creator,
7948
+				BatchNumberId:  warehouse.ID,
7949
+				WarehouseOutId: 0,
7950
+			}
7951
+			CreateGoodErrcode(goodErrcode)
7952
+			return errThree
7953
+		}
7954
+
7955
+		//查询剩余库存
7956
+		goodList, _ := GetNewAllGoodSumCount(goods.GoodId, orgID, goods.StorehouseId, tx)
7957
+		var sum_count int64
7958
+		for _, item := range goodList {
7959
+			sum_count += item.StockCount
7960
+		}
7961
+
7962
+		//查询已经出库的数据
7963
+		flowGood, _ := GetNewStockFlowIsBatchNumberSix(patient_id, record_time, goods.GoodId, goods.ProjectId, tx)
7964
+		var out_count int64
7965
+		var out_count_one int64
7966
+		for _, item := range flowGood {
7967
+			out_count += item.Count
7968
+		}
7969
+
7970
+		//查询退库数据
7971
+		flowGoodTwo, _ := GetNewStockFlowIsBatchNumberFour(patient_id, record_time, goods.GoodId, goods.ProjectId, tx)
7972
+		for _, item := range flowGoodTwo {
7973
+			out_count_one += item.Count
7974
+		}
7975
+
7976
+		var out_count_two int64
7977
+
7978
+		wareOutList, _ := GetNewStockFlowIsBatchNumberSixty(patient_id, record_time, goods.GoodId, goods.ProjectId, tx)
7979
+		for _, item := range wareOutList {
7980
+			out_count_two += item.Count
7981
+		}
7982
+
7983
+		OutInfo := &models.WarehouseOutInfo{
7984
+			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
7985
+			WarehouseOutId:          warehouseOut.ID,
7986
+			WarehouseInfotId:        warehouse.ID,
7987
+			Status:                  1,
7988
+			Ctime:                   time.Now().Unix(),
7989
+			Remark:                  warehouse.Remark,
7990
+			OrgId:                   orgID,
7991
+			Type:                    1,
7992
+			Manufacturer:            warehouse.Manufacturer,
7993
+			Dealer:                  warehouse.Dealer,
7994
+			IsSys:                   1,
7995
+			SysRecordTime:           record_time,
7996
+			GoodTypeId:              goods.GoodTypeId,
7997
+			GoodId:                  goods.GoodId,
7998
+			PatientId:               patient_id,
7999
+			Number:                  warehouse.Number,
8000
+			LicenseNumber:           warehouse.LicenseNumber,
8001
+			Price:                   warehouse.PackingPrice,
8002
+			ExpiryDate:              warehouse.ExpiryDate,
8003
+			ProductDate:             warehouse.ProductDate,
8004
+			ProjectId:               goods.ProjectId,
8005
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
8006
+			StorehouseId:            goods.StorehouseId,
8007
+			IsCheck:                 1,
8008
+			OverCount:               sum_count,
8009
+			RegisterNumber:          warehouse.RegisterNumber,
8010
+		}
8011
+		OutInfo.Count = count - out_count_two + out_count_one
8012
+
8013
+		_, errcodes := GetNewNewWarehouseOutInfoIsExistSix(goods.GoodId, patient_id, record_time, goods.ProjectId, warehouse.ID, tx)
8014
+		fmt.Println("errcodes-------------------------------------------", errcodes)
8015
+		if errcodes == gorm.ErrRecordNotFound {
8016
+			errOne := AddNewSigleWarehouseOutInfo(OutInfo, tx)
8017
+			if errOne != nil {
8018
+				return errOne
8019
+			}
8020
+		} else if errcodes == nil {
8021
+			outInfoOne, _ := GetNewWarehouseOutInfoIsExistThree(goods.GoodId, patient_id, record_time, goods.ProjectId, tx)
8022
+			if count != outInfoOne.Count {
8023
+				UpdatedNewWarehouseOutInfo(OutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId, tx)
8024
+			}
8025
+
8026
+		}
8027
+
8028
+		lastOut, _ := FindNewWarehouseOutInfoByPatientIdTwo(patient_id, record_time, goods.GoodId, orgID, goods.ProjectId, tx)
8029
+
8030
+		//如果本次出库数据大于历史出库数据 新增1条流水
8031
+		fmt.Println("本次出库数据", count)
8032
+		fmt.Println("历史出库数据", out_count)
8033
+		fmt.Println("退库数据", out_count_one)
8034
+		if count > (out_count - out_count_one) {
8035
+
8036
+			stockFlow := models.VmStockFlow{
8037
+				WarehousingId:           warehouse.ID,
8038
+				GoodId:                  goods.GoodId,
8039
+				Number:                  warehouse.Number,
8040
+				LicenseNumber:           warehouse.LicenseNumber,
8041
+				Count:                   count - out_count + out_count_one,
8042
+				UserOrgId:               orgID,
8043
+				PatientId:               goods.PatientId,
8044
+				SystemTime:              record_time,
8045
+				ConsumableType:          3,
8046
+				IsSys:                   1,
8047
+				WarehousingOrder:        warehouse.WarehousingOrder,
8048
+				WarehouseOutId:          warehouseOut.ID,
8049
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
8050
+				IsEdit:                  1,
8051
+				CancelStockId:           0,
8052
+				CancelOrderNumber:       "",
8053
+				Manufacturer:            warehouse.Manufacturer,
8054
+				Dealer:                  warehouse.Dealer,
8055
+				Creator:                 creator,
8056
+				UpdateCreator:           0,
8057
+				Status:                  1,
8058
+				Ctime:                   time.Now().Unix(),
8059
+				Mtime:                   0,
8060
+				Price:                   warehouse.PackingPrice, //零售价
8061
+				WarehousingDetailId:     warehouse.ID,
8062
+				WarehouseOutDetailId:    goods.ID,
8063
+				CancelOutDetailId:       0,
8064
+				ProductDate:             warehouse.ProductDate,
8065
+				ExpireDate:              warehouse.ExpiryDate,
8066
+				SupplyWarehouseId:       warehouse.SupplyWarehouseId,
8067
+				StorehouseId:            warehouse.StorehouseId,
8068
+				AdminUserId:             creator,
8069
+				BuyPrice:                warehouse.Price, //进货价
8070
+				StockCount:              "",
8071
+				BatchNumberCount:        warehouse.StockCount - goods.Count,
8072
+				IsCheck:                 1,
8073
+				OverCount:               sum_count,
8074
+				RegisterNumber:          warehouse.RegisterNumber,
8075
+				ProjectId:               goods.ProjectId,
8076
+			}
8077
+			//创建出库流水
8078
+			errflow := CreateNewStockFlowOne(stockFlow, tx)
8079
+			if errflow != nil {
8080
+				goodErrcode := models.XtGoodErrcode{
8081
+					UserOrgId:      orgID,
8082
+					Errcode:        "创建流水报错",
8083
+					GoodId:         goods.GoodId,
8084
+					Status:         1,
8085
+					Ctime:          time.Now().Unix(),
8086
+					Mtime:          0,
8087
+					Count:          0,
8088
+					StockCount:     0,
8089
+					Creater:        creator,
8090
+					BatchNumberId:  warehouse.ID,
8091
+					WarehouseOutId: 0,
8092
+				}
8093
+				CreateGoodErrcode(goodErrcode)
8094
+			}
8095
+
8096
+			//更新出库数量
8097
+			errsumcode := ModifyNewGoodSumCount(goods.StorehouseId, stockFlow.Count, orgID, goods.GoodId, tx)
8098
+			if errsumcode != nil {
8099
+				goodErrcode := models.XtGoodErrcode{
8100
+					UserOrgId:      orgID,
8101
+					Errcode:        "更新出库数量报错",
8102
+					GoodId:         goods.GoodId,
8103
+					Status:         1,
8104
+					Ctime:          time.Now().Unix(),
8105
+					Mtime:          0,
8106
+					Count:          0,
8107
+					StockCount:     0,
8108
+					Creater:        creator,
8109
+					BatchNumberId:  warehouse.ID,
8110
+					WarehouseOutId: 0,
8111
+				}
8112
+				CreateGoodErrcode(goodErrcode)
8113
+			}
8114
+		}
8115
+
8116
+		//如果本次出库数据小于历史出库数据 新增1条退库流水
8117
+
8118
+		if count < (out_count - out_count_one) {
8119
+
8120
+			operation_time := time.Now().Unix()
8121
+
8122
+			//创建退库单
8123
+			timeStr := time.Now().Format("2006-01-02")
8124
+			timeArr := strings.Split(timeStr, "-")
8125
+			total, _ := FindNewAllCancelStockTotal(orgID, tx)
8126
+			total = total + 1
8127
+			orderNumber := "CKTKD" + strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
8128
+
8129
+			cancelStock := models.CancelStock{
8130
+				OrderNumber:  orderNumber,
8131
+				OperaTime:    operation_time,
8132
+				OrgId:        orgID,
8133
+				Creater:      warehouseOut.Creater,
8134
+				Ctime:        time.Now().Unix(),
8135
+				Status:       1,
8136
+				ReturnTime:   record_time,
8137
+				Type:         1,
8138
+				StorehouseId: goods.StorehouseId,
8139
+				IsCheck:      1,
8140
+			}
8141
+			_, msgerrkonde := GetNewCancelStockDetailByOrderNumberOne(record_time, orgID, tx)
8142
+			if msgerrkonde == gorm.ErrRecordNotFound {
8143
+				AddNewSigleCancelStock(&cancelStock, tx)
8144
+			}
8145
+
8146
+			cancel, _ := GetNewLastCancelStockById(orgID, tx)
8147
+
8148
+			manufacturer, _ := GetNewManufactureById(warehouse.Manufacturer, tx)
8149
+			deaerler, _ := GetNewDealerById(warehouse.Dealer, tx)
8150
+			cancelStockInfo := models.CancelStockInfo{
8151
+				GoodId:          goods.GoodId,
8152
+				CancelStockId:   cancel.ID,
8153
+				GoodTypeId:      goods.GoodTypeId,
8154
+				Count:           out_count - out_count_one - count,
8155
+				Price:           warehouse.PackingPrice,
8156
+				Total:           0,
8157
+				ProductDate:     warehouse.ProductDate,
8158
+				ExpiryDate:      warehouse.ExpiryDate,
8159
+				Ctime:           time.Now().Unix(),
8160
+				Status:          1,
8161
+				OrgId:           orgID,
8162
+				OrderNumber:     cancel.OrderNumber,
8163
+				Type:            0,
8164
+				Dealer:          deaerler.DealerName,
8165
+				Manufacturer:    manufacturer.ManufacturerName,
8166
+				Number:          warehouse.Number,
8167
+				RegisterAccount: "",
8168
+				Remark:          "",
8169
+				WarehouseInfoId: warehouse.ID,
8170
+				PatientId:       patient_id,
8171
+				RecordDate:      record_time,
8172
+				StorehouseId:    goods.StorehouseId,
8173
+				IsCheck:         1,
8174
+			}
8175
+			if orgID == 9671 || orgID == 10265 {
8176
+				goodsInfo, _ := FindeNewGoodInfo(orgID, goods.ProjectId, tx)
8177
+				cancelStockInfo.Price = goodsInfo.PackingPrice
8178
+			}
8179
+			CreateNewCancelStockInfoOne(&cancelStockInfo, tx)
8180
+
8181
+			cancelInfo, _ := GetLastNewCancelStockInfoByGoodId(goods.GoodId, tx)
8182
+
8183
+			flow := models.VmStockFlow{
8184
+				WarehousingId:           warehouse.ID,
8185
+				GoodId:                  goods.GoodId,
8186
+				Number:                  warehouse.Number,
8187
+				LicenseNumber:           warehouse.LicenseNumber,
8188
+				Count:                   out_count - out_count_one - count,
8189
+				UserOrgId:               orgID,
8190
+				PatientId:               patient_id,
8191
+				SystemTime:              record_time,
8192
+				ConsumableType:          7,
8193
+				IsSys:                   1,
8194
+				WarehousingOrder:        "",
8195
+				WarehouseOutId:          lastOut.WarehouseOutId,
8196
+				WarehouseOutOrderNumber: lastOut.WarehouseOutOrderNumber,
8197
+				IsEdit:                  0,
8198
+				CancelStockId:           cancel.ID,
8199
+				CancelOrderNumber:       cancel.OrderNumber,
8200
+				Manufacturer:            manufacturer.ID,
8201
+				Dealer:                  0,
8202
+				Creator:                 warehouseOut.Creater,
8203
+				UpdateCreator:           0,
8204
+				Status:                  1,
8205
+				Ctime:                   time.Now().Unix(),
8206
+				Mtime:                   0,
8207
+				Price:                   warehouse.PackingPrice,
8208
+				WarehousingDetailId:     warehouse.ID,
8209
+				WarehouseOutDetailId:    lastOut.ID,
8210
+				CancelOutDetailId:       cancelInfo.ID,
8211
+				ProductDate:             warehouse.ProductDate,
8212
+				ExpireDate:              warehouse.ExpiryDate,
8213
+				StorehouseId:            goods.StorehouseId,
8214
+				BuyPrice:                warehouse.Price,
8215
+				ProjectId:               goods.ProjectId,
8216
+				OverCount:               sum_count,
8217
+				RegisterNumber:          warehouse.RegisterNumber,
8218
+			}
8219
+			if orgID == 9671 || orgID == 10265 {
8220
+				goodsInfo, _ := FindeNewGoodInfo(orgID, goods.ProjectId, tx)
8221
+				flow.Price = goodsInfo.PackingPrice
8222
+				flow.BuyPrice = goodsInfo.BuyPrice
8223
+			}
8224
+			CreateNewStockFlowOne(flow, tx)
8225
+
8226
+			//退库数量增加
8227
+			UpdateNewSumAddCancelCount(orgID, goods.GoodId, goods.StorehouseId, flow.Count, tx)
8228
+			ModifyNewAddGoodSumCount(goods.StorehouseId, flow.Count, orgID, goods.GoodId, tx)
8229
+		}
8230
+
8231
+		//添加入库ID
8232
+		errWarehouse := UpdateNewGoodWarehouseOutById(goods.ID, warehouse.ID, orgID, sum_count, tx)
8233
+		if errWarehouse != nil {
8234
+			goodErrcode := models.XtGoodErrcode{
8235
+				UserOrgId:      orgID,
8236
+				Errcode:        "添加入库ID报错",
8237
+				GoodId:         goods.GoodId,
8238
+				Status:         1,
8239
+				Ctime:          time.Now().Unix(),
8240
+				Mtime:          0,
8241
+				Count:          0,
8242
+				StockCount:     0,
8243
+				Creater:        creator,
8244
+				BatchNumberId:  warehouse.ID,
8245
+				WarehouseOutId: 0,
8246
+			}
8247
+			CreateGoodErrcode(goodErrcode)
8248
+		}
8249
+
8250
+		if warehouse.StockCount < maxNumber {
8251
+			goodErrcode := models.XtGoodErrcode{
8252
+				UserOrgId:      orgID,
8253
+				Errcode:        "出库接口库存数量不足",
8254
+				GoodId:         goods.GoodId,
8255
+				Status:         1,
8256
+				Ctime:          time.Now().Unix(),
8257
+				Mtime:          0,
8258
+				Count:          0,
8259
+				StockCount:     0,
8260
+				Creater:        creator,
8261
+				BatchNumberId:  warehouse.ID,
8262
+				WarehouseOutId: 0,
8263
+			}
8264
+			CreateGoodErrcode(goodErrcode)
8265
+			return errors.New("库存数量不足")
8266
+
8267
+		}
8268
+
8269
+		return nil
8270
+	} else {
8271
+		// 出库完成后,要将该批次库存清零
8272
+		warehouse.StockCount = 0
8273
+		warehouse.Mtime = time.Now().Unix()
8274
+
8275
+		errThree := UpDateNewWarehouseInfoByStock(&warehouse, tx)
8276
+		if errThree != nil {
8277
+			goodErrcode := models.XtGoodErrcode{
8278
+				UserOrgId:      orgID,
8279
+				Errcode:        "扣减库存报错",
8280
+				GoodId:         goods.GoodId,
8281
+				Status:         1,
8282
+				Ctime:          time.Now().Unix(),
8283
+				Mtime:          0,
8284
+				Count:          0,
8285
+				StockCount:     0,
8286
+				Creater:        creator,
8287
+				BatchNumberId:  warehouse.ID,
8288
+				WarehouseOutId: 0,
8289
+			}
8290
+			CreateGoodErrcode(goodErrcode)
8291
+			return errThree
8292
+		}
8293
+
8294
+		//查询剩余库存
8295
+		goodList, _ := GetNewAllGoodSumCount(goods.GoodId, orgID, goods.StorehouseId, tx)
8296
+		var sum_count int64
8297
+		for _, item := range goodList {
8298
+			sum_count += item.StockCount
8299
+		}
8300
+		fmt.Println("剩余库存", sum_count)
8301
+
8302
+		OutInfo := &models.WarehouseOutInfo{
8303
+			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
8304
+			WarehouseOutId:          warehouseOut.ID,
8305
+			WarehouseInfotId:        warehouse.ID,
8306
+			Status:                  1,
8307
+			Ctime:                   time.Now().Unix(),
8308
+			Remark:                  warehouse.Remark,
8309
+			OrgId:                   orgID,
8310
+			Type:                    1,
8311
+			Manufacturer:            warehouse.Manufacturer,
8312
+			Dealer:                  warehouse.Dealer,
8313
+			IsSys:                   1,
8314
+			SysRecordTime:           record_time,
8315
+			GoodTypeId:              goods.GoodTypeId,
8316
+			GoodId:                  goods.GoodId,
8317
+			PatientId:               patient_id,
8318
+			Number:                  warehouse.Number,
8319
+			LicenseNumber:           warehouse.LicenseNumber,
8320
+			Price:                   warehouse.PackingPrice,
8321
+			ExpiryDate:              warehouse.ExpiryDate,
8322
+			ProductDate:             warehouse.ProductDate,
8323
+			ProjectId:               goods.ProjectId,
8324
+			SupplyWarehouseId:       warehouse.SupplyWarehouseId,
8325
+			StorehouseId:            goods.StorehouseId,
8326
+			IsCheck:                 1,
8327
+			OverCount:               sum_count,
8328
+			RegisterNumber:          warehouse.RegisterNumber,
8329
+		}
8330
+		OutInfo.Count = stock_number
8331
+
8332
+		_, errcodes := GetNewNewWarehouseOutInfoIsExistSix(goods.GoodId, patient_id, record_time, goods.ProjectId, warehouse.ID, tx)
8333
+		if errcodes == gorm.ErrRecordNotFound {
8334
+			errOne := AddNewSigleWarehouseOutInfo(OutInfo, tx)
8335
+			if errOne != nil {
8336
+				return errOne
8337
+			}
8338
+		} else if errcodes == nil {
8339
+
8340
+			outInfoOne, _ := GetNewWarehouseOutInfoIsExistTen(goods.GoodId, patient_id, record_time, goods.ProjectId, warehouse.ID, tx)
8341
+			if count != outInfoOne.Count {
8342
+				UpdatedNewWarehouseOutInfoSix(OutInfo, goods.GoodId, patient_id, record_time, goods.ProjectId, warehouse.ID, tx)
8343
+			}
8344
+
8345
+		}
8346
+
8347
+		lastOut, _ := FindNewWarehouseOutInfoByPatientIdTwo(patient_id, record_time, goods.GoodId, orgID, goods.ProjectId, tx)
8348
+
8349
+		//查询该该批次已经出库的数据
8350
+		flowGood, _ := GetNewStockFlowIsBatchNumberSix(patient_id, record_time, goods.GoodId, goods.ProjectId, tx)
8351
+		var out_count int64
8352
+		var out_count_one int64
8353
+		for _, item := range flowGood {
8354
+			out_count += item.Count
8355
+		}
8356
+		flowGoodTwo, _ := GetNewStockFlowIsBatchNumberFour(patient_id, record_time, goods.GoodId, goods.ProjectId, tx)
8357
+		for _, item := range flowGoodTwo {
8358
+			out_count_one += item.Count
8359
+		}
8360
+		//如果出库数量 大于 历史出库数据 新增1条流水
8361
+		if count > out_count-out_count_one {
8362
+			stockFlow := models.VmStockFlow{
8363
+				WarehousingId:           warehouse.ID,
8364
+				GoodId:                  goods.GoodId,
8365
+				Number:                  warehouse.Number,
8366
+				LicenseNumber:           warehouse.LicenseNumber,
8367
+				Count:                   stock_number,
8368
+				UserOrgId:               orgID,
8369
+				PatientId:               goods.PatientId,
8370
+				SystemTime:              record_time,
8371
+				ConsumableType:          3,
8372
+				IsSys:                   1,
8373
+				WarehousingOrder:        warehouse.WarehousingOrder,
8374
+				WarehouseOutId:          warehouseOut.ID,
8375
+				WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
8376
+				IsEdit:                  1,
8377
+				CancelStockId:           0,
8378
+				CancelOrderNumber:       "",
8379
+				Manufacturer:            warehouse.Manufacturer,
8380
+				Dealer:                  warehouse.Dealer,
8381
+				Creator:                 creator,
8382
+				UpdateCreator:           0,
8383
+				Status:                  1,
8384
+				Ctime:                   time.Now().Unix(),
8385
+				Mtime:                   0,
8386
+				Price:                   warehouse.PackingPrice, //零售价
8387
+				WarehousingDetailId:     warehouse.ID,
8388
+				WarehouseOutDetailId:    goods.ID,
8389
+				CancelOutDetailId:       0,
8390
+				ProductDate:             warehouse.ProductDate,
8391
+				ExpireDate:              warehouse.ExpiryDate,
8392
+				SupplyWarehouseId:       warehouse.SupplyWarehouseId,
8393
+				StorehouseId:            warehouse.StorehouseId,
8394
+				AdminUserId:             creator,
8395
+				BuyPrice:                warehouse.Price, //进货价
8396
+				StockCount:              "",
8397
+				BatchNumberCount:        0,
8398
+				IsCheck:                 1,
8399
+				OverCount:               sum_count,
8400
+				RegisterNumber:          warehouse.RegisterNumber,
8401
+				ProjectId:               goods.ProjectId,
8402
+			}
8403
+			//创建出库流水
8404
+			errflow := CreateNewStockFlowOne(stockFlow, tx)
8405
+			if errflow != nil {
8406
+				goodErrcode := models.XtGoodErrcode{
8407
+					UserOrgId:      orgID,
8408
+					Errcode:        "创建出库流水报错",
8409
+					GoodId:         goods.GoodId,
8410
+					Status:         1,
8411
+					Ctime:          time.Now().Unix(),
8412
+					Mtime:          0,
8413
+					Count:          0,
8414
+					StockCount:     0,
8415
+					Creater:        creator,
8416
+					BatchNumberId:  warehouse.ID,
8417
+					WarehouseOutId: 0,
8418
+				}
8419
+				CreateGoodErrcode(goodErrcode)
8420
+			}
8421
+
8422
+			//更新出库数量
8423
+			errcodecout := ModifyNewGoodSumCount(goods.StorehouseId, stock_number, orgID, goods.GoodId, tx)
8424
+
8425
+			if errcodecout != nil {
8426
+				goodErrcode := models.XtGoodErrcode{
8427
+					UserOrgId:      orgID,
8428
+					Errcode:        "更新出库数量报错",
8429
+					GoodId:         goods.GoodId,
8430
+					Status:         1,
8431
+					Ctime:          time.Now().Unix(),
8432
+					Mtime:          0,
8433
+					Count:          0,
8434
+					StockCount:     0,
8435
+					Creater:        creator,
8436
+					BatchNumberId:  warehouse.ID,
8437
+					WarehouseOutId: 0,
8438
+				}
8439
+				CreateGoodErrcode(goodErrcode)
8440
+			}
8441
+		}
8442
+
8443
+		//退库
8444
+		if count < out_count-out_count_one {
8445
+
8446
+			operation_time := time.Now().Unix()
8447
+
8448
+			//创建退库单
8449
+			timeStr := time.Now().Format("2006-01-02")
8450
+			timeArr := strings.Split(timeStr, "-")
8451
+			total, _ := FindNewAllCancelStockTotal(orgID, tx)
8452
+			total = total + 1
8453
+			orderNumber := "CKTKD" + strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
8454
+
8455
+			cancelStock := models.CancelStock{
8456
+				OrderNumber:  orderNumber,
8457
+				OperaTime:    operation_time,
8458
+				OrgId:        orgID,
8459
+				Creater:      warehouseOut.Creater,
8460
+				Ctime:        time.Now().Unix(),
8461
+				Status:       1,
8462
+				ReturnTime:   record_time,
8463
+				Type:         1,
8464
+				StorehouseId: goods.StorehouseId,
8465
+				IsCheck:      1,
8466
+			}
8467
+			_, msgerrkonde := GetNewCancelStockDetailByOrderNumberOne(record_time, orgID, tx)
8468
+			if msgerrkonde == gorm.ErrRecordNotFound {
8469
+				AddNewSigleCancelStock(&cancelStock, tx)
8470
+			}
8471
+
8472
+			cancel, _ := GetNewLastCancelStockById(orgID, tx)
8473
+
8474
+			manufacturer, _ := GetNewManufactureById(warehouse.Manufacturer, tx)
8475
+			deaerler, _ := GetNewDealerById(warehouse.Dealer, tx)
8476
+			cancelStockInfo := models.CancelStockInfo{
8477
+				GoodId:          goods.GoodId,
8478
+				CancelStockId:   cancel.ID,
8479
+				GoodTypeId:      goods.GoodTypeId,
8480
+				Count:           out_count - out_count_one - count,
8481
+				Price:           warehouse.PackingPrice,
8482
+				Total:           0,
8483
+				ProductDate:     warehouse.ProductDate,
8484
+				ExpiryDate:      warehouse.ExpiryDate,
8485
+				Ctime:           time.Now().Unix(),
8486
+				Status:          1,
8487
+				OrgId:           orgID,
8488
+				OrderNumber:     cancel.OrderNumber,
8489
+				Type:            0,
8490
+				Dealer:          deaerler.DealerName,
8491
+				Manufacturer:    manufacturer.ManufacturerName,
8492
+				Number:          warehouse.Number,
8493
+				RegisterAccount: "",
8494
+				Remark:          "",
8495
+				WarehouseInfoId: warehouse.ID,
8496
+				PatientId:       patient_id,
8497
+				RecordDate:      record_time,
8498
+				StorehouseId:    goods.StorehouseId,
8499
+				IsCheck:         1,
8500
+			}
8501
+			if orgID == 9671 || orgID == 10265 {
8502
+				goodsInfo, _ := FindeNewGoodInfo(orgID, goods.ProjectId, tx)
8503
+				cancelStockInfo.Price = goodsInfo.PackingPrice
8504
+			}
8505
+			CreateNewCancelStockInfoOne(&cancelStockInfo, tx)
8506
+
8507
+			cancelInfo, _ := GetLastNewCancelStockInfoByGoodId(goods.GoodId, tx)
8508
+
8509
+			flow := models.VmStockFlow{
8510
+				WarehousingId:           warehouse.ID,
8511
+				GoodId:                  goods.GoodId,
8512
+				Number:                  warehouse.Number,
8513
+				LicenseNumber:           warehouse.LicenseNumber,
8514
+				Count:                   out_count - count,
8515
+				UserOrgId:               orgID,
8516
+				PatientId:               patient_id,
8517
+				SystemTime:              record_time,
8518
+				ConsumableType:          7,
8519
+				IsSys:                   1,
8520
+				WarehousingOrder:        "",
8521
+				WarehouseOutId:          lastOut.WarehouseOutId,
8522
+				WarehouseOutOrderNumber: lastOut.WarehouseOutOrderNumber,
8523
+				IsEdit:                  0,
8524
+				CancelStockId:           cancel.ID,
8525
+				CancelOrderNumber:       cancel.OrderNumber,
8526
+				Manufacturer:            manufacturer.ID,
8527
+				Dealer:                  0,
8528
+				Creator:                 warehouseOut.Creater,
8529
+				UpdateCreator:           0,
8530
+				Status:                  1,
8531
+				Ctime:                   time.Now().Unix(),
8532
+				Mtime:                   0,
8533
+				Price:                   warehouse.Price,
8534
+				WarehousingDetailId:     warehouse.ID,
8535
+				WarehouseOutDetailId:    lastOut.ID,
8536
+				CancelOutDetailId:       cancelInfo.ID,
8537
+				ProductDate:             warehouse.ProductDate,
8538
+				ExpireDate:              warehouse.ExpiryDate,
8539
+				StorehouseId:            goods.StorehouseId,
8540
+				BuyPrice:                warehouse.Price,
8541
+				ProjectId:               goods.ProjectId,
8542
+				OverCount:               sum_count,
8543
+				RegisterNumber:          warehouse.RegisterNumber,
8544
+			}
8545
+			if orgID == 9671 || orgID == 10265 {
8546
+				goodsInfo, _ := FindeNewGoodInfo(orgID, goods.ProjectId, tx)
8547
+				flow.Price = goodsInfo.PackingPrice
8548
+				flow.BuyPrice = goodsInfo.BuyPrice
8549
+			}
8550
+			CreateNewStockFlowOne(flow, tx)
8551
+
8552
+			//退库数量增加
8553
+			UpdateNewSumAddCancelCount(orgID, goods.GoodId, goods.StorehouseId, flow.Count, tx)
8554
+			//实际出库减少
8555
+			ModifyNewAddGoodSumCount(goods.StorehouseId, flow.Count, orgID, goods.GoodId, tx)
8556
+		}
8557
+
8558
+		errWarehouse := UpdateNewGoodWarehouseOutById(goods.ID, warehouse.ID, orgID, sum_count, tx)
8559
+		if errWarehouse != nil {
8560
+			goodErrcode := models.XtGoodErrcode{
8561
+				UserOrgId:      orgID,
8562
+				Errcode:        "添加入库ID报错",
8563
+				GoodId:         goods.GoodId,
8564
+				Status:         1,
8565
+				Ctime:          time.Now().Unix(),
8566
+				Mtime:          0,
8567
+				Count:          0,
8568
+				StockCount:     0,
8569
+				Creater:        creator,
8570
+				BatchNumberId:  warehouse.ID,
8571
+				WarehouseOutId: 0,
8572
+			}
8573
+			CreateGoodErrcode(goodErrcode)
8574
+		}
8575
+
8576
+	}
8577
+
8578
+	goods.Count = deliver_number - stock_number
8579
+	prepare := &models.DialysisBeforePrepare{
8580
+		Count:        deliver_number - stock_number,
8581
+		GoodTypeId:   goods.GoodTypeId,
8582
+		GoodId:       goods.GoodId,
8583
+		PatientId:    goods.PatientId,
8584
+		RecordDate:   goods.RecordDate,
8585
+		UserOrgId:    orgID,
8586
+		Ctime:        time.Now().Unix(),
8587
+		Creater:      creator,
8588
+		Status:       1,
8589
+		StorehouseId: goods.StorehouseId,
8590
+		ProjectId:    goods.ProjectId,
8591
+	}
8592
+	ConsumableNewPrescriptionDelivery(orgID, patient_id, record_time, prepare, warehouseOut, creator, count, tx)
8593
+
8594
+	return nil
8595
+}