XMLWAN 4 years ago
parent
commit
6a912f0859

+ 63 - 0
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -573,3 +573,66 @@ func (this *CommonApiController) GetLastCheckList() {
573 573
 		"checkList": checkList,
574 574
 	})
575 575
 }
576
+
577
+func (this *CommonApiController) GetDialysisDetailById() {
578
+	adminUser := this.GetAdminUserInfo()
579
+	orgId := adminUser.CurrentOrgId
580
+	id, _ := this.GetInt64("id")
581
+	fmt.Println("id", id)
582
+	startime := this.GetString("startime")
583
+	fmt.Println(startime)
584
+	endtime := this.GetString("endtime")
585
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
586
+	fmt.Println("parseDateErr", parseDateErr)
587
+	statime := startDate.Unix()
588
+	fmt.Println("开始时间", statime)
589
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
590
+
591
+	entime := endDate.Unix()
592
+	fmt.Println("开始时间", statime)
593
+	fmt.Println(endtime)
594
+	limit, _ := this.GetInt64("limit")
595
+	fmt.Println("limit", limit)
596
+	page, _ := this.GetInt64("page")
597
+	fmt.Println("page", page)
598
+	patients, total, err := service.GetDialysisDetailById(id, orgId, statime, entime, limit, page)
599
+	if err != nil {
600
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
601
+		return
602
+	}
603
+	this.ServeSuccessJSON(map[string]interface{}{
604
+		"patients": patients,
605
+		"total":    total,
606
+	})
607
+}
608
+
609
+func (this *CommonApiController) GetPrescritionByName() {
610
+	adminUser := this.GetAdminUserInfo()
611
+	orgId := adminUser.CurrentOrgId
612
+	keyword := this.GetString("keyword")
613
+	startime := this.GetString("startime")
614
+	fmt.Println(startime)
615
+	endtime := this.GetString("endtime")
616
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
617
+	fmt.Println("parseDateErr", parseDateErr)
618
+	statime := startDate.Unix()
619
+	fmt.Println("开始时间", statime)
620
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
621
+
622
+	entime := endDate.Unix()
623
+	fmt.Println("开始时间", statime)
624
+	fmt.Println(endtime)
625
+	limit, _ := this.GetInt64("limit")
626
+	fmt.Println("limit", limit)
627
+	page, _ := this.GetInt64("page")
628
+	fmt.Println("page", page)
629
+	patient, total, err := service.GetPrescritionByName(orgId, keyword, statime, entime, limit, page)
630
+	if err != nil {
631
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
632
+		return
633
+	}
634
+	this.ServeSuccessJSON(map[string]interface{}{
635
+		"patient": patient,
636
+		"total":   total,
637
+	})
638
+}

+ 2 - 0
controllers/new_mobile_api_controllers/common_api_router.go View File

@@ -31,4 +31,6 @@ func CommonApiControllersRegisterRouters() {
31 31
 	beego.Router("/com/api/getdialysislist", &CommonApiController{}, "Get:GetDialysislist")
32 32
 	beego.Router("/com/api/getlastsort", &CommonApiController{}, "Get:GetLastSort")
33 33
 	beego.Router("/com/api/getlastchecklist", &CommonApiController{}, "Get:GetLastCheckList")
34
+	beego.Router("/com/api/getdialysisdetailbyid", &CommonApiController{}, "Get:GetDialysisDetailById")
35
+	beego.Router("/com/api/getprescriptionbyname", &CommonApiController{}, "Get:GetPrescritionByName")
34 36
 }

+ 46 - 0
service/common_service.go View File

@@ -385,3 +385,49 @@ func GetLastCheckList(orgid int64) (models.XtCheckConfiguration, error) {
385 385
 	err := XTReadDB().Model(&configuration).Where("user_org_id = ? and status =1", orgid).Last(&configuration).Error
386 386
 	return configuration, err
387 387
 }
388
+
389
+func GetDialysisDetailById(id int64, orgid int64, startime int64, endtime int64, limit int64, page int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
390
+
391
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
392
+	table := XTReadDB().Table("xt_patients as s")
393
+	fmt.Println(table)
394
+	if id > 0 {
395
+		db = db.Where("p.patient_id = ?", id)
396
+	}
397
+
398
+	if orgid > 0 {
399
+		db = db.Where("p.user_org_id = ?", orgid)
400
+	}
401
+	if startime > 0 {
402
+		db = db.Where("p.record_date >= ?", startime)
403
+	}
404
+	if endtime > 0 {
405
+		db = db.Where("p.record_date <=?", endtime)
406
+	}
407
+	offset := (page - 1) * limit
408
+	err = db.Group("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
409
+	return prescription, total, err
410
+}
411
+
412
+func GetPrescritionByName(orgid int64, keywords string, startime int64, endtime int64, limit int64, page int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
413
+
414
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
415
+	table := XTReadDB().Table("xt_patients as s")
416
+	fmt.Println(table)
417
+	if len(keywords) > 0 {
418
+		likeKey := "%" + keywords + "%"
419
+		db = db.Where("s.name LIKE ? OR s.dialysis_no LIKE ?", likeKey, likeKey)
420
+	}
421
+	if orgid > 0 {
422
+		db = db.Where("p.user_org_id = ?", orgid)
423
+	}
424
+	if startime > 0 {
425
+		db = db.Where("p.record_date >= ?", startime)
426
+	}
427
+	if endtime > 0 {
428
+		db = db.Where("p.record_date <=?", endtime)
429
+	}
430
+	offset := (page - 1) * limit
431
+	err = db.Group("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
432
+	return prescription, total, err
433
+}