see999 před 3 roky
rodič
revize
89ef36e9c5

+ 1 - 1
conf/app.conf Zobrazit soubor

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

+ 60 - 59
controllers/base_api_controller.go Zobrazit soubor

@@ -2,6 +2,7 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6 7
 	"fmt"
7 8
 	"strconv"
@@ -69,36 +70,36 @@ type BaseAuthAPIController struct {
69 70
 func (this *BaseAuthAPIController) Prepare() {
70 71
 	this.BaseAPIController.Prepare()
71 72
 	if this.GetAdminUserInfo() == nil {
72
-		//var userAdmin models.AdminUser
73
-		//userAdmin.Id = 1448
74
-		//userAdmin.Mobile = "13318599895"
75
-	
76
-		//userAdmin.Id = 597
77
-		//userAdmin.Mobile = "19874122664"
78
-		//userAdmin.IsSuperAdmin = false
79
-		//userAdmin.Status = 1
80
-		//userAdmin.CreateTime = 1530786071
81
-		//userAdmin.ModifyTime = 1530786071
82
-		//var subscibe models.ServeSubscibe
83
-		//subscibe.ID = 1
84
-		//subscibe.OrgId = 9675
85
-		//subscibe.PeriodStart = 1538035409
86
-		//subscibe.PeriodEnd = 1569571409
87
-		//subscibe.State = 1
88
-		//subscibe.Status = 1
89
-		//subscibe.CreatedTime = 1538035409
90
-		//subscibe.UpdatedTime = 1538035409
91
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
-		//subscibes[4] = &subscibe
93
-		//var adminUserInfo service.AdminUserInfo
94
-		//adminUserInfo.CurrentOrgId = 9675
95
-		//adminUserInfo.CurrentAppId = 4
96
-		//adminUserInfo.AdminUser = &userAdmin
97
-		//adminUserInfo.Subscibes = subscibes
98
-		//this.SetSession("admin_user_info", &adminUserInfo)
99
-
100
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
-		this.StopRun()
73
+		var userAdmin models.AdminUser
74
+		userAdmin.Id = 1448
75
+		userAdmin.Mobile = "13318599895"
76
+
77
+		userAdmin.Id = 597
78
+		userAdmin.Mobile = "19874122664"
79
+		userAdmin.IsSuperAdmin = false
80
+		userAdmin.Status = 1
81
+		userAdmin.CreateTime = 1530786071
82
+		userAdmin.ModifyTime = 1530786071
83
+		var subscibe models.ServeSubscibe
84
+		subscibe.ID = 1
85
+		subscibe.OrgId = 3877
86
+		subscibe.PeriodStart = 1538035409
87
+		subscibe.PeriodEnd = 1569571409
88
+		subscibe.State = 1
89
+		subscibe.Status = 1
90
+		subscibe.CreatedTime = 1538035409
91
+		subscibe.UpdatedTime = 1538035409
92
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
+		subscibes[4] = &subscibe
94
+		var adminUserInfo service.AdminUserInfo
95
+		adminUserInfo.CurrentOrgId = 3877
96
+		adminUserInfo.CurrentAppId = 4
97
+		adminUserInfo.AdminUser = &userAdmin
98
+		adminUserInfo.Subscibes = subscibes
99
+		this.SetSession("admin_user_info", &adminUserInfo)
100
+
101
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
102
+		//this.StopRun()
102 103
 
103 104
 	}
104 105
 
@@ -315,35 +316,35 @@ type BaseServeAPIController struct {
315 316
 func (this *BaseServeAPIController) Prepare() {
316 317
 	this.BaseAPIController.Prepare()
317 318
 	if this.GetAdminUserInfo() == nil {
318
-		//var userAdmin models.AdminUser
319
-		//userAdmin.Id = 1448
320
-		//userAdmin.Mobile = "13318599895"
321
-		
322
-		//userAdmin.Id = 597
323
-		//userAdmin.Mobile = "19874122664"
324
-		//userAdmin.IsSuperAdmin = false
325
-		//userAdmin.Status = 1
326
-		//userAdmin.CreateTime = 1530786071
327
-		//userAdmin.ModifyTime = 1530786071
328
-		//var subscibe models.ServeSubscibe
329
-		//subscibe.ID = 1
330
-		//subscibe.OrgId = 9675
331
-		//subscibe.PeriodStart = 1538035409
332
-		//subscibe.PeriodEnd = 1569571409
333
-		//subscibe.State = 1
334
-		//subscibe.Status = 1
335
-		//subscibe.CreatedTime = 1538035409
336
-		//subscibe.UpdatedTime = 1538035409
337
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
-		//subscibes[4] = &subscibe
339
-		//var adminUserInfo service.AdminUserInfo
340
-		//adminUserInfo.CurrentOrgId = 9675
341
-		//adminUserInfo.CurrentAppId = 4
342
-		//adminUserInfo.AdminUser = &userAdmin
343
-		//adminUserInfo.Subscibes = subscibes
344
-		//this.SetSession("admin_user_info", &adminUserInfo)
345
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
-		this.StopRun()
319
+		var userAdmin models.AdminUser
320
+		userAdmin.Id = 1448
321
+		userAdmin.Mobile = "13318599895"
322
+
323
+		userAdmin.Id = 597
324
+		userAdmin.Mobile = "19874122664"
325
+		userAdmin.IsSuperAdmin = false
326
+		userAdmin.Status = 1
327
+		userAdmin.CreateTime = 1530786071
328
+		userAdmin.ModifyTime = 1530786071
329
+		var subscibe models.ServeSubscibe
330
+		subscibe.ID = 1
331
+		subscibe.OrgId = 3877
332
+		subscibe.PeriodStart = 1538035409
333
+		subscibe.PeriodEnd = 1569571409
334
+		subscibe.State = 1
335
+		subscibe.Status = 1
336
+		subscibe.CreatedTime = 1538035409
337
+		subscibe.UpdatedTime = 1538035409
338
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
+		subscibes[4] = &subscibe
340
+		var adminUserInfo service.AdminUserInfo
341
+		adminUserInfo.CurrentOrgId = 3877
342
+		adminUserInfo.CurrentAppId = 4
343
+		adminUserInfo.AdminUser = &userAdmin
344
+		adminUserInfo.Subscibes = subscibes
345
+		this.SetSession("admin_user_info", &adminUserInfo)
346
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
+		//this.StopRun()
347 348
 	}
348 349
 
349 350
 	//if adminUserInfo.AppRole != nil {

+ 5 - 3
controllers/dialysis_api_controller.go Zobrazit soubor

@@ -1348,7 +1348,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1348 1348
 	remark := c.GetString("remark")
1349 1349
 	puncture_method := c.GetString("puncture_method")
1350 1350
 
1351
-	dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1351
+	//dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1352
+	dialysis_count := c.GetString("dialysis_count")
1352 1353
 	emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
1353 1354
 	emergency_treatment_other := c.GetString("emergency_treatment_other")
1354 1355
 	ductus_arantii := c.GetString("ductus_arantii")
@@ -1365,14 +1366,15 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1365 1366
 
1366 1367
 	is_infect, _ := c.GetInt64("is_infect", 0)
1367 1368
 	exposed, _ := c.GetFloat("exposed", 0)
1368
-	//skin, _ := c.GetInt64("skin", 0)
1369 1369
 	skin := c.GetString("skin")
1370 1370
 	skin_other := c.GetString("skin_other")
1371 1371
 	infect_other := c.GetString("infect_other")
1372 1372
 	ductus_arantii_other := c.GetString("ductus_arantii_other")
1373 1373
 	machine_type := c.GetString("machine_type")
1374 1374
 	puncture_needle := c.GetString("puncture_needle")
1375
-	humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1375
+	//humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1376
+
1377
+	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1376 1378
 	phinholing := c.GetString("pinholing")
1377 1379
 
1378 1380
 	catheter_suture := c.GetString("catheter_suture")

+ 23 - 3
controllers/doctors_api_controller.go Zobrazit soubor

@@ -62,6 +62,7 @@ func (c *DoctorsApiController) ScheduleAdvices() {
62 62
 	delivery_way := c.GetString("delivery_way")
63 63
 	schedule_type, _ := c.GetInt64("schedule_type")
64 64
 	partition_type, _ := c.GetInt64("partition_type")
65
+	patient_id, _ := c.GetInt64("patient_id")
65 66
 	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
66 67
 		adviceType = 0
67 68
 	}
@@ -80,10 +81,29 @@ func (c *DoctorsApiController) ScheduleAdvices() {
80 81
 	adminUserInfo := c.GetAdminUserInfo()
81 82
 	orgID := adminUserInfo.CurrentOrgId
82 83
 
83
-	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
84
-	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
84
+	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id)
85
+	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
85 86
 
86
-	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
87
+	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
88
+
89
+	index := 0
90
+	for _, item := range project {
91
+		for _, subItem := range item.HisPrescriptionTeamProject {
92
+
93
+			if subItem.HisProject.CostClassify != 3 {
94
+				subItem.IsCheckTeam = 2
95
+				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
96
+			}
97
+
98
+			if subItem.HisProject.CostClassify == 3 {
99
+				subItem.IsCheckTeam = 1
100
+				index = index + 1
101
+				if index == 1 {
102
+					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
103
+				}
104
+			}
105
+		}
106
+	}
87 107
 
88 108
 	config, _ := service.GetHisDoctorConfig(orgID)
89 109
 	project_config, _ := service.GetHisProjectConfig(orgID)

+ 0 - 1
controllers/drug_stock_api_contorller.go Zobrazit soubor

@@ -755,7 +755,6 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
755 755
 
756 756
 			if item.WarehousingCount == warehouseInfo.WarehousingCount {
757 757
 				errs = service.UpDateDrugWarehousingInfo(item)
758
-				break
759 758
 			}
760 759
 		}
761 760
 	}

+ 83 - 17
controllers/his_api_controller.go Zobrazit soubor

@@ -3249,7 +3249,7 @@ func (c *HisApiController) GetUploadInfo() {
3249 3249
 			}
3250 3250
 		}
3251 3251
 
3252
-		allTotal := fmt.Sprintf("%.2f", total)
3252
+		allTotal := fmt.Sprintf("%.4f", total)
3253 3253
 		totals, _ := strconv.ParseFloat(allTotal, 64)
3254 3254
 		order := &models.HisOrder{
3255 3255
 			UserOrgId:             adminUser.CurrentOrgId,
@@ -3294,8 +3294,8 @@ func (c *HisApiController) GetUploadInfo() {
3294 3294
 					cus := &Custom{
3295 3295
 						AdviceId:         subItem.ID,
3296 3296
 						ProjectId:        0,
3297
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
3298
-						Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
3297
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
3298
+						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
3299 3299
 						FeedetlSn:        subItem.FeedetlSn,
3300 3300
 						Price:            fmt.Sprintf("%.2f", subItem.Price),
3301 3301
 						MedListCodg:      subItem.MedListCodg,
@@ -3309,10 +3309,10 @@ func (c *HisApiController) GetUploadInfo() {
3309 3309
 					cus := &Custom{
3310 3310
 						AdviceId:         0,
3311 3311
 						ProjectId:        subItem.ID,
3312
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
3313
-						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
3312
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
3313
+						Cut:              fmt.Sprintf("%.4f", float64(subItem.Count)),
3314 3314
 						FeedetlSn:        subItem.FeedetlSn,
3315
-						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
3315
+						Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
3316 3316
 						MedListCodg:      subItem.MedListCodg,
3317 3317
 						Type:             2,
3318 3318
 					}
@@ -3324,10 +3324,10 @@ func (c *HisApiController) GetUploadInfo() {
3324 3324
 					ItemId:           item.ID,
3325 3325
 					AdviceId:         0,
3326 3326
 					ProjectId:        0,
3327
-					DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
3328
-					Cut:              fmt.Sprintf("%.2f", float64(item.Count)),
3327
+					DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
3328
+					Cut:              fmt.Sprintf("%.4f", float64(item.Count)),
3329 3329
 					FeedetlSn:        item.FeedetlSn,
3330
-					Price:            fmt.Sprintf("%.2f", float64(item.Price)),
3330
+					Price:            fmt.Sprintf("%.4f", float64(item.Price)),
3331 3331
 					MedListCodg:      item.XtHisAddtionConfig.Code,
3332 3332
 					Type:             3,
3333 3333
 				}
@@ -5225,6 +5225,15 @@ func (c *HisApiController) PreSettle() {
5225 5225
 	}
5226 5226
 }
5227 5227
 
5228
+type CustomOrderInfo struct {
5229
+	Name  string
5230
+	Spec  string
5231
+	Unit  string
5232
+	Count float64
5233
+	Price float64
5234
+	Total float64
5235
+}
5236
+
5228 5237
 func (c *HisApiController) GetPrivateExpensesInfo() {
5229 5238
 	order_id, _ := c.GetInt64("id", 0)
5230 5239
 	his_patient_id, _ := c.GetInt64("his_patient_id", 0)
@@ -5238,16 +5247,56 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
5238 5247
 	his, _ := service.GetHisPatientByIdThree(his_patient_id)
5239 5248
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5240 5249
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5241
-	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5250
+	//order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5251
+
5252
+	orderInfos, _ := service.GetHisOrderInfoByNumberOne(order.Number)
5253
+	orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
5254
+	orderInfos_three, _ := service.GetHisOrderInfoByNumberThree(order.Number)
5255
+
5256
+	var orderInfos_four []*models.HisOrderInfoTwo
5257
+	for _, item := range orderInfos_three {
5258
+		if item.HisPrescriptionProject.HisProject.CostClassify == 3 {
5259
+			item.HisPrescriptionProject.IsCheckTeam = 1
5260
+			orderInfos_four = append(orderInfos_four, item)
5261
+
5262
+		}
5263
+		if item.HisPrescriptionProject.HisProject.CostClassify != 3 {
5264
+			item.HisPrescriptionProject.IsCheckTeam = 2
5265
+			orderInfos_two = append(orderInfos_two, item)
5266
+		}
5267
+	}
5268
+
5269
+	new_order_info := RemoveRepeatedTeam(orderInfos_four)
5270
+	var cus_slice []CustomOrderInfo
5271
+	for _, item := range new_order_info {
5272
+		var cus CustomOrderInfo
5273
+		cus.Name = item.HisPrescriptionProject.XtHisProjectTeam.ProjectTeam
5274
+		cus.Unit = ""
5275
+		cus.Spec = ""
5276
+		var total float64
5277
+		for _, subItem := range orderInfos_four {
5278
+			if item.HisPrescriptionProject.TeamId == subItem.HisPrescriptionProject.TeamId {
5279
+				total = total + subItem.DetItemFeeSumamt
5280
+				fmt.Println(subItem.DetItemFeeSumamt)
5281
+			}
5282
+		}
5283
+		cus.Count = 1
5284
+		cus.Total = total
5285
+		cus_slice = append(cus_slice, cus)
5286
+	}
5287
+
5288
+	orderInfos = append(orderInfos, orderInfos_two...)
5289
+
5242 5290
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5243 5291
 	c.ServeSuccessJSON(map[string]interface{}{
5244
-		"order":         order,
5245
-		"order_info":    order_info,
5246
-		"patient":       patient,
5247
-		"admin_info":    adminInfo,
5248
-		"his":           his,
5249
-		"current_admin": role,
5250
-		"org_config":    miConfig,
5292
+		"order":          order,
5293
+		"order_info":     orderInfos,
5294
+		"patient":        patient,
5295
+		"admin_info":     adminInfo,
5296
+		"his":            his,
5297
+		"current_admin":  role,
5298
+		"org_config":     miConfig,
5299
+		"new_order_info": cus_slice,
5251 5300
 	})
5252 5301
 
5253 5302
 }
@@ -5411,3 +5460,20 @@ func (c *HisApiController) GetAllOrder() {
5411 5460
 	return
5412 5461
 
5413 5462
 }
5463
+
5464
+func RemoveRepeatedTeam(arr []*models.HisOrderInfoTwo) (newArr []*models.HisOrderInfoTwo) {
5465
+	newArr = make([]*models.HisOrderInfoTwo, 0)
5466
+	for i := 0; i < len(arr); i++ {
5467
+		repeat := false
5468
+		for j := i + 1; j < len(arr); j++ {
5469
+			if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
5470
+				repeat = true
5471
+				break
5472
+			}
5473
+		}
5474
+		if !repeat {
5475
+			newArr = append(newArr, arr[i])
5476
+		}
5477
+	}
5478
+	return
5479
+}

+ 20 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Zobrazit soubor

@@ -379,6 +379,23 @@ func (this *DialysisAPIController) DialysisRecord() {
379 379
 	_, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
380 380
 
381 381
 	projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
382
+	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
383
+
384
+	var team_projects []*models.HisPrescriptionProject
385
+	var index int64 = 0
386
+	for _, item := range temp_team_projects {
387
+		//组套里面非检验项目的
388
+		if item.HisProject.CostClassify != 3 {
389
+			projects = append(projects, item)
390
+		}
391
+		//组套里面检验项目的
392
+		if item.HisProject.CostClassify == 3 {
393
+			index = index + 1
394
+			if index == 1 {
395
+				team_projects = append(team_projects, item)
396
+			}
397
+		}
398
+	}
382 399
 
383 400
 	stockType, _ := service.GetStockType(adminInfo.Org.Id)
384 401
 
@@ -446,6 +463,7 @@ func (this *DialysisAPIController) DialysisRecord() {
446 463
 		"prescribeOne":                   prescribeOne,
447 464
 		"is_project_open_config":         is_project_open_config,
448 465
 		"project":                        projects,
466
+		"team_projects":                  team_projects,
449 467
 	}
450 468
 	this.ServeSuccessJSON(returnData)
451 469
 }
@@ -1001,7 +1019,9 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1001 1019
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1002 1020
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1003 1021
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1022
+
1004 1023
 		if err == nil {
1024
+			fmt.Println("hhhhhhhhhhh0000000000", err)
1005 1025
 			c.ServeSuccessJSON(map[string]interface{}{
1006 1026
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1007 1027
 			})

+ 20 - 0
controllers/mobile_api_controllers/doctor_advice_api_controller.go Zobrazit soubor

@@ -44,6 +44,26 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
44 44
 	if project_config.IsOpen == 1 || project_config.IsOpen == 2 {
45 45
 		//获取his医嘱数据
46 46
 		project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
47
+		//team_project, _ := service.GetMobileHisPrescriptionTeamProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
48
+		index := 0
49
+		for _, item := range project {
50
+			for _, subItem := range item.HisPrescriptionTeamProject {
51
+
52
+				if subItem.HisProject.CostClassify != 3 {
53
+					subItem.IsCheckTeam = 2
54
+					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
55
+				}
56
+
57
+				if subItem.HisProject.CostClassify == 3 {
58
+					subItem.IsCheckTeam = 1
59
+					index = index + 1
60
+					if index == 1 {
61
+						item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
62
+					}
63
+				}
64
+			}
65
+		}
66
+
47 67
 		hisAdvices, _ := service.GetHisDoctorAdvicesTwo(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
48 68
 		adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
49 69
 		if err != nil {

+ 94 - 29
controllers/mobile_api_controllers/patient_api_controller.go Zobrazit soubor

@@ -1936,10 +1936,7 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
1936 1936
 		blood_access_part_id := dataBody["blood_access_part_id"].(string)
1937 1937
 		evaluation.BloodAccessPartId = blood_access_part_id
1938 1938
 	}
1939
-	//if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "float64" {
1940
-	//	blood_access_part_id := int64(dataBody["blood_access_part_id"].(float64))
1941
-	//	evaluation.BloodAccessPartId = blood_access_part_id
1942
-	//}
1939
+
1943 1940
 	if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
1944 1941
 		blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
1945 1942
 		evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
@@ -1958,9 +1955,6 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
1958 1955
 		is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
1959 1956
 		evaluation.IsHemorrhage = is_hemorrhage
1960 1957
 
1961
-		//if dataBody["is_hemorrhage"] != nil && reflect.TypeOf(dataBody["is_hemorrhage"]).String() == "float64" {
1962
-		//	is_hemorrhage := int64(dataBody["is_hemorrhage"].(float64))
1963
-		//	fmt.Println("is_hemorrhage2222222222222222",is_hemorrhage)
1964 1958
 		if is_hemorrhage != 1 && is_hemorrhage != 2 {
1965 1959
 			is_hemorrhage = 0
1966 1960
 		}
@@ -2031,8 +2025,8 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2031 2025
 
2032 2026
 	if dataBody["dialysis_count"] != nil && reflect.TypeOf(dataBody["dialysis_count"]).String() == "string" {
2033 2027
 		dialysis_count, _ := dataBody["dialysis_count"].(string)
2034
-		count, _ := strconv.ParseInt(dialysis_count, 10, 64)
2035
-		evaluation.DialysisCount = count
2028
+		//count, _ := strconv.ParseInt(dialysis_count, 10, 64)
2029
+		evaluation.DialysisCount = dialysis_count
2036 2030
 	}
2037 2031
 
2038 2032
 	if dataBody["is_infect"] != nil && reflect.TypeOf(dataBody["is_infect"]).String() == "string" {
@@ -2072,8 +2066,8 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2072 2066
 		evaluation.PunctureNeedle = punctureNeedle
2073 2067
 	}
2074 2068
 
2075
-	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "float64" {
2076
-		humor_excessive_symptom := int64(dataBody["humor_excessive_symptom"].(float64))
2069
+	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "string" {
2070
+		humor_excessive_symptom := dataBody["humor_excessive_symptom"].(string)
2077 2071
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2078 2072
 	}
2079 2073
 
@@ -3328,6 +3322,8 @@ func (this *PatientApiController) GetSearchPatient() {
3328 3322
 func (c *PatientApiController) ExecProject() {
3329 3323
 	execution_time := c.GetString("execution_time")
3330 3324
 	project_id, _ := c.GetInt64("project_id")
3325
+	team_id, _ := c.GetInt64("team_id")
3326
+	is_check_team, _ := c.GetInt64("is_check_team")
3331 3327
 
3332 3328
 	if len(execution_time) <= 0 {
3333 3329
 		utils.ErrorLog("execution_time")
@@ -3343,6 +3339,7 @@ func (c *PatientApiController) ExecProject() {
3343 3339
 		return
3344 3340
 	}
3345 3341
 	adminInfo := c.GetMobileAdminUserInfo()
3342
+
3346 3343
 	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3347 3344
 	if project.ExecutionState == 1 {
3348 3345
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
@@ -3352,29 +3349,63 @@ func (c *PatientApiController) ExecProject() {
3352 3349
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
3353 3350
 		return
3354 3351
 	}
3355
-
3356 3352
 	project.ExecutionState = 1
3357 3353
 	project.ExecutionStaff = adminInfo.AdminUser.Id
3358 3354
 	project.ExecutionTime = theTime.Unix()
3359
-	err := service.SaveHisProject(&project)
3360
-	if err == nil {
3361
-		c.ServeSuccessJSON(map[string]interface{}{
3362
-			"project": project,
3363
-		})
3355
+	if team_id == 0 {
3356
+
3357
+		err := service.SaveHisProject(&project)
3358
+		if err == nil {
3359
+			c.ServeSuccessJSON(map[string]interface{}{
3360
+				"project": project,
3361
+			})
3362
+		} else {
3363
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3364
+			return
3365
+
3366
+		}
3364 3367
 	} else {
3365
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3366
-		return
3368
+		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
3367 3369
 
3368
-	}
3370
+			err := service.SaveHisProject(&project)
3371
+			if err == nil {
3372
+				c.ServeSuccessJSON(map[string]interface{}{
3373
+					"project": project,
3374
+				})
3375
+			} else {
3376
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3377
+				return
3378
+
3379
+			}
3380
+		} else {
3381
+			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
3382
+			var ids []int64
3383
+			for _, items := range ps {
3384
+				ids = append(ids, items.ID)
3385
+			}
3386
+			err := service.UpdateTeamProjectExceStatus(ids, adminInfo.AdminUser.Id, theTime.Unix())
3387
+			if err == nil {
3388
+				c.ServeSuccessJSON(map[string]interface{}{
3389
+					"project": project,
3390
+				})
3391
+			} else {
3392
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3393
+				return
3394
+
3395
+			}
3396
+		}
3369 3397
 
3398
+	}
3370 3399
 }
3371 3400
 
3372 3401
 func (c *PatientApiController) CheckProject() {
3373 3402
 
3374 3403
 	adminInfo := c.GetMobileAdminUserInfo()
3375 3404
 	project_id, _ := c.GetInt64("project_id")
3376
-	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3405
+	team_id, _ := c.GetInt64("team_id")
3406
+	is_check_team, _ := c.GetInt64("is_check_team")
3377 3407
 
3408
+	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3378 3409
 	if project.CheckState == 1 {
3379 3410
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
3380 3411
 		return
@@ -3387,18 +3418,52 @@ func (c *PatientApiController) CheckProject() {
3387 3418
 	project.Checker = adminInfo.AdminUser.Id
3388 3419
 	project.CheckTime = time.Now().Unix()
3389 3420
 	project.CheckState = 1
3421
+	if team_id == 0 {
3422
+		err := service.SaveHisProject(&project)
3423
+		if err == nil {
3424
+			c.ServeSuccessJSON(map[string]interface{}{
3425
+				"msg":     "ok",
3426
+				"project": project,
3427
+			})
3390 3428
 
3391
-	err := service.SaveHisProject(&project)
3429
+		} else {
3430
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3431
+			return
3392 3432
 
3393
-	if err == nil {
3394
-		c.ServeSuccessJSON(map[string]interface{}{
3395
-			"msg":     "ok",
3396
-			"project": project,
3397
-		})
3433
+		}
3398 3434
 
3399 3435
 	} else {
3400
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3401
-		return
3436
+		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
3437
+			err := service.SaveHisProject(&project)
3438
+			if err == nil {
3439
+				c.ServeSuccessJSON(map[string]interface{}{
3440
+					"msg":     "ok",
3441
+					"project": project,
3442
+				})
3443
+
3444
+			} else {
3445
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3446
+				return
3447
+
3448
+			}
3449
+
3450
+		} else {
3451
+			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
3452
+			var ids []int64
3453
+			for _, items := range ps {
3454
+				ids = append(ids, items.ID)
3455
+			}
3456
+			err := service.UpdateTeamProjectCheckStatus(ids, project.PatientId, project.RecordDate, project.UserOrgId, adminInfo.AdminUser.Id, time.Now().Unix())
3457
+			if err == nil {
3458
+				c.ServeSuccessJSON(map[string]interface{}{
3459
+					"project": project,
3460
+				})
3461
+			} else {
3462
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3463
+				return
3464
+
3465
+			}
3466
+		}
3402 3467
 
3403 3468
 	}
3404 3469
 

+ 223 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Zobrazit soubor

@@ -5,8 +5,12 @@ import (
5 5
 	"XT_New/enums"
6 6
 	"XT_New/models"
7 7
 	"XT_New/service"
8
+	"XT_New/utils"
9
+	"encoding/json"
8 10
 	"fmt"
9 11
 	"github.com/jinzhu/gorm"
12
+	"reflect"
13
+	"strconv"
10 14
 	"strings"
11 15
 	"time"
12 16
 )
@@ -417,3 +421,222 @@ func (this *StaffScheduleApiController) UpdateBloodSchedule() {
417 421
 		service.UpdateDialysisPrescriptionOne(prescription, patient_id, startTime)
418 422
 	}
419 423
 }
424
+
425
+func (this *StaffScheduleApiController) GetSchedulePatient() {
426
+
427
+	schedule, _ := this.GetInt64("schedule", 0) //1已2未
428
+	contagion, _ := this.GetInt64("contagion", 0)
429
+	keywords := this.GetString("keywords", "")
430
+	adminInfo := this.GetAdminUserInfo()
431
+
432
+	thisTime := time.Now()
433
+	weekDay := int(thisTime.Weekday())
434
+	if weekDay == 0 {
435
+		weekDay = 7
436
+	}
437
+	thisWeekEnd := 7 - weekDay
438
+	weekStartPoint := thisWeekEnd - 6
439
+	weekStartDay := thisTime.AddDate(0, 0, weekStartPoint)
440
+	weekEndPoint := thisWeekEnd + 7
441
+	weekEndDay := thisTime.AddDate(0, 0, weekEndPoint)
442
+	fmt.Println(weekStartPoint, weekStartDay, weekEndPoint, weekEndDay)
443
+
444
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
445
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
446
+	fmt.Println(weekStartTime, weekEndTime)
447
+
448
+	timeLayout := "2006-01-02 15:04:05"
449
+	loc, _ := time.LoadLocation("Local")
450
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
451
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
452
+	weekStart := theStarTime.Unix()
453
+	weekEnd := theEndTime.Unix()
454
+
455
+	patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.CurrentOrgId, keywords, weekStart, weekEnd, schedule, contagion)
456
+
457
+	this.ServeSuccessJSON(map[string]interface{}{
458
+		"patients": patients,
459
+	})
460
+	return
461
+}
462
+
463
+func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
464
+
465
+	patientID, _ := c.GetInt64("patient_id", 0)
466
+	if patientID <= 0 {
467
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
468
+		return
469
+	}
470
+
471
+	adminUserInfo := c.GetAdminUserInfo()
472
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patientID)
473
+	if patientInfo.ID == 0 {
474
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
475
+		return
476
+	}
477
+
478
+	var schedule models.Schedule
479
+	dataBody := make(map[string]interface{}, 0)
480
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
481
+	if err != nil {
482
+		utils.ErrorLog(err.Error())
483
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
484
+		return
485
+	}
486
+
487
+	if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
488
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
489
+		return
490
+	}
491
+	scheduleDate, _ := dataBody["schedule_date"].(string)
492
+	if len(scheduleDate) == 0 {
493
+		utils.ErrorLog("len(schedule_date) == 0")
494
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
495
+		return
496
+	}
497
+	timeLayout := "2006-01-02"
498
+	loc, _ := time.LoadLocation("Local")
499
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
500
+	if err != nil {
501
+		utils.ErrorLog(err.Error())
502
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
503
+		return
504
+	}
505
+	schedule.ScheduleDate = theTime.Unix()
506
+
507
+	timeNow := time.Now().Format("2006-01-02")
508
+	if timeNow > scheduleDate {
509
+		utils.ErrorLog(timeNow)
510
+		utils.ErrorLog(scheduleDate)
511
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
512
+		return
513
+	}
514
+
515
+	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
516
+		utils.ErrorLog("schedule_type")
517
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
+		return
519
+	}
520
+	scheduleType := int64(dataBody["schedule_type"].(float64))
521
+	if scheduleType < 1 || scheduleType > 3 {
522
+		utils.ErrorLog("scheduleType < 3")
523
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
524
+		return
525
+	}
526
+	schedule.ScheduleType = scheduleType
527
+
528
+	if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
529
+		utils.ErrorLog("bed_id")
530
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
531
+		return
532
+	}
533
+	bedId := int64(dataBody["bed_id"].(float64))
534
+	if bedId < 1 {
535
+		utils.ErrorLog("bedId < 1")
536
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
537
+		return
538
+	}
539
+	schedule.BedId = bedId
540
+
541
+	if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
542
+		utils.ErrorLog("partition_id")
543
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
544
+		return
545
+	}
546
+	partitionId := int64(dataBody["partition_id"].(float64))
547
+	if partitionId < 1 {
548
+		utils.ErrorLog("partitionId < 1")
549
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
550
+		return
551
+	}
552
+	schedule.PartitionId = partitionId
553
+
554
+	if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
555
+		utils.ErrorLog("schedule_week")
556
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
557
+		return
558
+	}
559
+	scheduleWeek := int64(dataBody["schedule_week"].(float64))
560
+	if scheduleWeek < 1 || scheduleWeek > 7 {
561
+		utils.ErrorLog("scheduleWeek < 1")
562
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
563
+		return
564
+	}
565
+	schedule.ScheduleWeek = scheduleWeek
566
+
567
+	if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
568
+		utils.ErrorLog("mode_id")
569
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
570
+		return
571
+	}
572
+	modeId := int64(dataBody["mode_id"].(float64))
573
+	if modeId < 1 && modeId > 14 {
574
+		utils.ErrorLog("modeId < 1")
575
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
576
+		return
577
+	}
578
+	schedule.ModeId = modeId
579
+
580
+	schedule.PatientId = patientID
581
+	schedule.CreatedTime = time.Now().Unix()
582
+	schedule.UpdatedTime = time.Now().Unix()
583
+	schedule.Status = 1
584
+	schedule.UserOrgId = adminUserInfo.CurrentOrgId
585
+
586
+	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
587
+	if bed == nil {
588
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
589
+		return
590
+	}
591
+	if bed.ZoneID != schedule.PartitionId {
592
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
593
+		return
594
+	}
595
+
596
+	scheduleDateStart := scheduleDate + " 00:00:00"
597
+	scheduleDateEnd := scheduleDate + " 23:59:59"
598
+	timeLayout = "2006-01-02 15:04:05"
599
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
600
+	theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
601
+	startTime := theStartTime.Unix()
602
+	endTime := theEndTime.Unix()
603
+
604
+	//一天只有排班一次
605
+	daySchedule, err := service.GetDaySchedule(adminUserInfo.CurrentOrgId, startTime, endTime, patientID)
606
+	if daySchedule.ID > 0 {
607
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
608
+		return
609
+	}
610
+
611
+	//同天同位置只能排一个
612
+	pointSchedule, err := service.GetPointSchedule(adminUserInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
613
+	if err != nil {
614
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
615
+		return
616
+	}
617
+	if pointSchedule.ID > 0 {
618
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
619
+		return
620
+	}
621
+
622
+	redis := service.RedisClient()
623
+	defer redis.Close()
624
+	err = service.CreateSchedule(&schedule)
625
+
626
+	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
627
+	redis.Set(key, "", time.Second)
628
+
629
+	fmt.Println(err)
630
+	if err != nil {
631
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
632
+		return
633
+	}
634
+	schedule.Patient = patientInfo.Name
635
+
636
+	c.ServeSuccessJSON(map[string]interface{}{
637
+		"msg":      "ok",
638
+		"schedule": schedule,
639
+	})
640
+	return
641
+
642
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Zobrazit soubor

@@ -21,4 +21,6 @@ func StaffScheduleApiControllersRegisterRouters() {
21 21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22 22
 	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
23 23
 	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
24
+	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
25
+	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
24 26
 }

+ 10 - 4
controllers/stock_in_api_controller.go Zobrazit soubor

@@ -690,6 +690,10 @@ func (c *StockManagerApiController) EditWarehouse() {
690 690
 				}
691 691
 
692 692
 				service.UpdateWarehouseInfoByGoodId(goodinfo, item.ID)
693
+				flowStock := models.VmStockFlow{
694
+					Count: item.WarehousingCount,
695
+				}
696
+				service.UpdatedStockFlowByGoodId(item.WarehousingId, item.GoodId, flowStock)
693 697
 				//改变库存
694 698
 				good, _ := service.GetLastInfoMationById(info.GoodId)
695 699
 				warhouseCount := strconv.FormatInt(total, 10)
@@ -734,7 +738,6 @@ func (c *StockManagerApiController) EditWarehouse() {
734 738
 					Remark:           item.Remark,
735 739
 				}
736 740
 				service.UpdateWarehouseInfoByGoodIdOne(goodinfo, item.ID)
737
-				break
738 741
 			}
739 742
 
740 743
 		}
@@ -5339,7 +5342,7 @@ func (this *StockManagerApiController) GetReportStockList() {
5339 5342
 	fmt.Println("startTime", startTime, "endTime", endTime)
5340 5343
 	//list, total, _ := service.GetReportStockList(startTime, endTime, orgId, keyword, page, limit)
5341 5344
 
5342
-	list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit)
5345
+	list, total, _ := service.GetStockDamagedList(orgId, keyword, page, limit, startTime, endTime)
5343 5346
 	damageList, _ := service.GetStockDamagedCount(orgId)
5344 5347
 	doctorlist, _ := service.GetAllDoctorThree(orgId)
5345 5348
 
@@ -6482,9 +6485,12 @@ func (this *StockManagerApiController) SaveStockInventoryList() {
6482 6485
 func (this *StockManagerApiController) GetDamageDetailByGoodId() {
6483 6486
 
6484 6487
 	good_id, _ := this.GetInt64("good_id")
6485
-	list, _ := service.GetDamageDetailByGoodId(good_id)
6488
+	warehousing_order := this.GetString("warehousing_order")
6489
+	inventory_type, _ := this.GetInt64("type")
6490
+	fmt.Println("inventory_type23232323223322332", inventory_type)
6491
+	list, _ := service.GetDamageDetailByGoodId(good_id, warehousing_order, inventory_type)
6486 6492
 	orgId := this.GetAdminUserInfo().CurrentOrgId
6487
-	damageList, _ := service.GetStockDamagedCount(orgId)
6493
+	damageList, _ := service.GetStockDamagedCountOne(orgId, warehousing_order, inventory_type)
6488 6494
 	this.ServeSuccessJSON(map[string]interface{}{
6489 6495
 		"list":       list,
6490 6496
 		"damageList": damageList,

+ 11 - 10
models/device_models.go Zobrazit soubor

@@ -1056,16 +1056,17 @@ type VmXtSchedule struct {
1056 1056
 }
1057 1057
 
1058 1058
 type PatientDeviceNumber struct {
1059
-	ID       int64           `gorm:"column:id" json:"id" form:"id"`
1060
-	OrgId    int64           `gorm:"column:org_id" json:"org_id" form:"org_id"`
1061
-	Number   string          `gorm:"column:number" json:"number" form:"number"`
1062
-	GroupId  int64           `gorm:"column:group_id" json:"group_id" form:"group_id"`
1063
-	ZoneId   int64           `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1064
-	Status   int64           `gorm:"column:status" json:"status" form:"status"`
1065
-	Ctime    int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
1066
-	Mtime    int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
1067
-	Sort     int64           `gorm:"column:sort" json:"sort" form:"sort"`
1068
-	Schedule []*BlodSchedule `json:"schedule" gorm:"foreignkey:BedId;AssociationForeignKey:ID;"`
1059
+	ID         int64           `gorm:"column:id" json:"id" form:"id"`
1060
+	OrgId      int64           `gorm:"column:org_id" json:"org_id" form:"org_id"`
1061
+	Number     string          `gorm:"column:number" json:"number" form:"number"`
1062
+	GroupId    int64           `gorm:"column:group_id" json:"group_id" form:"group_id"`
1063
+	ZoneId     int64           `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
1064
+	Status     int64           `gorm:"column:status" json:"status" form:"status"`
1065
+	Ctime      int64           `gorm:"column:ctime" json:"ctime" form:"ctime"`
1066
+	Mtime      int64           `gorm:"column:mtime" json:"mtime" form:"mtime"`
1067
+	Sort       int64           `gorm:"column:sort" json:"sort" form:"sort"`
1068
+	DeviceZone DeviceZone      `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:ZoneId;"`
1069
+	Schedule   []*BlodSchedule `json:"schedule" gorm:"foreignkey:BedId;AssociationForeignKey:ID;"`
1069 1070
 }
1070 1071
 
1071 1072
 func (PatientDeviceNumber) TableName() string {

+ 3 - 3
models/dialysis.go Zobrazit soubor

@@ -287,7 +287,7 @@ type PredialysisEvaluation struct {
287 287
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
288 288
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
289 289
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
290
-	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count"`
290
+	DialysisCount                  string  `gorm:"column:dialysis_count" json:"dialysis_count"`
291 291
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
292 292
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
293 293
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
@@ -301,7 +301,7 @@ type PredialysisEvaluation struct {
301 301
 	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other"`
302 302
 	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other"`
303 303
 	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other"`
304
-	HumorExcessiveSymptom          int64   `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
304
+	HumorExcessiveSymptom          string  `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom"`
305 305
 	Phinholing                     string  `gorm:"column:pinholing" json:"pinholing" form:"pinholing"`
306 306
 	CatheterSuture                 string  `gorm:"column:catheter_suture" json:"catheter_suture" form:"catheter_suture"`
307 307
 	CatheterSutureOther            string  `gorm:"column:catheter_suture_other" json:"catheter_suture_other" form:"catheter_suture_other"`
@@ -862,7 +862,7 @@ type XtDialysisOrders struct {
862 862
 	FinishCreator  int64  `gorm:"column:finish_creator" json:"finish_creator" form:"finish_creator"`
863 863
 	FinishModifier int64  `gorm:"column:finish_modifier" json:"finish_modifier" form:"finish_modifier"`
864 864
 	SchedualType   int64  `gorm:"column:schedual_type" json:"schedual_type" form:"schedual_type"`
865
-	Number         int64  `gorm:"column:number" json:"number" form:"number"`
865
+	Number         string `gorm:"column:number" json:"number" form:"number"`
866 866
 	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
867 867
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
868 868
 	ModeId         int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`

+ 44 - 0
models/his_models.go Zobrazit soubor

@@ -778,6 +778,7 @@ type HisPrescriptionProject struct {
778 778
 	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
779 779
 	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
780 780
 	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
781
+	IsCheckTeam   int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
781 782
 }
782 783
 
783 784
 func (HisPrescriptionProject) TableName() string {
@@ -1015,6 +1016,49 @@ func (HisOrderInfo) TableName() string {
1015 1016
 	return "his_order_info"
1016 1017
 }
1017 1018
 
1019
+type HisOrderInfoTwo struct {
1020
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1021
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1022
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1023
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1024
+	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1025
+	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
1026
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
1027
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1028
+	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
1029
+	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
1030
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1031
+	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
1032
+	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1033
+	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
1034
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1035
+	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
1036
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1037
+	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
1038
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1039
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1040
+	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1041
+	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
1042
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1043
+	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
1044
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1045
+	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1046
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1047
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1048
+	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1049
+	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
1050
+	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1051
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
1052
+	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1053
+
1054
+	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1055
+	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1056
+}
1057
+
1058
+func (HisOrderInfoTwo) TableName() string {
1059
+	return "his_order_info"
1060
+}
1061
+
1018 1062
 type VMHisPatient struct {
1019 1063
 	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1020 1064
 	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`

+ 32 - 0
service/dialysis_service.go Zobrazit soubor

@@ -1233,3 +1233,35 @@ func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (ad
1233 1233
 	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1234 1234
 	return
1235 1235
 }
1236
+
1237
+func UpdateTeamProjectExceStatus(ids []int64, admin_user_id int64, execution_time int64) (err error) {
1238
+	ut := writeDb.Begin()
1239
+	db := ut.Model(&models.HisPrescriptionProject{})
1240
+	err = db.Where("status = 1   AND id IN (?)", ids).Updates(map[string]interface{}{"execution_time": execution_time, "execution_state": 1, "execution_staff": admin_user_id}).Error
1241
+	if err != nil {
1242
+		ut.Rollback()
1243
+		return
1244
+	}
1245
+
1246
+	ut.Commit()
1247
+	return err
1248
+
1249
+}
1250
+
1251
+func UpdateTeamProjectCheckStatus(ids []int64, patient_id int64, record_date int64, user_org_id int64, admin_user_id int64, check_time int64) (err error) {
1252
+	ut := writeDb.Begin()
1253
+	err = ut.Model(&models.HisPrescriptionProject{}).Where("status = 1   AND id IN (?) AND patient_id = ? AND user_org_id = ? AND record_date = ?", ids, patient_id, user_org_id, record_date).Updates(map[string]interface{}{"check_time": check_time, "check_state": 1, "checker": admin_user_id}).Error
1254
+	if err != nil {
1255
+		ut.Rollback()
1256
+		return
1257
+	}
1258
+
1259
+	ut.Commit()
1260
+	return err
1261
+
1262
+}
1263
+
1264
+func GetCheckTeamProject(team_id int64, patient_id int64, record_date int64, user_org_id int64) (ps []*models.HisPrescriptionProject, err error) {
1265
+	err = readDb.Model(&models.HisPrescriptionProject{}).Joins("JOIN xt_his_project as p On p.id = his_prescription_project.project_id AND p.cost_classify = 3").Where("his_prescription_project.team_id IN (?) AND his_prescription_project.patient_id = ? AND his_prescription_project.user_org_id = ? AND his_prescription_project.record_date = ? AND his_prescription_project.status = 1", team_id, patient_id, user_org_id, record_date).Find(&ps).Error
1266
+	return
1267
+}

+ 1 - 1
service/doctor_schedule_service.go Zobrazit soubor

@@ -607,7 +607,7 @@ func GetPatientScheduleByBed(schedule_date int64, zoneid int64, orgid int64) (li
607 607
 	if orgid > 0 {
608 608
 		db = db.Where("x.org_id = ?", orgid)
609 609
 	}
610
-	err = db.Select("x.id,x.number,x.sort,x.group_id,x.zone_id,x.sort").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
610
+	err = db.Select("x.id,x.number,x.sort,x.group_id,x.zone_id,x.sort").Preload("DeviceZone", "status = 1").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
611 611
 		return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ?", orgid, schedule_date).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1").Preload("BloodDialysisPrescription", "status = 1")
612 612
 	}).Find(&list).Error
613 613
 

+ 43 - 1
service/his_service.go Zobrazit soubor

@@ -1585,6 +1585,43 @@ func GetHisOrderDetailByNumber(order_number string, org_id int64) (order []*HisO
1585 1585
 	return
1586 1586
 }
1587 1587
 
1588
+//func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
1589
+//	db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1590
+//		return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
1591
+//	})
1592
+//	err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
1593
+//	return
1594
+//}
1595
+
1596
+func GetHisOrderInfoByNumberOne(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1597
+	db := readDb.Model(&models.HisOrderInfoTwo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1598
+		return db.Preload("Drug", "status = 1").Where("status = 1")
1599
+	})
1600
+	err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
1601
+	return
1602
+}
1603
+
1604
+func GetHisOrderInfoByNumberTwo(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1605
+	db := readDb.Model(&models.HisOrderInfoTwo{})
1606
+	db = db.Joins("Join his_prescription_project as p  On p.id = his_order_info.project_id AND p.team_id = 0")
1607
+	db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1608
+		return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
1609
+	})
1610
+	err = db.Where("his_order_info.order_number = ? AND his_order_info.status = 1 AND his_order_info.project_id > 0 ", order_number).Find(&order).Error
1611
+	return
1612
+}
1613
+
1614
+func GetHisOrderInfoByNumberThree(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1615
+	db := readDb.Model(&models.HisOrderInfoTwo{})
1616
+	db = db.Joins("Join his_prescription_project as p  On p.id = his_order_info.project_id AND p.team_id > 0")
1617
+
1618
+	db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1619
+		return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
1620
+	})
1621
+	err = db.Where("his_order_info.order_number = ? AND his_order_info.status = 1 AND his_order_info.project_id > 0", order_number).Find(&order).Error
1622
+	return
1623
+}
1624
+
1588 1625
 type MedicalInsuranceCostCompare struct {
1589 1626
 	ID        int64   `gorm:"column:id" json:"id" form:"id"`
1590 1627
 	StartTime int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
@@ -1986,7 +2023,12 @@ func GetHisPrescriptionProjectsByID(id int64) (projects []*models.HisPrescriptio
1986 2023
 }
1987 2024
 
1988 2025
 func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
1989
-	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1", user_org_id, patient_id, record_time).Find(&projects).Error
2026
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id = 0", user_org_id, patient_id, record_time).Find(&projects).Error
2027
+	return
2028
+}
2029
+
2030
+func GetHisPrescriptionTeamProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
2031
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id > 0", user_org_id, patient_id, record_time).Find(&projects).Error
1990 2032
 	return
1991 2033
 }
1992 2034
 

+ 263 - 90
service/mobile_dialysis_service.go Zobrazit soubor

@@ -1181,7 +1181,10 @@ func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay
1181 1181
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1182 1182
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1183 1183
 			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1184
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1184
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1185
+			}).
1186
+			Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
1187
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
1185 1188
 			}).
1186 1189
 			Where("status = 1 AND user_org_id = ?", orgID)
1187 1190
 		if scheduleDate != 0 {
@@ -1202,7 +1205,10 @@ func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay
1202 1205
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1203 1206
 			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1204 1207
 			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1205
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1208
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
1209
+			}).
1210
+			Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
1211
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
1206 1212
 			}).
1207 1213
 			Where("status = 1 AND user_org_id = ?", orgID)
1208 1214
 		if scheduleDate != 0 {
@@ -2070,20 +2076,21 @@ func (HisMScheduleDoctorAdviceVMOne) TableName() string {
2070 2076
 }
2071 2077
 
2072 2078
 type HisMScheduleProjectVM struct {
2073
-	ID                     int64                            `gorm:"column:id" json:"id"`
2074
-	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id"`
2075
-	PartitionId            int64                            `gorm:"column:partition_id" json:"partition_id"`
2076
-	BedId                  int64                            `gorm:"column:bed_id" json:"bed_id"`
2077
-	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id"`
2078
-	ScheduleDate           int64                            `gorm:"column:schedule_date" json:"schedule_date"`
2079
-	ScheduleType           int64                            `gorm:"column:schedule_type" json:"schedule_type"`
2080
-	ModeId                 int64                            `gorm:"column:mode_id" json:"mode_id"`
2081
-	Status                 int64                            `gorm:"column:status" json:"status"`
2082
-	DialysisOrder          *MDialysisOrderVM                `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
2083
-	SchedualPatient        *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
2084
-	DeviceNumber           *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
2085
-	Prescription           *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
2086
-	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
2079
+	ID                         int64                            `gorm:"column:id" json:"id"`
2080
+	UserOrgId                  int64                            `gorm:"column:user_org_id" json:"user_org_id"`
2081
+	PartitionId                int64                            `gorm:"column:partition_id" json:"partition_id"`
2082
+	BedId                      int64                            `gorm:"column:bed_id" json:"bed_id"`
2083
+	PatientId                  int64                            `gorm:"column:patient_id" json:"patient_id"`
2084
+	ScheduleDate               int64                            `gorm:"column:schedule_date" json:"schedule_date"`
2085
+	ScheduleType               int64                            `gorm:"column:schedule_type" json:"schedule_type"`
2086
+	ModeId                     int64                            `gorm:"column:mode_id" json:"mode_id"`
2087
+	Status                     int64                            `gorm:"column:status" json:"status"`
2088
+	DialysisOrder              *MDialysisOrderVM                `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
2089
+	SchedualPatient            *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
2090
+	DeviceNumber               *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
2091
+	Prescription               *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
2092
+	HisPrescriptionProject     []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
2093
+	HisPrescriptionTeamProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"team_project"`
2087 2094
 }
2088 2095
 
2089 2096
 func (HisMScheduleProjectVM) TableName() string {
@@ -2150,76 +2157,157 @@ func GetHisDoctorAdviceCount(startime int64, endtime int64, deliveway string, or
2150 2157
 	return advice, err
2151 2158
 }
2152 2159
 
2153
-func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64) ([]*MScheduleDoctorAdviceVM, error) {
2160
+func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64) ([]*MScheduleDoctorAdviceVM, error) {
2154 2161
 	var vms []*MScheduleDoctorAdviceVM
2155 2162
 	adviceWhere := ""
2156 2163
 	adviceCondition := []interface{}{}
2157 2164
 	if adviceType == 0 {
2158 2165
 		if patientType == 0 {
2159
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
2160
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2166
+			if patient_id > 0 {
2167
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1) and patient_id = ?"
2168
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2169
+			} else {
2170
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND (advice_type = 3 OR advice_type = 1)"
2171
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2172
+			}
2161 2173
 
2162 2174
 		} else if patientType == 1 {
2163
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
2164
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2175
+			if patient_id > 0 {
2176
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1) and patient_id = ?"
2177
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2178
+			} else {
2179
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_doctor = ? AND(advice_type = 3 OR advice_type = 1)"
2180
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2181
+			}
2165 2182
 
2166 2183
 		} else if patientType == 2 {
2167
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
2168
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2184
+			if patient_id > 0 {
2185
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1 and patient_id = ?)"
2186
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2187
+			} else {
2188
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND execution_staff = 0 AND(advice_type = 3 OR advice_type = 1)"
2189
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2190
+			}
2191
+
2169 2192
 		}
2170 2193
 
2171 2194
 	} else if adviceType == 1 {
2172 2195
 		if patientType == 0 {
2173
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
2174
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2196
+			if patient_id > 0 {
2197
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? and patient_id = ? "
2198
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2199
+			} else {
2200
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ?  "
2201
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2202
+			}
2175 2203
 
2176 2204
 		} else if patientType == 1 {
2177
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
2178
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2205
+			if patient_id > 0 {
2206
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? and patient_id = ?"
2207
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2208
+			} else {
2209
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND advice_doctor = ? "
2210
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2211
+			}
2179 2212
 
2180 2213
 		} else if patientType == 2 {
2181
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
2182
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2214
+			if patient_id > 0 {
2215
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0 and patient_id = ?"
2216
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2217
+			} else {
2218
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND record_date = ? AND execution_staff = 0"
2219
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2220
+			}
2183 2221
 
2184 2222
 		}
2185 2223
 
2186 2224
 	} else if adviceType == 3 {
2187 2225
 		if patientType == 0 {
2188
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
2189
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2226
+			if patient_id > 0 {
2227
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ? and patient_id = ?  "
2228
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2229
+			} else {
2230
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 3 AND record_date = ?  "
2231
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2232
+			}
2190 2233
 
2191 2234
 		} else if patientType == 1 {
2192
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
2193
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2235
+			if patient_id > 0 {
2236
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? and patient_id = ?"
2237
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2238
+			} else {
2239
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3 AND advice_doctor = ? "
2240
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2241
+			}
2242
+
2194 2243
 		} else if patientType == 2 {
2195
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
2196
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2244
+			if patient_id > 0 {
2245
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0 and patient_id = ?"
2246
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2247
+			} else {
2248
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 3  AND execution_staff = 0"
2249
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2250
+			}
2251
+
2197 2252
 		}
2198 2253
 
2199 2254
 	} else if adviceType == 2 && len(deliverWay) > 0 {
2200 2255
 		if patientType == 0 {
2201
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
2202
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2256
+			if patient_id > 0 {
2257
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ? and patient_id = ?"
2258
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay, patient_id)
2259
+			} else {
2260
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and delivery_way = ?"
2261
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2262
+			}
2203 2263
 
2204 2264
 		} else if patientType == 1 {
2205
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
2206
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
2265
+			if patient_id > 0 {
2266
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? and patient_id = ?"
2267
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay, patient_id)
2268
+			} else {
2269
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?  and delivery_way = ? "
2270
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, deliverWay)
2271
+			}
2272
+
2207 2273
 		} else if patientType == 2 {
2208
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
2209
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2274
+			if patient_id > 0 {
2275
+
2276
+			} else {
2277
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and delivery_way = ?"
2278
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, deliverWay)
2279
+			}
2280
+
2210 2281
 		}
2211 2282
 
2212 2283
 	} else if adviceType == 2 && len(deliverWay) <= 0 {
2213 2284
 		if patientType == 0 {
2214
-			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
2215
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2285
+			if patient_id > 0 {
2286
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ? and patient_id = ?"
2287
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2288
+			} else {
2289
+				adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
2290
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2291
+			}
2216 2292
 
2217 2293
 		} else if patientType == 1 {
2218
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
2219
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2294
+			if patient_id > 0 {
2295
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ? and patient_id = ?"
2296
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, patient_id)
2297
+			} else {
2298
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
2299
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
2300
+			}
2301
+
2220 2302
 		} else if patientType == 2 {
2221
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
2222
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2303
+			if patient_id > 0 {
2304
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0 and patient_id = ?"
2305
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, patient_id)
2306
+			} else {
2307
+				adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
2308
+				adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
2309
+			}
2310
+
2223 2311
 		}
2224 2312
 
2225 2313
 	}
@@ -2249,7 +2337,7 @@ func MobileGetScheduleDoctorAdvicesOne(orgID int64, scheduleDate int64, adviceTy
2249 2337
 	return vms, err
2250 2338
 }
2251 2339
 
2252
-func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64) ([]*HisMScheduleDoctorAdviceVM, error) {
2340
+func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string, scheduleType int64, partitionType int64, patient_id int64) ([]*HisMScheduleDoctorAdviceVM, error) {
2253 2341
 
2254 2342
 	var vms []*HisMScheduleDoctorAdviceVM
2255 2343
 	if len(deliverWay) > 0 {
@@ -2260,19 +2348,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
2260 2348
 		if partitionType > 0 {
2261 2349
 			db = db.Where("partition_id = ?", partitionType)
2262 2350
 		}
2263
-		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2264
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2265
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2266
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2267
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
2268
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2269
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2270
-			}).
2271
-			Where("status = 1 AND user_org_id = ?", orgID)
2272
-		if scheduleDate != 0 {
2273
-			db = db.Where("schedule_date = ?", scheduleDate)
2351
+		if patient_id > 0 {
2352
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id =?", orgID, patient_id).
2353
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2354
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2355
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2356
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and patient_id = ?", orgID, scheduleDate, deliverWay, patient_id).
2357
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2358
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2359
+				}).
2360
+				Where("status = 1 AND user_org_id = ?", orgID)
2361
+			if scheduleDate != 0 {
2362
+				db = db.Where("schedule_date = ?", scheduleDate)
2363
+			}
2364
+			err = db.Find(&vms).Error
2365
+		} else {
2366
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2367
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2368
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2369
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2370
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
2371
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2372
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2373
+				}).
2374
+				Where("status = 1 AND user_org_id = ?", orgID)
2375
+			if scheduleDate != 0 {
2376
+				db = db.Where("schedule_date = ?", scheduleDate)
2377
+			}
2378
+			err = db.Find(&vms).Error
2274 2379
 		}
2275
-		err = db.Find(&vms).Error
2380
+
2276 2381
 	} else {
2277 2382
 		db := readDb.Table("xt_schedule")
2278 2383
 		if scheduleType > 0 {
@@ -2281,19 +2386,36 @@ func GetHisDoctorAdvicesOne(orgID int64, scheduleDate int64, deliverWay string,
2281 2386
 		if partitionType > 0 {
2282 2387
 			db = db.Where("partition_id = ?", partitionType)
2283 2388
 		}
2284
-		db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2285
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2286
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2287
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2288
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
2289
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2290
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2291
-			}).
2292
-			Where("status = 1 AND user_org_id = ?", orgID)
2293
-		if scheduleDate != 0 {
2294
-			db = db.Where("schedule_date = ?", scheduleDate)
2389
+		if patient_id > 0 {
2390
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
2391
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2392
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2393
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2394
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2395
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2396
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2397
+				}).
2398
+				Where("status = 1 AND user_org_id = ?", orgID)
2399
+			if scheduleDate != 0 {
2400
+				db = db.Where("schedule_date = ?", scheduleDate)
2401
+			}
2402
+			err = db.Find(&vms).Error
2403
+		} else {
2404
+			db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2405
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2406
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2407
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2408
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
2409
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2410
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2411
+				}).
2412
+				Where("status = 1 AND user_org_id = ?", orgID)
2413
+			if scheduleDate != 0 {
2414
+				db = db.Where("schedule_date = ?", scheduleDate)
2415
+			}
2416
+			err = db.Find(&vms).Error
2295 2417
 		}
2296
-		err = db.Find(&vms).Error
2418
+
2297 2419
 	}
2298 2420
 
2299 2421
 	return vms, err
@@ -2423,25 +2545,74 @@ func GetHisPrescriptionProject(org_id int64, patient_id int64, record_date int64
2423 2545
 	return
2424 2546
 }
2425 2547
 
2426
-func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
2548
+func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64, patient_id int64) ([]*HisMScheduleProjectVM, error) {
2427 2549
 	var vms []*HisMScheduleProjectVM
2428 2550
 	if patientType == 0 {
2429
-		db := readDb.
2430
-			Table("xt_schedule").
2431
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2432
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2433
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2434
-			}).
2435
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2436
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2437
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2438
-			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2439
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2440
-			}).Where("status = 1 AND user_org_id = ?", orgID)
2441
-		if scheduleDate != 0 {
2442
-			db = db.Where("schedule_date = ?", scheduleDate)
2551
+
2552
+		if patient_id > 0 {
2553
+			db := readDb.
2554
+				Table("xt_schedule").
2555
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2556
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2557
+					return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2558
+				}).
2559
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2560
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2561
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2562
+				Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2563
+					return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2564
+				}).
2565
+				Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2566
+					return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2567
+				}).Where("status = 1 AND user_org_id = ?", orgID)
2568
+			if scheduleDate != 0 {
2569
+				db = db.Where("schedule_date = ?", scheduleDate)
2570
+			}
2571
+			err = db.Find(&vms).Error
2572
+		} else {
2573
+			if patient_id > 0 {
2574
+				db := readDb.
2575
+					Table("xt_schedule").
2576
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id= ?", orgID, patient_id).
2577
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2578
+						return db.Where("status = 1 AND user_org_id = ? and patient_id = ?", orgID, patient_id).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2579
+					}).
2580
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2581
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2582
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ? and patient_id = ?", orgID, scheduleDate, patient_id).
2583
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2584
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2585
+					}).
2586
+					Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2587
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2588
+					}).Where("status = 1 AND user_org_id = ?", orgID)
2589
+				if scheduleDate != 0 {
2590
+					db = db.Where("schedule_date = ?", scheduleDate)
2591
+				}
2592
+				err = db.Find(&vms).Error
2593
+			} else {
2594
+				db := readDb.
2595
+					Table("xt_schedule").
2596
+					Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
2597
+					Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
2598
+						return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
2599
+					}).
2600
+					Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
2601
+					Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2602
+					Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2603
+					Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2604
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2605
+					}).
2606
+					Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2607
+						return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2608
+					}).Where("status = 1 AND user_org_id = ?", orgID)
2609
+				if scheduleDate != 0 {
2610
+					db = db.Where("schedule_date = ?", scheduleDate)
2611
+				}
2612
+				err = db.Find(&vms).Error
2613
+			}
2443 2614
 		}
2444
-		err = db.Find(&vms).Error
2615
+
2445 2616
 	}
2446 2617
 
2447 2618
 	if patientType > 0 {
@@ -2456,9 +2627,11 @@ func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay str
2456 2627
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2457 2628
 			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
2458 2629
 			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2459
-				return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2630
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2460 2631
 			}).
2461
-			Where("status = 1 AND user_org_id = ?", orgID)
2632
+			Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2633
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
2634
+			}).Where("status = 1 AND user_org_id = ?", orgID)
2462 2635
 		if scheduleDate != 0 {
2463 2636
 			db = db.Where("schedule_date = ?", scheduleDate)
2464 2637
 		}

+ 2 - 1
service/patient_service.go Zobrazit soubor

@@ -947,7 +947,7 @@ func GetPatientDialysisRecord(orgID, patientID int64, page, limit, start, end, m
947 947
 		}).
948 948
 		Joins("JOIN xt_schedule as s ON s.patient_id=? and FROM_UNIXTIME(s.schedule_date, '%Y-%m-%d')=FROM_UNIXTIME(do.dialysis_date, '%Y-%m-%d')", patientID).
949 949
 		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
950
-		Where("do.patient_id=? and do.user_org_id=? and do.stage = 2 and do.status=1", patientID, orgID).Group("s.schedule_date")
950
+		Where("do.patient_id=? and do.user_org_id=?  and do.status=1", patientID, orgID).Group("s.schedule_date")
951 951
 
952 952
 	if start != 0 {
953 953
 		db = db.Where("do.dialysis_date>=?", start)
@@ -1105,6 +1105,7 @@ func MobileGetMonitorsWithPatient(orgID int64, keyword string, page int) ([]*mod
1105 1105
 
1106 1106
 func GetPatientByKeyWord(orgID int64, keywords string) (patient []*models.Patients, err error) {
1107 1107
 	db := readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1", orgID)
1108
+	fmt.Println("keywords22222223322332322332322323323", keywords)
1108 1109
 	if len(keywords) > 0 {
1109 1110
 		likekey := "%" + keywords + "%"
1110 1111
 		err = db.Where("name LIKE ? OR dialysis_no LIKE ? ", likekey, likekey).Find(&patient).Error

+ 3 - 3
service/self_drug_service.go Zobrazit soubor

@@ -879,7 +879,7 @@ func CreateDrugDamage(damage models.XtDrugDamage) error {
879 879
 func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword string, limit int64, page int64) (adjust []*models.VmDrugInventory, total int64, err error) {
880 880
 	likeKey := "%" + keyword + "%"
881 881
 	offset := (page - 1) * limit
882
-	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and inventory_type = 11")
882
+	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1 and type = 4")
883 883
 	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
884 884
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
885 885
 	fmt.Println(table, tab)
@@ -903,7 +903,7 @@ func GetDrugDamageList(startime int64, endtime int64, orgId int64, keyword strin
903 903
 }
904 904
 
905 905
 func GetDrugDamageByOrgId(orgid int64) (list []*models.XtDrugInventory, err error) {
906
-	err = XTReadDB().Model(&list).Where("user_org_id = ? and inventory_type = 11 and status = 1", orgid).Find(&list).Error
906
+	err = XTReadDB().Model(&list).Where("user_org_id = ? and type = 4 and status = 1", orgid).Find(&list).Error
907 907
 	return list, err
908 908
 }
909 909
 
@@ -1126,7 +1126,7 @@ func CreateDrugWarehouseOutInfo(info models.DrugWarehouseOutInfo) error {
1126 1126
 
1127 1127
 func GetDamageByDrugId(drugid int64, warhousingorder string, drugtype int64) (drug []*models.VmXtDrugInventory, err error) {
1128 1128
 
1129
-	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and inventory_type = 11 ")
1129
+	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and type = 4 ")
1130 1130
 
1131 1131
 	if drugid > 0 {
1132 1132
 		db = db.Where("drug_id = ?", drugid)

+ 61 - 8
service/stock_service.go Zobrazit soubor

@@ -3835,7 +3835,7 @@ func GetCancelStockOrderPrintOne(idstr []string, orgid int64) (info []*models.Ca
3835 3835
 
3836 3836
 func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
3837 3837
 
3838
-	db := XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
3838
+	db := readDb2.Table("xt_cancel_stock_info as x").Where("x.status = 1")
3839 3839
 
3840 3840
 	if startime > 0 {
3841 3841
 		db = db.Where("x.ctime >=?", startime)
@@ -3888,7 +3888,7 @@ func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3888 3888
 
3889 3889
 func GetStockBatchNumber(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3890 3890
 
3891
-	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> '' and stock_count<> 0", id, orgid).Find(&info).Error
3891
+	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Find(&info).Error
3892 3892
 	return info, err
3893 3893
 }
3894 3894
 
@@ -4133,6 +4133,13 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4133 4133
 		if consumable_type == 4 {
4134 4134
 			db = db.Where(" consumable_type = ?", consumable_type)
4135 4135
 		}
4136
+
4137
+		if consumable_type == 10 {
4138
+			db = db.Where(" consumable_type = ?", consumable_type)
4139
+		}
4140
+		if consumable_type == 11 {
4141
+			db = db.Where(" consumable_type = ?", consumable_type)
4142
+		}
4136 4143
 	}
4137 4144
 	if orgId > 0 {
4138 4145
 		db = db.Where("user_org_id = ?", orgId)
@@ -4592,7 +4599,7 @@ func GetReportStockList(startime int64, endtime int64, orgid int64, keyword stri
4592 4599
 	return adjust, total, err
4593 4600
 }
4594 4601
 
4595
-func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64) (adjust []*models.VmStockInventory, total int64, err error) {
4602
+func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64, startime int64, endtime int64) (adjust []*models.VmStockInventory, total int64, err error) {
4596 4603
 	likeKey := "%" + keyword + "%"
4597 4604
 	offset := (page - 1) * limit
4598 4605
 	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
@@ -4607,15 +4614,41 @@ func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64) (
4607 4614
 	if orgid > 0 {
4608 4615
 		db = db.Where("x.user_org_id = ?", orgid)
4609 4616
 	}
4617
+	if startime > 0 {
4618
+		db = db.Where("x.ctime >=?", startime)
4619
+	}
4620
+	if endtime > 0 {
4621
+		db = db.Where("x.ctime <=?", endtime)
4622
+	}
4610 4623
 
4611
-	err = db.Group("x.id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4624
+	err = db.Group("x.id").Select("x.ctime,x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4612 4625
 	return adjust, total, err
4613 4626
 
4614 4627
 }
4615 4628
 
4629
+func GetStockDamagedCountOne(orgid int64, keyword string, inventory_type int64) (adjust []*models.VmStockInventory, err error) {
4630
+
4631
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1")
4632
+	if inventory_type == 0 {
4633
+		db = db.Where("x.inventory_type = 4")
4634
+	}
4635
+	if inventory_type > 0 {
4636
+		db = db.Where("x.inventory_type = ?", inventory_type)
4637
+	}
4638
+	if len(keyword) > 0 {
4639
+		likeKey := "%" + keyword + "%"
4640
+		db = db.Where("x.warehousing_order like ?", likeKey)
4641
+	}
4642
+	if orgid > 0 {
4643
+		db = db.Where("x.user_org_id = ?", orgid)
4644
+	}
4645
+	err = db.Group("x.good_id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,sum(x.count) as count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number").Scan(&adjust).Error
4646
+	return adjust, err
4647
+}
4648
+
4616 4649
 func GetStockDamagedCount(orgid int64) (adjust []*models.VmStockInventory, err error) {
4617 4650
 
4618
-	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
4651
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and inventory_type = 4 ")
4619 4652
 	if orgid > 0 {
4620 4653
 		db = db.Where("x.user_org_id = ?", orgid)
4621 4654
 	}
@@ -4766,7 +4799,7 @@ func GetInventoryDetailList(keyword string, limit int64, page int64, orgid int64
4766 4799
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4767 4800
 	fmt.Println(table, tab)
4768 4801
 	if len(keyword) > 0 {
4769
-		db = db.Where("x.good_name = ?", likeKey)
4802
+		db = db.Where("x.good_name like ?", likeKey)
4770 4803
 	}
4771 4804
 	if orgid > 0 {
4772 4805
 		db = db.Where("x.user_org_id = ?", orgid)
@@ -4866,9 +4899,23 @@ func UpdatedWarehousingInfo(info models.WarehousingInfo, id int64) error {
4866 4899
 	return err
4867 4900
 }
4868 4901
 
4869
-func GetDamageDetailByGoodId(good_id int64) (list []*models.XtStockInventory, err error) {
4902
+func GetDamageDetailByGoodId(good_id int64, keyword string, inventory_type int64) (list []*models.XtStockInventory, err error) {
4870 4903
 
4871
-	err = XTReadDB().Model(&list).Where("good_id = ? and status = 1", good_id).Find(&list).Error
4904
+	db := XTReadDB().Model(&list).Where(" status = 1")
4905
+	if good_id > 0 {
4906
+		db = db.Where("good_id = ?", good_id)
4907
+	}
4908
+	if len(keyword) > 0 {
4909
+		likeKey := "%" + keyword + "%"
4910
+		db = db.Where("warehousing_order like ?", likeKey)
4911
+	}
4912
+	if inventory_type > 0 {
4913
+		db = db.Where("inventory_type = ?", inventory_type)
4914
+	}
4915
+	if inventory_type == 0 {
4916
+		db = db.Where("inventory_type = 4")
4917
+	}
4918
+	err = db.Find(&list).Error
4872 4919
 
4873 4920
 	return list, err
4874 4921
 }
@@ -4940,3 +4987,9 @@ func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error
4940 4987
 	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark}).Error
4941 4988
 	return err
4942 4989
 }
4990
+
4991
+func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
4992
+
4993
+	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4994
+	return err
4995
+}

+ 2 - 1
service/warhouse_service.go Zobrazit soubor

@@ -615,7 +615,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
615 615
 		fmt.Println("库存数量2332232323", stock_number)
616 616
 		fmt.Println("c出库数量", maxNumber)
617 617
 		fmt.Println("c出库数量", minNumber)
618
-		return
618
+
619 619
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
620 620
 
621 621
 		fmt.Println("剩余库存", warehouse.StockMaxNumber)
@@ -633,6 +633,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
633 633
 		}
634 634
 		//扣减库存232332332332
635 635
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
636
+		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
636 637
 		if errThree != nil {
637 638
 			return errThree
638 639
 		}