Bladeren bron

历史排班

28169 1 jaar geleden
bovenliggende
commit
93341a1d49

+ 26 - 0
controllers/dialysis_api_controller.go Bestand weergeven

3154
 
3154
 
3155
 	} else {
3155
 	} else {
3156
 		dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
3156
 		dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
3157
+
3158
+		for _, item := range dialysisSchedule {
3159
+			patients, _ := service.GetMonitorPatients(item.PatientId)
3160
+			item.MonitorPatients = patients
3161
+
3162
+			orderObj, _ := service.GetMonitorDialysisOrderObj(item.PatientId, item.ScheduleDate)
3163
+
3164
+			item.DialysisOrder = orderObj
3165
+
3166
+			prescription, _ := service.GetMonitorDialysisPrescription(item.PatientId, item.ScheduleDate)
3167
+
3168
+			item.Prescription = prescription
3169
+
3170
+			evaluation, _ := service.GetMonitorPredialysisEvaluation(item.PatientId, item.ScheduleDate)
3171
+
3172
+			item.AssessmentBeforeDislysis = evaluation
3173
+
3174
+			afterdislysis, _ := service.GetMonitorAssessmentAfterDislysis(item.PatientId, item.ScheduleDate)
3175
+
3176
+			item.AssessmentAfterDislysis = afterdislysis
3177
+
3178
+			monitorRecord, _ := service.GetMonitoringRecordList(item.PatientId, item.ScheduleDate)
3179
+
3180
+			item.MonitoringRecord = monitorRecord
3181
+
3182
+		}
3157
 		if err == nil {
3183
 		if err == nil {
3158
 			c.ServeSuccessJSON(map[string]interface{}{
3184
 			c.ServeSuccessJSON(map[string]interface{}{
3159
 				"schedule": dialysisSchedule,
3185
 				"schedule": dialysisSchedule,

+ 11 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go Bestand weergeven

86
 	defer redis.Close()
86
 	defer redis.Close()
87
 
87
 
88
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
88
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
89
-
89
+	//redis.Set(key, "", time.Second)
90
 	scheduals_json_str, _ := redis.Get(key).Result()
90
 	scheduals_json_str, _ := redis.Get(key).Result()
91
 
91
 
92
 	patients, _ := service.GetAllPatientListSix(orgID)
92
 	patients, _ := service.GetAllPatientListSix(orgID)
93
+	fmt.Println("scheduals_json_strwoowowow", len(scheduals_json_str))
93
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
94
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
94
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
95
 		scheduals, err := service.MobileGetDialysisScheduals(orgID, date.Unix(), schedualType)
96
+
97
+		for _, item := range scheduals {
98
+			order, _ := service.GetMonitDialysisOrder(item.UserOrgId, item.PatientId, date.Unix())
99
+			item.DialysisLastOrder = order
100
+
101
+			solution, _ := service.GetMonitDialysisSolution(item.UserOrgId, item.PatientId, item.ModeId)
102
+			item.DialysisSolution = solution
103
+		}
95
 		fmt.Println("len2223o32o23o23owo", len(scheduals))
104
 		fmt.Println("len2223o32o23o23owo", len(scheduals))
96
 		if err != nil {
105
 		if err != nil {
97
 			this.ErrorLog("获取排班信息失败:%v", err)
106
 			this.ErrorLog("获取排班信息失败:%v", err)
106
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
115
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
107
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
116
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
108
 				dobulecheck, _ := service.GetAllDobuleCheckList(orgID, date.Unix())
117
 				dobulecheck, _ := service.GetAllDobuleCheckList(orgID, date.Unix())
109
-				fmt.Println("dobulecheck", dobulecheck)
118
+
110
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
119
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
111
 				inforMation, _ := service.GetTodayInforMation(orgID, date.Unix())
120
 				inforMation, _ := service.GetTodayInforMation(orgID, date.Unix())
112
 				for key, item := range scheduals {
121
 				for key, item := range scheduals {

+ 1 - 1
controllers/mobile_api_controllers/patient_api_controller.go Bestand weergeven

3897
 	//获取患者的透析次数
3897
 	//获取患者的透析次数
3898
 	//count, err := service.GetDialysisCount(orgID, partition)
3898
 	//count, err := service.GetDialysisCount(orgID, partition)
3899
 
3899
 
3900
-	patients, err := service.GetAllpatientThirty(orgID)
3900
+	patients, err := service.GetAllpatientFourty(orgID)
3901
 	if err == nil {
3901
 	if err == nil {
3902
 		c.ServeSuccessJSON(map[string]interface{}{
3902
 		c.ServeSuccessJSON(map[string]interface{}{
3903
 			"monitor": monitor,
3903
 			"monitor": monitor,

+ 112 - 11
controllers/schedule_api_controller.go Bestand weergeven

87
 
87
 
88
 	beego.Router("/api/schedule/create_two", &ScheduleApiController{}, "Post:CreateScheduleTwo")
88
 	beego.Router("/api/schedule/create_two", &ScheduleApiController{}, "Post:CreateScheduleTwo")
89
 
89
 
90
+	beego.Router("/api/schedule/changeschedule", &ScheduleApiController{}, "Put:ChangeScheduleTen")
91
+
90
 }
92
 }
91
 func (c *ScheduleApiController) CoverSch() {
93
 func (c *ScheduleApiController) CoverSch() {
92
 	id_one, _ := c.GetInt64("id_one")
94
 	id_one, _ := c.GetInt64("id_one")
1983
 		var DialysisMachineName string
1985
 		var DialysisMachineName string
1984
 		if filedRecordOne.IsShow == 1 {
1986
 		if filedRecordOne.IsShow == 1 {
1985
 			DialysisMachineName = so.DialysisDialyszers
1987
 			DialysisMachineName = so.DialysisDialyszers
1986
-			fmt.Println("1111")
1988
+			//fmt.Println("1111")
1987
 			fmt.Println(DialysisMachineName)
1989
 			fmt.Println(DialysisMachineName)
1988
 
1990
 
1989
 		}
1991
 		}
1990
 		if filedRecordThree.IsShow == 1 {
1992
 		if filedRecordThree.IsShow == 1 {
1991
 			if len(schedule.DialysisMachineName) > 0 {
1993
 			if len(schedule.DialysisMachineName) > 0 {
1992
 				DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
1994
 				DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
1993
-				fmt.Println("22222")
1995
+				//fmt.Println("22222")
1994
 				fmt.Println(DialysisMachineName)
1996
 				fmt.Println(DialysisMachineName)
1995
 			} else {
1997
 			} else {
1996
 				DialysisMachineName = so.DialyzerPerfusionApparatus
1998
 				DialysisMachineName = so.DialyzerPerfusionApparatus
1997
-				fmt.Println("333333")
1999
+				//fmt.Println("333333")
1998
 				fmt.Println(DialysisMachineName)
2000
 				fmt.Println(DialysisMachineName)
1999
 			}
2001
 			}
2000
 		}
2002
 		}
2001
 		if filedRecordTwo.IsShow == 1 {
2003
 		if filedRecordTwo.IsShow == 1 {
2002
 			if len(DialysisMachineName) > 0 {
2004
 			if len(DialysisMachineName) > 0 {
2003
 				DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
2005
 				DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
2004
-				fmt.Println("55555555")
2006
+				//fmt.Println("55555555")
2005
 				fmt.Println(DialysisMachineName)
2007
 				fmt.Println(DialysisMachineName)
2006
 			} else {
2008
 			} else {
2007
 				DialysisMachineName = so.DialysisIrrigation
2009
 				DialysisMachineName = so.DialysisIrrigation
2008
-				fmt.Println("66666666")
2010
+				//fmt.Println("66666666")
2009
 				fmt.Println(DialysisMachineName)
2011
 				fmt.Println(DialysisMachineName)
2010
 			}
2012
 			}
2011
 		}
2013
 		}
3788
 	adminUserInfo := this.GetAdminUserInfo()
3790
 	adminUserInfo := this.GetAdminUserInfo()
3789
 	orgId := adminUserInfo.CurrentOrgId
3791
 	orgId := adminUserInfo.CurrentOrgId
3790
 	start_time, _ := this.GetInt64("start_time")
3792
 	start_time, _ := this.GetInt64("start_time")
3791
-	fmt.Println("start_time", start_time)
3793
+
3792
 	end_time, _ := this.GetInt64("end_time")
3794
 	end_time, _ := this.GetInt64("end_time")
3793
-	fmt.Println("end_time", end_time)
3795
+
3794
 	copy_startime, _ := this.GetInt64("copy_startime")
3796
 	copy_startime, _ := this.GetInt64("copy_startime")
3795
-	fmt.Println("copy_startime", copy_startime)
3797
+
3796
 	copy_endtime, _ := this.GetInt64("copy_endtime")
3798
 	copy_endtime, _ := this.GetInt64("copy_endtime")
3797
 
3799
 
3798
 	//获取本周患者排班
3800
 	//获取本周患者排班
4394
 	}
4396
 	}
4395
 	schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4397
 	schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
4396
 
4398
 
4397
-	if adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10346 {
4399
+	if adminInfo.CurrentOrgId == 10346 {
4398
 
4400
 
4399
 		if len(schdules) > 0 {
4401
 		if len(schdules) > 0 {
4400
 			//获取长期医嘱里面的透析器灌流器
4402
 			//获取长期医嘱里面的透析器灌流器
4420
 
4422
 
4421
 	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
4423
 	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
4422
 
4424
 
4423
-	fmt.Println("weekwoowowowowowowowowowo", week)
4424
 	patitionIdStr := c.GetString("patitionid")
4425
 	patitionIdStr := c.GetString("patitionid")
4425
 
4426
 
4426
 	ids := strings.Split(patitionIdStr, ",")
4427
 	ids := strings.Split(patitionIdStr, ",")
4429
 
4430
 
4430
 	adminInfo := c.GetAdminUserInfo()
4431
 	adminInfo := c.GetAdminUserInfo()
4431
 	weekDateStr := c.GetString("week_date")
4432
 	weekDateStr := c.GetString("week_date")
4432
-	fmt.Println("weekDateStr--------------------", weekDateStr)
4433
+
4433
 	WeekDayIds := strings.Split(weekDateStr, ",")
4434
 	WeekDayIds := strings.Split(weekDateStr, ",")
4434
 
4435
 
4435
 	thisTime := time.Now()
4436
 	thisTime := time.Now()
4901
 	}
4902
 	}
4902
 
4903
 
4903
 }
4904
 }
4905
+
4906
+func (c *ScheduleApiController) ChangeScheduleTen() {
4907
+
4908
+	id, _ := c.GetInt64("id", 0)
4909
+	bed_id, _ := c.GetInt64("bed_id")
4910
+	mode_id, _ := c.GetInt64("mode_id")
4911
+	schedule_type, _ := c.GetInt64("schedule_type")
4912
+	if id <= 0 {
4913
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4914
+		return
4915
+	}
4916
+
4917
+	adminINfo := c.GetAdminUserInfo()
4918
+
4919
+	schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
4920
+
4921
+	//获取分区号
4922
+	number, _ := service.GetZoneId(bed_id, adminINfo.CurrentOrgId)
4923
+	if schedule == nil {
4924
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
4925
+		return
4926
+	}
4927
+	//如果透析模式相等 床位号相等,班次相等
4928
+	if mode_id == schedule.ModeId && bed_id == schedule.BedId && schedule_type == schedule.ScheduleType && number.ZoneID == schedule.PartitionId {
4929
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorScheduleCode)
4930
+		return
4931
+	} else {
4932
+
4933
+		//查询该床位今天是否存在排班
4934
+		sch, _ := service.GetScheduleByBedId(bed_id, schedule_type, adminINfo.CurrentOrgId, schedule.ScheduleDate)
4935
+		fmt.Println("schwowowoowowowowowo", sch.ID)
4936
+		if sch.ID == 0 {
4937
+			//删除排班
4938
+			service.UpdateScheduleByScheduleId(id)
4939
+			xtSchedule := models.XtSchedule{
4940
+				UserOrgId:           adminINfo.CurrentOrgId,
4941
+				PartitionId:         number.ZoneID,
4942
+				BedId:               bed_id,
4943
+				PatientId:           schedule.PatientId,
4944
+				ScheduleDate:        schedule.ScheduleDate,
4945
+				ScheduleType:        schedule.ScheduleType,
4946
+				ScheduleWeek:        schedule.ScheduleWeek,
4947
+				ModeId:              mode_id,
4948
+				Status:              1,
4949
+				CreatedTime:         time.Now().Unix(),
4950
+				UpdatedTime:         0,
4951
+				IsExport:            999999,
4952
+				DialysisMachineName: "",
4953
+			}
4954
+			service.CreateNewSchedule(xtSchedule)
4955
+		}
4956
+
4957
+		//存在排班
4958
+		if sch.ID > 0 {
4959
+			//删除排班
4960
+			//service.UpdateScheduleByScheduleId(id)
4961
+			//查询该患者的透析模式对应的透析器灌流器
4962
+			//service.GetDialysisSolutionByMode(schedule.PatientId)
4963
+			xtSchedule := models.XtSchedule{
4964
+				UserOrgId:           adminINfo.CurrentOrgId,
4965
+				PartitionId:         number.ZoneID,
4966
+				BedId:               bed_id,
4967
+				PatientId:           schedule.PatientId,
4968
+				ScheduleDate:        schedule.ScheduleDate,
4969
+				ScheduleType:        schedule_type,
4970
+				ScheduleWeek:        schedule.ScheduleWeek,
4971
+				ModeId:              mode_id,
4972
+				Status:              1,
4973
+				CreatedTime:         time.Now().Unix(),
4974
+				UpdatedTime:         time.Now().Unix(),
4975
+				IsExport:            8888,
4976
+				DialysisMachineName: "",
4977
+			}
4978
+
4979
+			service.UpdateScheduleSixTy(sch.ID, xtSchedule)
4980
+
4981
+			msch := models.XtSchedule{
4982
+				UserOrgId:    adminINfo.CurrentOrgId,
4983
+				PartitionId:  number.ZoneID,
4984
+				BedId:        bed_id,
4985
+				PatientId:    sch.PatientId,
4986
+				ScheduleDate: sch.ScheduleDate,
4987
+				ScheduleType: sch.ScheduleType,
4988
+				ScheduleWeek: sch.ScheduleWeek,
4989
+				ModeId:       sch.ModeId,
4990
+				IsExport:     88888,
4991
+				CreatedTime:  time.Now().Unix(),
4992
+				UpdatedTime:  time.Now().Unix(),
4993
+			}
4994
+
4995
+			service.UpdateScheduleSixTy(id, msch)
4996
+
4997
+		}
4998
+	}
4999
+
5000
+	c.ServeSuccessJSON(map[string]interface{}{
5001
+		"msg": "ok",
5002
+	})
5003
+
5004
+}

+ 4 - 2
enums/error_code.go Bestand weergeven

279
 	AdviceCodeParamWrong = 600000007
279
 	AdviceCodeParamWrong = 600000007
280
 
280
 
281
 	ErrorCodeInformationExist = 600000008
281
 	ErrorCodeInformationExist = 600000008
282
+
283
+	ErrorScheduleCode = 600000009
282
 )
284
 )
283
 
285
 
284
 var ErrCodeMsgs = map[int]string{
286
 var ErrCodeMsgs = map[int]string{
538
 	ErrorCodePatientScheduleRepeat:        "一天只能存在一次排班",
540
 	ErrorCodePatientScheduleRepeat:        "一天只能存在一次排班",
539
 	ErrorCodeDelScheduleFailByDialysisTwo: "已经上机透析,不能操作排班",
541
 	ErrorCodeDelScheduleFailByDialysisTwo: "已经上机透析,不能操作排班",
540
 	AdviceCodeParamWrong:                  "医嘱核对人和执行人不能为同一人,请更换第二核对人!",
542
 	AdviceCodeParamWrong:                  "医嘱核对人和执行人不能为同一人,请更换第二核对人!",
541
-
542
-	ErrorCodeInformationExist: "已经超过归档天数,不予编辑,请提交申请",
543
+	ErrorCodeInformationExist:             "已经超过归档天数,不予编辑,请提交申请",
544
+	ErrorScheduleCode:                     "未更改排班,保存失败!",
543
 }
545
 }
544
 
546
 
545
 type SGJError struct {
547
 type SGJError struct {

+ 0 - 6
models/dialysis.go Bestand weergeven

191
 	AssessmentBeforeDislysis *PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
191
 	AssessmentBeforeDislysis *PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
192
 	AssessmentAfterDislysis  *AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
192
 	AssessmentAfterDislysis  *AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
193
 	MonitoringRecord         []*MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
193
 	MonitoringRecord         []*MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
194
-
195
-	//Patient         string          `gorm:"-" json:"patient" form:"patient"`
196
-	//SchedualPatient SchedualPatient `gorm:"ForeignKey:PatientId"`
197
-	//DeviceNumber    DeviceNumber    `gorm:"ForeignKey:BedId"`
198
-	//DeviceZone      DeviceZone      `gorm:"ForeignKey:PartitionId"`
199
-	//TreatmentMode   TreatmentMode   `gorm:"ForeignKey:ModeId"`
200
 }
194
 }
201
 
195
 
202
 type DialysisScheduleOne struct {
196
 type DialysisScheduleOne struct {

+ 1 - 0
models/patient_models.go Bestand weergeven

1684
 	DialysisNo    string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1684
 	DialysisNo    string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
1685
 	Name          string `gorm:"column:name" json:"name" form:"name"`
1685
 	Name          string `gorm:"column:name" json:"name" form:"name"`
1686
 	TotalDialysis int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
1686
 	TotalDialysis int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
1687
+	Lapseto       int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
1687
 }
1688
 }
1688
 
1689
 
1689
 func (PatientsThirty) TableName() string {
1690
 func (PatientsThirty) TableName() string {

+ 52 - 13
service/dialysis_service.go Bestand weergeven

742
 	if start > 0 && end > 0 {
742
 	if start > 0 && end > 0 {
743
 		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
743
 		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
744
 			Preload("TreatmentMode", "status = 1").
744
 			Preload("TreatmentMode", "status = 1").
745
-			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, start, end).
746
-			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
747
-			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, start, end).
748
 			Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
745
 			Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
749
 				return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, start, end).Order("operate_time asc")
746
 				return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, start, end).Order("operate_time asc")
750
-			}).
751
-			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, start, end).
752
-			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
747
+			})
753
 		db = db.Where("xt_schedule.status = 1")
748
 		db = db.Where("xt_schedule.status = 1")
754
 	}
749
 	}
755
 	if schedulDate > 0 {
750
 	if schedulDate > 0 {
756
 		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
751
 		db = db.Preload("DeviceNumber", "org_id = ?", orgID).
757
 			Preload("TreatmentMode", "status = 1").
752
 			Preload("TreatmentMode", "status = 1").
758
-			Preload("Prescription", "status = 1 AND user_org_id = ? and record_date>=? and record_date <=?", orgID, schedulDate, schedulDate).
759
-			Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, schedulDate, schedulDate).
760
-			Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? and assessment_date >=? and assessment_date <=?", orgID, schedulDate, schedulDate).
761
 			Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
753
 			Preload("MonitoringRecord", func(db *gorm.DB) *gorm.DB {
762
 				return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, schedulDate, schedulDate).Order("operate_time asc")
754
 				return db.Where("status = 1 AND user_org_id = ? and monitoring_date >=? and monitoring_date<=? ", orgID, schedulDate, schedulDate).Order("operate_time asc")
763
-			}).
764
-			Preload("DialysisOrder", "status = 1 AND user_org_id = ? and dialysis_date>=? and dialysis_date<=?", orgID, schedulDate, schedulDate).
765
-			Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
755
+			})
766
 		db = db.Where("xt_schedule.status = 1")
756
 		db = db.Where("xt_schedule.status = 1")
767
 		db = db.Where("schedule_date = ?", schedulDate)
757
 		db = db.Where("schedule_date = ?", schedulDate)
768
 	}
758
 	}
780
 	}
770
 	}
781
 	if partitionType > 0 {
771
 	if partitionType > 0 {
782
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ?", partitionType)
772
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ?", partitionType)
783
-		// db = db.Where("partition_id = ?", partitionType)
784
 	}
773
 	}
785
 	offset := (page - 1) * limit
774
 	offset := (page - 1) * limit
786
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("bed_id desc").Find(&schedule).Error
775
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("bed_id desc").Find(&schedule).Error
2309
 
2298
 
2310
 	return schedules, err
2299
 	return schedules, err
2311
 }
2300
 }
2301
+
2302
+func GetMonitorPatients(patient_id int64) (*models.MonitorPatients, error) {
2303
+
2304
+	patients := models.MonitorPatients{}
2305
+	err := XTReadDB().Where("id = ? and status = 1", patient_id).Find(&patients).Error
2306
+
2307
+	return &patients, err
2308
+}
2309
+
2310
+func GetMonitorDialysisOrderObj(patient_id int64, schedule_date int64) (*models.MonitorDialysisOrder, error) {
2311
+
2312
+	order := models.MonitorDialysisOrder{}
2313
+
2314
+	err := XTReadDB().Where("patient_id = ? and dialysis_date = ? and status = 1", patient_id, schedule_date).Find(&order).Error
2315
+
2316
+	return &order, err
2317
+}
2318
+
2319
+func GetMonitorDialysisPrescription(patient_id int64, record_date int64) (*models.DialysisPrescription, error) {
2320
+
2321
+	prescription := models.DialysisPrescription{}
2322
+	err := XTReadDB().Where("patient_id = ? and status =1 and record_date = ?", patient_id, record_date).Find(&prescription).Error
2323
+
2324
+	return &prescription, err
2325
+}
2326
+
2327
+func GetMonitorPredialysisEvaluation(patient_id int64, record_date int64) (*models.PredialysisEvaluation, error) {
2328
+
2329
+	evaluation := models.PredialysisEvaluation{}
2330
+
2331
+	err := XTReadDB().Where("patient_id = ? and status =1 and assessment_date = ?", patient_id, record_date).Find(&evaluation).Error
2332
+
2333
+	return &evaluation, err
2334
+}
2335
+
2336
+func GetMonitorAssessmentAfterDislysis(patient_id int64, record_date int64) (*models.AssessmentAfterDislysis, error) {
2337
+
2338
+	dislysis := models.AssessmentAfterDislysis{}
2339
+
2340
+	err = XTReadDB().Where("patient_id = ? and status =1 and assessment_date = ?", patient_id, record_date).Find(&dislysis).Error
2341
+
2342
+	return &dislysis, err
2343
+}
2344
+
2345
+func GetMonitoringRecordList(patient_id int64, record_date int64) (record []*models.MonitoringRecord, err error) {
2346
+
2347
+	err = XTReadDB().Where("patient_id = ? and monitoring_date=? and status =1", patient_id, record_date).Find(&record).Error
2348
+
2349
+	return record, err
2350
+}

+ 5 - 0
service/manage_service.go Bestand weergeven

920
 	return patients, err
920
 	return patients, err
921
 }
921
 }
922
 
922
 
923
+func GetAllpatientFourty(orgid int64) (patients []*models.PatientsThirty, err error) {
924
+	err = XTReadDB().Where("user_org_id = ? and status = 1 and lapseto = 1", orgid).Find(&patients).Error
925
+	return patients, err
926
+}
927
+
923
 func GetInformation(eid int64, startdate int64, orgid int64, classtype int64) (*models.DeviceInformation, error) {
928
 func GetInformation(eid int64, startdate int64, orgid int64, classtype int64) (*models.DeviceInformation, error) {
924
 	var information models.DeviceInformation
929
 	var information models.DeviceInformation
925
 	var err error
930
 	var err error

+ 20 - 3
service/mobile_dialysis_service.go Bestand weergeven

37
 		db = db.Where("schedule_type = ?", scheduleType)
37
 		db = db.Where("schedule_type = ?", scheduleType)
38
 	}
38
 	}
39
 
39
 
40
-	err := db.Preload("DialysisLastOrder", func(db *gorm.DB) *gorm.DB {
41
-		return db.Order("dialysis_date desc").Where(" status = 1 AND user_org_id = ? and dialysis_date>=1672502400 && dialysis_date < ?", orgID, scheduleDate)
42
-	}).Preload("DialysisSolution", "status = 1 and user_org_id = ? and solution_status = 1", orgID).Find(&vms).Error
40
+	err := db.Find(&vms).Error
41
+	//err := db.Preload("DialysisLastOrder", func(db *gorm.DB) *gorm.DB {
42
+	//	return db.Order("dialysis_date desc").Where(" status = 1 AND user_org_id = ? and dialysis_date>=1672502400 && dialysis_date < ?", orgID, scheduleDate)
43
+	//}).Preload("DialysisSolution", "status = 1 and user_org_id = ? and solution_status = 1", orgID).Find(&vms).Error
43
 	return vms, err
44
 	return vms, err
44
 }
45
 }
45
 
46
 
47
+func GetMonitDialysisOrder(user_org_id int64, patient_id int64, scheduleDate int64) (*models.MDialysisOrderForList, error) {
48
+
49
+	order := models.MDialysisOrderForList{}
50
+	err := XTReadDB().Where("user_org_id = ? and status =1 and patient_id = ?", user_org_id, patient_id).Order("id asc").Last(&order).Error
51
+	return &order, err
52
+}
53
+
54
+func GetMonitDialysisSolution(user_org_id int64, patient_id int64, mode_id int64) (*models.DialysisSolution, error) {
55
+
56
+	solution := models.DialysisSolution{}
57
+
58
+	err := XTReadDB().Where("user_org_id = ? and patient_id =? and solution_status = 1 and mode_id = ?", user_org_id, patient_id, mode_id).Find(&solution).Error
59
+
60
+	return &solution, err
61
+}
62
+
46
 func MobileGetWaitingScheduals(orgID int64, scheduleDate int64) ([]*MDialysisScheduleVM, error) {
63
 func MobileGetWaitingScheduals(orgID int64, scheduleDate int64) ([]*MDialysisScheduleVM, error) {
47
 	var vms []*MDialysisScheduleVM
64
 	var vms []*MDialysisScheduleVM
48
 	db := readDb.
65
 	db := readDb.

+ 30 - 0
service/schedule_service.go Bestand weergeven

1688
 
1688
 
1689
 	return err
1689
 	return err
1690
 }
1690
 }
1691
+
1692
+func GetScheduleByBedId(bed_id int64, schedule_type int64, user_org_id int64, schedule_date int64) (models.XtSchedule, error) {
1693
+
1694
+	schedule := models.XtSchedule{}
1695
+
1696
+	err := XTReadDB().Model(&schedule).Where("bed_id = ? and schedule_type =? and user_org_id = ? and schedule_date = ? and status =1", bed_id, schedule_type, user_org_id, schedule_date).Find(&schedule).Error
1697
+
1698
+	return schedule, err
1699
+}
1700
+
1701
+func UpdateScheduleByScheduleId(id int64) error {
1702
+
1703
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1704
+
1705
+	return err
1706
+}
1707
+
1708
+func UpdateScheduleSixTy(id int64, schedules models.XtSchedule) error {
1709
+
1710
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"mode_id": schedules.ModeId, "partition_id": schedules.PartitionId, "bed_id": schedules.BedId, "patient_id": schedules.PatientId, "schedule_date": schedules.ScheduleDate, "schedule_type": schedules.ScheduleType, "schedule_week": schedules.ScheduleWeek}).Error
1711
+
1712
+	return err
1713
+}
1714
+
1715
+func CreateNewSchedule(schedule models.XtSchedule) error {
1716
+
1717
+	err := XTWriteDB().Create(&schedule).Error
1718
+
1719
+	return err
1720
+}