Browse Source

Merge branch 'xt_statistics_branch' of http://git.shengws.com/csx/XT_New into xt_statistics_branch

csx 4 years ago
parent
commit
4d1d51df31

+ 0 - 2
controllers/data_api_controller.go View File

@@ -54,9 +54,7 @@ func DataApiRegistRouters() {
54 54
 //GetPatientsList 取配置信息列表
55 55
 func (c *DataApiController) GetConfigList() {
56 56
 	adminUserInfo := c.GetAdminUserInfo()
57
-
58 57
 	configList, _ := service.GetConfigList(adminUserInfo.CurrentOrgId)
59
-
60 58
 	c.ServeSuccessJSON(map[string]interface{}{
61 59
 		"configlist": configList,
62 60
 	})

+ 14 - 0
controllers/gobal_config_api_controller.go View File

@@ -1025,6 +1025,20 @@ func (this *GobalConfigApiController) ChangeOrg() {
1025 1025
 			}
1026 1026
 		}
1027 1027
 
1028
+		QualityeList, err := service.FindQualityByOrgId(tempOrg.Id)
1029
+		if len(QualityeList) == 0 {
1030
+			err = service.BatchInsertQualityControl(tempOrg.Id)
1031
+		} else {
1032
+			utils.ErrorLog("字段批量插入失败:%v", err)
1033
+		}
1034
+
1035
+		InspectionList, err := service.FindeInspectionByOrgId(tempOrg.Id)
1036
+		if len(InspectionList) == 0 {
1037
+			err = service.BatchInspectionConfiguration(tempOrg.Id)
1038
+		} else {
1039
+			utils.ErrorLog("字段批量插入失败:%v", err)
1040
+		}
1041
+
1028 1042
 		var didRegistedForSCRM bool = false
1029 1043
 		var didRegistedForCDM bool = false
1030 1044
 		var didRegistedForMall bool = false

+ 16 - 0
controllers/mobile_api_controllers/login_api_controller.go View File

@@ -167,6 +167,22 @@ func (this *LoginAPIController) LoginByPwd() {
167 167
 			}
168 168
 		}
169 169
 
170
+		//批量插入质控达标统计配置
171
+		QualityeList, err := service.FindQualityByOrgId(org.Id)
172
+		if len(QualityeList) == 0 {
173
+			err = service.BatchInsertQualityControl(org.Id)
174
+		} else {
175
+			utils.ErrorLog("字段批量插入失败:%v", err)
176
+		}
177
+
178
+		//批量插入检验检查统计配置
179
+		InspectionList, err := service.FindeInspectionByOrgId(org.Id)
180
+		if len(InspectionList) == 0 {
181
+			err = service.BatchInspectionConfiguration(org.Id)
182
+		} else {
183
+			utils.ErrorLog("字段批量插入失败:%v", err)
184
+		}
185
+
170 186
 		this.ServeSuccessJSON(map[string]interface{}{
171 187
 			"admin": adminUser,
172 188
 			"user":  appRole,

+ 314 - 2
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/enums"
6 6
 	"XT_New/models"
7 7
 	"XT_New/service"
8
+	"XT_New/utils"
8 9
 	"encoding/json"
9 10
 	"fmt"
10 11
 	"github.com/jinzhu/gorm"
@@ -468,12 +469,19 @@ func (this *CommonApiController) GetTotalDialysisCount() {
468 469
 	fmt.Println(startime)
469 470
 	endtime, _ := this.GetInt64("endtime")
470 471
 	fmt.Println(endtime)
472
+	recordDateStr := time.Now().Format("2006-01-02")
473
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
474
+	fmt.Println("parseDateErr", parseDateErr)
475
+	nowtime := recordDate.Unix()
471 476
 	//统计透析总人数
472 477
 	total := service.GetPatientTotalCount(orgid)
473
-	fmt.Println("total--------------", total)
478
+	fmt.Println("total", total)
474 479
 	//获取该机构下的所有病人数据
475 480
 	patients, err := service.GetTotalDialysisAgeCount(orgid)
476
-	fmt.Println("patients--------", patients)
481
+	fmt.Println("patients", patients)
482
+
483
+	//统计透年龄
484
+	dataage, _ := service.GetDialysisAgeData(orgid)
477 485
 	if err != nil {
478 486
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
479 487
 		return
@@ -481,5 +489,309 @@ func (this *CommonApiController) GetTotalDialysisCount() {
481 489
 	this.ServeSuccessJSON(map[string]interface{}{
482 490
 		"total":    total,
483 491
 		"patients": patients,
492
+		"nowtime":  nowtime,
493
+		"dataage":  dataage,
494
+	})
495
+}
496
+
497
+func (this *CommonApiController) GetCurentOrgPatients() {
498
+
499
+	adminUser := this.GetAdminUserInfo()
500
+	orgid := adminUser.CurrentOrgId
501
+	patients, err := service.GetCurentOrgPatients(orgid)
502
+	if err != nil {
503
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
504
+		return
505
+	}
506
+	this.ServeSuccessJSON(map[string]interface{}{
507
+		"patients": patients,
508
+	})
509
+}
510
+
511
+func (this *CommonApiController) GetDialysislist() {
512
+	startime := this.GetString("startime")
513
+	fmt.Println("startime", startime)
514
+	endtime := this.GetString("endtime")
515
+	fmt.Println("enditme", endtime)
516
+
517
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
518
+	fmt.Println("parseDateErr", parseDateErr)
519
+	statime := startDate.Unix()
520
+	fmt.Println("开始时间", statime)
521
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
522
+
523
+	entime := endDate.Unix()
524
+	fmt.Println("开始时间", statime)
525
+	page, _ := this.GetInt64("page")
526
+	fmt.Println("page", page)
527
+	limit, _ := this.GetInt64("limit")
528
+	fmt.Println("limit", limit)
529
+	adminUser := this.GetAdminUserInfo()
530
+	orgId := adminUser.CurrentOrgId
531
+
532
+	dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
533
+
534
+	prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
535
+	list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
536
+	fmt.Println("err", err)
537
+	if err != nil {
538
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
539
+		return
540
+	}
541
+	this.ServeSuccessJSON(map[string]interface{}{
542
+		"dialysislist":     dialysislist,
543
+		"total":            total,
544
+		"list":             list,
545
+		"totallist":        totallist,
546
+		"prescriptionList": prescriptionList,
547
+	})
548
+}
549
+
550
+func (this *CommonApiController) GetLastSort() {
551
+
552
+	adminUser := this.GetAdminUserInfo()
553
+	orgid := adminUser.CurrentOrgId
554
+	standard, err := service.GetLastSort(orgid)
555
+	if err != nil {
556
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
557
+		return
558
+	}
559
+	this.ServeSuccessJSON(map[string]interface{}{
560
+		"standard": standard,
561
+	})
562
+}
563
+
564
+func (this *CommonApiController) GetLastCheckList() {
565
+	adminUser := this.GetAdminUserInfo()
566
+	orgid := adminUser.CurrentOrgId
567
+	checkList, err := service.GetLastCheckList(orgid)
568
+	if err != nil {
569
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
570
+		return
571
+	}
572
+	this.ServeSuccessJSON(map[string]interface{}{
573
+		"checkList": checkList,
574
+	})
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
+}
639
+
640
+func (this *CommonApiController) GetStatistics() {
641
+	adminUser := this.GetAdminUserInfo()
642
+	orgId := adminUser.CurrentOrgId
643
+	fmt.Println("orgid", orgId)
644
+	startime := this.GetString("start_time")
645
+	fmt.Println(startime)
646
+	endtime := this.GetString("end_time")
647
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
648
+	fmt.Println("parseDateErr", parseDateErr)
649
+	statime := startDate.Unix()
650
+	fmt.Println("开始时间", statime)
651
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
652
+	entime := endDate.Unix()
653
+	fmt.Println("结束日期", entime)
654
+	value, _ := this.GetInt64("value")
655
+	fmt.Println("value", value)
656
+	limit, _ := this.GetInt64("limit")
657
+	fmt.Println("limit", limit)
658
+	page, _ := this.GetInt64("page")
659
+	fmt.Println("page", page)
660
+	modeId, _ := this.GetInt64("mode_id")
661
+	statistics, ttd, total, err := service.GetStatistics(orgId, statime, entime, value, limit, page, modeId)
662
+	if err != nil {
663
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
664
+		return
665
+	}
666
+	this.ServeSuccessJSON(map[string]interface{}{
667
+		"statistics": statistics,
668
+		"ttd":        ttd,
669
+		"total":      total,
670
+	})
671
+}
672
+
673
+func (this *CommonApiController) GetInspectionTatolCount() {
674
+	adminUser := this.GetAdminUserInfo()
675
+	orgid := adminUser.CurrentOrgId
676
+	startime := this.GetString("startime")
677
+	fmt.Println(startime)
678
+	endtime := this.GetString("endtime")
679
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
680
+	fmt.Println("parseDateErr", parseDateErr)
681
+	statime := startDate.Unix()
682
+	fmt.Println("开始时间", statime)
683
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
684
+	entime := endDate.Unix()
685
+	fmt.Println("结束日期", entime)
686
+	references, err := service.GetInspectionTotalCount(orgid)
687
+	if err != nil {
688
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
689
+		return
690
+	}
691
+
692
+	counts, err := service.GetInspectionProjectCount(orgid, statime, entime)
693
+
694
+	this.ServeSuccessJSON(map[string]interface{}{
695
+		"Inspection": references,
696
+		"counts":     counts,
697
+	})
698
+}
699
+
700
+func (this *CommonApiController) GetInspectionDetailById() {
701
+	adminUser := this.GetAdminUserInfo()
702
+	orgId := adminUser.CurrentOrgId
703
+	id, _ := this.GetInt64("id")
704
+	fmt.Println("id", id)
705
+	startime := this.GetString("startime")
706
+	endtime := this.GetString("endtime")
707
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
708
+	fmt.Println("parseDateErr", parseDateErr)
709
+	statime := startDate.Unix()
710
+	fmt.Println("开始时间", statime)
711
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
712
+	entime := endDate.Unix()
713
+	fmt.Println("结束日期", entime)
714
+	patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
715
+	if err != nil {
716
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
717
+		return
718
+	}
719
+	this.ServeSuccessJSON(map[string]interface{}{
720
+		"patientdetail": patientdetail,
721
+	})
722
+}
723
+
724
+func (this *CommonApiController) GetSearchPatientInfo() {
725
+	adminUser := this.GetAdminUserInfo()
726
+	orgId := adminUser.CurrentOrgId
727
+	keyword := this.GetString("keyword")
728
+	fmt.Println("keyword", keyword)
729
+	startime := this.GetString("startime")
730
+	endtime := this.GetString("endtime")
731
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
732
+	fmt.Println("parseDateErr", parseDateErr)
733
+	statime := startDate.Unix()
734
+	fmt.Println("开始时间", statime)
735
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
736
+	entime := endDate.Unix()
737
+	fmt.Println("结束日期", entime)
738
+	PatientsInfo, err := service.GetSearchPatientInfo(orgId, keyword, statime, entime)
739
+	if err != nil {
740
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
741
+		return
742
+	}
743
+	this.ServeSuccessJSON(map[string]interface{}{
744
+		"PatientsInfo": PatientsInfo,
745
+	})
746
+}
747
+
748
+func (this *CommonApiController) GetAllMajorInspection() {
749
+	adminUser := this.GetAdminUserInfo()
750
+	orgid := adminUser.CurrentOrgId
751
+	inspection, err := service.GetMajorInspectionByOrgid(orgid)
752
+	if len(inspection) == 0 {
753
+		inspect, err := service.GetDefaultByOrgId(0)
754
+		if err != nil {
755
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
756
+			return
757
+		}
758
+		this.ServeSuccessJSON(map[string]interface{}{
759
+			"inspection": inspect,
760
+		})
761
+	} else {
762
+		if err != nil {
763
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
764
+			return
765
+		}
766
+		this.ServeSuccessJSON(map[string]interface{}{
767
+			"inspection": inspection,
768
+		})
769
+	}
770
+}
771
+
772
+func (this *CommonApiController) GetPatientList() {
773
+	adminUser := this.GetAdminUserInfo()
774
+	orgid := adminUser.CurrentOrgId
775
+	startime := this.GetString("startime")
776
+	endtime := this.GetString("endtime")
777
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
778
+	fmt.Println("parseDateErr", parseDateErr)
779
+	statime := startDate.Unix()
780
+	fmt.Println("开始时间", statime)
781
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
782
+	entime := endDate.Unix()
783
+	fmt.Println("结束日期", entime)
784
+	limit, _ := this.GetInt64("limit")
785
+	fmt.Println("limit", limit)
786
+	page, _ := this.GetInt64("page")
787
+	fmt.Println("page", page)
788
+	patientInfo, total, err := service.GetPatientListData(orgid, statime, entime, limit, page)
789
+	if err != nil {
790
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
791
+		return
792
+	}
793
+	this.ServeSuccessJSON(map[string]interface{}{
794
+		"patientInfo": patientInfo,
795
+		"total":       total,
484 796
 	})
485 797
 }

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

@@ -27,4 +27,16 @@ func CommonApiControllersRegisterRouters() {
27 27
 	beego.Router("/com/api/gettoalinfectiouscount", &CommonApiController{}, "Get:GetTotalInfectiouscount")
28 28
 	beego.Router("/com/api/gettotalagecount", &CommonApiController{}, "Get:GetTotalAgeCount")
29 29
 	beego.Router("/com/api/gettotaldialysiscount", &CommonApiController{}, "Get:GetTotalDialysisCount")
30
+	beego.Router("/com/api/getcurentorgpatients", &CommonApiController{}, "Get:GetCurentOrgPatients")
31
+	beego.Router("/com/api/getdialysislist", &CommonApiController{}, "Get:GetDialysislist")
32
+	beego.Router("/com/api/getlastsort", &CommonApiController{}, "Get:GetLastSort")
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")
36
+	beego.Router("/com/api/getstatistics", &CommonApiController{}, "Get:GetStatistics")
37
+	beego.Router("/com/api/getinspectiontotalcount", &CommonApiController{}, "Get:GetInspectionTatolCount")
38
+	beego.Router("/com/api/getinspectionDetailById", &CommonApiController{}, "Get:GetInspectionDetailById")
39
+	beego.Router("/com/api/getsearchpatientinfo", &CommonApiController{}, "Get:GetSearchPatientInfo")
40
+	beego.Router("/com/api/getallmajorInspection", &CommonApiController{}, "Get:GetAllMajorInspection")
41
+	beego.Router("/com/api/getpatientlist", &CommonApiController{}, "Get:GetPatientList")
30 42
 }

+ 16 - 0
controllers/new_mobile_api_controllers/forget_password_controller.go View File

@@ -179,6 +179,22 @@ func (this *ForgetPwdController) ModifyPassword() {
179 179
 				}
180 180
 			}
181 181
 
182
+			if org.Id > 0 {
183
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
184
+				if len(QualityeList) == 0 {
185
+					err = service.BatchInsertQualityControl(org.Id)
186
+				} else {
187
+					utils.ErrorLog("字段批量插入失败:%v", err)
188
+				}
189
+
190
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
191
+				if len(InspectionList) == 0 {
192
+					err = service.BatchInspectionConfiguration(org.Id)
193
+				} else {
194
+					utils.ErrorLog("字段批量插入失败:%v", err)
195
+				}
196
+			}
197
+
182 198
 			this.ServeSuccessJSON(map[string]interface{}{
183 199
 				"admin": adminUser,
184 200
 				"user":  appRole,

+ 33 - 0
controllers/new_mobile_api_controllers/home_api_controller.go View File

@@ -232,6 +232,23 @@ func (this *HomeController) ChangeOrg() {
232 232
 			} else {
233 233
 				FiledList = make([]*models.FiledConfig, 0)
234 234
 			}
235
+
236
+			if org.Id > 0 {
237
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
238
+				if len(QualityeList) == 0 {
239
+					err = service.BatchInsertQualityControl(org.Id)
240
+				} else {
241
+					utils.ErrorLog("字段批量插入失败:%v", err)
242
+				}
243
+
244
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
245
+				if len(InspectionList) == 0 {
246
+					err = service.BatchInspectionConfiguration(org.Id)
247
+				} else {
248
+					utils.ErrorLog("字段批量插入失败:%v", err)
249
+				}
250
+			}
251
+
235 252
 		}
236 253
 		this.ServeSuccessJSON(map[string]interface{}{
237 254
 			"admin": adminUser,
@@ -516,6 +533,22 @@ func (this *HomeController) CreateOrg() {
516 533
 					}
517 534
 				}
518 535
 
536
+				if org.Id > 0 {
537
+					QualityeList, err := service.FindQualityByOrgId(org.Id)
538
+					if len(QualityeList) == 0 {
539
+						err = service.BatchInsertQualityControl(org.Id)
540
+					} else {
541
+						utils.ErrorLog("字段批量插入失败:%v", err)
542
+					}
543
+
544
+					InspectionList, err := service.FindeInspectionByOrgId(org.Id)
545
+					if len(InspectionList) == 0 {
546
+						err = service.BatchInspectionConfiguration(org.Id)
547
+					} else {
548
+						utils.ErrorLog("字段批量插入失败:%v", err)
549
+					}
550
+				}
551
+
519 552
 				this.ServeSuccessJSON(map[string]interface{}{
520 553
 					"admin": adminUser,
521 554
 					"user":  appRole,

+ 16 - 0
controllers/new_mobile_api_controllers/mobile_regist_controller.go View File

@@ -382,6 +382,22 @@ func (this *MobileRegistController) CreateOrg() {
382 382
 				}
383 383
 			}
384 384
 
385
+			if org.Id > 0 {
386
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
387
+				if len(QualityeList) == 0 {
388
+					err = service.BatchInsertQualityControl(org.Id)
389
+				} else {
390
+					utils.ErrorLog("字段批量插入失败:%v", err)
391
+				}
392
+
393
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
394
+				if len(InspectionList) == 0 {
395
+					err = service.BatchInspectionConfiguration(org.Id)
396
+				} else {
397
+					utils.ErrorLog("字段批量插入失败:%v", err)
398
+				}
399
+			}
400
+
385 401
 			this.ServeSuccessJSON(map[string]interface{}{
386 402
 				"admin": adminUser,
387 403
 				"user":  appRole,

+ 247 - 0
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -4,6 +4,7 @@ import (
4 4
 	"XT_New/controllers/mobile_api_controllers"
5 5
 	"XT_New/enums"
6 6
 	"XT_New/service"
7
+	"XT_New/utils"
7 8
 	"fmt"
8 9
 	"time"
9 10
 )
@@ -123,3 +124,249 @@ func (this *NewCommonApiController) GetMobileTotalAgeCount() {
123 124
 		"ageCount": agecount,
124 125
 	})
125 126
 }
127
+
128
+func (this *NewCommonApiController) GetMobileTotalDialysisCount() {
129
+	startime, _ := this.GetInt64("startime")
130
+	fmt.Println("开始时间", startime)
131
+	endtime, _ := this.GetInt64("endtime")
132
+	fmt.Println("结束时间", endtime)
133
+	adminUser := this.GetMobileAdminUserInfo()
134
+	orgid := adminUser.Org.Id
135
+	recordDateStr := time.Now().Format("2006-01-02")
136
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
137
+	fmt.Println(parseDateErr)
138
+	nowtime := recordDate.Unix()
139
+	//统计透析总人数
140
+	total := service.GetPatientTotalCount(orgid)
141
+	fmt.Println("total", total)
142
+	//获取该机构下的所有病人数据
143
+	patients, err := service.GetTotalDialysisAgeCount(orgid)
144
+	if err != nil {
145
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
146
+		return
147
+	}
148
+	this.ServeSuccessJSON(map[string]interface{}{
149
+		"total":    total,
150
+		"patients": patients,
151
+		"nowtime":  nowtime,
152
+	})
153
+}
154
+
155
+func (this *NewCommonApiController) GetMobilePatientList() {
156
+	adminUser := this.GetMobileAdminUserInfo()
157
+	orgid := adminUser.Org.Id
158
+	patients, err := service.GetCurentOrgPatients(orgid)
159
+	if err != nil {
160
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
161
+		return
162
+	}
163
+	this.ServeSuccessJSON(map[string]interface{}{
164
+		"patients": patients,
165
+	})
166
+}
167
+
168
+func (this *NewCommonApiController) GetPrescriptionlist() {
169
+
170
+	startime := this.GetString("startime")
171
+	fmt.Println("startime", startime)
172
+	endtime := this.GetString("endtime")
173
+	fmt.Println("enditme", endtime)
174
+
175
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
176
+	fmt.Println("parseDateErr", parseDateErr)
177
+	statime := startDate.Unix()
178
+	fmt.Println("开始时间", statime)
179
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
180
+
181
+	entime := endDate.Unix()
182
+	fmt.Println("开始时间", statime)
183
+	page, _ := this.GetInt64("page")
184
+	fmt.Println("page", page)
185
+	limit, _ := this.GetInt64("limit")
186
+	fmt.Println("limit", limit)
187
+	adminInfo := this.GetMobileAdminUserInfo()
188
+	orgId := adminInfo.Org.Id
189
+	prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
190
+	list, totallist, err := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
191
+	fmt.Println("err--------------------", err)
192
+	if err != nil {
193
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
194
+		return
195
+	}
196
+	this.ServeSuccessJSON(map[string]interface{}{
197
+		"list":             list,
198
+		"totallist":        totallist,
199
+		"prescriptionList": prescriptionList,
200
+	})
201
+}
202
+
203
+func (this *NewCommonApiController) GetMobilePatientDetail() {
204
+	adminUser := this.GetMobileAdminUserInfo()
205
+	orgId := adminUser.Org.Id
206
+	id, _ := this.GetInt64("id")
207
+	fmt.Println("id", id)
208
+	startime := this.GetString("startime")
209
+	fmt.Println(startime)
210
+	endtime := this.GetString("endtime")
211
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
212
+	fmt.Println("parseDateErr", parseDateErr)
213
+	statime := startDate.Unix()
214
+	fmt.Println("开始时间", statime)
215
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
216
+
217
+	entime := endDate.Unix()
218
+	fmt.Println("开始时间", statime)
219
+	fmt.Println(endtime)
220
+	limit, _ := this.GetInt64("limit")
221
+	fmt.Println("limit", limit)
222
+	page, _ := this.GetInt64("page")
223
+	fmt.Println("page", page)
224
+	patients, total, err := service.GetDialysisDetailById(id, orgId, statime, entime, limit, page)
225
+	if err != nil {
226
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
227
+		return
228
+	}
229
+	this.ServeSuccessJSON(map[string]interface{}{
230
+		"patients": patients,
231
+		"total":    total,
232
+	})
233
+}
234
+
235
+func (this *NewCommonApiController) ToSearchPatient() {
236
+	adminUser := this.GetMobileAdminUserInfo()
237
+	orgId := adminUser.Org.Id
238
+	keyword := this.GetString("keyword")
239
+	startime := this.GetString("startime")
240
+	fmt.Println(startime)
241
+	endtime := this.GetString("endtime")
242
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
243
+	fmt.Println("parseDateErr", parseDateErr)
244
+	statime := startDate.Unix()
245
+	fmt.Println("开始时间", statime)
246
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
247
+
248
+	entime := endDate.Unix()
249
+	fmt.Println("开始时间", statime)
250
+	fmt.Println(endtime)
251
+	limit, _ := this.GetInt64("limit")
252
+	fmt.Println("limit", limit)
253
+	page, _ := this.GetInt64("page")
254
+	fmt.Println("page", page)
255
+	patient, total, err := service.GetPrescritionByName(orgId, keyword, statime, entime, limit, page)
256
+	if err != nil {
257
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
258
+		return
259
+	}
260
+	this.ServeSuccessJSON(map[string]interface{}{
261
+		"patient": patient,
262
+		"total":   total,
263
+	})
264
+}
265
+
266
+func (this *NewCommonApiController) GetAllPatientsMode() {
267
+	adminUser := this.GetMobileAdminUserInfo()
268
+	orgId := adminUser.Org.Id
269
+	startime := this.GetString("startime")
270
+	fmt.Println(startime)
271
+	endtime := this.GetString("endtime")
272
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
273
+	fmt.Println("parseDateErr", parseDateErr)
274
+	statime := startDate.Unix()
275
+	fmt.Println("开始时间", statime)
276
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
277
+	entime := endDate.Unix()
278
+	fmt.Println("结束日期", entime)
279
+	value, _ := this.GetInt64("value")
280
+	fmt.Println("value", value)
281
+	limit, _ := this.GetInt64("limit")
282
+	fmt.Println("limit", limit)
283
+	page, _ := this.GetInt64("page")
284
+	fmt.Println("page", page)
285
+	modeId, _ := this.GetInt64("mode_id")
286
+	fmt.Println("modeId", modeId)
287
+	statistics, ttd, total, err := service.GetStatistics(orgId, statime, entime, value, limit, page, modeId)
288
+	if err != nil {
289
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
290
+		return
291
+	}
292
+	this.ServeSuccessJSON(map[string]interface{}{
293
+		"statistics": statistics,
294
+		"ttd":        ttd,
295
+		"total":      total,
296
+	})
297
+}
298
+
299
+func (this *NewCommonApiController) GetMobileInspectionList() {
300
+	adminUser := this.GetMobileAdminUserInfo()
301
+	orgid := adminUser.Org.Id
302
+	startime := this.GetString("startime")
303
+	fmt.Println(startime)
304
+	endtime := this.GetString("endtime")
305
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
306
+	fmt.Println("parseDateErr", parseDateErr)
307
+	statime := startDate.Unix()
308
+	fmt.Println("开始时间", statime)
309
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
310
+	entime := endDate.Unix()
311
+	fmt.Println("结束日期", entime)
312
+	references, err := service.GetInspectionTotalCount(orgid)
313
+	if err != nil {
314
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
315
+		return
316
+	}
317
+
318
+	counts, err := service.GetInspectionProjectCount(orgid, statime, entime)
319
+
320
+	this.ServeSuccessJSON(map[string]interface{}{
321
+		"Inspection": references,
322
+		"counts":     counts,
323
+	})
324
+}
325
+
326
+func (this *NewCommonApiController) GetPatientInspectionDetail() {
327
+	adminUser := this.GetMobileAdminUserInfo()
328
+	orgId := adminUser.Org.Id
329
+	id, _ := this.GetInt64("id")
330
+	fmt.Println("id", id)
331
+	startime := this.GetString("startime")
332
+	endtime := this.GetString("endtime")
333
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
334
+	fmt.Println("parseDateErr", parseDateErr)
335
+	statime := startDate.Unix()
336
+	fmt.Println("开始时间", statime)
337
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
338
+	entime := endDate.Unix()
339
+	fmt.Println("结束日期", entime)
340
+	patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
341
+	if err != nil {
342
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
343
+		return
344
+	}
345
+	this.ServeSuccessJSON(map[string]interface{}{
346
+		"patientdetail": patientdetail,
347
+	})
348
+}
349
+
350
+func (this *NewCommonApiController) GetSeachPatientDetail() {
351
+	adminUser := this.GetMobileAdminUserInfo()
352
+	orgId := adminUser.Org.Id
353
+	keyword := this.GetString("keyword")
354
+	fmt.Println("keyword", keyword)
355
+	startime := this.GetString("startime")
356
+	endtime := this.GetString("endtime")
357
+	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
358
+	fmt.Println("parseDateErr", parseDateErr)
359
+	statime := startDate.Unix()
360
+	fmt.Println("开始时间", statime)
361
+	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
362
+	entime := endDate.Unix()
363
+	fmt.Println("结束日期", entime)
364
+	PatientsInfo, err := service.GetSearchPatientInfo(orgId, keyword, statime, entime)
365
+	if err != nil {
366
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
367
+		return
368
+	}
369
+	this.ServeSuccessJSON(map[string]interface{}{
370
+		"PatientsInfo": PatientsInfo,
371
+	})
372
+}

+ 9 - 0
controllers/new_mobile_api_controllers/new_common_api_router.go View File

@@ -9,4 +9,13 @@ func NewCommonApiControllersRegisterRouters() {
9 9
 	beego.Router("/m/api/getmobiletotalsexcount", &NewCommonApiController{}, "Get:GetMobileTotalSexCount")
10 10
 	beego.Router("/m/api/getmobiletotalinfectiouscount", &NewCommonApiController{}, "Get:GetMobileTotalInfectiousCout")
11 11
 	beego.Router("/m/api/getmobiletotalagecount", &NewCommonApiController{}, "Get:GetMobileTotalAgeCount")
12
+	beego.Router("/m/api/getmobiletotaldialysiscount", &NewCommonApiController{}, "Get:GetMobileTotalDialysisCount")
13
+	beego.Router("/m/api/gemobilepatientlist", &NewCommonApiController{}, "Get:GetMobilePatientList")
14
+	beego.Router("/m/api/getprescriptionlist", &NewCommonApiController{}, "Get:GetPrescriptionlist")
15
+	beego.Router("/m/api/getmobilepatientdetail", &NewCommonApiController{}, "Get:GetMobilePatientDetail")
16
+	beego.Router("/m/api/tosearchpatient", &NewCommonApiController{}, "Get:ToSearchPatient")
17
+	beego.Router("/m/api/getallpatientsmode", &NewCommonApiController{}, "Get:GetAllPatientsMode")
18
+	beego.Router("/m/api/getmobileInspectionList", &NewCommonApiController{}, "Get:GetMobileInspectionList")
19
+	beego.Router("/m/api/getpatientinspectiondetail", &NewCommonApiController{}, "Get:GetPatientInspectionDetail")
20
+	beego.Router("m/api/getseachpatientdetail", &NewCommonApiController{}, "Get:GetSeachPatientDetail")
12 21
 }

+ 16 - 0
controllers/new_mobile_api_controllers/new_login_api_controller.go View File

@@ -295,6 +295,22 @@ func (this *NewLoginApiController) LoginByCs() {
295 295
 				}
296 296
 			}
297 297
 
298
+			if org.Id > 0 {
299
+				QualityeList, err := service.FindQualityByOrgId(org.Id)
300
+				if len(QualityeList) == 0 {
301
+					err = service.BatchInsertQualityControl(org.Id)
302
+				} else {
303
+					utils.ErrorLog("字段批量插入失败0:%v", err)
304
+				}
305
+
306
+				InspectionList, err := service.FindeInspectionByOrgId(org.Id)
307
+				if len(InspectionList) == 0 {
308
+					err = service.BatchInspectionConfiguration(org.Id)
309
+				} else {
310
+					utils.ErrorLog("字段批量插入失败0:%v", err)
311
+				}
312
+			}
313
+
298 314
 			this.ServeSuccessJSON(map[string]interface{}{
299 315
 				"admin": adminUser,
300 316
 				"user": map[string]interface{}{

+ 79 - 79
controllers/patient_api_controller.go View File

@@ -252,29 +252,29 @@ func (c *PatientApiController) CreatePatient() {
252 252
 	//获取老表的最后一条数据
253 253
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
254 254
 	patientsNew := models.XtPatientsNew{
255
-		UserOrgId:          adminUserInfo.CurrentOrgId,
256
-		UserId:             0,
257
-		Avatar:             patients.Avatar,
258
-		PatientType:        patients.PatientType,
259
-		DialysisNo:         patients.DialysisNo,
260
-		AdmissionNumber:    patients.AdmissionNumber,
261
-		Source:             patients.Source,
262
-		Lapseto:            patients.Lapseto,
263
-		PartitionId:        patients.PartitionId,
264
-		BedId:              patients.BedId,
265
-		Name:               patients.Name,
266
-		Alias:              patients.Alias,
267
-		Gender:             patients.Gender,
268
-		MaritalStatus:      patients.MaritalStatus,
269
-		IdCardNo:           patients.IdCardNo,
270
-		Birthday:           patients.Birthday,
271
-		ReimbursementWayId: patients.ReimbursementWayId,
272
-		HealthCareType:     patients.HealthCareType,
273
-		HealthCareNo:       patients.HealthCareNo,
274
-		HealthCareDueDate:  patients.HealthCareDueDate,
275
-		Height:             patients.Height,
276
-		BloodType:          patients.BloodType,
277
-		Rh:                 patients.Rh,
255
+		UserOrgId:                    adminUserInfo.CurrentOrgId,
256
+		UserId:                       0,
257
+		Avatar:                       patients.Avatar,
258
+		PatientType:                  patients.PatientType,
259
+		DialysisNo:                   patients.DialysisNo,
260
+		AdmissionNumber:              patients.AdmissionNumber,
261
+		Source:                       patients.Source,
262
+		Lapseto:                      patients.Lapseto,
263
+		PartitionId:                  patients.PartitionId,
264
+		BedId:                        patients.BedId,
265
+		Name:                         patients.Name,
266
+		Alias:                        patients.Alias,
267
+		Gender:                       patients.Gender,
268
+		MaritalStatus:                patients.MaritalStatus,
269
+		IdCardNo:                     patients.IdCardNo,
270
+		Birthday:                     patients.Birthday,
271
+		ReimbursementWayId:           patients.ReimbursementWayId,
272
+		HealthCareType:               patients.HealthCareType,
273
+		HealthCareNo:                 patients.HealthCareNo,
274
+		HealthCareDueDate:            patients.HealthCareDueDate,
275
+		Height:                       patients.Height,
276
+		BloodType:                    patients.BloodType,
277
+		Rh:                           patients.Rh,
278 278
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
279 279
 		EducationLevel:               patients.EducationLevel,
280 280
 		Profession:                   patients.Profession,
@@ -320,28 +320,28 @@ func (c *PatientApiController) CreatePatient() {
320 320
 		Nation:                       patients.Nation,
321 321
 		NativePlace:                  patients.NativePlace,
322 322
 		Age:                          patients.Age,
323
-		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
324
-		IsInfectious:             patients.IsInfectious,
325
-		RemindCycle:              patients.RemindCycle,
326
-		ResponseResult:           patients.ResponseResult,
327
-		IsOpenRemind:             patients.IsOpenRemind,
328
-		FirstTreatmentDate:       patients.FirstTreatmentDate,
329
-		DialysisAge:              patients.DialysisAge,
330
-		ExpenseKind:              patients.ExpenseKind,
331
-		TellPhone:                patients.TellPhone,
332
-		ContactName:              patients.ContactName,
333
-		BloodPatients:            1,
334
-		SlowPatients:             0,
335
-		MemberPatients:           0,
336
-		EcommerPatients:          "",
337
-		BloodId:                  patients.ID,
338
-		SlowId:                   0,
339
-		MemberId:                 0,
340
-		MemberFistdate:           0,
341
-		MemberPatienttype:        0,
342
-		MemberTreatement:         0,
343
-		EquitmentId:              "",
344
-		UserSysBeforeCount:       patient.UserSysBeforeCount,
323
+		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
324
+		IsInfectious:                 patients.IsInfectious,
325
+		RemindCycle:                  patients.RemindCycle,
326
+		ResponseResult:               patients.ResponseResult,
327
+		IsOpenRemind:                 patients.IsOpenRemind,
328
+		FirstTreatmentDate:           patients.FirstTreatmentDate,
329
+		DialysisAge:                  patients.DialysisAge,
330
+		ExpenseKind:                  patients.ExpenseKind,
331
+		TellPhone:                    patients.TellPhone,
332
+		ContactName:                  patients.ContactName,
333
+		BloodPatients:                1,
334
+		SlowPatients:                 0,
335
+		MemberPatients:               0,
336
+		EcommerPatients:              "",
337
+		BloodId:                      patients.ID,
338
+		SlowId:                       0,
339
+		MemberId:                     0,
340
+		MemberFistdate:               0,
341
+		MemberPatienttype:            0,
342
+		MemberTreatement:             0,
343
+		EquitmentId:                  "",
344
+		UserSysBeforeCount:           patient.UserSysBeforeCount,
345 345
 	}
346 346
 
347 347
 	err = service.CreatePatientsNew(&patientsNew)
@@ -469,29 +469,29 @@ func (c *PatientApiController) EditPatient() {
469 469
 	}
470 470
 	fmt.Println("病人--------------------------------------------------------------", patient.Name, patient.Age)
471 471
 	patientsNew := models.XtPatientsNew{
472
-		UserOrgId:          patient.UserOrgId,
473
-		UserId:             patient.UserId,
474
-		Avatar:             patient.Avatar,
475
-		PatientType:        patient.PatientType,
476
-		DialysisNo:         patient.DialysisNo,
477
-		AdmissionNumber:    patient.AdmissionNumber,
478
-		Source:             patient.Source,
479
-		Lapseto:            patient.Lapseto,
480
-		PartitionId:        patient.PartitionId,
481
-		BedId:              patient.BedId,
482
-		Name:               patient.Name,
483
-		Alias:              patient.Alias,
484
-		Gender:             patient.Gender,
485
-		MaritalStatus:      patient.MaritalStatus,
486
-		IdCardNo:           patient.IdCardNo,
487
-		Birthday:           patient.Birthday,
488
-		ReimbursementWayId: patient.ReimbursementWayId,
489
-		HealthCareType:     patient.HealthCareType,
490
-		HealthCareNo:       patient.HealthCareNo,
491
-		HealthCareDueDate:  patient.HealthCareDueDate,
492
-		Height:             patient.Height,
493
-		BloodType:          patient.BloodType,
494
-		Rh:                 patient.Rh,
472
+		UserOrgId:                 patient.UserOrgId,
473
+		UserId:                    patient.UserId,
474
+		Avatar:                    patient.Avatar,
475
+		PatientType:               patient.PatientType,
476
+		DialysisNo:                patient.DialysisNo,
477
+		AdmissionNumber:           patient.AdmissionNumber,
478
+		Source:                    patient.Source,
479
+		Lapseto:                   patient.Lapseto,
480
+		PartitionId:               patient.PartitionId,
481
+		BedId:                     patient.BedId,
482
+		Name:                      patient.Name,
483
+		Alias:                     patient.Alias,
484
+		Gender:                    patient.Gender,
485
+		MaritalStatus:             patient.MaritalStatus,
486
+		IdCardNo:                  patient.IdCardNo,
487
+		Birthday:                  patient.Birthday,
488
+		ReimbursementWayId:        patient.ReimbursementWayId,
489
+		HealthCareType:            patient.HealthCareType,
490
+		HealthCareNo:              patient.HealthCareNo,
491
+		HealthCareDueDate:         patient.HealthCareDueDate,
492
+		Height:                    patient.Height,
493
+		BloodType:                 patient.BloodType,
494
+		Rh:                        patient.Rh,
495 495
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
496 496
 		EducationLevel:            patient.EducationLevel,
497 497
 		Profession:                patient.Profession,
@@ -533,17 +533,17 @@ func (c *PatientApiController) EditPatient() {
533 533
 		Nation:                    patient.Nation,
534 534
 		NativePlace:               patient.NativePlace,
535 535
 		Age:                       patient.Age,
536
-		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
537
-		IsInfectious:             patient.IsInfectious,
538
-		RemindCycle:              patient.RemindCycle,
539
-		ResponseResult:           patient.ResponseResult,
540
-		IsOpenRemind:             patient.IsOpenRemind,
541
-		FirstTreatmentDate:       patient.FirstTreatmentDate,
542
-		DialysisAge:              patient.DialysisAge,
543
-		ExpenseKind:              patient.ExpenseKind,
544
-		TellPhone:                patient.TellPhone,
545
-		ContactName:              patient.ContactName,
546
-		UpdatedTime:              time.Now().Unix(),
536
+		InfectiousNextRecordTime:  patient.InfectiousNextRecordTime,
537
+		IsInfectious:              patient.IsInfectious,
538
+		RemindCycle:               patient.RemindCycle,
539
+		ResponseResult:            patient.ResponseResult,
540
+		IsOpenRemind:              patient.IsOpenRemind,
541
+		FirstTreatmentDate:        patient.FirstTreatmentDate,
542
+		DialysisAge:               patient.DialysisAge,
543
+		ExpenseKind:               patient.ExpenseKind,
544
+		TellPhone:                 patient.TellPhone,
545
+		ContactName:               patient.ContactName,
546
+		UpdatedTime:               time.Now().Unix(),
547 547
 	}
548 548
 	//	//更新病人ID获取新表病人ID
549 549
 	err = service.UpdatepatientTwo(&patientsNew, id)

+ 14 - 0
controllers/verify_login_controller.go View File

@@ -166,6 +166,20 @@ func (this *VerifyUserLoginAPIController) VerifyToken() {
166 166
 				}
167 167
 			}
168 168
 
169
+			QualityeList, err := service.FindQualityByOrgId(curOrg.Id)
170
+			if len(QualityeList) == 0 {
171
+				err = service.BatchInsertQualityControl(curOrg.Id)
172
+			} else {
173
+				utils.ErrorLog("字段批量插入失败:%v", err)
174
+			}
175
+
176
+			InspectionList, err := service.FindeInspectionByOrgId(curOrg.Id)
177
+			if len(InspectionList) == 0 {
178
+				err = service.BatchInspectionConfiguration(curOrg.Id)
179
+			} else {
180
+				utils.ErrorLog("字段批量插入失败:%v", err)
181
+			}
182
+
169 183
 			var pruviews []*models.Purview
170 184
 			var curAppUrlfors []string
171 185
 			if len(curAppUrlfors) == 0 {

+ 216 - 0
models/common_models.go View File

@@ -109,3 +109,219 @@ type PatientAgeCountStruct struct {
109 109
 	Age   int64 `json:"age"`
110 110
 	Count int64 `json:"count"`
111 111
 }
112
+
113
+type DialysisAgePieDataStruct struct {
114
+	Age   int64 `json:"age"`
115
+	Count int64 `json:"count"`
116
+}
117
+
118
+type BloodPatients struct {
119
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
120
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
121
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
122
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
123
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
124
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
125
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
126
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
127
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
128
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
129
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
130
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
131
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
132
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
133
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
134
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
135
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
136
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
137
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
138
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
139
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
140
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
141
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
142
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
143
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
144
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
145
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
146
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
147
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
148
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
149
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
150
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
151
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
152
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
153
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
154
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
155
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
156
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
157
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
158
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
159
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
160
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
161
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
162
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
163
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
164
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
165
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
166
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
167
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
168
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
169
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
170
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
171
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
172
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
173
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
174
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
175
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
176
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
177
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
178
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
179
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
180
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
181
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
182
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
183
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
184
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
185
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
186
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
187
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
188
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
189
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
190
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
191
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
192
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
193
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
194
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
195
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
196
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
197
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
198
+	UserSysBeforeCount           int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
199
+	IsExcelExport                int64   `gorm:"column:is_excel_export" json:"is_excel_export" form:"is_excel_export"`
200
+}
201
+
202
+func (BloodPatients) TableName() string {
203
+	return "xt_patients"
204
+}
205
+
206
+type BloodDialysisPrescription struct {
207
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
208
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
209
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
210
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
211
+	MachineType                string  `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
212
+	DewaterAmount              float64 `gorm:"column:dewater_amount" json:"dewater_amount" form:"dewater_amount"`
213
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
214
+	PrescriptionDewatering     float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering" form:"prescription_dewatering"`
215
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
216
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
217
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
218
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
219
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
220
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
221
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
222
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
223
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
224
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
225
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
226
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
227
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
228
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
229
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
230
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
231
+	VascularAccessMode         int64   `gorm:"column:vascular_access_mode" json:"vascular_access_mode" form:"vascular_access_mode"`
232
+	VascularAccess             int64   `gorm:"column:vascular_access" json:"vascular_access" form:"vascular_access"`
233
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
234
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
235
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
236
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
237
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
238
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
239
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
240
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
241
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
242
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
243
+	PrescriptionDoctor         int64   `gorm:"column:prescription_doctor" json:"prescription_doctor" form:"prescription_doctor"`
244
+	Creater                    int64   `gorm:"column:creater" json:"creater" form:"creater"`
245
+	Modifier                   int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
246
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
247
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
248
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
249
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
250
+	RecordDate                 int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
251
+	RecordId                   int64   `gorm:"column:record_id" json:"record_id" form:"record_id"`
252
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
253
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
254
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
255
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
256
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
257
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
258
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
259
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
260
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
261
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
262
+	Niprocart                  int64   `gorm:"column:niprocart" json:"niprocart" form:"niprocart"`
263
+	Jms                        int64   `gorm:"column:jms" json:"jms" form:"jms"`
264
+	FistulaNeedleSet           int64   `gorm:"column:fistula_needle_set" json:"fistula_needle_set" form:"fistula_needle_set"`
265
+	FistulaNeedleSet16         int64   `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16" form:"fistula_needle_set_16"`
266
+	Hemoperfusion              int64   `gorm:"column:hemoperfusion" json:"hemoperfusion" form:"hemoperfusion"`
267
+	DialyserSterilised         int64   `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised" form:"dialyser_sterilised"`
268
+	Filtryzer                  int64   `gorm:"column:filtryzer" json:"filtryzer" form:"filtryzer"`
269
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
270
+	Dialyzers                  int64   `gorm:"column:dialyzers" json:"dialyzers" form:"dialyzers"`
271
+	Injector                   int64   `gorm:"column:injector" json:"injector" form:"injector"`
272
+	Bloodlines                 int64   `gorm:"column:bloodlines" json:"bloodlines" form:"bloodlines"`
273
+	TubingHemodialysis         int64   `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis" form:"tubing_hemodialysis"`
274
+	Package                    int64   `gorm:"column:package" json:"package" form:"package"`
275
+	ALiquid                    int64   `gorm:"column:a_liquid" json:"a_liquid" form:"a_liquid"`
276
+	Name                       string  `gorm:"column:name" json:"name" form:"name"`
277
+	DialysisNo                 string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
278
+	IdCardNo                   string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
279
+	TotalDialysis              int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
280
+	UserSysBeforeCount         int64   `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
281
+}
282
+
283
+func (BloodDialysisPrescription) TableName() string {
284
+	return "xt_dialysis_prescription"
285
+}
286
+
287
+type DialysisTotalDataStruct struct {
288
+	Date   string `json:"date"`
289
+	Number string `json:"number"`
290
+	ModeID string `json:"mode_id"`
291
+}
292
+
293
+type UserInspectionProjectCount struct {
294
+	PatientId int64
295
+	Count     int64
296
+	ProjectId int64
297
+}
298
+
299
+type InspectionReferenceMaps struct {
300
+	ProjectName        string               `gorm:"-" json:"project_name" form:"project_name"`
301
+	Project            string               `gorm:"-" json:"project" form:"project"`
302
+	ProjectId          int64                `gorm:"-" json:"project_id" form:"project_id"`
303
+	Count              int64                `gorm:"-" json:"count" form:"count"`
304
+	CheckConfiguration []CheckConfiguration `gorm:"-" json:"inspection_reference" form:"inspection_reference"`
305
+}
306
+
307
+type PatientsInspection struct {
308
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
309
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
310
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
311
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
312
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
313
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
314
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
315
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
316
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
317
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
318
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
319
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
320
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
321
+	Name         string `gorm:"column:name" json:"name" form:"name"`
322
+}
323
+
324
+func (PatientsInspection) TableName() string {
325
+
326
+	return "xt_inspection"
327
+}

+ 6 - 4
models/inspection_models.go View File

@@ -68,10 +68,12 @@ func (InspectionReference) TableName() string {
68 68
 	return "xt_inspection_reference"
69 69
 }
70 70
 
71
-type UserInspectionProjectCount struct {
72
-	PatientId int64
73
-	Count     int64
74
-	ProjectId int64
71
+type UserInspectionProjectCounts struct {
72
+	PatientId           int64
73
+	Count               int64
74
+	ProjectId           int64
75
+	ProjectName         string
76
+	InspectionFrequency string
75 77
 }
76 78
 
77 79
 type UserDoctorAdvicesCount struct {

+ 347 - 0
service/common_service.go View File

@@ -263,3 +263,350 @@ func GetTotalDialysisAgeCount(orgid int64) (patients []*models.XtPatients, err e
263 263
 	err = XTReadDB().Where("user_org_id = ? and status =1", orgid).Find(&patients).Error
264 264
 	return patients, err
265 265
 }
266
+
267
+func GetDialysisAgeData(orgID int64) (counts []*models.DialysisAgePieDataStruct, err error) {
268
+	loc, _ := time.LoadLocation("Local")
269
+	nowTime := time.Now()
270
+	nowDay := nowTime.Format("2006-01-02")
271
+	dayTime, err := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
272
+	fmt.Println("datTime", dayTime)
273
+	if err != nil {
274
+		return
275
+	}
276
+	oneYearPoint := dayTime.AddDate(-12, 0, 0).Unix()
277
+
278
+	fiveYearPoint := dayTime.AddDate(-36, 0, 0).Unix()
279
+
280
+	tenYearPoint := dayTime.AddDate(-60, 0, 0).Unix()
281
+
282
+	twentyYearPoint := dayTime.AddDate(-61, 0, 0).Unix()
283
+
284
+	db := readDb.Table("xt_patients").Where("status=1")
285
+	countSQL := "SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(" +
286
+		"SELECT " +
287
+		"CASE " +
288
+		" WHEN first_dialysis_date<>0 AND first_dialysis_date>? THEN '1'" +
289
+		" WHEN first_dialysis_date<>0 AND first_dialysis_date>? && first_dialysis_date<=? THEN '2'" +
290
+		" WHEN first_dialysis_date<>0 AND first_dialysis_date>? && first_dialysis_date<=? THEN '3'" +
291
+		" WHEN first_dialysis_date<>0 AND first_dialysis_date>? && first_dialysis_date<=? THEN '4'" +
292
+		" WHEN first_dialysis_date<>0 AND first_dialysis_date<=? THEN '5'" +
293
+		" ELSE '0'" +
294
+		"END AS nnd FROM xt_patients WHERE status=1"
295
+	countParams := make([]interface{}, 0)
296
+	countParams = append(countParams, oneYearPoint)
297
+	countParams = append(countParams, fiveYearPoint)
298
+	countParams = append(countParams, oneYearPoint)
299
+	countParams = append(countParams, tenYearPoint)
300
+	countParams = append(countParams, fiveYearPoint)
301
+	countParams = append(countParams, twentyYearPoint)
302
+	countParams = append(countParams, tenYearPoint)
303
+	countParams = append(countParams, twentyYearPoint)
304
+
305
+	if orgID > 0 {
306
+		db = db.Where("user_org_id=?", orgID)
307
+		countSQL += " AND user_org_id=?"
308
+		countParams = append(countParams, orgID)
309
+	}
310
+
311
+	countSQL += ")a GROUP BY nnd"
312
+	err = readDb.Raw(countSQL, countParams...).Scan(&counts).Error
313
+	return
314
+
315
+}
316
+
317
+func GetCurentOrgPatients(orgid int64) (patients []*models.XtPatients, err error) {
318
+
319
+	err = XTReadDB().Where("user_org_id = ? and status =1", orgid).Order("created_time desc").Find(&patients).Error
320
+	return patients, err
321
+}
322
+
323
+func GetDialysisList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
324
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
325
+	table := XTReadDB().Table("xt_patients as s")
326
+	fmt.Println("table", table)
327
+	if orgid > 0 {
328
+		db = db.Where("p.user_org_id = ?", orgid)
329
+	}
330
+	if startime > 0 {
331
+		db = db.Where("p.record_date >= ?", startime)
332
+	}
333
+	if endtime > 0 {
334
+		db = db.Where("p.record_date <=?", endtime)
335
+	}
336
+	offset := (page - 1) * limit
337
+	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
338
+	return prescription, total, err
339
+}
340
+
341
+func GetAllDialysisList(startime int64, endtime int64, orgid int64) (prescription []*models.BloodDialysisPrescription, err error) {
342
+
343
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
344
+	table := XTReadDB().Table("xt_patients as s")
345
+	fmt.Println(table)
346
+	if orgid > 0 {
347
+		db = db.Where("p.user_org_id = ?", orgid)
348
+	}
349
+	if startime > 0 {
350
+		db = db.Where("p.record_date >= ?", startime)
351
+	}
352
+	if endtime > 0 {
353
+		db = db.Where("p.record_date <=?", endtime)
354
+	}
355
+	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
356
+	return prescription, err
357
+}
358
+
359
+func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (prescription []*models.BloodDialysisPrescription, total int64, err error) {
360
+	db := XTReadDB().Table("xt_dialysis_prescription as p").Where("p.status =1 ")
361
+	table := XTReadDB().Table("xt_patients as s")
362
+	fmt.Println("table", table)
363
+	if orgid > 0 {
364
+		db = db.Where("p.user_org_id = ?", orgid)
365
+	}
366
+	if startime > 0 {
367
+		db = db.Where("p.record_date >= ?", startime)
368
+	}
369
+	if endtime > 0 {
370
+		db = db.Where("p.record_date <=?", endtime)
371
+	}
372
+	offset := (page - 1) * limit
373
+	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
374
+	return prescription, total, err
375
+}
376
+
377
+func GetLastSort(orgid int64) (models.XtQualityControlStandard, error) {
378
+	standard := models.XtQualityControlStandard{}
379
+	err := XTReadDB().Model(&standard).Where("user_org_id = ? and status =1", orgid).Last(&standard).Error
380
+	return standard, err
381
+}
382
+
383
+func GetLastCheckList(orgid int64) (models.XtCheckConfiguration, error) {
384
+	configuration := models.XtCheckConfiguration{}
385
+	err := XTReadDB().Model(&configuration).Where("user_org_id = ? and status =1", orgid).Last(&configuration).Error
386
+	return configuration, err
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
+}
434
+
435
+func GetStatistics(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64, modeID int64) (dtd []*DialysisTotalDataStruct, ttd []*DialysisTotalDataStruct, total int64, err error) {
436
+	db := readDb
437
+	sql := "s.mode_id,from_unixtime(s.record_date, '%Y%m%d') as date, count(s.record_date) as number"
438
+	datesql := "s.record_date as date"
439
+	group := "from_unixtime(s.record_date, '%Y%m%d')"
440
+	db = db.Table("xt_dialysis_prescription as s")
441
+	if orgID > 0 {
442
+		db = db.Where("s.user_org_id = ?", orgID)
443
+	}
444
+	if modeID > 0 {
445
+		db = db.Where("s.mode_id=?", modeID)
446
+	}
447
+	if startime > 0 {
448
+		db = db.Where("s.record_date>=?", startime)
449
+	}
450
+	if endtime > 0 {
451
+		db = db.Where("s.record_date<=?", endtime)
452
+	}
453
+	db = db.Where("s.status=1")
454
+
455
+	if lapseto > 0 {
456
+		joinString := "JOIN xt_patients as p ON s.patient_id=p.id and p.lapseto=? and p.status=1"
457
+		joinParams := make([]interface{}, 0)
458
+		joinParams = append(joinParams, lapseto)
459
+		if orgID > 0 {
460
+			joinString += "AND p.user_org_id=?"
461
+			joinParams = append(joinParams, orgID)
462
+		}
463
+
464
+		db = db.Joins(joinString, joinParams...)
465
+	}
466
+
467
+	err = db.Select("s.mode_id, count(s.mode_id) as number").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
468
+	if err != nil {
469
+		return
470
+	}
471
+
472
+	offset := (page - 1) * limit
473
+
474
+	var ds []*DialysisTotalDataStruct
475
+	err = db.Select(datesql).Group(group).Count(&total).Order("date asc").Offset(offset).Limit(limit).Find(&ds).Error
476
+	if err != nil {
477
+		return
478
+	}
479
+
480
+	dates := make([]string, 0)
481
+	if len(ds) > 0 {
482
+		for _, d := range ds {
483
+			dates = append(dates, d.Date)
484
+		}
485
+
486
+		db = db.Where("s.record_date IN (?)", dates)
487
+
488
+	}
489
+
490
+	err = db.Select(sql).Group(group + ", s.mode_id").Order("date asc, mode_id").Find(&dtd).Error
491
+	return
492
+}
493
+
494
+func GetInspectionTotalCount(orgid int64) (configuration []*models.CheckConfiguration, err error) {
495
+	var count int
496
+	db := XTReadDB().Table("xt_check_configuration as x").Where("x.status = 1")
497
+	table := XTReadDB().Table("xt_inspection_reference as s")
498
+	if orgid > 0 {
499
+		db = db.Where("x.user_org_id = ?", orgid)
500
+	}
501
+	fmt.Println(table)
502
+	err = db.Group("x.inspection_major").Select("x.id,x.inspection_major,x.inspection_frequency,x.sort,x.user_org_id,s.project_name").Joins("left join xt_inspection_reference as s on s.project_id = x.inspection_major").Count(&count).Order("x.sort asc").Scan(&configuration).Error
503
+	return configuration, err
504
+}
505
+
506
+func GetInspectionProjectCount(orgid int64, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
507
+
508
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
509
+	table := XTReadDB().Table("xt_inspection_reference as r")
510
+	fmt.Println(table)
511
+	d := XTReadDB().Table("xt_check_configuration as t").Where("t.status = 1")
512
+	fmt.Println(d)
513
+	if orgid > 0 {
514
+		db = db.Where("x.org_id = ?", orgid)
515
+	}
516
+	if startime > 0 {
517
+		db = db.Where("x.inspect_date >=?", startime)
518
+	}
519
+	if endtime > 0 {
520
+		db = db.Where("x.inspect_date <=?", endtime)
521
+	}
522
+
523
+	err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left  join xt_inspection_reference as r on r.project_id = x.project_id").Group("project_id,patient_id").Scan(&projectCounts).Error
524
+	return
525
+}
526
+
527
+func GetInspectionDetailById(id int64, orgid int64, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
528
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
529
+	table := XTReadDB().Table("xt_inspection_reference as r")
530
+	fmt.Println(table)
531
+	d := XTReadDB().Table("xt_check_configuration as t").Where("t.status = 1")
532
+	fmt.Println(d)
533
+	if id > 0 {
534
+		db = db.Where("x.patient_id=?", id)
535
+	}
536
+	if orgid > 0 {
537
+		db = db.Where("x.org_id = ?", orgid)
538
+	}
539
+	if startime > 0 {
540
+		db = db.Where("x.inspect_date >=?", startime)
541
+	}
542
+	if endtime > 0 {
543
+		db = db.Where("x.inspect_date <=?", endtime)
544
+	}
545
+
546
+	err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left  join xt_inspection_reference as r on r.project_id = x.project_id").Group("project_id,patient_id").Scan(&projectCounts).Error
547
+	return
548
+}
549
+
550
+func GetSearchPatientInfo(orgid int64, keywords string, startime int64, endtime int64) (projectCounts []*models.UserInspectionProjectCounts, err error) {
551
+
552
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
553
+	table := XTReadDB().Table("xt_inspection_reference as r")
554
+	fmt.Println(table)
555
+	d := XTReadDB().Table("xt_check_configuration as t").Where("t.status = 1")
556
+	fmt.Println(d)
557
+	p := XTReadDB().Table("xt_patients as p")
558
+	fmt.Println(p)
559
+	if len(keywords) > 0 {
560
+		likeKey := "%" + keywords + "%"
561
+		db = db.Where("p.name LIKE ? OR p.dialysis_no LIKE ?", likeKey, likeKey)
562
+	}
563
+	if orgid > 0 {
564
+		db = db.Where("x.org_id = ?", orgid)
565
+	}
566
+	if startime > 0 {
567
+		db = db.Where("x.inspect_date >=?", startime)
568
+	}
569
+	if endtime > 0 {
570
+		db = db.Where("x.inspect_date <=?", endtime)
571
+	}
572
+
573
+	err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left  join xt_inspection_reference as r on r.project_id = x.project_id").Joins("left join xt_patients as p on p.id = x.patient_id").Group("project_id,patient_id").Scan(&projectCounts).Error
574
+	return
575
+}
576
+
577
+func GetMajorInspectionByOrgid(orgid int64) (checkconfiguration []*models.CheckConfiguration, err error) {
578
+
579
+	db := XTReadDB().Table("xt_check_configuration as x").Where("x.status =1")
580
+	table := XTReadDB().Table("xt_inspection_reference ar r")
581
+	fmt.Println(table)
582
+	err = db.Group("x.inspection_major").Select("x.id,x.inspection_major,x.inspection_frequency,x.sort,x.user_org_id,r.project_name").Where("x.user_org_id = ?", orgid).Joins("left join xt_inspection_reference as r on r.project_id = x.inspection_major").Scan(&checkconfiguration).Error
583
+	return checkconfiguration, err
584
+}
585
+
586
+func GetDefaultByOrgId(orgid int64) (checkconfiguration []*models.CheckConfiguration, err error) {
587
+
588
+	db := XTReadDB().Table("xt_check_configuration as x").Where("x.status =1")
589
+	table := XTReadDB().Table("xt_inspection_reference ar r")
590
+	fmt.Println(table)
591
+	err = db.Group("x.inspection_major").Select("x.id,x.inspection_major,x.inspection_frequency,x.sort,x.user_org_id,r.project_name").Where("x.user_org_id = ?", orgid).Joins("left join xt_inspection_reference as r on r.project_id = x.inspection_major").Scan(&checkconfiguration).Error
592
+	return checkconfiguration, err
593
+}
594
+
595
+func GetPatientListData(orgid int64, startime int64, endtime int64, limit int64, page int64) (inspection []*models.PatientsInspection, total int64, err error) {
596
+
597
+	db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
598
+	table := XTReadDB().Table("xt_patients as s")
599
+	fmt.Println("table", table)
600
+	if orgid > 0 {
601
+		db = db.Where("x.org_id = ?", orgid)
602
+	}
603
+	if startime > 0 {
604
+		db = db.Where("x.inspect_date >= ?", startime)
605
+	}
606
+	if endtime > 0 {
607
+		db = db.Where("x.inspect_date <=?", endtime)
608
+	}
609
+	offset := (page - 1) * limit
610
+	err = db.Group("x.patient_id").Select("x.id,x.patient_id,x.project_id,x.project_name,s.name").Joins("left join xt_patients as s on s.id = x.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&inspection).Error
611
+	return inspection, total, err
612
+}

+ 24 - 0
service/data.go View File

@@ -171,11 +171,35 @@ func FindFiledByOrgId(org_id int64) (filedConfig []*models.FiledConfig, err erro
171 171
 	return
172 172
 }
173 173
 
174
+func FindQualityByOrgId(orgid int64) (xtquality []*models.XtQualityControlStandard, err error) {
175
+
176
+	err = readDb.Model(&models.XtQualityControlStandard{}).Where("user_org_id =? and status =1", orgid).Find(&xtquality).Error
177
+	return
178
+}
179
+
180
+func FindeInspectionByOrgId(orgid int64) (xtquality []*models.XtCheckConfiguration, err error) {
181
+
182
+	err = readDb.Model(&models.XtQualityControlStandard{}).Where("user_org_id = ? and status =1", orgid).Find(&xtquality).Error
183
+	return
184
+}
185
+
174 186
 func BatchInsertFiledConfig(org_id int64) (err error) {
175 187
 	err = readDb.Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 0 AND is_show = 1", org_id).Error
176 188
 	return
177 189
 }
178 190
 
191
+func BatchInsertQualityControl(org_id int64) (err error) {
192
+
193
+	err = readDb.Exec("INSERT INTO xt_quality_control_standard(user_org_id,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status) SELECT ?,inspection_major,inspection_minor,min_range,large_range,sort,created_time,status FROM xt_quality_control_standard where user_org_id = 0", org_id).Error
194
+	return
195
+}
196
+
197
+func BatchInspectionConfiguration(orgid int64) (err error) {
198
+
199
+	err = readDb.Exec("INSERT INTO xt_check_configuration(user_org_id,inspection_major,inspection_frequency,sort,created_time,status) SELECT ?,inspection_major,inspection_frequency,sort,created_time,status FROM xt_check_configuration where user_org_id = 0", orgid).Error
200
+	return
201
+}
202
+
179 203
 func ShowFiledConfig(org_id int64, isShow int, id int64) (err error) {
180 204
 	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"ctime": time.Now().Unix(), "mtime": time.Now().Unix(), "is_show": isShow}).Error
181 205
 	return

+ 3 - 1
service/qcd_service.go View File

@@ -114,6 +114,7 @@ func GetProcessIndicatorsData(orgID, page, limit, lapseto, dialysisAge, projectI
114 114
 			nowTime := time.Now()
115 115
 			nowDay := nowTime.Format("2006-01-02")
116 116
 			dayTime, err := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
117
+
117 118
 			if err != nil {
118 119
 				return inspections, references, patients, counts, total, err
119 120
 			}
@@ -526,6 +527,7 @@ type PADialysisAgePieDataStruct struct {
526 527
 }
527 528
 
528 529
 func GetPADialysisAgeData(orgID, page, limit, lapseto, age, dialysisAge, startTime, endTime int64, isStartTime, isEndTime bool) (patients []*models.Patients, counts []*PADialysisAgePieDataStruct, total int64, err error) {
530
+
529 531
 	loc, _ := time.LoadLocation("Local")
530 532
 	nowTime := time.Now()
531 533
 	nowDay := nowTime.Format("2006-01-02")
@@ -550,7 +552,7 @@ func GetPADialysisAgeData(orgID, page, limit, lapseto, age, dialysisAge, startTi
550 552
 		" WHEN first_dialysis_date<>0 AND first_dialysis_date>? && first_dialysis_date<=? THEN '4'" +
551 553
 		" WHEN first_dialysis_date<>0 AND first_dialysis_date<=? THEN '5'" +
552 554
 		" ELSE '0'" +
553
-		"END AS nnd FROM xt_patients WHERE status=1 "
555
+		"END AS nnd FROM xt_patients WHERE status=1"
554 556
 	countParams := make([]interface{}, 0)
555 557
 	countParams = append(countParams, oneYearPoint)
556 558
 	countParams = append(countParams, fiveYearPoint)