소스 검색

bug修改

XMLWAN 4 년 전
부모
커밋
5841fcfb02

+ 1 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go 파일 보기

@@ -85,6 +85,7 @@ func (this *DialysisAPIController) Scheduals() {
85 85
 
86 86
 	// cur_date := time.Now().Format("2006-01-02")
87 87
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
88
+
88 89
 	scheduals_json_str, _ := redis.Get(key).Result()
89 90
 
90 91
 	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis

+ 46 - 13
controllers/new_mobile_api_controllers/common_api_controller.go 파일 보기

@@ -200,6 +200,7 @@ func (this *CommonApiController) UpdateConfiguration() {
200 200
 		Sort:            sort,
201 201
 	}
202 202
 	err = service.UpdarteConfiguration(&standard, id)
203
+	fmt.Println("爆粗========================================", err)
203 204
 	if err != nil {
204 205
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
205 206
 		return
@@ -431,6 +432,7 @@ func (this *CommonApiController) GetTotalSexCount() {
431 432
 	endtime, _ := this.GetInt64("endtime")
432 433
 	fmt.Println("结束时间", endtime)
433 434
 	total := service.GetPatientTotalCount(orgid)
435
+
434 436
 	_, totalSex, err := service.GetManPatientTotal(orgid)
435 437
 
436 438
 	if err != nil {
@@ -559,7 +561,6 @@ func (this *CommonApiController) GetDialysislist() {
559 561
 	orgId := adminUser.CurrentOrgId
560 562
 
561 563
 	dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
562
-
563 564
 	prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
564 565
 	list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
565 566
 	fmt.Println("err", err)
@@ -638,7 +639,8 @@ func (this *CommonApiController) GetDialysisDetailById() {
638 639
 func (this *CommonApiController) GetPrescritionByName() {
639 640
 	adminUser := this.GetAdminUserInfo()
640 641
 	orgId := adminUser.CurrentOrgId
641
-	keyword := this.GetString("keyword")
642
+	//keyword := this.GetString("keyword")
643
+	patientid, _ := this.GetInt64("patientid")
642 644
 	startime := this.GetString("startime")
643 645
 	fmt.Println(startime)
644 646
 	endtime := this.GetString("endtime")
@@ -655,7 +657,7 @@ func (this *CommonApiController) GetPrescritionByName() {
655 657
 	fmt.Println("limit", limit)
656 658
 	page, _ := this.GetInt64("page")
657 659
 	fmt.Println("page", page)
658
-	patient, total, err := service.GetPrescritionByName(orgId, keyword, statime, entime, limit, page)
660
+	patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
659 661
 	if err != nil {
660 662
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
661 663
 		return
@@ -687,7 +689,8 @@ func (this *CommonApiController) GetStatistics() {
687 689
 	page, _ := this.GetInt64("page")
688 690
 	fmt.Println("page", page)
689 691
 	modeId, _ := this.GetInt64("mode_id")
690
-	statistics, ttd, total, err := service.GetStatistics(orgId, statime, entime, value, limit, page, modeId)
692
+	treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
693
+	statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)
691 694
 	if err != nil {
692 695
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
693 696
 		return
@@ -696,6 +699,7 @@ func (this *CommonApiController) GetStatistics() {
696 699
 		"statistics": statistics,
697 700
 		"ttd":        ttd,
698 701
 		"total":      total,
702
+		"treatinfo":  treatinfo,
699 703
 	})
700 704
 }
701 705
 
@@ -753,8 +757,9 @@ func (this *CommonApiController) GetInspectionDetailById() {
753 757
 func (this *CommonApiController) GetSearchPatientInfo() {
754 758
 	adminUser := this.GetAdminUserInfo()
755 759
 	orgId := adminUser.CurrentOrgId
756
-	keyword := this.GetString("keyword")
757
-	fmt.Println("keyword", keyword)
760
+	//keyword := this.GetString("keyword")
761
+	//fmt.Println("keyword", keyword)
762
+	patientid, _ := this.GetInt64("patientid")
758 763
 	startime := this.GetString("startime")
759 764
 	endtime := this.GetString("endtime")
760 765
 	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
@@ -764,7 +769,7 @@ func (this *CommonApiController) GetSearchPatientInfo() {
764 769
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
765 770
 	entime := endDate.Unix()
766 771
 	fmt.Println("结束日期", entime)
767
-	PatientsInfo, err := service.GetSearchPatientInfo(orgId, keyword, statime, entime)
772
+	PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
768 773
 	if err != nil {
769 774
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
770 775
 		return
@@ -877,10 +882,10 @@ func (this *CommonApiController) GetNormData() {
877 882
 	orgid := this.GetAdminUserInfo().CurrentOrgId
878 883
 	//获取系统数据
879 884
 	normdata, err := service.GetNormDataByOrgId(orgid)
880
-	fmt.Println("normdata==============================", normdata)
885
+
881 886
 	if len(normdata) == 0 {
882 887
 		normdata, err := service.GetNormData(0)
883
-		fmt.Println("normdata=============================+++++", normdata)
888
+
884 889
 		if err != nil {
885 890
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
886 891
 			return
@@ -1219,6 +1224,7 @@ func (this *CommonApiController) GetPatientscontrol() {
1219 1224
 func (this *CommonApiController) GetCartogramList() {
1220 1225
 	adminUser := this.GetAdminUserInfo()
1221 1226
 	orgid := adminUser.CurrentOrgId
1227
+	fmt.Println("orgid", orgid)
1222 1228
 	lapstor, _ := this.GetInt64("lapstor")
1223 1229
 	fmt.Println("lapstor", lapstor)
1224 1230
 	startime := this.GetString("startime")
@@ -1254,8 +1260,7 @@ func (this *CommonApiController) GetPatientContor() {
1254 1260
 	fmt.Println(orgid)
1255 1261
 	lapstor, _ := this.GetInt64("lapstor")
1256 1262
 	fmt.Println("lapstor", lapstor)
1257
-	keyword := this.GetString("keyword")
1258
-	fmt.Println("keyword", keyword)
1263
+	patientid, _ := this.GetInt64("patientid")
1259 1264
 	startime := this.GetString("startime")
1260 1265
 	fmt.Println("开始时间", startime)
1261 1266
 	startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
@@ -1267,8 +1272,8 @@ func (this *CommonApiController) GetPatientContor() {
1267 1272
 	endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
1268 1273
 	endtimeStrsUnix := endtimeStrs.Unix()
1269 1274
 	fmt.Println("结束时间搓", endtimeStrsUnix)
1270
-	patients, err := service.GetPatientNames(orgid, keyword)
1271
-	patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patients.ID, startimeStrUnix, endtimeStrsUnix)
1275
+	patients, err := service.GetPatientNames(orgid, patientid)
1276
+	patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patientid, startimeStrUnix, endtimeStrsUnix)
1272 1277
 	if err != nil {
1273 1278
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1274 1279
 		return
@@ -1303,3 +1308,31 @@ func (this *CommonApiController) GetQualityControl() {
1303 1308
 		"list": list,
1304 1309
 	})
1305 1310
 }
1311
+
1312
+func (this *CommonApiController) GetTreatlist() {
1313
+	adminuser := this.GetAdminUserInfo()
1314
+	orgId := adminuser.CurrentOrgId
1315
+	startime := this.GetString("start_time")
1316
+	fmt.Println(startime)
1317
+	endtime := this.GetString("end_time")
1318
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
1319
+	fmt.Println("parseDateErr", parseDateErr)
1320
+	statime := startDate.Unix()
1321
+	fmt.Println("开始时间", statime)
1322
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
1323
+	entime := endDate.Unix()
1324
+	fmt.Println("结束日期", entime)
1325
+	value, _ := this.GetInt64("value")
1326
+	fmt.Println("value", value)
1327
+
1328
+	list, err := service.GetTreatList(orgId, statime, entime, value)
1329
+	if err != nil {
1330
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
1331
+		return
1332
+	}
1333
+
1334
+	this.ServeSuccessJSON(map[string]interface{}{
1335
+
1336
+		"list": list,
1337
+	})
1338
+}

+ 1 - 0
controllers/new_mobile_api_controllers/common_api_router.go 파일 보기

@@ -49,4 +49,5 @@ func CommonApiControllersRegisterRouters() {
49 49
 	beego.Router("/com/api/getcartogramlist", &CommonApiController{}, "Get:GetCartogramList")
50 50
 	beego.Router("/com/api/getpatientcontor", &CommonApiController{}, "Get:GetPatientContor")
51 51
 	beego.Router("/com/api/getqualitycontrol", &CommonApiController{}, "Get:GetQualityControl")
52
+	beego.Router("/com/api/gettreatlist", &CommonApiController{}, "Get:GetTreatlist")
52 53
 }

+ 38 - 6
controllers/new_mobile_api_controllers/new_common_api_controller.go 파일 보기

@@ -239,7 +239,8 @@ func (this *NewCommonApiController) GetMobilePatientDetail() {
239 239
 func (this *NewCommonApiController) ToSearchPatient() {
240 240
 	adminUser := this.GetMobileAdminUserInfo()
241 241
 	orgId := adminUser.Org.Id
242
-	keyword := this.GetString("keyword")
242
+	//keyword := this.GetString("keyword")
243
+	patientid, _ := this.GetInt64("patientid")
243 244
 	startime := this.GetString("startime")
244 245
 	fmt.Println(startime)
245 246
 	endtime := this.GetString("endtime")
@@ -256,7 +257,8 @@ func (this *NewCommonApiController) ToSearchPatient() {
256 257
 	fmt.Println("limit", limit)
257 258
 	page, _ := this.GetInt64("page")
258 259
 	fmt.Println("page", page)
259
-	patient, total, err := service.GetPrescritionByName(orgId, keyword, statime, entime, limit, page)
260
+	patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
261
+	fmt.Println("报错==========", err)
260 262
 	if err != nil {
261 263
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
262 264
 		return
@@ -288,7 +290,8 @@ func (this *NewCommonApiController) GetAllPatientsMode() {
288 290
 	fmt.Println("page", page)
289 291
 	modeId, _ := this.GetInt64("mode_id")
290 292
 	fmt.Println("modeId", modeId)
291
-	statistics, ttd, total, err := service.GetStatistics(orgId, statime, entime, value, limit, page, modeId)
293
+	treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
294
+	statistics, ttd, err := service.GetStatistics(orgId, statime, entime, modeId)
292 295
 	if err != nil {
293 296
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
294 297
 		return
@@ -297,6 +300,7 @@ func (this *NewCommonApiController) GetAllPatientsMode() {
297 300
 		"statistics": statistics,
298 301
 		"ttd":        ttd,
299 302
 		"total":      total,
303
+		"treatinfo":  treatinfo,
300 304
 	})
301 305
 }
302 306
 
@@ -354,8 +358,9 @@ func (this *NewCommonApiController) GetPatientInspectionDetail() {
354 358
 func (this *NewCommonApiController) GetSeachPatientDetail() {
355 359
 	adminUser := this.GetMobileAdminUserInfo()
356 360
 	orgId := adminUser.Org.Id
357
-	keyword := this.GetString("keyword")
358
-	fmt.Println("keyword", keyword)
361
+	//keyword := this.GetString("keyword")
362
+	//fmt.Println("keyword", keyword)
363
+	patientid, _ := this.GetInt64("patientid")
359 364
 	startime := this.GetString("startime")
360 365
 	endtime := this.GetString("endtime")
361 366
 	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
@@ -365,7 +370,7 @@ func (this *NewCommonApiController) GetSeachPatientDetail() {
365 370
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
366 371
 	entime := endDate.Unix()
367 372
 	fmt.Println("结束日期", entime)
368
-	PatientsInfo, err := service.GetSearchPatientInfo(orgId, keyword, statime, entime)
373
+	PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
369 374
 	if err != nil {
370 375
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
371 376
 		return
@@ -864,3 +869,30 @@ func (this *NewCommonApiController) GetSeachPatientsControl() {
864 869
 		"control": control,
865 870
 	})
866 871
 }
872
+
873
+func (this *NewCommonApiController) GetMobileTreatlist() {
874
+	adminUser := this.GetMobileAdminUserInfo()
875
+	orgId := adminUser.Org.Id
876
+	startime := this.GetString("startime")
877
+	fmt.Println(startime)
878
+	endtime := this.GetString("endtime")
879
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
880
+	fmt.Println("parseDateErr", parseDateErr)
881
+	statime := startDate.Unix()
882
+	fmt.Println("开始时间", statime)
883
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
884
+	entime := endDate.Unix()
885
+	fmt.Println("结束日期", entime)
886
+	value, _ := this.GetInt64("value")
887
+	fmt.Println("value", value)
888
+	list, err := service.GetTreatList(orgId, statime, entime, value)
889
+	if err != nil {
890
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
891
+		return
892
+	}
893
+
894
+	this.ServeSuccessJSON(map[string]interface{}{
895
+
896
+		"list": list,
897
+	})
898
+}

+ 1 - 0
controllers/new_mobile_api_controllers/new_common_api_router.go 파일 보기

@@ -29,4 +29,5 @@ func NewCommonApiControllersRegisterRouters() {
29 29
 	beego.Router("m/api/getmobilecartogramlist", &NewCommonApiController{}, "Get:GetMobileCartogramlist")
30 30
 	beego.Router("/m/api/getmobilequalitycontrol", &NewCommonApiController{}, "Get:GetMobileQualityControl")
31 31
 	beego.Router("/m/api/toseachpatientscontrol", &NewCommonApiController{}, "Get:GetSeachPatientsControl")
32
+	beego.Router("/m/api/getmobiletreatlist", &NewCommonApiController{}, "Get:GetMobileTreatlist")
32 33
 }

+ 39 - 0
models/common_models.go 파일 보기

@@ -414,3 +414,42 @@ func (PatientInspectionCount) TableName() string {
414 414
 
415 415
 	return "xt_inspection"
416 416
 }
417
+
418
+type BloodDialysisOrder struct {
419
+	ID                 int64  `gorm:"column:id" json:"id" form:"id"`
420
+	DialysisDate       int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
421
+	UserOrgId          int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
422
+	PatientId          int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
423
+	PrescriptionId     int64  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
424
+	Stage              int64  `gorm:"column:stage" json:"stage" form:"stage"`
425
+	Remark             string `gorm:"column:remark" json:"remark" form:"remark"`
426
+	BedId              int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
427
+	StartNurse         int64  `gorm:"column:start_nurse" json:"start_nurse" form:"start_nurse"`
428
+	FinishNurse        int64  `gorm:"column:finish_nurse" json:"finish_nurse" form:"finish_nurse"`
429
+	Status             int64  `gorm:"column:status" json:"status" form:"status"`
430
+	CreatedTime        int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
431
+	UpdatedTime        int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
432
+	PunctureNurse      int64  `gorm:"column:puncture_nurse" json:"puncture_nurse" form:"puncture_nurse"`
433
+	Creator            int64  `gorm:"column:creator" json:"creator" form:"creator"`
434
+	Modifier           int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
435
+	FinishCreator      int64  `gorm:"column:finish_creator" json:"finish_creator" form:"finish_creator"`
436
+	FinishModifier     int64  `gorm:"column:finish_modifier" json:"finish_modifier" form:"finish_modifier"`
437
+	SchedualType       int64  `gorm:"column:schedual_type" json:"schedual_type" form:"schedual_type"`
438
+	StartTime          int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
439
+	EndTime            int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
440
+	ModeId             int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
441
+	Name               string `gorm:"column:name" json:"name" form:"name"`
442
+	DialysisNo         string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
443
+	IdCardNo           string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
444
+	TotalDialysis      int64  `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
445
+	UserSysBeforeCount int64  `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
446
+}
447
+
448
+type TreatDialysisOrder struct {
449
+	Date string `json:"date"`
450
+}
451
+
452
+type TreatTotalStruct struct {
453
+	Number string `json:"number"`
454
+	ModeID string `json:"mode_id"`
455
+}

+ 118 - 62
service/common_service.go 파일 보기

@@ -296,58 +296,67 @@ func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error
296 296
 	return patients, err
297 297
 }
298 298
 
299
-func GetDialysisList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
300
-	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
301
-	table := XTReadDB().Table("xt_patients as s")
302
-	fmt.Println("table", table)
299
+func GetDialysisList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
300
+
301
+	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
302
+	table := XTReadDB().Table("xt_schedule as s")
303
+	fmt.Println(table)
304
+	d := XTReadDB().Table("xt_patients as p")
305
+	fmt.Println(d)
303 306
 	if orgid > 0 {
304
-		db = db.Where("p.user_org_id = ?", orgid)
307
+		db = db.Where("o.user_org_id = ?", orgid)
305 308
 	}
306 309
 	if startime > 0 {
307
-		db = db.Where("p.record_date >= ?", startime)
310
+		db = db.Where("o.dialysis_date>=?", startime)
308 311
 	}
309 312
 	if endtime > 0 {
310
-		db = db.Where("p.record_date <=?", endtime)
313
+		db = db.Where("o.dialysis_date<=?", endtime)
311 314
 	}
312 315
 	offset := (page - 1) * limit
313
-	err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
314
-	return prescription, total, err
316
+	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").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 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
317
+	return order, total, err
318
+
315 319
 }
316 320
 
317
-func GetAllDialysisList(startime int64, endtime int64, orgid int64) (prescription []*models.BloodDialysisPrescription, err error) {
321
+func GetAllDialysisList(startime int64, endtime int64, orgid int64) (order []*models.BloodDialysisOrder, err error) {
318 322
 
319
-	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
320
-	table := XTReadDB().Table("xt_patients as s")
323
+	table := XTReadDB().Table("xt_schedule as s")
321 324
 	fmt.Println(table)
325
+	d := XTReadDB().Table("xt_patients as p")
326
+	fmt.Println(d)
327
+	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
322 328
 	if orgid > 0 {
323
-		db = db.Where("p.user_org_id = ?", orgid)
329
+		db = db.Where("o.user_org_id = ?", orgid)
324 330
 	}
325 331
 	if startime > 0 {
326
-		db = db.Where("p.record_date >= ?", startime)
332
+		db = db.Where("o.dialysis_date>=?", startime)
327 333
 	}
328 334
 	if endtime > 0 {
329
-		db = db.Where("p.record_date <=?", endtime)
335
+		db = db.Where("o.dialysis_date<=?", endtime)
330 336
 	}
331
-	err = db.Group("p.patient_id,p.mode_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Scan(&prescription).Error
332
-	return prescription, err
337
+	err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").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 ").Scan(&order).Error
338
+	return order, err
333 339
 }
334 340
 
335
-func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
336
-	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
337
-	table := XTReadDB().Table("xt_patients as s")
338
-	fmt.Println("table", table)
341
+func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
342
+
343
+	table := XTReadDB().Table("xt_schedule as s")
344
+	fmt.Println(table)
345
+	d := XTReadDB().Table("xt_patients as p")
346
+	fmt.Println(d)
347
+	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
339 348
 	if orgid > 0 {
340
-		db = db.Where("p.user_org_id = ?", orgid)
349
+		db = db.Where("o.user_org_id = ?", orgid)
341 350
 	}
342 351
 	if startime > 0 {
343
-		db = db.Where("p.record_date >= ?", startime)
352
+		db = db.Where("o.dialysis_date>=?", startime)
344 353
 	}
345 354
 	if endtime > 0 {
346
-		db = db.Where("p.record_date <=?", endtime)
355
+		db = db.Where("o.dialysis_date<=?", endtime)
347 356
 	}
348 357
 	offset := (page - 1) * limit
349
-	err = db.Group("p.patient_id").Select("p.mode_id,p.patient_id,s.name,s.id_card_no,s.dialysis_no,s.total_dialysis,s.user_sys_before_count").Joins("left join xt_patients as s on s.id = p.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&prescription).Error
350
-	return prescription, total, err
358
+	err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").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 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
359
+	return order, total, err
351 360
 }
352 361
 
353 362
 func GetLastSort(orgid int64) (models.XtQualityControlStandard, error) {
@@ -385,14 +394,17 @@ func GetDialysisDetailById(id int64, orgid int64, startime int64, endtime int64,
385 394
 	return prescription, total, err
386 395
 }
387 396
 
388
-func GetPrescritionByName(orgid int64, keywords string, startime int64, endtime int64, limit int64, page int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
397
+func GetPrescritionByName(orgid int64, patient_id int64, startime int64, endtime int64, limit int64, page int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
389 398
 
390 399
 	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
391 400
 	table := XTReadDB().Table("xt_patients as s")
392 401
 	fmt.Println(table)
393
-	if len(keywords) > 0 {
394
-		likeKey := "%" + keywords + "%"
395
-		db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", likeKey, likeKey)
402
+	//if len(keywords) > 0 {
403
+	//	likeKey := "%" + keywords + "%"
404
+	//	db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", likeKey, likeKey)
405
+	//}
406
+	if patient_id > 0 {
407
+		db = db.Where("s.id = ?", patient_id)
396 408
 	}
397 409
 	if orgid > 0 {
398 410
 		db = db.Where("p.user_org_id = ?", orgid)
@@ -408,47 +420,87 @@ func GetPrescritionByName(orgid int64, keywords string, startime int64, endtime
408 420
 	return prescription, total, err
409 421
 }
410 422
 
411
-func GetStatistics(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64, modeID int64) (dtd []*DialysisTotalDataStruct, ttd []*DialysisTotalDataStruct, total int64, err error) {
412
-	db := readDb
413
-	sql := "s.mode_id,from_unixtime(s.record_date, '%Y%m%d') as date, count(s.record_date) as number"
414
-	datesql := "s.record_date as date"
415
-	group := "from_unixtime(s.record_date, '%Y%m%d')"
416
-	db = db.Table("xt_dialysis_prescription as s")
423
+func GetTreateInfo(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64) (blood []*models.TreatDialysisOrder, total int64, err error) {
424
+
425
+	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status =  1")
426
+	table := XTReadDB().Table("xt_schedule as s")
427
+	fmt.Println(table)
428
+	p := XTReadDB().Table("xt_patients as p")
429
+	fmt.Println(p)
430
+	sql := "from_unixtime(o.dialysis_date, '%Y%m%d') AS date"
431
+
417 432
 	if orgID > 0 {
418
-		db = db.Where("s.user_org_id = ?", orgID)
419
-	}
420
-	if modeID > 0 {
421
-		db = db.Where("s.mode_id=?", modeID)
433
+		db = db.Where("o.user_org_id = ?", orgID)
422 434
 	}
423 435
 	if startime > 0 {
424
-		db = db.Where("s.record_date>=?", startime)
436
+		db = db.Where("o.dialysis_date >=?", startime)
425 437
 	}
426 438
 	if endtime > 0 {
427
-		db = db.Where("s.record_date<=?", endtime)
439
+		db = db.Where("o.dialysis_date<=?", endtime)
440
+	}
441
+	if lapseto == 0 {
442
+		db = db.Where("p.lapseto = 1 or p.lapseto = 2")
428 443
 	}
429
-	db = db.Where("s.status=1")
444
+	if lapseto > 0 {
445
+		db = db.Where("p.lapseto = ?", lapseto)
446
+	}
447
+	offset := (page - 1) * limit
448
+	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").Count(&total).Offset(offset).Limit(limit).Scan(&blood).Error
449
+	return blood, total, err
430 450
 
451
+}
452
+func GetTreatList(orgid int64, startime int64, endtime int64, lapseto int64) (ttd []*models.TreatTotalStruct, err error) {
453
+	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status =  1")
454
+	table := XTReadDB().Table("xt_schedule as s")
455
+	fmt.Println(table)
456
+	p := XTReadDB().Table("xt_patients as p")
457
+	fmt.Println(p)
458
+	if orgid > 0 {
459
+		db = db.Where("o.user_org_id = ?", orgid)
460
+	}
461
+	if startime > 0 {
462
+		db = db.Where("o.dialysis_date>=?", startime)
463
+	}
464
+	if endtime > 0 {
465
+		db = db.Where("o.dialysis_date<=?", endtime)
466
+	}
467
+	if lapseto == 0 {
468
+		db = db.Where("p.lapseto = 1 or p.lapseto = 2")
469
+	}
431 470
 	if lapseto > 0 {
432
-		joinString := "JOIN xt_patients as p ON s.patient_id=p.id and p.lapseto=? and p.status=1"
433
-		joinParams := make([]interface{}, 0)
434
-		joinParams = append(joinParams, lapseto)
435
-		if orgID > 0 {
436
-			joinString += "AND p.user_org_id=?"
437
-			joinParams = append(joinParams, orgID)
438
-		}
471
+		db = db.Where("p.lapseto = ?", lapseto)
472
+	}
473
+	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").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
474
+	return ttd, err
475
+}
439 476
 
440
-		db = db.Joins(joinString, joinParams...)
477
+func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dtd []*DialysisTotalDataStruct, ttd []*DialysisTotalDataStruct, err error) {
478
+	db := readDb
479
+	sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
480
+	datesql := " o.dialysis_date as date"
481
+	group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
482
+	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")
483
+	if orgID > 0 {
484
+		db = db.Where("o.user_org_id = ?", orgID)
485
+	}
486
+	if modeID > 0 {
487
+		db = db.Where("s.mode_id=?", modeID)
441 488
 	}
489
+	if startime > 0 {
490
+		db = db.Where("o.dialysis_date>=?", startime)
491
+	}
492
+	if endtime > 0 {
493
+		db = db.Where("o.dialysis_date<=?", endtime)
494
+	}
495
+	db = db.Where("o.status=1")
442 496
 
443 497
 	err = db.Select("s.mode_id, count(s.mode_id) as number").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
444 498
 	if err != nil {
445 499
 		return
446 500
 	}
447 501
 
448
-	offset := (page - 1) * limit
449
-
450 502
 	var ds []*DialysisTotalDataStruct
451
-	err = db.Select(datesql).Group(group).Count(&total).Order("date asc").Offset(offset).Limit(limit).Find(&ds).Error
503
+	err = db.Select(datesql).Group(group).Find(&ds).Error
452 504
 	if err != nil {
453 505
 		return
454 506
 	}
@@ -459,12 +511,13 @@ func GetStatistics(orgID int64, startime int64, endtime int64, lapseto int64, li
459 511
 			dates = append(dates, d.Date)
460 512
 		}
461 513
 
462
-		db = db.Where("s.record_date IN (?)", dates)
514
+		db = db.Where("o.dialysis_date IN (?)", dates)
463 515
 
464 516
 	}
465 517
 
466
-	err = db.Select(sql).Group(group + ", s.mode_id").Order("date asc, mode_id").Find(&dtd).Error
518
+	err = db.Select(sql).Group(group + ", s.mode_id").Order("date asc, s.mode_id").Find(&dtd).Error
467 519
 	return
520
+
468 521
 }
469 522
 
470 523
 func GetInspectionTotalCount(orgid int64) (configuration []*models.CheckConfiguration, err error) {
@@ -523,7 +576,7 @@ func GetInspectionDetailById(id int64, orgid int64, startime int64, endtime int6
523 576
 	return
524 577
 }
525 578
 
526
-func GetSearchPatientInfo(orgid int64, keywords string, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
579
+func GetSearchPatientInfo(orgid int64, keywords int64, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
527 580
 
528 581
 	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
529 582
 	table := XTReadDB().Table("xt_inspection_reference as r")
@@ -532,9 +585,12 @@ func GetSearchPatientInfo(orgid int64, keywords string, startime int64, endtime
532 585
 	fmt.Println(d)
533 586
 	p := XTReadDB().Table("xt_patients as p")
534 587
 	fmt.Println(p)
535
-	if len(keywords) > 0 {
536
-		likeKey := "%" + keywords + "%"
537
-		db = db.Where("p.name LIKE ? OR p.dialysis_no LIKE ?", likeKey, likeKey)
588
+	//if len(keywords) > 0 {
589
+	//	likeKey := "%" + keywords + "%"
590
+	//	db = db.Where("p.name LIKE ? OR p.dialysis_no LIKE ?", likeKey, likeKey)
591
+	//}
592
+	if keywords > 0 {
593
+		db = db.Where("x.patient_id = ?", keywords)
538 594
 	}
539 595
 	if orgid > 0 {
540 596
 		db = db.Where("x.org_id = ?", orgid)
@@ -1603,9 +1659,9 @@ func GetPatientContor(lapstor, orgid int64, keywords string, startime int64, end
1603 1659
 	return inspection, err
1604 1660
 }
1605 1661
 
1606
-func GetPatientNames(orgid int64, patientname string) (models.XtPatients, error) {
1662
+func GetPatientNames(orgid int64, patientid int64) (models.XtPatients, error) {
1607 1663
 	patients := models.XtPatients{}
1608
-	err := readDb.Where("user_org_id = ? and (name=? or dialysis_no=?) and status = 1", orgid, patientname, patientname).Find(&patients).Error
1664
+	err := readDb.Where("user_org_id = ? and id = ? and status = 1", orgid, patientid).Find(&patients).Error
1609 1665
 	return patients, err
1610 1666
 }
1611 1667