XMLWAN 4 lat temu
rodzic
commit
acce0e8487

+ 12 - 0
controllers/dialysis_api_controller.go Wyświetl plik

@@ -251,6 +251,9 @@ func (c *DialysisApiController) PostPrescription() {
251 251
 	displace_speed := c.GetString("displace_speed")
252 252
 	illness, _ := c.GetInt64("illness")
253 253
 	amylaceum := c.GetString("amylaceum")
254
+	single_time := c.GetString("single_time")
255
+	single_water := c.GetString("single_water")
256
+	replacement_flow := c.GetString("replacement_flow")
254 257
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
255 258
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
256 259
 
@@ -336,6 +339,9 @@ func (c *DialysisApiController) PostPrescription() {
336 339
 		DisplaceSpeed:              displace_speed,
337 340
 		Illness:                    illness,
338 341
 		Amylaceum:                  amylaceum,
342
+		SingleTime:                 single_time,
343
+		SingleWater:                single_water,
344
+		ReplacementFlow:            replacement_flow,
339 345
 	}
340 346
 
341 347
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -573,6 +579,9 @@ func (c *DialysisApiController) PostSoulution() {
573 579
 	displace_speed := c.GetString("displace_speed")
574 580
 	illness, _ := c.GetInt64("illness")
575 581
 	amylaceum := c.GetString("amylaceum")
582
+	single_time := c.GetString("single_time")
583
+	single_water := c.GetString("single_water")
584
+	replacement_flow := c.GetString("replacement_flow")
576 585
 	var prescription_doctor int64
577 586
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
578 587
 
@@ -669,6 +678,9 @@ func (c *DialysisApiController) PostSoulution() {
669 678
 		DisplaceSpeed:             displace_speed,
670 679
 		Illness:                   illness,
671 680
 		Amylaceum:                 amylaceum,
681
+		SingleTime:                single_time,
682
+		SingleWater:               single_water,
683
+		ReplacementFlow:           replacement_flow,
672 684
 	}
673 685
 
674 686
 	//查询最近透析准备表里是否存在 透析器 灌流器

+ 12 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go Wyświetl plik

@@ -1096,6 +1096,9 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1096 1096
 	displace_speed := c.GetString("displace_speed")
1097 1097
 	illness, _ := c.GetInt64("illness")
1098 1098
 	amylaceum := c.GetString("amylaceum")
1099
+	single_time := c.GetString("single_time")
1100
+	single_water := c.GetString("single_water")
1101
+	replacement_flow := c.GetString("replacement_flow")
1099 1102
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1100 1103
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1101 1104
 	//
@@ -1185,6 +1188,9 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1185 1188
 		DisplaceSpeed:              displace_speed,
1186 1189
 		Illness:                    illness,
1187 1190
 		Amylaceum:                  amylaceum,
1191
+		SingleTime:                 single_time,
1192
+		SingleWater:                single_water,
1193
+		ReplacementFlow:            replacement_flow,
1188 1194
 	}
1189 1195
 
1190 1196
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1980,6 +1986,9 @@ func (c *DialysisAPIController) PostSolution() {
1980 1986
 	displace_speed := c.GetString("displace_speed")
1981 1987
 	illness, _ := c.GetInt64("illness")
1982 1988
 	amylaceum := c.GetString("amylaceum")
1989
+	single_time := c.GetString("single_time")
1990
+	single_water := c.GetString("single_water")
1991
+	replacement_flow := c.GetString("replacement_flow")
1983 1992
 	if mode_id > 0 {
1984 1993
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1985 1994
 	}
@@ -2070,6 +2079,9 @@ func (c *DialysisAPIController) PostSolution() {
2070 2079
 		DisplaceSpeed:             displace_speed,
2071 2080
 		Illness:                   illness,
2072 2081
 		Amylaceum:                 amylaceum,
2082
+		SingleWater:               single_water,
2083
+		SingleTime:                single_time,
2084
+		ReplacementFlow:           replacement_flow,
2073 2085
 	}
2074 2086
 
2075 2087
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)

+ 174 - 0
controllers/schedule_api_controller.go Wyświetl plik

@@ -22,6 +22,7 @@ type ScheduleApiController struct {
22 22
 
23 23
 func ScheduleApiRegistRouters() {
24 24
 	beego.Router("/api/schedule/weekpanel", &ScheduleApiController{}, "Get:GetWeekPanels")
25
+
25 26
 	beego.Router("/api/schedule/schedules", &ScheduleApiController{}, "Get:GetSchedules")
26 27
 	beego.Router("/api/excel_date/init", &ScheduleApiController{}, "Get:GetInitExcelInitDate")
27 28
 
@@ -56,6 +57,11 @@ func ScheduleApiRegistRouters() {
56 57
 	beego.Router("/api/schedule/getprintlist", &ScheduleApiController{}, "Get:GetPrintList")
57 58
 
58 59
 	beego.Router("/api/schedule/getallzonelist", &ScheduleApiController{}, "Get:GetAllZoneList")
60
+
61
+	beego.Router("/api/schedule/getpatientschedulecount", &ScheduleApiController{}, "Get:GetPatientScheduleCount")
62
+
63
+	beego.Router("/api/schedule/weekpanelone", &ScheduleApiController{}, "Get:GetWeekPanelsOne")
64
+	beego.Router("/api/schedule/schedulesone", &ScheduleApiController{}, "Get:GetScheduleOne")
59 65
 }
60 66
 
61 67
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -2411,3 +2417,171 @@ func (this *ScheduleApiController) GetAllZoneList() {
2411 2417
 		"zoneList": zoneList,
2412 2418
 	})
2413 2419
 }
2420
+
2421
+func (this *ScheduleApiController) GetPatientScheduleCount() {
2422
+	patitionIdStr := this.GetString("partition_id")
2423
+	week, _ := this.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
2424
+	ids := strings.Split(patitionIdStr, ",")
2425
+	adminUserInfo := this.GetAdminUserInfo()
2426
+	orgId := adminUserInfo.CurrentOrgId
2427
+	thisTime := time.Now()
2428
+	weekDay := int(thisTime.Weekday())
2429
+	if week < 1 || week > 4 {
2430
+		week = 2
2431
+	}
2432
+	if week == 1 {
2433
+		thisTime = thisTime.AddDate(0, 0, -7)
2434
+	} else if week == 3 {
2435
+		thisTime = thisTime.AddDate(0, 0, 7)
2436
+	} else if week == 4 {
2437
+		thisTime = thisTime.AddDate(0, 0, 14)
2438
+	}
2439
+	if weekDay == 0 {
2440
+		weekDay = 7
2441
+	}
2442
+	weekEnd := 7 - weekDay
2443
+	weekStart := weekEnd - 6
2444
+	weekTitle := make([]string, 0)
2445
+	days := make([]string, 0)
2446
+	for index := weekStart; index <= weekEnd; index++ {
2447
+		theDay := thisTime.AddDate(0, 0, index)
2448
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2449
+		indexMonth := int(indexMonthTime)
2450
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2451
+		weekTitle = append(weekTitle, indexWeek)
2452
+		days = append(days, theDay.Format("2006-01-02"))
2453
+	}
2454
+
2455
+	weekStartDay := thisTime.AddDate(0, 0, weekStart)
2456
+	weekEndDay := thisTime.AddDate(0, 0, weekEnd)
2457
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
2458
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
2459
+
2460
+	timeLayout := "2006-01-02 15:04:05"
2461
+	loc, _ := time.LoadLocation("Local")
2462
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
2463
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
2464
+	weekStartPoint := theStarTime.Unix()
2465
+	weekEndPoint := theEndTime.Unix()
2466
+	fmt.Println("startTime222222222222222", weekStartPoint)
2467
+	fmt.Println("endtime33333333333333", weekEndPoint)
2468
+	list, err := service.GetPatientScheduleCount(orgId, weekStartPoint, weekEndPoint, ids)
2469
+	_, total, _ := service.GetTotalBedNumber(orgId, ids)
2470
+	if err != nil {
2471
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2472
+		return
2473
+	}
2474
+
2475
+	this.ServeSuccessJSON(map[string]interface{}{
2476
+		"list":  list,
2477
+		"total": total,
2478
+	})
2479
+}
2480
+
2481
+func (c *ScheduleApiController) GetWeekPanelsOne() {
2482
+
2483
+	data, _ := c.GetInt64("data", 1)
2484
+	patitionIdStr := c.GetString("patitionid")
2485
+
2486
+	ids := strings.Split(patitionIdStr, ",")
2487
+
2488
+	adminInfo := c.GetAdminUserInfo()
2489
+	thisTime := time.Now()
2490
+	year, monthTime, day := thisTime.Date()
2491
+	month := int(monthTime)
2492
+	_, theWeek := thisTime.ISOWeek()
2493
+	weekDay := int(thisTime.Weekday())
2494
+	if weekDay == 0 {
2495
+		weekDay = 7
2496
+	}
2497
+	weekEnd := 7 - weekDay
2498
+	weekStart := weekEnd - 6
2499
+	weekDays := make([]string, 0)
2500
+	for index := weekStart; index <= weekEnd; index++ {
2501
+		theDay := thisTime.AddDate(0, 0, index)
2502
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2503
+		indexMonth := int(indexMonthTime)
2504
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2505
+		weekDays = append(weekDays, indexWeek)
2506
+	}
2507
+
2508
+	returnData := map[string]interface{}{
2509
+		"year":     year,
2510
+		"month":    month,
2511
+		"day":      day,
2512
+		"theWeek":  theWeek,
2513
+		"weekDay":  weekDay,
2514
+		"weekDays": weekDays,
2515
+	}
2516
+
2517
+	if data == 1 {
2518
+		partitions, _ := service.GetSchedulePartitionPanelTwo(adminInfo.CurrentOrgId, ids)
2519
+		returnData["partitions"] = partitions
2520
+	}
2521
+
2522
+	c.ServeSuccessJSON(returnData)
2523
+	return
2524
+}
2525
+
2526
+func (c *ScheduleApiController) GetScheduleOne() {
2527
+
2528
+	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
2529
+	patitionIdStr := c.GetString("patitionid")
2530
+
2531
+	ids := strings.Split(patitionIdStr, ",")
2532
+	fmt.Println("patitonStr", ids)
2533
+	schedule_type, _ := c.GetInt64("schedule_type")
2534
+
2535
+	adminInfo := c.GetAdminUserInfo()
2536
+
2537
+	thisTime := time.Now()
2538
+	today := thisTime.Format("2006-01-02")
2539
+	if week < 1 || week > 4 {
2540
+		week = 2
2541
+	}
2542
+	if week == 1 {
2543
+		thisTime = thisTime.AddDate(0, 0, -7)
2544
+	} else if week == 3 {
2545
+		thisTime = thisTime.AddDate(0, 0, 7)
2546
+	} else if week == 4 {
2547
+		thisTime = thisTime.AddDate(0, 0, 14)
2548
+	}
2549
+
2550
+	weekDay := int(thisTime.Weekday())
2551
+	if weekDay == 0 {
2552
+		weekDay = 7
2553
+	}
2554
+	weekEnd := 7 - weekDay
2555
+	weekStart := weekEnd - 6
2556
+	weekTitle := make([]string, 0)
2557
+	days := make([]string, 0)
2558
+	for index := weekStart; index <= weekEnd; index++ {
2559
+		theDay := thisTime.AddDate(0, 0, index)
2560
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2561
+		indexMonth := int(indexMonthTime)
2562
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2563
+		weekTitle = append(weekTitle, indexWeek)
2564
+		days = append(days, theDay.Format("2006-01-02"))
2565
+	}
2566
+
2567
+	weekStartDay := thisTime.AddDate(0, 0, weekStart)
2568
+	weekEndDay := thisTime.AddDate(0, 0, weekEnd)
2569
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
2570
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
2571
+
2572
+	timeLayout := "2006-01-02 15:04:05"
2573
+	loc, _ := time.LoadLocation("Local")
2574
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
2575
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
2576
+	weekStartPoint := theStarTime.Unix()
2577
+	weekEndPoint := theEndTime.Unix()
2578
+
2579
+	schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
2580
+	c.ServeSuccessJSON(map[string]interface{}{
2581
+		"days":      days,
2582
+		"weekTitle": weekTitle,
2583
+		"schdules":  schdules,
2584
+		"today":     today,
2585
+	})
2586
+	return
2587
+}

+ 7 - 0
models/device_models.go Wyświetl plik

@@ -1047,3 +1047,10 @@ func (XtRemindPrintSetting) TableName() string {
1047 1047
 
1048 1048
 	return "xt_remind_print_setting"
1049 1049
 }
1050
+
1051
+type VmXtSchedule struct {
1052
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
1053
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1054
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1055
+	Count        int64
1056
+}

+ 3 - 0
models/patient_models.go Wyświetl plik

@@ -232,6 +232,9 @@ type DialysisPrescription struct {
232 232
 	DisplaceSpeed              string        `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
233 233
 	Illness                    int64         `gorm:"column:illness" json:"illness" form:"illness"`
234 234
 	Amylaceum                  string        `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
235
+	SingleTime                 string        `gorm:"column:single_time" json:"single_time" form:"single_time"`
236
+	SingleWater                string        `gorm:"column:single_water" json:"single_water" form:"single_water"`
237
+	ReplacementFlow            string        `gorm:"column:replacement_flow" json:"replacement_flow" form:"replacement_flow"`
235 238
 }
236 239
 
237 240
 func (DialysisPrescription) TableName() string {

+ 34 - 0
service/patientmanage_service.go Wyświetl plik

@@ -1587,3 +1587,37 @@ func GetBloodAccess(orgid int64) (*models.Dataconfig, error) {
1587 1587
 	err := XTReadDB().Model(&dataconfig).Where("org_id = 0 and name = '血管通路部位' and status = 1 ").Find(&dataconfig).Error
1588 1588
 	return &dataconfig, err
1589 1589
 }
1590
+
1591
+func GetPatientScheduleCount(orgid int64, startTime int64, endTime int64, ids []string) (schedule []*models.VmXtSchedule, err error) {
1592
+
1593
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status =1")
1594
+	if orgid > 0 {
1595
+		db = db.Where("x.user_org_id = ?", orgid)
1596
+	}
1597
+	if startTime > 0 {
1598
+		db = db.Where("x.schedule_date >=?", startTime)
1599
+	}
1600
+	if endTime > 0 {
1601
+		db = db.Where("x.schedule_date<=?", endTime)
1602
+	}
1603
+	if len(ids) > 0 {
1604
+		db = db.Where("x.partition_id in (?)", ids)
1605
+	}
1606
+	err = db.Select("count(x.id) as count,x.schedule_type,x.schedule_week").Group("x.schedule_week,x.schedule_type").Scan(&schedule).Error
1607
+	return schedule, err
1608
+}
1609
+
1610
+func GetTotalBedNumber(orgid int64, ids []string) (list []*models.XtDeviceNumber, total int64, err error) {
1611
+
1612
+	//err = XTReadDB().Model(&list).Where("org_id = ? and status = 1 ",orgid).Count(&total).Find(&list).Error
1613
+	//return list,total,err
1614
+	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
1615
+	if orgid > 0 {
1616
+		db = db.Where("x.org_id = ?", orgid)
1617
+	}
1618
+	if len(ids) > 0 {
1619
+		db = db.Where("x.zone_id in (?)", ids)
1620
+	}
1621
+	err = db.Count(&total).Find(&list).Error
1622
+	return list, total, err
1623
+}

+ 31 - 0
service/schedule_service.go Wyświetl plik

@@ -30,6 +30,18 @@ func GetSchedulePartitionPanelOne(orgID int64, partionId int64) (partitions []*m
30 30
 	return
31 31
 }
32 32
 
33
+func GetSchedulePartitionPanelTwo(orgID int64, schIDs []string) (partitions []*models.Partition, err error) {
34
+
35
+	if len(schIDs) == 0 {
36
+		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Find(&partitions).Error
37
+	}
38
+	if len(schIDs) > 0 {
39
+		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1 and zone_id in(?)", orgID, schIDs).Where("org_id=? and status=1 and id in(?)", orgID, schIDs).Find(&partitions).Error
40
+	}
41
+
42
+	return
43
+}
44
+
33 45
 func GetPatientWithScheduleAndSolution(orgID int64, keywords string, weekStart, weekEnd, schedule, contagion int64) (patients []*models.Patients, err error) {
34 46
 	db := readDb.Table("xt_patients as p").
35 47
 		Preload("DialysisSolutions", "user_org_id=? and initiate_mode=1 and affirm_state=1 and parent_id=0 and status=1", orgID).
@@ -83,6 +95,25 @@ func GetWeekScheduleOne(orgID int64, start, end int64, partionid int64, schedule
83 95
 	return
84 96
 }
85 97
 
98
+func GetWeekScheduleTwo(orgID int64, start, end int64, schIds []string, scheduletype int64) (schedules []*models.Schedule, err error) {
99
+
100
+	db := readDb.Table("xt_schedule as s")
101
+	fmt.Println("schIds2222222")
102
+	if len(schIds) > 0 {
103
+		db = db.Where("s.partition_id in (?)", schIds)
104
+	}
105
+	if scheduletype > 0 {
106
+		db = db.Where("s.schedule_type = ?", scheduletype)
107
+	}
108
+	err = db.Preload("PatientInfectiousDiseases", "status = 1 ").
109
+		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
110
+		Where("s.user_org_id=? and s.schedule_date>=? and s.schedule_date<=? and s.status=1", orgID, start, end).
111
+		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
112
+		Order("updated_time asc").
113
+		Find(&schedules).Error
114
+	return
115
+}
116
+
86 117
 func GetDaySchedule(orgID, start, end, patientID int64) (schedule models.Schedule, err error) {
87 118
 	err = readDb.Model(&models.Schedule{}).Where("user_org_id=? and patient_id=? and schedule_date>=? and schedule_date<=? and status=1", orgID, patientID, start, end).First(&schedule).Error
88 119
 	return