Browse Source

2024/6/17

28169 2 months ago
parent
commit
c672cb24c8

+ 10 - 10
controllers/base_api_controller.go View File

72
 	this.BaseAPIController.Prepare()
72
 	this.BaseAPIController.Prepare()
73
 	if this.GetAdminUserInfo() == nil {
73
 	if this.GetAdminUserInfo() == nil {
74
 		var userAdmin models.AdminUser
74
 		var userAdmin models.AdminUser
75
-		userAdmin.Id = 4608
75
+		userAdmin.Id = 5386
76
 		userAdmin.Mobile = "13318599895"
76
 		userAdmin.Mobile = "13318599895"
77
 
77
 
78
-		userAdmin.Id = 4608 //4,809
78
+		userAdmin.Id = 5386 //4,809
79
 		userAdmin.Mobile = "12222222222"
79
 		userAdmin.Mobile = "12222222222"
80
 		userAdmin.IsSuperAdmin = true
80
 		userAdmin.IsSuperAdmin = true
81
 		userAdmin.Status = 1
81
 		userAdmin.Status = 1
83
 		userAdmin.ModifyTime = 1530786071
83
 		userAdmin.ModifyTime = 1530786071
84
 		var subscibe models.ServeSubscibe
84
 		var subscibe models.ServeSubscibe
85
 		subscibe.ID = 11
85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10602 //机构id
86
+		subscibe.OrgId = 10206 //机构id
87
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodStart = 1547447814
88
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.PeriodEnd = 1550039814
89
 		subscibe.State = 1
89
 		subscibe.State = 1
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94
 		subscibes[4] = &subscibe
94
 		subscibes[4] = &subscibe
95
 		var adminUserInfo service.AdminUserInfo
95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10602 //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 7421  //4
96
+		adminUserInfo.CurrentOrgId = 10206 //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 18470 //4
98
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.AdminUser = &userAdmin
99
 		adminUserInfo.Subscibes = subscibes
99
 		adminUserInfo.Subscibes = subscibes
100
 		this.SetSession("admin_user_info", &adminUserInfo)
100
 		this.SetSession("admin_user_info", &adminUserInfo)
318
 	this.BaseAPIController.Prepare()
318
 	this.BaseAPIController.Prepare()
319
 	if this.GetAdminUserInfo() == nil {
319
 	if this.GetAdminUserInfo() == nil {
320
 		var userAdmin models.AdminUser
320
 		var userAdmin models.AdminUser
321
-		userAdmin.Id = 4608
321
+		userAdmin.Id = 5386
322
 		userAdmin.Mobile = "13318599895"
322
 		userAdmin.Mobile = "13318599895"
323
 
323
 
324
-		userAdmin.Id = 4608 //4,809
324
+		userAdmin.Id = 5386 //4,809
325
 		userAdmin.Mobile = "12222222222"
325
 		userAdmin.Mobile = "12222222222"
326
 		userAdmin.IsSuperAdmin = false
326
 		userAdmin.IsSuperAdmin = false
327
 		userAdmin.Status = 1
327
 		userAdmin.Status = 1
329
 		userAdmin.ModifyTime = 1530786071
329
 		userAdmin.ModifyTime = 1530786071
330
 		var subscibe models.ServeSubscibe
330
 		var subscibe models.ServeSubscibe
331
 		subscibe.ID = 11
331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10602 //机构id小英9675或4
332
+		subscibe.OrgId = 10206 //机构id小英9675或4
333
 		subscibe.PeriodStart = 1538035409
333
 		subscibe.PeriodStart = 1538035409
334
 		subscibe.PeriodEnd = 1569571409
334
 		subscibe.PeriodEnd = 1569571409
335
 		subscibe.State = 1
335
 		subscibe.State = 1
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340
 		subscibes[4] = &subscibe
340
 		subscibes[4] = &subscibe
341
 		var adminUserInfo service.AdminUserInfo
341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10602 //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 7421  //4
342
+		adminUserInfo.CurrentOrgId = 10206 //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 18470 //4
344
 		adminUserInfo.AdminUser = &userAdmin
344
 		adminUserInfo.AdminUser = &userAdmin
345
 		adminUserInfo.Subscibes = subscibes
345
 		adminUserInfo.Subscibes = subscibes
346
 		this.SetSession("admin_user_info", &adminUserInfo)
346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 30 - 0
controllers/dialysis_api_controller.go View File

151
 
151
 
152
 	beego.Router("/api/schedule/getdialysisproject", &DialysisApiController{}, "Get:GetDialysisProject")
152
 	beego.Router("/api/schedule/getdialysisproject", &DialysisApiController{}, "Get:GetDialysisProject")
153
 
153
 
154
+	beego.Router("/api/schedule/getpatientbefor", &DialysisApiController{}, "Get:GetPatientBefor")
155
+
154
 }
156
 }
155
 
157
 
156
 func (c *DialysisApiController) GetQueueCall() {
158
 func (c *DialysisApiController) GetQueueCall() {
7961
 		"order": order,
7963
 		"order": order,
7962
 	})
7964
 	})
7963
 }
7965
 }
7966
+
7967
+func (this *DialysisApiController) GetPatientBefor() {
7968
+
7969
+	timeLayout := "2006-01-02"
7970
+	loc, _ := time.LoadLocation("Local")
7971
+
7972
+	record_date := this.GetString("record_date")
7973
+
7974
+	patient_id, _ := this.GetInt64("patient_id")
7975
+
7976
+	user_org_id := this.GetAdminUserInfo().CurrentOrgId
7977
+
7978
+	var startdateunix int64
7979
+	if len(record_date) > 0 {
7980
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
7981
+		if err != nil {
7982
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
7983
+			return
7984
+		}
7985
+		startdateunix = theTime.Unix()
7986
+	}
7987
+
7988
+	patientBefor, _ := service.GetPatientBefor(patient_id, startdateunix, user_org_id)
7989
+
7990
+	this.ServeSuccessJSON(map[string]interface{}{
7991
+		"patientBefor": patientBefor,
7992
+	})
7993
+}

+ 1 - 0
controllers/his_api_controller.go View File

3779
 									storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
3779
 									storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
3780
 									if p.Type == 3 {
3780
 									if p.Type == 3 {
3781
 										lastWarehouse, _ := service.FindFirstWarehousingInfoByStockThree(p.ProjectId, storeConfig.DrugStorehouseOut)
3781
 										lastWarehouse, _ := service.FindFirstWarehousingInfoByStockThree(p.ProjectId, storeConfig.DrugStorehouseOut)
3782
+
3782
 										if p.Price != lastWarehouse.PackingPrice {
3783
 										if p.Price != lastWarehouse.PackingPrice {
3783
 											p.Price = lastWarehouse.PackingPrice
3784
 											p.Price = lastWarehouse.PackingPrice
3784
 										}
3785
 										}

+ 16 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go View File

3761
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3761
 				ultrafiltration_rate = ultrafiltration_rate / 1000
3762
 			}
3762
 			}
3763
 
3763
 
3764
-			if adminUserInfo.Org.Id == 10721 {
3765
-				replacement_rate = math.Floor(prescription.ReplacementTotal * 1000 / float64(totalMin) * 60 * 1000)
3766
-				replacement_rate = replacement_rate / 1000
3767
-			}
3768
-
3769
 		}
3764
 		}
3770
 	}
3765
 	}
3771
 
3766
 
4850
 			}
4845
 			}
4851
 
4846
 
4852
 			if adminInfo.Org.Id == 10721 {
4847
 			if adminInfo.Org.Id == 10721 {
4853
-				fmt.Println("prescription.PrescriptionWater-------------------", prescription.PrescriptionWater)
4854
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4848
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4855
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
4849
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
4856
 			}
4850
 			}
4938
 		}
4932
 		}
4939
 
4933
 
4940
 	}
4934
 	}
4935
+
4936
+	if adminInfo.Org.Id == 10721 {
4937
+		var replacement_rate float64
4938
+		var displacement_quantity float64
4939
+		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4940
+		replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*60) / 1000
4941
+		fmt.Println("replacement_rate-----------------", replacement_rate)
4942
+		record.ReplacementRate = replacement_rate
4943
+
4944
+		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
4945
+		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
4946
+		fmt.Println("displacement_quantity-----------------", displacement_quantity)
4947
+		record.DisplacementQuantity = displacement_quantity
4948
+
4949
+	}
4950
+
4941
 	lastMonitorRecordList, _ := service.GetLastMonitorRecordList(patientID, monitorDate, adminInfo.Org.Id)
4951
 	lastMonitorRecordList, _ := service.GetLastMonitorRecordList(patientID, monitorDate, adminInfo.Org.Id)
4942
 
4952
 
4943
 	this.ServeSuccessJSON(map[string]interface{}{
4953
 	this.ServeSuccessJSON(map[string]interface{}{

+ 7 - 7
controllers/mobile_api_controllers/patient_api_controller.go View File

1418
 											//查询今日是否出库
1418
 											//查询今日是否出库
1419
 											drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1419
 											drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1420
 											if drugOutInfo.ID == 0 {
1420
 											if drugOutInfo.ID == 0 {
1421
-												if item.UserOrgId != 10644 {
1421
+												if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
1422
 													service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1422
 													service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1423
 												}
1423
 												}
1424
 
1424
 
1428
 										if pharmacyConfig.IsOpen != 1 {
1428
 										if pharmacyConfig.IsOpen != 1 {
1429
 											drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1429
 											drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1430
 											if drugOutInfo.ID == 0 {
1430
 											if drugOutInfo.ID == 0 {
1431
-												if item.UserOrgId != 10644 {
1431
+												if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
1432
 													service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1432
 													service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1433
 												}
1433
 												}
1434
 
1434
 
1455
 									if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1455
 									if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1456
 										drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1456
 										drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1457
 										if drugOutInfo.ID == 0 {
1457
 										if drugOutInfo.ID == 0 {
1458
-											if item.UserOrgId != 10644 {
1458
+											if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
1459
 												service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1459
 												service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1460
 											}
1460
 											}
1461
 
1461
 
1479
 										service.CreateDrugError(drugError)
1479
 										service.CreateDrugError(drugError)
1480
 										drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1480
 										drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1481
 										if drugOutInfo.ID == 0 {
1481
 										if drugOutInfo.ID == 0 {
1482
-											if item.UserOrgId != 10644 {
1482
+											if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
1483
 												service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1483
 												service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1484
 											}
1484
 											}
1485
 
1485
 
1591
 									//查询今日是否出库
1591
 									//查询今日是否出库
1592
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1592
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1593
 									if drugOutInfo.ID == 0 {
1593
 									if drugOutInfo.ID == 0 {
1594
-										if item.UserOrgId != 10644 {
1594
+										if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
1595
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1595
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1596
 										}
1596
 										}
1597
 
1597
 
1601
 									//查询今日是否出库
1601
 									//查询今日是否出库
1602
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1602
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
1603
 									if drugOutInfo.ID == 0 {
1603
 									if drugOutInfo.ID == 0 {
1604
-										if item.UserOrgId != 10644 {
1604
+										if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
1605
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1605
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
1606
 										}
1606
 										}
1607
 
1607
 
4207
 	}
4207
 	}
4208
 
4208
 
4209
 	//针对孝昌康桥超滤率计算问题
4209
 	//针对孝昌康桥超滤率计算问题
4210
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 {
4210
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 {
4211
 		if evaluation.ID == 0 {
4211
 		if evaluation.ID == 0 {
4212
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4212
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4213
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4213
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {

+ 5 - 4
controllers/patient_api_controller.go View File

2614
 
2614
 
2615
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2615
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2616
 									if drugOutInfo.ID == 0 {
2616
 									if drugOutInfo.ID == 0 {
2617
-										if item.UserOrgId != 10644 {
2617
+										if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
2618
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2618
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2619
 										}
2619
 										}
2620
 
2620
 
2626
 
2626
 
2627
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2627
 									drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2628
 									if drugOutInfo.ID == 0 {
2628
 									if drugOutInfo.ID == 0 {
2629
-										if item.UserOrgId != 10644 {
2629
+										if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
2630
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2630
 											service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2631
 										}
2631
 										}
2632
 
2632
 
2682
 
2682
 
2683
 								drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2683
 								drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2684
 								if drugOutInfo.ID == 0 {
2684
 								if drugOutInfo.ID == 0 {
2685
-									if item.UserOrgId != 10644 {
2685
+									if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
2686
 										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2686
 										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2687
 									}
2687
 									}
2688
 
2688
 
2693
 
2693
 
2694
 								drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2694
 								drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
2695
 								if drugOutInfo.ID == 0 {
2695
 								if drugOutInfo.ID == 0 {
2696
-									if item.UserOrgId != 10644 {
2696
+									if item.UserOrgId != 10644 && item.UserOrgId != 10721 && item.UserOrgId != 10138 && item.UserOrgId != 10278 {
2697
 										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2697
 										service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
2698
 									}
2698
 									}
2699
 
2699
 
4700
 			service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, adminInfo.CurrentOrgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID, prescribeOne.ModeId)
4700
 			service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, adminInfo.CurrentOrgId, item.BedId, item.ZoneId, item.SchedualType, schedule.ID, prescribeOne.ModeId)
4701
 		}
4701
 		}
4702
 	}
4702
 	}
4703
+
4703
 	c.ServeSuccessJSON(map[string]interface{}{
4704
 	c.ServeSuccessJSON(map[string]interface{}{
4704
 		"total":   total,
4705
 		"total":   total,
4705
 		"records": records,
4706
 		"records": records,

+ 516 - 8
controllers/sign_weigh_api_controller.go View File

1
 package controllers
1
 package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/enums"
5
-	"XT_New/models"
6
-	"XT_New/service"
7
 	"encoding/json"
4
 	"encoding/json"
8
 	"fmt"
5
 	"fmt"
9
-	"github.com/astaxie/beego"
10
-	"github.com/jinzhu/gorm"
11
 	"reflect"
6
 	"reflect"
12
 	"strconv"
7
 	"strconv"
13
 	"time"
8
 	"time"
9
+
10
+	"XT_New/enums"
11
+	"XT_New/models"
12
+	"XT_New/service"
13
+	"github.com/astaxie/beego"
14
+	"github.com/jinzhu/gorm"
14
 )
15
 )
15
 
16
 
16
 func SignWeighAPIControllerRegistRouters() {
17
 func SignWeighAPIControllerRegistRouters() {
490
 func (c *SignWeighAPIController) UpdateSignweight() {
491
 func (c *SignWeighAPIController) UpdateSignweight() {
491
 	patientID, _ := c.GetInt64("patient_id", 0)
492
 	patientID, _ := c.GetInt64("patient_id", 0)
492
 	dateTime := c.GetString("date_time")
493
 	dateTime := c.GetString("date_time")
493
-	fmt.Println("病人ID", patientID, dateTime)
494
 	timeLayout := "2006-01-02"
494
 	timeLayout := "2006-01-02"
495
 	loc, _ := time.LoadLocation("Local")
495
 	loc, _ := time.LoadLocation("Local")
496
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
496
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
506
 	weight_before, _ := c.GetFloat("weight_before", 0)
506
 	weight_before, _ := c.GetFloat("weight_before", 0)
507
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
507
 	dry_weight, _ := c.GetFloat("dry_weight", 0)
508
 	temperature, _ := c.GetFloat("temperature", 0)
508
 	temperature, _ := c.GetFloat("temperature", 0)
509
-	fmt.Println("温度", temperature)
510
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
509
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
511
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
510
 	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
512
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
511
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
513
-	fmt.Println("dry_weight", dry_weight)
514
 	var predialysisevaluation models.PredialysisEvaluation
512
 	var predialysisevaluation models.PredialysisEvaluation
515
 	predialysisevaluation.PatientId = patientID
513
 	predialysisevaluation.PatientId = patientID
516
 	predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
514
 	predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
527
 	predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
525
 	predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
528
 	fmt.Println("sigh", predialysis)
526
 	fmt.Println("sigh", predialysis)
529
 	fmt.Println("错误:", errcode)
527
 	fmt.Println("错误:", errcode)
528
+
529
+	lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.CurrentOrgId, patientID, dateTimeStam)
530
+
531
+	if lastPredialysisEvaluation != nil {
532
+		predialysisevaluation.DryWeight = lastPredialysisEvaluation.DryWeight
533
+		predialysisevaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
534
+		predialysisevaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin
535
+		predialysisevaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
536
+		predialysisevaluation.Catheter = lastPredialysisEvaluation.Catheter
537
+		predialysisevaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend
538
+		predialysisevaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
539
+		predialysisevaluation.PunctureNeedleDirection = lastPredialysisEvaluation.PunctureNeedleDirection
540
+		predialysisevaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
541
+		predialysisevaluation.PointPuncture = lastPredialysisEvaluation.PointPuncture
542
+		predialysisevaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage
543
+		predialysisevaluation.ThromubusType = lastPredialysisEvaluation.ThromubusType
544
+		predialysisevaluation.Skin = lastPredialysisEvaluation.Skin
545
+		predialysisevaluation.Complication = lastPredialysisEvaluation.Complication
546
+		predialysisevaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
547
+		predialysisevaluation.LastPostDialysisOther = lastPredialysisEvaluation.LastPostDialysisOther
548
+	}
549
+
530
 	if errcode == gorm.ErrRecordNotFound {
550
 	if errcode == gorm.ErrRecordNotFound {
551
+
531
 		service.SaveDislysisiBefore(&predialysisevaluation)
552
 		service.SaveDislysisiBefore(&predialysisevaluation)
532
 	} else if errcode == nil {
553
 	} else if errcode == nil {
533
 
554
 
537
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
558
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
538
 	}
559
 	}
539
 
560
 
561
+	// 计算透析处方的相关超滤量
562
+	schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patientID, dateTimeStam)
563
+
564
+	var lastDialysisPrescribe *models.DialysisPrescription
565
+	var dialysisSolution *models.DialysisSolution
566
+	var dialysisPrescribe *models.DialysisPrescription
567
+	var system_dialysisPrescribe *models.SystemPrescription
568
+
569
+	dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patientID, dateTimeStam)
570
+
571
+	var dewater_amount float64
572
+
573
+	dewater_amount = predialysisevaluation.WeightBefore - predialysisevaluation.DryWeight - predialysisevaluation.AdditionalWeight
574
+
575
+	dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patientID, schedual.ModeId)
576
+
577
+	// 插入透析处方
578
+	if dialysisPrescribe == nil && dialysisSolution != nil {
579
+		var newprescribe models.DialysisPrescription
580
+		newprescribe.UserOrgId = dialysisSolution.UserOrgId
581
+		newprescribe.PatientId = dialysisSolution.PatientId
582
+		newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
583
+		newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
584
+		newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
585
+		newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
586
+		newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
587
+		newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
588
+		newprescribe.ModeId = dialysisSolution.ModeId
589
+		newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
590
+		newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
591
+		newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
592
+		newprescribe.BloodFilter = dialysisSolution.BloodFilter
593
+		newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
594
+		newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
595
+		newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
596
+		newprescribe.Glucose = dialysisSolution.Glucose
597
+		newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
598
+		newprescribe.Kalium = dialysisSolution.Kalium
599
+		newprescribe.Sodium = dialysisSolution.Sodium
600
+		newprescribe.Calcium = dialysisSolution.Calcium
601
+		newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
602
+		newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
603
+		newprescribe.Conductivity = dialysisSolution.Conductivity
604
+		newprescribe.BodyFluid = dialysisSolution.BodyFluid
605
+		newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
606
+		newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
607
+		newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
608
+		newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
609
+		newprescribe.BloodAccess = dialysisSolution.BloodAccess
610
+		newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
611
+		newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
612
+		newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
613
+		newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
614
+		newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
615
+		newprescribe.Dialyzer = dialysisSolution.Dialyzer
616
+		newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
617
+		newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
618
+		newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
619
+		newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
620
+		newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
621
+		newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
622
+		newprescribe.TargetKtv = dialysisSolution.TargetKtv
623
+
624
+		newprescribe.CreatedTime = time.Now().Unix()
625
+		newprescribe.UpdatedTime = time.Now().Unix()
626
+		newprescribe.RecordDate = dateTimeStam
627
+		newprescribe.DewaterAmount = dewater_amount
628
+		newprescribe.TargetUltrafiltration = dewater_amount
629
+		newprescribe.PrescriptionWater = dewater_amount
630
+		newprescribe.Chaptalization = dialysisSolution.Chaptalization
631
+		newprescribe.PrescribingNumber = 1
632
+		newprescribe.BloodAccessPartId = dialysisSolution.BloodAccessPartId
633
+		newprescribe.Status = 1
634
+		if adminUserInfo.CurrentOrgId != 10013 && adminUserInfo.CurrentOrgId != 10014 && adminUserInfo.CurrentOrgId != 10016 {
635
+			newprescribe.Remark = dialysisSolution.Remark
636
+		}
637
+
638
+		if adminUserInfo.CurrentOrgId == 10340 {
639
+			newprescribe.TargetUltrafiltration = 0
640
+			newprescribe.Sodium = 138
641
+			newprescribe.Bicarbonate = 31.1
642
+			newprescribe.DialysateFlow = 500
643
+			newprescribe.TargetUltrafiltration = 0
644
+		}
645
+		// 针对新化博翔
646
+		if adminUserInfo.CurrentOrgId == 10447 {
647
+			newprescribe.DisplaceLiquiPart = 1
648
+			newprescribe.DisplaceLiquiValue = 32
649
+			newprescribe.DialysateFlow = 500
650
+		}
651
+
652
+		if adminUserInfo.CurrentOrgId == 10121 {
653
+			newprescribe.DialysisDurationHour = 4
654
+			newprescribe.DialysisDurationMinute = 0
655
+			newprescribe.BloodAccess = dialysisSolution.BloodAccess
656
+		}
657
+
658
+		if adminUserInfo.CurrentOrgId == 10445 {
659
+			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
660
+			newprescribe.Remark = lastDialysisPrescription.Remark
661
+		}
662
+
663
+		//恒泰
664
+		if adminUserInfo.CurrentOrgId == 10490 || adminUserInfo.CurrentOrgId == 10016 {
665
+			newprescribe.Remark = ""
666
+		}
667
+
668
+		if adminUserInfo.CurrentOrgId == 10599 {
669
+			// 获取透析模版
670
+			solutionone, _ := service.MobileGetDialysisSolutionByModeIdSevenTwety(adminUserInfo.CurrentOrgId, patientID, schedual.ModeId)
671
+			if solutionone.Anticoagulant > 0 {
672
+				newprescribe.Anticoagulant = solutionone.Anticoagulant
673
+				newprescribe.AnticoagulantShouji = solutionone.AnticoagulantShouji
674
+				newprescribe.AnticoagulantWeichi = solutionone.AnticoagulantWeichi
675
+				newprescribe.AnticoagulantZongliang = solutionone.AnticoagulantZongliang
676
+				newprescribe.BloodAccess = solutionone.BloodAccess
677
+				newprescribe.DialysisDurationHour = solutionone.DialysisDurationHour
678
+				newprescribe.DialysisDurationMinute = solutionone.DialysisDurationMinute
679
+				newprescribe.DialysisIrrigation = solutionone.DialysisIrrigation
680
+				newprescribe.DialysisDialyszers = solutionone.DialysisDialyszers
681
+				newprescribe.DialysisStrainer = solutionone.DialysisStrainer
682
+
683
+			}
684
+
685
+		}
686
+
687
+		//针对普宁和揭阳
688
+		if adminUserInfo.CurrentOrgId == 10597 || adminUserInfo.CurrentOrgId == 10599 {
689
+			prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
690
+			if prescriptionTwenty.ID == 0 {
691
+				//插入透析处方
692
+				service.AddSigleRecord(&newprescribe)
693
+			} else {
694
+				//插入透析处方
695
+				service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
696
+			}
697
+		} else {
698
+			//插入透析处方
699
+			service.AddSigleRecord(&newprescribe)
700
+		}
701
+
702
+		//记录日志
703
+		byterequest, _ := json.Marshal(newprescribe)
704
+		prescriptionLog := models.XtDialysisPrescriptionLog{
705
+			UserOrgId:   newprescribe.UserOrgId,
706
+			Ctime:       time.Now().Unix(),
707
+			Mtime:       0,
708
+			ErrLog:      string(byterequest),
709
+			AdminUserId: adminUserInfo.AdminUser.Id,
710
+			RecordDate:  newprescribe.RecordDate,
711
+			PatientId:   newprescribe.PatientId,
712
+			Source:      "物联网上传",
713
+			Status:      1,
714
+		}
715
+
716
+		service.CreatePrescriptionLog(prescriptionLog)
717
+
718
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
719
+		redis := service.RedisClient()
720
+		//清空key 值
721
+		redis.Set(key, "", time.Second)
722
+		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
723
+		redis.Set(keyTwo, "", time.Second)
724
+		thisTime := time.Now()
725
+		scheduleDateStartOne := thisTime.Format("2006-01-02")
726
+		keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
727
+		redis.Set(keyThree, "", time.Second)
728
+		defer redis.Close()
729
+	}
730
+
731
+	if dialysisPrescribe == nil && dialysisSolution == nil {
732
+		if lastDialysisPrescribe != nil {
733
+			var newprescribe models.DialysisPrescription
734
+			newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
735
+			newprescribe.PatientId = lastDialysisPrescribe.PatientId
736
+			newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
737
+			newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
738
+			newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
739
+			newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
740
+			newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
741
+			newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
742
+			newprescribe.ModeId = lastDialysisPrescribe.ModeId
743
+			newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
744
+			newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
745
+			newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
746
+			newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
747
+			newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
748
+			newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
749
+			newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
750
+			newprescribe.Glucose = lastDialysisPrescribe.Glucose
751
+			newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
752
+			newprescribe.Kalium = lastDialysisPrescribe.Kalium
753
+			newprescribe.Sodium = lastDialysisPrescribe.Sodium
754
+			newprescribe.Calcium = lastDialysisPrescribe.Calcium
755
+			newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
756
+			newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
757
+			newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
758
+			newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
759
+			newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
760
+			newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
761
+			newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
762
+			newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
763
+			newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
764
+			newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
765
+			newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
766
+			newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
767
+			newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
768
+			newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
769
+			newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
770
+			newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
771
+			newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
772
+			newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
773
+			newprescribe.DialysisStrainer = lastDialysisPrescribe.DialysisStrainer
774
+			newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
775
+			newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
776
+			newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
777
+			newprescribe.CreatedTime = time.Now().Unix()
778
+			newprescribe.UpdatedTime = time.Now().Unix()
779
+			newprescribe.RecordDate = dateTimeStam
780
+			newprescribe.DewaterAmount = dewater_amount
781
+			newprescribe.TargetUltrafiltration = dewater_amount
782
+			newprescribe.PrescriptionWater = dewater_amount
783
+			newprescribe.Status = 1
784
+
785
+			if adminUserInfo.CurrentOrgId == 10490 || adminUserInfo.CurrentOrgId == 10016 {
786
+				newprescribe.Remark = ""
787
+			}
788
+
789
+			newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
790
+			newprescribe.PrescribingNumber = 1
791
+			if adminUserInfo.CurrentOrgId == 10340 {
792
+				newprescribe.TargetUltrafiltration = 0
793
+			}
794
+			if adminUserInfo.CurrentOrgId == 10121 {
795
+				newprescribe.DialysisDurationHour = 4
796
+				newprescribe.DialysisDurationMinute = 0
797
+				newprescribe.BloodAccess = dialysisSolution.BloodAccess
798
+			}
799
+
800
+			if adminUserInfo.CurrentOrgId == 10445 {
801
+				lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
802
+				newprescribe.Remark = lastDialysisPrescription.Remark
803
+			}
804
+			//err := service.AddSigleRecord(&newprescribe)
805
+			var err error
806
+			if adminUserInfo.CurrentOrgId == 10597 || adminUserInfo.CurrentOrgId == 10599 || adminUserInfo.CurrentOrgId == 3877 {
807
+				prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
808
+				if prescriptionTwenty.ID == 0 {
809
+					//插入透析处方
810
+					service.AddSigleRecord(&newprescribe)
811
+				} else {
812
+					//插入透析处方
813
+					service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
814
+				}
815
+			} else {
816
+				//插入透析处方
817
+				err = service.AddSigleRecord(&newprescribe)
818
+			}
819
+			//记录日志
820
+			byterequest, _ := json.Marshal(newprescribe)
821
+			prescriptionLog := models.XtDialysisPrescriptionLog{
822
+				UserOrgId:   adminUserInfo.CurrentOrgId,
823
+				Ctime:       time.Now().Unix(),
824
+				Mtime:       0,
825
+				ErrLog:      string(byterequest),
826
+				AdminUserId: adminUserInfo.AdminUser.Id,
827
+				RecordDate:  newprescribe.RecordDate,
828
+				PatientId:   patientID,
829
+				Source:      "物联网上传",
830
+				Status:      1,
831
+			}
832
+
833
+			service.CreatePrescriptionLog(prescriptionLog)
834
+
835
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
836
+			redis := service.RedisClient()
837
+			//清空key 值
838
+			redis.Set(key, "", time.Second)
839
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
840
+			redis.Set(keyTwo, "", time.Second)
841
+			thisTime := time.Now()
842
+			scheduleDateStartOne := thisTime.Format("2006-01-02")
843
+			keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
844
+			redis.Set(keyThree, "", time.Second)
845
+			defer redis.Close()
846
+			if err != nil {
847
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
848
+			}
849
+		} else if system_dialysisPrescribe != nil {
850
+			var newprescribe models.DialysisPrescription
851
+			newprescribe.UserOrgId = system_dialysisPrescribe.UserOrgId
852
+			newprescribe.PatientId = patientID
853
+			newprescribe.Anticoagulant = system_dialysisPrescribe.Anticoagulant
854
+			newprescribe.AnticoagulantShouji = system_dialysisPrescribe.AnticoagulantShouji
855
+			newprescribe.AnticoagulantWeichi = system_dialysisPrescribe.AnticoagulantWeichi
856
+			newprescribe.AnticoagulantZongliang = system_dialysisPrescribe.AnticoagulantZongliang
857
+			newprescribe.AnticoagulantGaimingcheng = system_dialysisPrescribe.AnticoagulantGaimingcheng
858
+			newprescribe.AnticoagulantGaijiliang = system_dialysisPrescribe.AnticoagulantGaijiliang
859
+			newprescribe.ModeId = system_dialysisPrescribe.ModeId
860
+			newprescribe.DialysisDuration = system_dialysisPrescribe.DialysisDuration
861
+			newprescribe.ReplacementWay = system_dialysisPrescribe.ReplacementWay
862
+			newprescribe.HemodialysisMachine = system_dialysisPrescribe.HemodialysisMachine
863
+			newprescribe.BloodFilter = system_dialysisPrescribe.BloodFilter
864
+			newprescribe.PerfusionApparatus = system_dialysisPrescribe.PerfusionApparatus
865
+			newprescribe.BloodFlowVolume = system_dialysisPrescribe.BloodFlowVolume
866
+			newprescribe.DisplaceLiqui = system_dialysisPrescribe.DisplaceLiqui
867
+			newprescribe.Glucose = system_dialysisPrescribe.Glucose
868
+			newprescribe.DialysateFlow = system_dialysisPrescribe.DialysateFlow
869
+			newprescribe.Kalium = system_dialysisPrescribe.Kalium
870
+			newprescribe.Sodium = system_dialysisPrescribe.Sodium
871
+			newprescribe.Calcium = system_dialysisPrescribe.Calcium
872
+			newprescribe.Bicarbonate = system_dialysisPrescribe.Bicarbonate
873
+			newprescribe.DialysateTemperature = system_dialysisPrescribe.DialysateTemperature
874
+			newprescribe.Conductivity = system_dialysisPrescribe.Conductivity
875
+			newprescribe.BodyFluid = system_dialysisPrescribe.BodyFluid
876
+			newprescribe.SpecialMedicine = system_dialysisPrescribe.SpecialMedicine
877
+			newprescribe.SpecialMedicineOther = system_dialysisPrescribe.SpecialMedicineOther
878
+			newprescribe.DisplaceLiquiPart = system_dialysisPrescribe.DisplaceLiquiPart
879
+			newprescribe.DisplaceLiquiValue = system_dialysisPrescribe.DisplaceLiquiValue
880
+			newprescribe.BloodAccess = system_dialysisPrescribe.BloodAccess
881
+			newprescribe.Ultrafiltration = system_dialysisPrescribe.Ultrafiltration
882
+			newprescribe.DialysisDurationHour = system_dialysisPrescribe.DialysisDurationHour
883
+			newprescribe.DialysisDurationMinute = system_dialysisPrescribe.DialysisDurationMinute
884
+			newprescribe.DialysateFormulation = system_dialysisPrescribe.DialysateFormulation
885
+			newprescribe.Dialyzer = system_dialysisPrescribe.Dialyzer
886
+			newprescribe.ReplacementTotal = system_dialysisPrescribe.ReplacementTotal
887
+			newprescribe.DialyzerPerfusionApparatus = system_dialysisPrescribe.DialyzerPerfusionApparatus
888
+			newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
889
+			newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
890
+			newprescribe.BodyFluidOther = system_dialysisPrescribe.BodyFluidOther
891
+			newprescribe.TargetKtv = system_dialysisPrescribe.TargetKtv
892
+			newprescribe.CreatedTime = time.Now().Unix()
893
+			newprescribe.UpdatedTime = time.Now().Unix()
894
+			newprescribe.RecordDate = dateTimeStam
895
+			newprescribe.DewaterAmount = dewater_amount
896
+			newprescribe.TargetUltrafiltration = dewater_amount
897
+			newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
898
+			newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
899
+			newprescribe.Status = 1
900
+			newprescribe.PrescribingNumber = 1
901
+
902
+			if adminUserInfo.CurrentOrgId == 10340 {
903
+				newprescribe.TargetUltrafiltration = 0
904
+			}
905
+			if adminUserInfo.CurrentOrgId == 10121 {
906
+				newprescribe.DialysisDurationHour = 4
907
+				newprescribe.DialysisDurationMinute = 0
908
+				newprescribe.BloodAccess = dialysisSolution.BloodAccess
909
+			}
910
+			if adminUserInfo.CurrentOrgId == 10445 {
911
+				lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
912
+				newprescribe.Remark = lastDialysisPrescription.Remark
913
+			}
914
+
915
+			if adminUserInfo.CurrentOrgId == 10597 || adminUserInfo.CurrentOrgId == 10599 || adminUserInfo.CurrentOrgId == 3877 {
916
+				prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
917
+				if prescriptionTwenty.ID == 0 {
918
+					//插入透析处方
919
+					service.AddSigleRecord(&newprescribe)
920
+				} else {
921
+					//插入透析处方
922
+					service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
923
+				}
924
+			} else {
925
+				service.AddSigleRecord(&newprescribe)
926
+			}
927
+
928
+			//记录日志
929
+			byterequest, _ := json.Marshal(newprescribe)
930
+			prescriptionLog := models.XtDialysisPrescriptionLog{
931
+				UserOrgId:   adminUserInfo.CurrentOrgId,
932
+				Ctime:       time.Now().Unix(),
933
+				Mtime:       0,
934
+				ErrLog:      string(byterequest),
935
+				AdminUserId: adminUserInfo.AdminUser.Id,
936
+				RecordDate:  newprescribe.RecordDate,
937
+				PatientId:   patientID,
938
+				Source:      "物联网上传",
939
+				Status:      1,
940
+			}
941
+
942
+			service.CreatePrescriptionLog(prescriptionLog)
943
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
944
+			redis := service.RedisClient()
945
+			//清空key 值
946
+			redis.Set(key, "", time.Second)
947
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
948
+			redis.Set(keyTwo, "", time.Second)
949
+			thisTime := time.Now()
950
+			scheduleDateStartOne := thisTime.Format("2006-01-02")
951
+			keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
952
+			redis.Set(keyThree, "", time.Second)
953
+			defer redis.Close()
954
+
955
+		} else {
956
+			var newprescribe models.DialysisPrescription
957
+			newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
958
+			newprescribe.PatientId = patientID
959
+			newprescribe.ModeId = schedual.ModeId
960
+			newprescribe.CreatedTime = time.Now().Unix()
961
+			newprescribe.UpdatedTime = time.Now().Unix()
962
+			newprescribe.RecordDate = dateTimeStam
963
+			newprescribe.DewaterAmount = dewater_amount
964
+			newprescribe.TargetUltrafiltration = dewater_amount
965
+			newprescribe.Status = 1
966
+			if adminUserInfo.CurrentOrgId == 10445 {
967
+				lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
968
+				newprescribe.Remark = lastDialysisPrescription.Remark
969
+			}
970
+			err := service.AddSigleRecord(&newprescribe)
971
+			//记录日志
972
+			byterequest, _ := json.Marshal(newprescribe)
973
+			prescriptionLog := models.XtDialysisPrescriptionLog{
974
+				UserOrgId:   adminUserInfo.CurrentOrgId,
975
+				Ctime:       time.Now().Unix(),
976
+				Mtime:       0,
977
+				ErrLog:      string(byterequest),
978
+				AdminUserId: adminUserInfo.AdminUser.Id,
979
+				RecordDate:  newprescribe.RecordDate,
980
+				PatientId:   patientID,
981
+				Source:      "物联网上传",
982
+				Status:      1,
983
+			}
984
+
985
+			service.CreatePrescriptionLog(prescriptionLog)
986
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
987
+			redis := service.RedisClient()
988
+			//清空key 值
989
+			redis.Set(key, "", time.Second)
990
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
991
+			redis.Set(keyTwo, "", time.Second)
992
+			thisTime := time.Now()
993
+			scheduleDateStartOne := thisTime.Format("2006-01-02")
994
+			keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
995
+			redis.Set(keyThree, "", time.Second)
996
+			defer redis.Close()
997
+			if err != nil {
998
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
999
+			}
1000
+		}
1001
+	}
1002
+
1003
+	if dialysisPrescribe != nil && dialysisPrescribe.TargetUltrafiltration == 0 {
1004
+		dialysisPrescribe.UpdatedTime = time.Now().Unix()
1005
+		dialysisPrescribe.RecordDate = dateTimeStam
1006
+		dialysisPrescribe.DewaterAmount = dewater_amount
1007
+		dialysisPrescribe.TargetUltrafiltration = dewater_amount
1008
+		dialysisPrescribe.Status = 1
1009
+		if adminUserInfo.CurrentOrgId == 10340 {
1010
+			dialysisPrescribe.TargetUltrafiltration = 0
1011
+		}
1012
+		if adminUserInfo.CurrentOrgId == 10445 {
1013
+			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminUserInfo.CurrentOrgId)
1014
+			dialysisPrescribe.Remark = lastDialysisPrescription.Remark
1015
+		}
1016
+		updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
1017
+		//记录日志
1018
+		byterequest, _ := json.Marshal(dialysisPrescribe)
1019
+		prescriptionLog := models.XtDialysisPrescriptionLog{
1020
+			UserOrgId:   adminUserInfo.CurrentOrgId,
1021
+			Ctime:       time.Now().Unix(),
1022
+			Mtime:       0,
1023
+			ErrLog:      string(byterequest),
1024
+			AdminUserId: adminUserInfo.AdminUser.Id,
1025
+			RecordDate:  dialysisPrescribe.RecordDate,
1026
+			PatientId:   patientID,
1027
+			Source:      "物联网上传",
1028
+			Status:      1,
1029
+		}
1030
+
1031
+		service.CreatePrescriptionLog(prescriptionLog)
1032
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":" + strconv.FormatInt(schedual.ModeId, 10) + ":dialysis_prescribe"
1033
+		redis := service.RedisClient()
1034
+		//清空key 值
1035
+		redis.Set(key, "", time.Second)
1036
+		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dateTimeStam, 10) + ":prescriptions_list_all"
1037
+		redis.Set(keyTwo, "", time.Second)
1038
+		thisTime := time.Now()
1039
+		scheduleDateStartOne := thisTime.Format("2006-01-02")
1040
+		keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1041
+		redis.Set(keyThree, "", time.Second)
1042
+		defer redis.Close()
1043
+		if updateErr != nil {
1044
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1045
+		}
1046
+	}
1047
+
540
 	//透后
1048
 	//透后
541
 	weight_after, _ := c.GetFloat("weight_after", 0)
1049
 	weight_after, _ := c.GetFloat("weight_after", 0)
542
 	temperatureafter, _ := c.GetFloat("temperatureafter", 0)
1050
 	temperatureafter, _ := c.GetFloat("temperatureafter", 0)

+ 1 - 0
models/device_models.go View File

518
 	LastAfterWeight     AssessmentAfterDislysis `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
518
 	LastAfterWeight     AssessmentAfterDislysis `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
519
 	DialysisMachineName string                  `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
519
 	DialysisMachineName string                  `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
520
 	MaxId               int64                   `gorm:"column:max_id" json:"max_id" form:"max_id"`
520
 	MaxId               int64                   `gorm:"column:max_id" json:"max_id" form:"max_id"`
521
+	Remark              string                  `gorm:"column:remark" json:"remark" form:"remark"`
521
 }
522
 }
522
 
523
 
523
 func (XtSchedule) TableName() string {
524
 func (XtSchedule) TableName() string {

+ 15 - 1
service/patient_service.go View File

2217
 }
2217
 }
2218
 
2218
 
2219
 func UpdateScheduleByDeathTime(patientid int64, shcheduledate int64) error {
2219
 func UpdateScheduleByDeathTime(patientid int64, shcheduledate int64) error {
2220
-	err := XTWriteDB().Model(models.XtSchedule{}).Where("patient_id = ? and schedule_date > ? and status=1", patientid, shcheduledate).Updates(map[string]interface{}{"status": 0}).Error
2220
+	var err error
2221
+	if shcheduledate > 0 {
2222
+		err = XTWriteDB().Model(models.XtSchedule{}).Where("patient_id = ? and schedule_date > ? and status=1", patientid, shcheduledate).Updates(map[string]interface{}{"status": 0, "remark": "转出删除排班"}).Error
2223
+	}
2224
+
2221
 	return err
2225
 	return err
2226
+
2222
 }
2227
 }
2223
 
2228
 
2224
 func UpdatePatientLapsetoByPatientId(patient_id int64, record_date int64, lapse_reason string) error {
2229
 func UpdatePatientLapsetoByPatientId(patient_id int64, record_date int64, lapse_reason string) error {
4326
 
4331
 
4327
 	return lapseto, err
4332
 	return lapseto, err
4328
 }
4333
 }
4334
+
4335
+func GetPatientBefor(patient_id int64, record_date int64, user_org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4336
+
4337
+	beforeDislysis := models.XtAssessmentBeforeDislysis{}
4338
+
4339
+	err := XTReadDB().Where("patient_id = ? and assessment_date= ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Find(&beforeDislysis).Error
4340
+
4341
+	return beforeDislysis, err
4342
+}

+ 1 - 1
service/sign_service.go View File

2134
 
2134
 
2135
 func GetAllDialysisOrder(patient_id int64, start_time int64, end_time int64) (list []*models.XtDialysisOrder, err error) {
2135
 func GetAllDialysisOrder(patient_id int64, start_time int64, end_time int64) (list []*models.XtDialysisOrder, err error) {
2136
 
2136
 
2137
-	err = XTReadDB().Where("patient_id = ? and status =1 and dialysis_date>=? and dialysis_date<=?", patient_id, start_time, end_time).Find(&list).Error
2137
+	err = XTReadDB().Where("patient_id = ? and status =1 and dialysis_date>=1541001600 and dialysis_date<=?", patient_id, end_time).Find(&list).Error
2138
 
2138
 
2139
 	return list, err
2139
 	return list, err
2140
 }
2140
 }