XMLWAN il y a 4 ans
Parent
révision
09656f7e7b

+ 24 - 11
controllers/dialysis_parameter_api_controller.go Voir le fichier

@@ -40,10 +40,22 @@ func (this *DialysisPrameterApiController) GetDialysisParameters() {
40 40
 	fmt.Println("scheduletype", schedulType, start_time, partitionType, keywords, theTime.Unix())
41 41
 	if len(keywords) > 0 {
42 42
 		dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, theTime.Unix())
43
+		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords)
44
+		var vlist []interface{}
45
+		var elist []interface{}
46
+		for _, item := range patient {
47
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
48
+			vlist = append(vlist, prescription)
49
+			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
50
+			elist = append(elist, dialysis)
51
+		}
43 52
 		if err == nil {
44 53
 			this.ServeSuccessJSON(map[string]interface{}{
45
-				"schedule": dialysisSchedule,
46
-				"total":    total,
54
+				"schedule":     dialysisSchedule,
55
+				"total":        total,
56
+				"prescription": vlist,
57
+				"dialysbefor":  elist,
58
+				"patient":      patient,
47 59
 			})
48 60
 		} else {
49 61
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -52,7 +64,7 @@ func (this *DialysisPrameterApiController) GetDialysisParameters() {
52 64
 		dialysisSchedule, err, total := service.GetDialysisParameter(adminUserInfo.CurrentOrgId, theTime.Unix(), schedulType, partitionType, page, limit)
53 65
 
54 66
 		//查询今日排班的病人
55
-		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit)
67
+		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords)
56 68
 
57 69
 		var vlist []interface{}
58 70
 		var elist []interface{}
@@ -91,6 +103,7 @@ func (this *DialysisPrameterApiController) GetDialysisParameters() {
91 103
 				"total":        total,
92 104
 				"prescription": vlist,
93 105
 				"dialysbefor":  elist,
106
+				"patient":      patient,
94 107
 			})
95 108
 		} else {
96 109
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -208,7 +221,7 @@ func (this *DialysisPrameterApiController) GetCollectList() {
208 221
 	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
209 222
 
210 223
 	//查询今日排班的病人
211
-	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit)
224
+	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword)
212 225
 	var vlist []interface{}
213 226
 	var clist []interface{}
214 227
 	for _, item := range patient {
@@ -243,7 +256,7 @@ func (this *DialysisPrameterApiController) GetCollectList() {
243 256
 		clist = append(clist, reduece)
244 257
 	}
245 258
 	//获取透析耗材数据
246
-	consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
259
+	//consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
247 260
 
248 261
 	//if err == nil {
249 262
 	// this.ServeSuccessJSON(map[string]interface{}{
@@ -273,9 +286,9 @@ func (this *DialysisPrameterApiController) GetCollectList() {
273 286
 			"good_type":      goodTypes,
274 287
 			"total":          total,
275 288
 			"schedule":       schedule,
276
-			"consumables":    consumables,
277
-			"prescription":   vlist,
278
-			"reducelist":     clist,
289
+			//"consumables":    consumables,
290
+			"prescription": vlist,
291
+			"reducelist":   clist,
279 292
 		})
280 293
 		return
281 294
 
@@ -298,9 +311,9 @@ func (this *DialysisPrameterApiController) GetCollectList() {
298 311
 				"good_type":      goodTypes,
299 312
 				"total":          total,
300 313
 				"schedule":       schedule,
301
-				"consumables":    consumables,
302
-				"prescription":   vlist,
303
-				"reducelist":     clist,
314
+				//"consumables":    consumables,
315
+				"prescription": vlist,
316
+				"reducelist":   clist,
304 317
 			})
305 318
 			return
306 319
 

+ 7 - 27
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go Voir le fichier

@@ -47,7 +47,7 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
47 47
 	if len(keywords) > 0 {
48 48
 		dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(orgid, keywords, scheduleType, partitionType, page, limit, theTime.Unix())
49 49
 		//查询今日排班的病人
50
-		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit)
50
+		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords)
51 51
 		var vlist []interface{}
52 52
 		var elist []interface{}
53 53
 		for _, item := range patient {
@@ -61,6 +61,7 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
61 61
 					"total":        total,
62 62
 					"prescription": vlist,
63 63
 					"dialysbefor":  elist,
64
+					"patient":      patient,
64 65
 				})
65 66
 			} else {
66 67
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -69,31 +70,10 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
69 70
 	} else {
70 71
 		dialysisSchedule, err, total := service.GetDialysisParameter(orgid, theTime.Unix(), scheduleType, partitionType, page, limit)
71 72
 		//查询今日排班的病人
72
-		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit)
73
+		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords)
73 74
 		var vlist []interface{}
74 75
 		var elist []interface{}
75 76
 		for _, item := range patient {
76
-			//查询当前日期的病人是否存在数据
77
-			//_, errcode := service.GetToDayDialysisPrescription(item.PatientId, orgid, theTime.Unix())
78
-			//if errcode == gorm.ErrRecordNotFound {
79
-			//	//查询每个病人透析处方的最后一次数据
80
-			//	prescription, _ := service.GetLastDialysisPrescription(item.PatientId, orgid)
81
-			//	vlist = append(vlist, prescription)
82
-			//} else if errcode == nil {
83
-			//	//获取当前日期
84
-			//	prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgid, theTime.Unix())
85
-			//	vlist = append(vlist, prescription)
86
-			//}
87
-			//
88
-			//_, errcodes := service.GetTodayAssessmentBeforDialysis(item.PatientId, orgid, theTime.Unix())
89
-			//if errcodes == gorm.ErrRecordNotFound {
90
-			//	//查询每个病人透前评估的最后一次数据
91
-			//	dialysis, _ := service.GetLastAssessmentBeforDialysis(item.PatientId, orgid)
92
-			//	elist = append(elist, dialysis)
93
-			//} else if errcodes == nil {
94
-			//	dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgid, theTime.Unix())
95
-			//	elist = append(elist, dialysis)
96
-			//}
97 77
 			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgid, theTime.Unix())
98 78
 			vlist = append(vlist, prescription)
99 79
 			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgid, theTime.Unix())
@@ -105,6 +85,7 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
105 85
 				"total":        total,
106 86
 				"prescription": vlist,
107 87
 				"dialysbefor":  elist,
88
+				"patient":      patient,
108 89
 			})
109 90
 		} else {
110 91
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -173,7 +154,7 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
173 154
 	//获取透析参数数据
174 155
 	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
175 156
 	//查询今日排班的病人
176
-	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit)
157
+	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword)
177 158
 	var vlist []interface{}
178 159
 	var clist []interface{}
179 160
 	for _, item := range patient {
@@ -226,9 +207,8 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
226 207
 			"good_type":      goodTypes,
227 208
 			"total":          total,
228 209
 			"schedule":       schedule,
229
-			//"consumables":    consumables,
230
-			"prescription": vlist,
231
-			//"reducelist":     clist,
210
+			"prescription":   vlist,
211
+			"patient":        patient,
232 212
 		})
233 213
 		return
234 214
 

+ 12 - 0
models/dialysis_parameter_models.go Voir le fichier

@@ -100,3 +100,15 @@ type BloodAutomaticReduceDetail struct {
100 100
 func (BloodAutomaticReduceDetail) TableName() string {
101 101
 	return "xt_automatic_reduce_detail"
102 102
 }
103
+
104
+type XtScheduleTwo struct {
105
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
106
+	ModeId    int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
107
+	PatientId int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
108
+	Name      string `gorm:"column:name" json:"name" form:"name"`
109
+}
110
+
111
+func (XtScheduleTwo) TableName() string {
112
+
113
+	return "xt_schedule"
114
+}

+ 17 - 3
service/dialysis_parameter_service.go Voir le fichier

@@ -69,7 +69,7 @@ func GetDialysisParameter(orgID int64, schedulDate int64, schedulType int64, par
69 69
 		db = db.Joins("inner join xt_device_number on xt_device_number.id = xt_schedule.bed_id and xt_device_number.zone_id = ? and xt_device_number.status = 1", partitionType)
70 70
 	}
71 71
 	offset := (page - 1) * limit
72
-	err = db.Count(&total).Offset(offset).Limit(limit).Order("bed_id desc").Find(&schedule).Error
72
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&schedule).Error
73 73
 	return schedule, err, total
74 74
 }
75 75
 
@@ -217,9 +217,23 @@ func GetAnticoagulantCount(startime int64, endtime int64, orgid int64) (prescrip
217 217
 	return prescriptionCount, err
218 218
 }
219 219
 
220
-func GetDialysisTodaySchedulePatient(orgid int64, startime int64, page int64, limit int64) (schedule []*models.XtSchedule, err error) {
220
+func GetDialysisTodaySchedulePatient(orgid int64, startime int64, page int64, limit int64, keywords string) (schedule []*models.XtScheduleTwo, err error) {
221
+	//offset := (page - 1) * limit
222
+	//err = XTReadDB().Model(&schedule).Where("user_org_id = ? and schedule_date = ? and status = 1", orgid, startime).Offset(offset).Limit(limit).Order("id desc").Find(&schedule).Error
223
+	//return schedule, err
224
+	keywords = "%" + keywords + "%"
225
+
221 226
 	offset := (page - 1) * limit
222
-	err = XTReadDB().Model(&schedule).Where("user_org_id = ? and schedule_date = ? and status = 1", orgid, startime).Offset(offset).Limit(limit).Find(&schedule).Error
227
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
228
+	table := XTReadDB().Table("xt_patients as s")
229
+	fmt.Println(table)
230
+	if len(keywords) > 0 {
231
+		err = db.Group("x.id").Select("x.id,x.patient_id,x.mode_id,s.name").Joins("left join xt_patients as s on s.id = x.patient_id").Where("x.user_org_id = ? and x.schedule_date = ? and x.status = 1 and s.name like ?", orgid, startime, keywords).Offset(offset).Limit(limit).Order("id desc").Scan(&schedule).Error
232
+		//db = db.Where("s.name like ?", keywords)
233
+	} else {
234
+		err = db.Group("x.id").Select("x.id,x.patient_id,x.mode_id,s.name").Joins("left join xt_patients as s on s.id = x.patient_id").Where("x.user_org_id = ? and x.schedule_date = ? and x.status = 1", orgid, startime).Offset(offset).Limit(limit).Order("id desc").Scan(&schedule).Error
235
+
236
+	}
223 237
 	return schedule, err
224 238
 }
225 239
 

+ 2 - 2
service/mobile_dialysis_service.go Voir le fichier

@@ -1551,7 +1551,7 @@ func GetLastDialysisGoodsTwo(patient_id int64, orgID int64, record_time int64) (
1551 1551
 
1552 1552
 	var Id []*DialysisGoodsDetailDate
1553 1553
 
1554
-	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
1554
+	err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time < ? AND count > 0", patient_id, orgID, record_time).Select("record_time").Group("record_time").Order("record_time asc").Scan(&Id).Error
1555 1555
 	if len(Id) > 0 {
1556 1556
 
1557 1557
 		err = readDb.Model(&AutomaticReduceDetail{}).Where("patient_id = ? AND org_id = ? AND status=1 AND record_time = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordTime).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0)  ", orgID).Find(&goodUser).Error
@@ -1561,7 +1561,7 @@ func GetLastDialysisGoodsTwo(patient_id int64, orgID int64, record_time int64) (
1561 1561
 
1562 1562
 func GetLastDialysisBeforePrepareTwo(patient_id int64, orgID int64, record_time int64) (goodUser []*DialysisBeforePrepare, err error) {
1563 1563
 	var Id []*DialysisGoodsDate
1564
-	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
1564
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date < ? AND count > 0", patient_id, orgID, record_time).Select("record_date").Group("record_date").Order("record_date asc").Scan(&Id).Error
1565 1565
 	if len(Id) > 0 {
1566 1566
 		err = readDb.Model(&models.DialysisBeforePrepare{}).Where("patient_id = ? AND user_org_id = ? AND status=1 AND record_date = ? AND count > 0", patient_id, orgID, Id[len(Id)-1].RecordDate).Preload("VMGoodInfo", "status = 1 AND org_id = ? ", orgID).Preload("GoodsType", "status = 1 AND (org_id = ? OR org_id = 0) ", orgID).Find(&goodUser).Error
1567 1567
 	}