Ver código fonte

医保对接

csx 3 anos atrás
pai
commit
94d739e747

+ 19 - 0
controllers/doctors_api_controller.go Ver arquivo

@@ -85,6 +85,25 @@ func (c *DoctorsApiController) ScheduleAdvices() {
85 85
 
86 86
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
87 87
 
88
+	index := 0
89
+	for _, item := range project {
90
+		for _, subItem := range item.HisPrescriptionTeamProject {
91
+
92
+			if subItem.HisProject.CostClassify != 3 {
93
+				subItem.IsCheckTeam = 2
94
+				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
95
+			}
96
+
97
+			if subItem.HisProject.CostClassify == 3 {
98
+				subItem.IsCheckTeam = 1
99
+				index = index + 1
100
+				if index == 1 {
101
+					item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
102
+				}
103
+			}
104
+		}
105
+	}
106
+
88 107
 	config, _ := service.GetHisDoctorConfig(orgID)
89 108
 	project_config, _ := service.GetHisProjectConfig(orgID)
90 109
 

+ 9 - 9
controllers/his_api_controller.go Ver arquivo

@@ -3250,7 +3250,7 @@ func (c *HisApiController) GetUploadInfo() {
3250 3250
 			}
3251 3251
 		}
3252 3252
 
3253
-		allTotal := fmt.Sprintf("%.2f", total)
3253
+		allTotal := fmt.Sprintf("%.4f", total)
3254 3254
 		totals, _ := strconv.ParseFloat(allTotal, 64)
3255 3255
 		order := &models.HisOrder{
3256 3256
 			UserOrgId:             adminUser.CurrentOrgId,
@@ -3295,8 +3295,8 @@ func (c *HisApiController) GetUploadInfo() {
3295 3295
 					cus := &Custom{
3296 3296
 						AdviceId:         subItem.ID,
3297 3297
 						ProjectId:        0,
3298
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
3299
-						Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
3298
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
3299
+						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
3300 3300
 						FeedetlSn:        subItem.FeedetlSn,
3301 3301
 						Price:            fmt.Sprintf("%.2f", subItem.Price),
3302 3302
 						MedListCodg:      subItem.MedListCodg,
@@ -3310,10 +3310,10 @@ func (c *HisApiController) GetUploadInfo() {
3310 3310
 					cus := &Custom{
3311 3311
 						AdviceId:         0,
3312 3312
 						ProjectId:        subItem.ID,
3313
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
3314
-						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
3313
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
3314
+						Cut:              fmt.Sprintf("%.4f", float64(subItem.Count)),
3315 3315
 						FeedetlSn:        subItem.FeedetlSn,
3316
-						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
3316
+						Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
3317 3317
 						MedListCodg:      subItem.MedListCodg,
3318 3318
 						Type:             2,
3319 3319
 					}
@@ -3325,10 +3325,10 @@ func (c *HisApiController) GetUploadInfo() {
3325 3325
 					ItemId:           item.ID,
3326 3326
 					AdviceId:         0,
3327 3327
 					ProjectId:        0,
3328
-					DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
3329
-					Cut:              fmt.Sprintf("%.2f", float64(item.Count)),
3328
+					DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
3329
+					Cut:              fmt.Sprintf("%.4f", float64(item.Count)),
3330 3330
 					FeedetlSn:        item.FeedetlSn,
3331
-					Price:            fmt.Sprintf("%.2f", float64(item.Price)),
3331
+					Price:            fmt.Sprintf("%.4f", float64(item.Price)),
3332 3332
 					MedListCodg:      item.XtHisAddtionConfig.Code,
3333 3333
 					Type:             3,
3334 3334
 				}

+ 18 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Ver arquivo

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

+ 20 - 0
controllers/mobile_api_controllers/doctor_advice_api_controller.go Ver arquivo

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

+ 89 - 18
controllers/mobile_api_controllers/patient_api_controller.go Ver arquivo

@@ -3342,6 +3342,8 @@ func (this *PatientApiController) GetSearchPatient() {
3342 3342
 func (c *PatientApiController) ExecProject() {
3343 3343
 	execution_time := c.GetString("execution_time")
3344 3344
 	project_id, _ := c.GetInt64("project_id")
3345
+	team_id, _ := c.GetInt64("team_id")
3346
+	is_check_team, _ := c.GetInt64("is_check_team")
3345 3347
 
3346 3348
 	if len(execution_time) <= 0 {
3347 3349
 		utils.ErrorLog("execution_time")
@@ -3357,6 +3359,7 @@ func (c *PatientApiController) ExecProject() {
3357 3359
 		return
3358 3360
 	}
3359 3361
 	adminInfo := c.GetMobileAdminUserInfo()
3362
+
3360 3363
 	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3361 3364
 	if project.ExecutionState == 1 {
3362 3365
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
@@ -3366,29 +3369,63 @@ func (c *PatientApiController) ExecProject() {
3366 3369
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
3367 3370
 		return
3368 3371
 	}
3369
-
3370 3372
 	project.ExecutionState = 1
3371 3373
 	project.ExecutionStaff = adminInfo.AdminUser.Id
3372 3374
 	project.ExecutionTime = theTime.Unix()
3373
-	err := service.SaveHisProject(&project)
3374
-	if err == nil {
3375
-		c.ServeSuccessJSON(map[string]interface{}{
3376
-			"project": project,
3377
-		})
3375
+	if team_id == 0 {
3376
+
3377
+		err := service.SaveHisProject(&project)
3378
+		if err == nil {
3379
+			c.ServeSuccessJSON(map[string]interface{}{
3380
+				"project": project,
3381
+			})
3382
+		} else {
3383
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3384
+			return
3385
+
3386
+		}
3378 3387
 	} else {
3379
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3380
-		return
3388
+		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
3381 3389
 
3382
-	}
3390
+			err := service.SaveHisProject(&project)
3391
+			if err == nil {
3392
+				c.ServeSuccessJSON(map[string]interface{}{
3393
+					"project": project,
3394
+				})
3395
+			} else {
3396
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3397
+				return
3398
+
3399
+			}
3400
+		} else {
3401
+			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
3402
+			var ids []int64
3403
+			for _, items := range ps {
3404
+				ids = append(ids, items.ID)
3405
+			}
3406
+			err := service.UpdateTeamProjectExceStatus(ids, adminInfo.AdminUser.Id, theTime.Unix())
3407
+			if err == nil {
3408
+				c.ServeSuccessJSON(map[string]interface{}{
3409
+					"project": project,
3410
+				})
3411
+			} else {
3412
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3413
+				return
3383 3414
 
3415
+			}
3416
+		}
3417
+
3418
+	}
3384 3419
 }
3385 3420
 
3386 3421
 func (c *PatientApiController) CheckProject() {
3387 3422
 
3388 3423
 	adminInfo := c.GetMobileAdminUserInfo()
3389 3424
 	project_id, _ := c.GetInt64("project_id")
3390
-	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3425
+	team_id, _ := c.GetInt64("team_id")
3426
+	is_check_team, _ := c.GetInt64("is_check_team")
3391 3427
 
3428
+	project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
3392 3429
 	if project.CheckState == 1 {
3393 3430
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
3394 3431
 		return
@@ -3401,18 +3438,52 @@ func (c *PatientApiController) CheckProject() {
3401 3438
 	project.Checker = adminInfo.AdminUser.Id
3402 3439
 	project.CheckTime = time.Now().Unix()
3403 3440
 	project.CheckState = 1
3441
+	if team_id == 0 {
3442
+		err := service.SaveHisProject(&project)
3443
+		if err == nil {
3444
+			c.ServeSuccessJSON(map[string]interface{}{
3445
+				"msg":     "ok",
3446
+				"project": project,
3447
+			})
3404 3448
 
3405
-	err := service.SaveHisProject(&project)
3449
+		} else {
3450
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3451
+			return
3406 3452
 
3407
-	if err == nil {
3408
-		c.ServeSuccessJSON(map[string]interface{}{
3409
-			"msg":     "ok",
3410
-			"project": project,
3411
-		})
3453
+		}
3412 3454
 
3413 3455
 	} else {
3414
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3415
-		return
3456
+		if is_check_team == 2 { //虽然是组套数据,但不是检验项目
3457
+			err := service.SaveHisProject(&project)
3458
+			if err == nil {
3459
+				c.ServeSuccessJSON(map[string]interface{}{
3460
+					"msg":     "ok",
3461
+					"project": project,
3462
+				})
3463
+
3464
+			} else {
3465
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3466
+				return
3467
+
3468
+			}
3469
+
3470
+		} else {
3471
+			ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
3472
+			var ids []int64
3473
+			for _, items := range ps {
3474
+				ids = append(ids, items.ID)
3475
+			}
3476
+			err := service.UpdateTeamProjectCheckStatus(ids, project.PatientId, project.RecordDate, project.UserOrgId, adminInfo.AdminUser.Id, time.Now().Unix())
3477
+			if err == nil {
3478
+				c.ServeSuccessJSON(map[string]interface{}{
3479
+					"project": project,
3480
+				})
3481
+			} else {
3482
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
3483
+				return
3484
+
3485
+			}
3486
+		}
3416 3487
 
3417 3488
 	}
3418 3489
 

+ 1 - 0
models/his_models.go Ver arquivo

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

+ 32 - 0
service/dialysis_service.go Ver arquivo

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

+ 6 - 1
service/his_service.go Ver arquivo

@@ -1984,7 +1984,12 @@ func GetHisPrescriptionProjectsByID(id int64) (projects []*models.HisPrescriptio
1984 1984
 }
1985 1985
 
1986 1986
 func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
1987
-	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
1987
+	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
1988
+	return
1989
+}
1990
+
1991
+func GetHisPrescriptionTeamProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
1992
+	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
1988 1993
 	return
1989 1994
 }
1990 1995
 

+ 77 - 19
service/mobile_dialysis_service.go Ver arquivo

@@ -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 {
@@ -1214,6 +1220,52 @@ func GetMobileHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay
1214 1220
 	return vms, err
1215 1221
 }
1216 1222
 
1223
+//func GetMobileHisPrescriptionTeamProject(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleProjectVM, error) {
1224
+//	var vms []*HisMScheduleProjectVM
1225
+//	if patientType == 0 {
1226
+//		db := readDb.
1227
+//			Table("xt_schedule").
1228
+//			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1229
+//			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1230
+//				return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1231
+//			}).
1232
+//			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1233
+//			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1234
+//			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1235
+//			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1236
+//				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id > 0", orgID, scheduleDate).Group("team_id").Preload("XtHisProjectTeam", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1")
1237
+//			}).
1238
+//			Where("status = 1 AND user_org_id = ?", orgID)
1239
+//		if scheduleDate != 0 {
1240
+//			db = db.Where("schedule_date = ?", scheduleDate)
1241
+//		}
1242
+//		err = db.Find(&vms).Error
1243
+//	}
1244
+//
1245
+//	if patientType > 0 {
1246
+//		db := readDb.
1247
+//			Table("xt_schedule").
1248
+//			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
1249
+//			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
1250
+//				return db.Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
1251
+//			}).
1252
+//			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1253
+//			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
1254
+//			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
1255
+//			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
1256
+//			Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1257
+//				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")
1258
+//			}).
1259
+//			Where("status = 1 AND user_org_id = ?", orgID)
1260
+//		if scheduleDate != 0 {
1261
+//			db = db.Where("schedule_date = ?", scheduleDate)
1262
+//		}
1263
+//		err = db.Find(&vms).Error
1264
+//	}
1265
+//
1266
+//	return vms, err
1267
+//}
1268
+
1217 1269
 func MobileCreateDialysisOrder(orgID int64, patientID int64, order *models.DialysisOrder) error {
1218 1270
 	now := time.Now()
1219 1271
 	tx := writeDb.Begin()
@@ -2070,20 +2122,21 @@ func (HisMScheduleDoctorAdviceVMOne) TableName() string {
2070 2122
 }
2071 2123
 
2072 2124
 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"`
2125
+	ID                         int64                            `gorm:"column:id" json:"id"`
2126
+	UserOrgId                  int64                            `gorm:"column:user_org_id" json:"user_org_id"`
2127
+	PartitionId                int64                            `gorm:"column:partition_id" json:"partition_id"`
2128
+	BedId                      int64                            `gorm:"column:bed_id" json:"bed_id"`
2129
+	PatientId                  int64                            `gorm:"column:patient_id" json:"patient_id"`
2130
+	ScheduleDate               int64                            `gorm:"column:schedule_date" json:"schedule_date"`
2131
+	ScheduleType               int64                            `gorm:"column:schedule_type" json:"schedule_type"`
2132
+	ModeId                     int64                            `gorm:"column:mode_id" json:"mode_id"`
2133
+	Status                     int64                            `gorm:"column:status" json:"status"`
2134
+	DialysisOrder              *MDialysisOrderVM                `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
2135
+	SchedualPatient            *MSchedualPatientVM              `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
2136
+	DeviceNumber               *MDeviceNumberVM                 `gorm:"ForeignKey:BedId" json:"device_number"`
2137
+	Prescription               *models.DialysisPrescriptionList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
2138
+	HisPrescriptionProject     []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"project"`
2139
+	HisPrescriptionTeamProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"team_project"`
2087 2140
 }
2088 2141
 
2089 2142
 func (HisMScheduleProjectVM) TableName() string {
@@ -2436,7 +2489,10 @@ func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay str
2436 2489
 			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
2437 2490
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2438 2491
 			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")
2492
+				return db.Where("status = 1 AND user_org_id = ? AND record_date = ? AND team_id = 0", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
2493
+			}).
2494
+			Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2495
+				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")
2440 2496
 			}).Where("status = 1 AND user_org_id = ?", orgID)
2441 2497
 		if scheduleDate != 0 {
2442 2498
 			db = db.Where("schedule_date = ?", scheduleDate)
@@ -2456,9 +2512,11 @@ func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay str
2456 2512
 			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
2457 2513
 			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
2458 2514
 			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")
2515
+				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 2516
 			}).
2461
-			Where("status = 1 AND user_org_id = ?", orgID)
2517
+			Preload("HisPrescriptionTeamProject", func(db *gorm.DB) *gorm.DB {
2518
+				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")
2519
+			}).Where("status = 1 AND user_org_id = ?", orgID)
2462 2520
 		if scheduleDate != 0 {
2463 2521
 			db = db.Where("schedule_date = ?", scheduleDate)
2464 2522
 		}