csx преди 3 години
родител
ревизия
a1c6ef4b27

controllers/new_mobile_api_controllers/common_api_controller.go → controllers/common_api_controller.go Целия файл

1
-package new_mobile_api_controllers
1
+package controllers
2
 
2
 
3
 import (
3
 import (
4
-	"XT_New/controllers"
5
 	"XT_New/enums"
4
 	"XT_New/enums"
6
 	"XT_New/models"
5
 	"XT_New/models"
7
 	"XT_New/service"
6
 	"XT_New/service"
14
 )
13
 )
15
 
14
 
16
 type CommonApiController struct {
15
 type CommonApiController struct {
17
-	controllers.BaseAuthAPIController
16
+	BaseAuthAPIController
18
 }
17
 }
19
 
18
 
20
 func (this *CommonApiController) GetInspectionMajor() {
19
 func (this *CommonApiController) GetInspectionMajor() {
527
 	orgid := adminUser.CurrentOrgId
526
 	orgid := adminUser.CurrentOrgId
528
 	//统计透析总量
527
 	//统计透析总量
529
 	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
528
 	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
530
-	fmt.Println("total3333333333333", total)
529
+	//var mode models.PatientPrescriptionCountStruct
530
+	//mode.Count = total
531
 	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
531
 	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
532
-	fmt.Println("modetype555555555555555", modeType)
532
+
533
+	//var total models.PatientPrescriptionCountStruct
534
+	//for _, item := range modeType {
535
+	//	total.Count = total.Count + item.Count
536
+	//}
537
+
533
 	if err != nil {
538
 	if err != nil {
534
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
539
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
535
 		return
540
 		return
645
 	sourcetype, _ := this.GetInt64("sourcetype")
650
 	sourcetype, _ := this.GetInt64("sourcetype")
646
 	//统计透析总人数
651
 	//统计透析总人数
647
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
652
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
653
+
648
 	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
654
 	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
649
-	fmt.Println("ageCount22222222222", agecount)
650
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
655
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
651
 	if err != nil {
656
 	if err != nil {
652
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
657
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
717
 	statime := startDate.Unix()
722
 	statime := startDate.Unix()
718
 
723
 
719
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
724
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
720
-
721
 	entime := endDate.Unix()
725
 	entime := endDate.Unix()
722
 
726
 
723
 	page, _ := this.GetInt64("page")
727
 	page, _ := this.GetInt64("page")

controllers/new_mobile_api_controllers/common_api_router.go → controllers/common_api_router.go Целия файл

1
-package new_mobile_api_controllers
1
+package controllers
2
 
2
 
3
 import (
3
 import (
4
 	"github.com/astaxie/beego"
4
 	"github.com/astaxie/beego"

+ 61 - 43
controllers/doctors_api_controller.go Целия файл

90
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
90
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
91
 
91
 
92
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
92
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
93
-
93
+	//project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
94
 	for _, item := range project {
94
 	for _, item := range project {
95
 		index := 0
95
 		index := 0
96
 		for _, subItem := range item.HisPrescriptionTeamProject {
96
 		for _, subItem := range item.HisPrescriptionTeamProject {
97
 
97
 
98
-			//获取所有的患者
99
-			patients, _ := service.GetAllPatientListByListTwo(orgID)
100
-
101
-			//获取所有床位
102
-			numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
103
-
104
-			//获取透析处方
105
-			prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
106
-
107
-			//获取上机
108
-			dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
109
-			for key, item := range project {
110
-				for _, patient := range patients {
111
-					if item.PatientId == patient.ID {
112
-						project[key].SchedualPatient = patient
113
-						break
114
-					}
115
-				}
116
-				// 获取床位信息
117
-				for _, it := range numberList {
118
-					if item.BedId == it.ID {
119
-						project[key].DeviceNumber = it
120
-						break
121
-					}
122
-				}
123
-
124
-				// 获取处方
125
-				for _, it := range prescriptions {
126
-					if item.PatientId == it.PatientId {
127
-						project[key].Prescription = it
128
-						break
129
-					}
130
-				}
131
-
132
-				//获取上机
133
-				for _, it := range dialysisOrders {
134
-					if item.PatientId == it.PatientId {
135
-						project[key].DialysisOrder = it
136
-						break
137
-					}
138
-				}
139
-			}
140
 			if subItem.HisProject.CostClassify != 3 {
98
 			if subItem.HisProject.CostClassify != 3 {
141
 				subItem.IsCheckTeam = 2
99
 				subItem.IsCheckTeam = 2
142
 				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
100
 				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
151
 			}
109
 			}
152
 		}
110
 		}
153
 	}
111
 	}
112
+	//for _, item := range project {
113
+	//	index := 0
114
+	//	for _, subItem := range item.HisPrescriptionTeamProject {
115
+	//
116
+	//		//获取所有的患者
117
+	//		patients, _ := service.GetAllPatientListByListTwo(orgID)
118
+	//
119
+	//		//获取所有床位
120
+	//		numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
121
+	//
122
+	//		//获取透析处方
123
+	//		prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
124
+	//
125
+	//		//获取上机
126
+	//		dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
127
+	//		for key, item := range project {
128
+	//			for _, patient := range patients {
129
+	//				if item.PatientId == patient.ID {
130
+	//					project[key].SchedualPatient = patient
131
+	//					break
132
+	//				}
133
+	//			}
134
+	//			// 获取床位信息
135
+	//			for _, it := range numberList {
136
+	//				if item.BedId == it.ID {
137
+	//					project[key].DeviceNumber = it
138
+	//					break
139
+	//				}
140
+	//			}
141
+	//
142
+	//			// 获取处方
143
+	//			for _, it := range prescriptions {
144
+	//				if item.PatientId == it.PatientId {
145
+	//					project[key].Prescription = it
146
+	//					break
147
+	//				}
148
+	//			}
149
+	//
150
+	//			//获取上机
151
+	//			for _, it := range dialysisOrders {
152
+	//				if item.PatientId == it.PatientId {
153
+	//					project[key].DialysisOrder = it
154
+	//					break
155
+	//				}
156
+	//			}
157
+	//		}
158
+	//		if subItem.HisProject.CostClassify != 3 {
159
+	//			subItem.IsCheckTeam = 2
160
+	//			item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
161
+	//		}
162
+	//
163
+	//		if subItem.HisProject.CostClassify == 3 {
164
+	//			subItem.IsCheckTeam = 1
165
+	//			index = index + 1
166
+	//			if index == 1 {
167
+	//				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
168
+	//			}
169
+	//		}
170
+	//	}
171
+	//}
154
 	config, _ := service.GetHisDoctorConfig(orgID)
172
 	config, _ := service.GetHisDoctorConfig(orgID)
155
 	project_config, _ := service.GetHisProjectConfig(orgID)
173
 	project_config, _ := service.GetHisProjectConfig(orgID)
156
 
174
 

+ 32 - 30
controllers/his_api_controller.go Целия файл

1063
 							timeFormat := tempTime.Format("20060102150405")
1063
 							timeFormat := tempTime.Format("20060102150405")
1064
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
1064
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
1065
 
1065
 
1066
-							//新增或者编辑项目,修改对应的标签数据
1067
-							labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
1068
-							if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
1069
-								var label models.HisLabelPrintInfo
1070
-								project, _ := service.GetProjectDetail(p.ProjectId)
1071
-								if project.CostClassify == 3 { //类别为检验检查
1072
-									if p.TeamId > 0 { //检验检查组套
1073
-										tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
1074
-										if tempLabel.ID == 0 {
1075
-											team, _ := service.GetProjectTeamDetail(p.TeamId)
1066
+							if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
1067
+								//新增或者编辑项目,修改对应的标签数据
1068
+								labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
1069
+								if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
1070
+									var label models.HisLabelPrintInfo
1071
+									project, _ := service.GetProjectDetail(p.ProjectId)
1072
+									if project.CostClassify == 3 { //类别为检验检查
1073
+										if p.TeamId > 0 { //检验检查组套
1074
+											tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
1075
+											if tempLabel.ID == 0 {
1076
+												team, _ := service.GetProjectTeamDetail(p.TeamId)
1077
+												label.Number = tempPrescription.PrescriptionNumber
1078
+												label.ProjectId = project.ID
1079
+												label.Status = 1
1080
+												label.IsPrint = 2
1081
+												label.DoctorId = info.DoctorId
1082
+												label.UserOrgId = p.UserOrgId
1083
+												label.PatientId = patient_id
1084
+												label.RecordDate = recordDateTime
1085
+												label.Ctime = time.Now().Unix()
1086
+												label.Mtime = time.Now().Unix()
1087
+												label.ItemId = p.TeamId
1088
+												label.FeedetlSn = p.FeedetlSn
1089
+												label.PProjectId = p.ID
1090
+												label.ProjectName = team.ProjectTeam
1091
+												label.PatientName = patient.Name
1092
+												service.CreateHisLabelRecord(&label)
1093
+											}
1094
+										} else { //单条检验检查项目
1076
 											label.Number = tempPrescription.PrescriptionNumber
1095
 											label.Number = tempPrescription.PrescriptionNumber
1077
 											label.ProjectId = project.ID
1096
 											label.ProjectId = project.ID
1078
 											label.Status = 1
1097
 											label.Status = 1
1079
-											label.IsPrint = 2
1080
 											label.DoctorId = info.DoctorId
1098
 											label.DoctorId = info.DoctorId
1081
 											label.UserOrgId = p.UserOrgId
1099
 											label.UserOrgId = p.UserOrgId
1082
 											label.PatientId = patient_id
1100
 											label.PatientId = patient_id
1083
 											label.RecordDate = recordDateTime
1101
 											label.RecordDate = recordDateTime
1102
+											label.IsPrint = 2
1084
 											label.Ctime = time.Now().Unix()
1103
 											label.Ctime = time.Now().Unix()
1085
 											label.Mtime = time.Now().Unix()
1104
 											label.Mtime = time.Now().Unix()
1086
-											label.ItemId = p.TeamId
1087
 											label.FeedetlSn = p.FeedetlSn
1105
 											label.FeedetlSn = p.FeedetlSn
1088
 											label.PProjectId = p.ID
1106
 											label.PProjectId = p.ID
1089
-											label.ProjectName = team.ProjectTeam
1107
+											label.ItemId = p.TeamId
1108
+											label.ProjectName = project.ProjectName
1090
 											label.PatientName = patient.Name
1109
 											label.PatientName = patient.Name
1091
 											service.CreateHisLabelRecord(&label)
1110
 											service.CreateHisLabelRecord(&label)
1092
 										}
1111
 										}
1093
-									} else { //单条检验检查项目
1094
-										label.Number = tempPrescription.PrescriptionNumber
1095
-										label.ProjectId = project.ID
1096
-										label.Status = 1
1097
-										label.DoctorId = info.DoctorId
1098
-										label.UserOrgId = p.UserOrgId
1099
-										label.PatientId = patient_id
1100
-										label.RecordDate = recordDateTime
1101
-										label.IsPrint = 2
1102
-										label.Ctime = time.Now().Unix()
1103
-										label.Mtime = time.Now().Unix()
1104
-										label.FeedetlSn = p.FeedetlSn
1105
-										label.PProjectId = p.ID
1106
-										label.ItemId = p.TeamId
1107
-										label.ProjectName = project.ProjectName
1108
-										label.PatientName = patient.Name
1109
-										service.CreateHisLabelRecord(&label)
1110
 									}
1112
 									}
1111
 								}
1113
 								}
1112
 							}
1114
 							}

+ 6 - 2
controllers/new_mobile_api_controllers/new_common_api_controller.go Целия файл

36
 
36
 
37
 	//统计透析总量
37
 	//统计透析总量
38
 	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
38
 	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
39
-
39
+	//var mode models.PatientPrescriptionCountStruct
40
+	//mode.Count = total
40
 	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
41
 	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
41
-
42
+	//var total models.PatientPrescriptionCountStruct
43
+	//for _, item := range modeType {
44
+	//	total.Count = total.Count + item.Count
45
+	//}
42
 	if err != nil {
46
 	if err != nil {
43
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
47
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
44
 		return
48
 		return

+ 11 - 24
service/common_service.go Целия файл

213
 func GetDialysiTotal(startime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (models.PatientPrescriptionCountStruct, error) {
213
 func GetDialysiTotal(startime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (models.PatientPrescriptionCountStruct, error) {
214
 	counts := models.PatientPrescriptionCountStruct{}
214
 	counts := models.PatientPrescriptionCountStruct{}
215
 
215
 
216
-	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
217
-	table := XTReadDB().Table("xt_paitents as s").Where("s.status = 1")
218
-	fmt.Println(table)
216
+	db := XTReadDB().Table("xt_dialysis_order as x").Select("count(x.id) as count").Joins("Join xt_dialysis_prescription as prescription On x.dialysis_date = prescription.record_date AND x.patient_id = prescription.patient_id  AND prescription.status = 1 AND prescription.mode_id > 0").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? AND x.status = 1", startime, endtime, orgid)
219
 
217
 
220
 	if lapsetotype > 0 {
218
 	if lapsetotype > 0 {
221
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.lapseto = ?", startime, endtime, orgid, lapsetotype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
219
+		err = db.Where("x.user_org_id = ? and s.lapseto = ?", startime, endtime, orgid, lapsetotype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
222
 	}
220
 	}
223
 	if lapsetotype == 0 {
221
 	if lapsetotype == 0 {
224
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? ", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
222
+		err = db.Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
225
 	}
223
 	}
226
 
224
 
227
 	if sourcetype > 0 {
225
 	if sourcetype > 0 {
228
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.source = ?", startime, endtime, orgid, sourcetype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
226
+		err = db.Where("x.user_org_id = ? and s.source = ?", startime, endtime, orgid, sourcetype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
229
 	}
227
 	}
230
 
228
 
231
 	if sourcetype == 0 {
229
 	if sourcetype == 0 {
232
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ?", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
230
+		err = db.Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
233
 	}
231
 	}
234
 
232
 
235
 	return counts, err
233
 	return counts, err
236
 }
234
 }
237
 
235
 
238
 func GetDialysisCountMode(starttime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
236
 func GetDialysisCountMode(starttime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
239
-
240
-	//err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
241
-	//return counts, err
242
-
243
 	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
237
 	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
244
-	table := readDb.Table("xt_schedule as s").Where("s.status = 1")
245
-	fmt.Println(table)
246
-	p := readDb.Table("xt_patients as p").Where("p.status = 1")
247
-	fmt.Println(p)
248
 	if starttime > 0 {
238
 	if starttime > 0 {
249
 		db = db.Where("o.dialysis_date >=?", starttime)
239
 		db = db.Where("o.dialysis_date >=?", starttime)
250
 	}
240
 	}
260
 	if sourcetype > 0 {
250
 	if sourcetype > 0 {
261
 		db = db.Where("p.source = ?", sourcetype)
251
 		db = db.Where("p.source = ?", sourcetype)
262
 	}
252
 	}
263
-	err = db.Select("s.mode_id,count(s.mode_id) as count").Joins("left join xt_schedule as s on s.patient_id = o.patient_id and s.schedule_date = o.dialysis_date and s.status= 1").Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
253
+	err = db.Select("s.mode_id,count(s.mode_id) as count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id and s.record_date = o.dialysis_date and s.status= 1 AND s.record_date >= ? AND s.record_date <= ? AND AND s.mode_id > 0 ", starttime, endtime).Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
264
 	return counts, err
254
 	return counts, err
265
 }
255
 }
266
 
256
 
287
 }
277
 }
288
 
278
 
289
 func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
279
 func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
290
-
291
 	db := XTReadDB().Table("xt_patients as x")
280
 	db := XTReadDB().Table("xt_patients as x")
292
 	if sourcetype == 0 {
281
 	if sourcetype == 0 {
282
+
293
 		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
283
 		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
294
 
284
 
295
 	}
285
 	}
296
 	if sourcetype > 0 {
286
 	if sourcetype > 0 {
287
+
297
 		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
288
 		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
298
 	}
289
 	}
299
 	return patients, err
290
 	return patients, err
629
 func GetTreateInfo(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64) (blood []*models.TreatDialysisOrder, total int64, err error) {
620
 func GetTreateInfo(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64) (blood []*models.TreatDialysisOrder, total int64, err error) {
630
 
621
 
631
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status =  1")
622
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status =  1")
632
-	table := XTReadDB().Table("xt_schedule as s")
633
-	fmt.Println(table)
634
-	p := XTReadDB().Table("xt_patients as p")
635
-	fmt.Println(p)
636
 	sql := "from_unixtime(o.dialysis_date, '%Y%m%d') AS date"
623
 	sql := "from_unixtime(o.dialysis_date, '%Y%m%d') AS date"
637
 
624
 
638
 	if orgID > 0 {
625
 	if orgID > 0 {
651
 		db = db.Where("p.lapseto = ?", lapseto)
638
 		db = db.Where("p.lapseto = ?", lapseto)
652
 	}
639
 	}
653
 	offset := (page - 1) * limit
640
 	offset := (page - 1) * limit
654
-	err = db.Group("o.dialysis_date").Select(sql).Joins("left join xt_schedule as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.schedule_date = o.dialysis_date and s.status =1").Count(&total).Offset(offset).Limit(limit).Scan(&blood).Error
641
+	err = db.Group("o.dialysis_date").Select(sql).Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.record_date = o.dialysis_date and s.status =1").Count(&total).Offset(offset).Limit(limit).Scan(&blood).Error
655
 	return blood, total, err
642
 	return blood, total, err
656
 
643
 
657
 }
644
 }
676
 	if lapseto > 0 {
663
 	if lapseto > 0 {
677
 		db = db.Where("p.lapseto = ?", lapseto)
664
 		db = db.Where("p.lapseto = ?", lapseto)
678
 	}
665
 	}
679
-	err = db.Select("s.mode_id, count(s.mode_id) as number").Joins("left join xt_schedule as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.schedule_date = o.dialysis_date and s.status = 1").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
666
+	err = db.Select("s.mode_id, count(s.mode_id) as number").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.record_date = o.dialysis_date and s.status = 1").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
680
 	return ttd, err
667
 	return ttd, err
681
 }
668
 }
682
 
669
 
685
 	sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
672
 	sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
686
 	datesql := " o.dialysis_date as date"
673
 	datesql := " o.dialysis_date as date"
687
 	group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
674
 	group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
688
-	db = db.Table(" xt_dialysis_order AS o").Joins("left join xt_schedule as s on o.patient_id = s.patient_id").Where("s.schedule_date = o.dialysis_date and s.status =1")
675
+	db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id").Where("s.record_date = o.dialysis_date and s.status =1")
689
 	if orgID > 0 {
676
 	if orgID > 0 {
690
 		db = db.Where("o.user_org_id = ?", orgID)
677
 		db = db.Where("o.user_org_id = ?", orgID)
691
 	}
678
 	}

+ 0 - 49
service/mobile_dialysis_service.go Целия файл

3466
 		}
3466
 		}
3467
 		err = db.Find(&vms).Error
3467
 		err = db.Find(&vms).Error
3468
 	}
3468
 	}
3469
-	//if patientType == 0 {
3470
-	//	db := readDb.
3471
-	//		Table("xt_schedule").
3472
-	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
3473
-	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3474
-	//			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3475
-	//		}).
3476
-	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
3477
-	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
3478
-	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
3479
-	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
3480
-	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
3481
-	//		}).Where("status = 1 AND user_org_id = ?", orgID)
3482
-	//	if scheduleDate != 0 {
3483
-	//		db = db.Where("schedule_date = ?", scheduleDate)
3484
-	//	}
3485
-	//	err = db.Find(&vms).Error
3486
-	//}
3487
-	//
3488
-	//if patientType > 0 {
3489
-	//	db := readDb.
3490
-	//		Table("xt_schedule").
3491
-	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
3492
-	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3493
-	//			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3494
-	//		}).
3495
-	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
3496
-	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
3497
-	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
3498
-	//		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
3499
-	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
3500
-	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
3501
-	//		}).
3502
-	//		Where("status = 1 AND user_org_id = ?", orgID)
3503
-	//	if scheduleDate != 0 {
3504
-	//		db = db.Where("schedule_date = ?", scheduleDate)
3505
-	//	}
3506
-	//	err = db.Find(&vms).Error
3507
-	//}
3508
-
3509
-	db := readDb.Table("xt_schedule").Where("status = 1")
3510
-	if scheduleDate > 0 {
3511
-		db = db.Where("schedule_date = ?", scheduleDate)
3512
-	}
3513
-	if orgID > 0 {
3514
-		db = db.Where("user_org_id = ?", orgID)
3515
-	}
3516
-
3517
-	err = db.Find(&vms).Error
3518
 
3469
 
3519
 	return vms, err
3470
 	return vms, err
3520
 }
3471
 }