Browse Source

耗材参数

XMLWAN 3 years ago
parent
commit
92b943c689

+ 4 - 1
controllers/dialysis_api_controller.go View File

@@ -979,7 +979,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
979 979
 	precaution_other := c.GetString("precaution_other")
980 980
 	psychological_other := c.GetString("psychological_other")
981 981
 	admission_number := c.GetString("admission_number")
982
-
982
+	tumble, _ := c.GetInt64("tumble")
983 983
 	if id <= 0 {
984 984
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
985 985
 		return
@@ -1027,6 +1027,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1027 1027
 		PrecautionOther:              precaution_other,
1028 1028
 		PsychologicalOther:           psychological_other,
1029 1029
 		AdmissionNumber:              admission_number,
1030
+		Tumble:                       tumble,
1030 1031
 	}
1031 1032
 
1032 1033
 	if receiveTreatment.ID == 0 { //新增
@@ -1179,6 +1180,8 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1179 1180
 	assessment.Hypopiesia = data.Hypopiesia
1180 1181
 	assessment.LeaveOfficeMethod = data.LeaveOfficeMethod
1181 1182
 	assessment.Lapse = data.Lapse
1183
+	assessment.Consciousness = data.Consciousness
1184
+	assessment.Fallrisk = data.Fallrisk
1182 1185
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1183 1186
 
1184 1187
 	if assessment.ID > 0 {

+ 6 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -688,6 +688,7 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
688 688
 	psychological_other := c.GetString("psychological_other")
689 689
 
690 690
 	admission_number := c.GetString("admission_number")
691
+	tumble, _ := c.GetInt64("tumble")
691 692
 
692 693
 	if id <= 0 {
693 694
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -741,6 +742,7 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
741 742
 		PrecautionOther:              precaution_other,
742 743
 		PsychologicalOther:           psychological_other,
743 744
 		AdmissionNumber:              admission_number,
745
+		Tumble:                       tumble,
744 746
 	}
745 747
 
746 748
 	if receiveTreatment.ID == 0 { //新增
@@ -852,6 +854,8 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
852 854
 	hypopiesia, _ := c.GetInt64("hypopiesia")
853 855
 	leave_office_method, _ := c.GetInt64("leave_office_method")
854 856
 	lapse, _ := c.GetInt64("lapse")
857
+	consciousness, _ := c.GetInt64("consciousness")
858
+	fallrisk, _ := c.GetInt64("fallrisk")
855 859
 	if id <= 0 {
856 860
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
857 861
 		return
@@ -950,6 +954,8 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
950 954
 		Hypertenison:                 hypertenison,
951 955
 		Lapse:                        lapse,
952 956
 		LeaveOfficeMethod:            leave_office_method,
957
+		Consciousness:                consciousness,
958
+		Fallrisk:                     fallrisk,
953 959
 	}
954 960
 
955 961
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)

+ 45 - 24
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -220,7 +220,7 @@ func (this *CommonApiController) GetConfigurationDetail() {
220 220
 		}
221 221
 		this.ServeSuccessJSON(map[string]interface{}{
222 222
 			"configurationdetail": detail,
223
-			"vid": vid,
223
+			"vid":                 vid,
224 224
 		})
225 225
 	} else {
226 226
 		itemId, err := service.GetIdByItemId(detail.InspectionMinor, orgId)
@@ -230,7 +230,7 @@ func (this *CommonApiController) GetConfigurationDetail() {
230 230
 		}
231 231
 		this.ServeSuccessJSON(map[string]interface{}{
232 232
 			"configurationdetail": detail,
233
-			"vid": itemId.ID,
233
+			"vid":                 itemId.ID,
234 234
 		})
235 235
 	}
236 236
 
@@ -513,19 +513,23 @@ func (this *CommonApiController) GetDialysisModeType() {
513 513
 	loc, _ := time.LoadLocation("Local")
514 514
 	startime := this.GetString("startime")
515 515
 	endtime := this.GetString("endtime")
516
-	//fmt.Println("endtime", endtime)
516
+
517 517
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
518 518
 	startimes := startTimes.Unix()
519
-	// fmt.Println("startime",startimes)
519
+
520 520
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
521 521
 	endtimeData := endtimes.Unix()
522
-	// fmt.Println("结束日期",endtimeData)
522
+
523
+	lapsetotype, _ := this.GetInt64("lapsetotype")
524
+	sourcetype, _ := this.GetInt64("sourcetype")
525
+
523 526
 	adminUser := this.GetAdminUserInfo()
524 527
 	orgid := adminUser.CurrentOrgId
525 528
 	//统计透析总量
526
-	_, total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid)
527
-
528
-	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid)
529
+	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
530
+	fmt.Println("total3333333333333", total)
531
+	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
532
+	fmt.Println("modetype555555555555555", modeType)
529 533
 	if err != nil {
530 534
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
531 535
 		return
@@ -547,19 +551,21 @@ func (this *CommonApiController) GetTotalLapseCount() {
547 551
 	endtime := this.GetString("endtime")
548 552
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
549 553
 	endunix := endtimes.Unix()
550
-
554
+	lapsetotype, _ := this.GetInt64("lapsetotype")
555
+	sourcetype, _ := this.GetInt64("sourcetype")
551 556
 	//统计该机构的转出人数
552
-	patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix)
557
+	patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix, lapsetotype, sourcetype)
558
+
553 559
 	//统计该机构转出病人
554
-	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix)
555
-	count := service.GetPatientTotalCount(orgid)
560
+	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix, lapsetotype, sourcetype)
561
+	count := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
556 562
 	if err != nil {
557 563
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
558 564
 		return
559 565
 	}
560 566
 
561 567
 	//统计当前机构转出的人数
562
-	rollout, err := service.GetCountRollout(orgid, startnunix, endunix)
568
+	rollout, err := service.GetCountRollout(orgid, startnunix, endunix, lapsetotype, sourcetype)
563 569
 	this.ServeSuccessJSON(map[string]interface{}{
564 570
 		"patients":   patients,
565 571
 		"count":      count,
@@ -576,17 +582,22 @@ func (this *CommonApiController) GetTotalSexCount() {
576 582
 	fmt.Println("开始时间", startime)
577 583
 	endtime, _ := this.GetInt64("endtime")
578 584
 	fmt.Println("结束时间", endtime)
579
-	total := service.GetPatientTotalCount(orgid)
585
+	lapsetotype, _ := this.GetInt64("lapsetotype")
586
+	sourcetype, _ := this.GetInt64("sourcetype")
587
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
588
+
589
+	_, totalSex, err := service.GetManPatientTotal(orgid, lapsetotype, sourcetype)
580 590
 
581
-	_, totalSex, err := service.GetManPatientTotal(orgid)
591
+	_, totalWoman, err := service.GetWoManPatientTotal(orgid, lapsetotype, sourcetype)
582 592
 
583 593
 	if err != nil {
584 594
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
585 595
 		return
586 596
 	}
587 597
 	this.ServeSuccessJSON(map[string]interface{}{
588
-		"total":    total,
589
-		"totalSex": totalSex,
598
+		"total":      total,
599
+		"totalSex":   totalSex,
600
+		"totalWoman": totalWoman,
590 601
 	})
591 602
 }
592 603
 
@@ -602,10 +613,13 @@ func (this *CommonApiController) GetTotalInfectiouscount() {
602 613
 	endtime := this.GetString("endtime")
603 614
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
604 615
 	endunix := endtimes.Unix()
616
+	lapsetotype, _ := this.GetInt64("lapsetotype")
617
+	sourcetype, _ := this.GetInt64("sourcetype")
618
+
605 619
 	//统计透析总人数
606
-	total := service.GetPatientTotalCount(orgid)
620
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
607 621
 	//统计透析人数传染病所占比例
608
-	count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix)
622
+	count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix, lapsetotype, sourcetype)
609 623
 	//统计其他
610 624
 	_, otherTotal, err := service.GetPatientOtherInfectious(orgid)
611 625
 	if err != nil {
@@ -627,9 +641,12 @@ func (this *CommonApiController) GetTotalAgeCount() {
627 641
 	fmt.Println("开始时间", startime)
628 642
 	endtime, _ := this.GetInt64("endtime")
629 643
 	fmt.Println("结束时间", endtime)
644
+	lapsetotype, _ := this.GetInt64("lapsetotype")
645
+	sourcetype, _ := this.GetInt64("sourcetype")
630 646
 	//统计透析总人数
631
-	total := service.GetPatientTotalCount(orgid)
632
-	agecount, err := service.GetTotalAgeCount(orgid)
647
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
648
+	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
649
+	fmt.Println("ageCount22222222222", agecount)
633 650
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
634 651
 	if err != nil {
635 652
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -653,15 +670,17 @@ func (this *CommonApiController) GetTotalDialysisCount() {
653 670
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
654 671
 	fmt.Println("parseDateErr", parseDateErr)
655 672
 	nowtime := recordDate.Unix()
673
+	lapsetotype, _ := this.GetInt64("lapsetotype")
674
+	sourcetype, _ := this.GetInt64("sourcetype")
656 675
 	//统计透析总人数
657
-	total := service.GetPatientTotalCount(orgid)
676
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
658 677
 	fmt.Println("total", total)
659 678
 	//获取该机构下的所有病人数据
660 679
 	patients, err := service.GetTotalDialysisAgeCount(orgid)
661 680
 	fmt.Println("patients", patients)
662 681
 
663 682
 	//统计透年龄
664
-	dataage, _ := service.GetDialysisAgeData(orgid)
683
+	dataage, _ := service.GetDialysisAgeData(orgid, lapsetotype, sourcetype)
665 684
 	if err != nil {
666 685
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
667 686
 		return
@@ -2104,11 +2123,13 @@ func (this *CommonApiController) GetRolloutCount() {
2104 2123
 
2105 2124
 	start_time, _ := this.GetInt64("start_time")
2106 2125
 	end_time, _ := this.GetInt64("end_time")
2126
+	lapsetotype, _ := this.GetInt64("lapsetotype")
2127
+	sourcetype, _ := this.GetInt64("sourcetype")
2107 2128
 	adminUserInfo := this.GetAdminUserInfo()
2108 2129
 	orgId := adminUserInfo.CurrentOrgId
2109 2130
 
2110 2131
 	//统计当前机构转出的人数
2111
-	rollout, err := service.GetCountRollout(orgId, start_time, end_time)
2132
+	rollout, err := service.GetCountRollout(orgId, start_time, end_time, lapsetotype, sourcetype)
2112 2133
 
2113 2134
 	if err != nil {
2114 2135
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 4 - 2
controllers/new_mobile_api_controllers/good_types.json View File

@@ -28,7 +28,8 @@
28 28
       "status": 1,
29 29
       "type": 1,
30 30
       "number": 2,
31
-      "out_stock": 1
31
+      "out_stock": 1,
32
+      "stock_attribute": 2,
32 33
     },
33 34
     {
34 35
       "id": 10002,
@@ -43,7 +44,8 @@
43 44
       "status": 1,
44 45
       "type": 1,
45 46
       "number": 3,
46
-      "out_stock": 1
47
+      "out_stock": 1,
48
+      "stock_attribute": 3,
47 49
     },
48 50
     {
49 51
       "id": 10003,

+ 40 - 17
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -31,10 +31,14 @@ func (this *NewCommonApiController) GetTotalDialysis() {
31 31
 	adminUser := this.GetMobileAdminUserInfo()
32 32
 	orgid := adminUser.Org.Id
33 33
 
34
+	lapsetotype, _ := this.GetInt64("lapsetotype")
35
+	sourcetype, _ := this.GetInt64("sourcetype")
36
+
34 37
 	//统计透析总量
35
-	_, total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid)
38
+	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
39
+
40
+	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
36 41
 
37
-	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid)
38 42
 	if err != nil {
39 43
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
40 44
 		return
@@ -52,10 +56,16 @@ func (this *NewCommonApiController) GetMobileTotalLapseCount() {
52 56
 
53 57
 	adminUser := this.GetMobileAdminUserInfo()
54 58
 	orgid := adminUser.Org.Id
59
+	lapsetotype, _ := this.GetInt64("lapsetotype")
60
+	sourcetype, _ := this.GetInt64("sourcetype")
55 61
 	//统计转出的病人
56
-	patient, err := service.GetTotalRollOutPatients(orgid, startime, endtime)
57
-	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startime, endtime)
58
-	count := service.GetPatientTotalCount(orgid)
62
+	patient, err := service.GetTotalRollOutPatients(orgid, startime, endtime, lapsetotype, sourcetype)
63
+
64
+	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startime, endtime, lapsetotype, sourcetype)
65
+	count := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
66
+	//统计当前机构转出的人数
67
+	rollout, err := service.GetCountRollout(orgid, startime, endtime, lapsetotype, sourcetype)
68
+	fmt.Println("roullout", rollout)
59 69
 	if err != nil {
60 70
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
61 71
 		return
@@ -64,6 +74,7 @@ func (this *NewCommonApiController) GetMobileTotalLapseCount() {
64 74
 		"patient":    patient,
65 75
 		"count":      count,
66 76
 		"patienttwo": patienttwo,
77
+		"rollout":    rollout,
67 78
 	})
68 79
 }
69 80
 
@@ -72,17 +83,21 @@ func (this *NewCommonApiController) GetMobileTotalSexCount() {
72 83
 	//fmt.Println("startime", startime)
73 84
 	//endtime, _ := this.GetInt64("endtime")
74 85
 	//fmt.Println("endtime", endtime)
86
+	lapsetotype, _ := this.GetInt64("lapsetotype")
87
+	sourcetype, _ := this.GetInt64("sourcetype")
75 88
 	adminUser := this.GetMobileAdminUserInfo()
76 89
 	orgid := adminUser.Org.Id
77
-	total := service.GetPatientTotalCount(orgid)
78
-	_, totalSex, err := service.GetManPatientTotal(orgid)
90
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
91
+	_, totalSex, err := service.GetManPatientTotal(orgid, lapsetotype, sourcetype)
92
+	_, totalWoman, err := service.GetWoManPatientTotal(orgid, lapsetotype, sourcetype)
79 93
 	if err != nil {
80 94
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
81 95
 		return
82 96
 	}
83 97
 	this.ServeSuccessJSON(map[string]interface{}{
84
-		"total":    total,
85
-		"totalSex": totalSex,
98
+		"total":      total,
99
+		"totalSex":   totalSex,
100
+		"totalWoman": totalWoman,
86 101
 	})
87 102
 }
88 103
 
@@ -93,10 +108,13 @@ func (this *NewCommonApiController) GetMobileTotalInfectiousCout() {
93 108
 
94 109
 	adminUser := this.GetMobileAdminUserInfo()
95 110
 	orgid := adminUser.Org.Id
111
+	lapsetotype, _ := this.GetInt64("lapsetotype")
112
+	sourcetype, _ := this.GetInt64("sourcetype")
113
+
96 114
 	//统计透析总人数
97
-	total := service.GetPatientTotalCount(orgid)
115
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
98 116
 	//统计透析人数传染病所占比例
99
-	count, err := service.GetPatientInfectiousCount(orgid, startime, endtime)
117
+	count, err := service.GetPatientInfectiousCount(orgid, startime, endtime, lapsetotype, sourcetype)
100 118
 	//统计其他
101 119
 	_, otherTotal, err := service.GetPatientOtherInfectious(orgid)
102 120
 	if err != nil {
@@ -114,11 +132,12 @@ func (this *NewCommonApiController) GetMobileTotalAgeCount() {
114 132
 	//startime, _ := this.GetInt64("startime")
115 133
 	//
116 134
 	//endtime, _ := this.GetInt64("endtime")
117
-
135
+	lapsetotype, _ := this.GetInt64("lapsetotype")
136
+	sourcetype, _ := this.GetInt64("sourcetype")
118 137
 	adminUser := this.GetMobileAdminUserInfo()
119 138
 	orgid := adminUser.Org.Id
120
-	total := service.GetPatientTotalCount(orgid)
121
-	agecount, err := service.GetTotalAgeCount(orgid)
139
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
140
+	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
122 141
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
123 142
 	if err != nil {
124 143
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -141,10 +160,12 @@ func (this *NewCommonApiController) GetMobileTotalDialysisCount() {
141 160
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
142 161
 	fmt.Println(parseDateErr)
143 162
 	nowtime := recordDate.Unix()
163
+	lapsetotype, _ := this.GetInt64("lapsetotype")
164
+	sourcetype, _ := this.GetInt64("sourcetype")
144 165
 	//统计透析总人数
145
-	total := service.GetPatientTotalCount(orgid)
166
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
146 167
 	//获取该机构下的所有病人数据
147
-	ageData, err := service.GetDialysisAgeData(orgid)
168
+	ageData, err := service.GetDialysisAgeData(orgid, lapsetotype, sourcetype)
148 169
 
149 170
 	if err != nil {
150 171
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -2123,8 +2144,10 @@ func (this *NewCommonApiController) GetMobileRolloutCount() {
2123 2144
 
2124 2145
 	adminUserInfo := this.GetMobileAdminUserInfo()
2125 2146
 	orgId := adminUserInfo.Org.Id
2147
+	lapsetotype, _ := this.GetInt64("lapsetotype")
2148
+	sourcetype, _ := this.GetInt64("sourcetype")
2126 2149
 	//统计当前机构转出的人数
2127
-	rollout, err := service.GetCountRollout(orgId, startimes, endtimeData)
2150
+	rollout, err := service.GetCountRollout(orgId, startimes, endtimeData, lapsetotype, sourcetype)
2128 2151
 
2129 2152
 	if err != nil {
2130 2153
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 226 - 6
controllers/schedule_api_controller.go View File

@@ -46,6 +46,16 @@ func ScheduleApiRegistRouters() {
46 46
 	beego.Router("/api/schedule/getallzones", &ScheduleApiController{}, "Get:GetAllZones")
47 47
 
48 48
 	beego.Router("/api/schedule/copypatientschedules", &ScheduleApiController{}, "Get:GetCopyPatientSchedules")
49
+
50
+	beego.Router("/api/schedule/saveremindprint", &ScheduleApiController{}, "Get:SaveRemindPrint")
51
+
52
+	beego.Router("/api/schedule/getremindprintlist", &ScheduleApiController{}, "Get:GetRemindPrintList")
53
+
54
+	beego.Router("/api/schedule/getbloodschedulelist", &ScheduleApiController{}, "Get:GetBloodScheduleList")
55
+
56
+	beego.Router("/api/schedule/getprintlist", &ScheduleApiController{}, "Get:GetPrintList")
57
+
58
+	beego.Router("/api/schedule/getallzonelist", &ScheduleApiController{}, "Get:GetAllZoneList")
49 59
 }
50 60
 
51 61
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -790,7 +800,7 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
790 800
 func (this *ScheduleApiController) GetWeekDaySchedule() {
791 801
 	week_type, _ := this.GetInt64("week_type", -1)
792 802
 	week_time, _ := this.GetInt64("week_time")
793
-	fmt.Println("week_time22222222222222", week_time)
803
+
794 804
 	thisTime := time.Now()
795 805
 	weekDay := int(thisTime.Weekday())
796 806
 	if weekDay == 0 {
@@ -811,7 +821,14 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
811 821
 	fmt.Println(days)
812 822
 
813 823
 	var targetDayStr string
824
+	var startTime string
825
+	var endTime string
814 826
 	switch week_type {
827
+	case 0:
828
+		{
829
+			startTime = days[0]
830
+			endTime = days[6]
831
+		}
815 832
 	case 1:
816 833
 		targetDayStr = days[0]
817 834
 		break
@@ -841,14 +858,17 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
841 858
 		break
842 859
 	}
843 860
 	targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
844
-
861
+	startDay, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
862
+	endDay, _ := utils.ParseTimeStringToTime("2006-01-02", endTime)
863
+	fmt.Println(startDay, endDay)
845 864
 	if parseErr != nil {
846 865
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
847 866
 		return
848 867
 	}
849 868
 
850
-	adminUserInfo := this.GetAdminUserInfo()
851
-	list, _ := service.GetWeekDayScheduleTwo(adminUserInfo.CurrentOrgId, targetDay.Unix(), targetDay, week_time)
869
+	orgId := this.GetAdminUserInfo().CurrentOrgId
870
+
871
+	list, _ := service.GetWeekDayScheduleTwo(orgId, targetDay.Unix(), targetDay, week_time)
852 872
 
853 873
 	this.ServeSuccessJSON(map[string]interface{}{
854 874
 		"schdules": list,
@@ -1950,10 +1970,10 @@ func (this *ScheduleApiController) GetNextWeekDaySchedule() {
1950 1970
 	week_time, _ := this.GetInt64("week_time")
1951 1971
 	start_time, _ := this.GetInt64("start_time")
1952 1972
 	end_time, _ := this.GetInt64("end_time")
1953
-
1973
+	zone, _ := this.GetInt64("zone")
1954 1974
 	adminUserInfo := this.GetAdminUserInfo()
1955 1975
 
1956
-	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId)
1976
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone)
1957 1977
 	if err != nil {
1958 1978
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1959 1979
 		return
@@ -2191,3 +2211,203 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2191 2211
 	//	}
2192 2212
 	//}
2193 2213
 }
2214
+
2215
+func (this *ScheduleApiController) SaveRemindPrint() {
2216
+
2217
+	id, _ := this.GetInt64("id")
2218
+	anticoagulants, _ := this.GetInt64("anticoagulant")
2219
+	anticoagulant_zongliang, _ := this.GetInt64("anticoagulant_zongliang")
2220
+	classes, _ := this.GetInt64("classes")
2221
+	dialyzers, _ := this.GetInt64("dialyzers")
2222
+	doctor_advice, _ := this.GetInt64("doctor_advice")
2223
+	mode, _ := this.GetInt64("mode")
2224
+	name, _ := this.GetInt64("name")
2225
+	number, _ := this.GetInt64("number")
2226
+	perfusion_apparatus, _ := this.GetInt64("perfusion_apparatus")
2227
+	prescription_status, _ := this.GetInt64("prescription_status")
2228
+	week, _ := this.GetInt64("week")
2229
+	zone, _ := this.GetInt64("zone")
2230
+	adminUserInfo := this.GetAdminUserInfo()
2231
+	orgId := adminUserInfo.CurrentOrgId
2232
+	setting := models.XtRemindPrintSetting{
2233
+		Anticoagulant:          anticoagulants,
2234
+		Classes:                classes,
2235
+		AnticoagulantZongliang: anticoagulant_zongliang,
2236
+		Dialyzers:              dialyzers,
2237
+		DoctorAdvice:           doctor_advice,
2238
+		Mode:                   mode,
2239
+		Name:                   name,
2240
+		Number:                 number,
2241
+		PerfusionApparatus:     perfusion_apparatus,
2242
+		PrescriptionStatus:     prescription_status,
2243
+		Week:                   week,
2244
+		Zone:                   zone,
2245
+		UserOrgId:              orgId,
2246
+		Status:                 1,
2247
+		Ctime:                  time.Now().Unix(),
2248
+	}
2249
+	_, errcode := service.GetSettingById(id)
2250
+	if errcode == gorm.ErrRecordNotFound {
2251
+		err := service.CreateSetting(&setting)
2252
+		if err != nil {
2253
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2254
+			return
2255
+		}
2256
+
2257
+		this.ServeSuccessJSON(map[string]interface{}{
2258
+			"setting": setting,
2259
+		})
2260
+	} else if errcode == nil {
2261
+		err := service.UpdatedRemindPrint(&setting, id)
2262
+		if err != nil {
2263
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2264
+			return
2265
+		}
2266
+
2267
+		this.ServeSuccessJSON(map[string]interface{}{
2268
+			"setting": setting,
2269
+		})
2270
+	}
2271
+
2272
+}
2273
+func (this *ScheduleApiController) GetRemindPrintList() {
2274
+
2275
+	adminUserInfo := this.GetAdminUserInfo()
2276
+	orgId := adminUserInfo.CurrentOrgId
2277
+	list, err := service.GetRemindPrintList(orgId)
2278
+	if err != nil {
2279
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2280
+		return
2281
+	}
2282
+
2283
+	this.ServeSuccessJSON(map[string]interface{}{
2284
+		"list": list,
2285
+	})
2286
+}
2287
+
2288
+func (this *ScheduleApiController) GetBloodScheduleList() {
2289
+
2290
+	week_type, _ := this.GetInt64("week_type", -1)
2291
+	week_time, _ := this.GetInt64("week_time")
2292
+	zone, _ := this.GetInt64("zone")
2293
+	thisTime := time.Now()
2294
+	weekDay := int(thisTime.Weekday())
2295
+	if weekDay == 0 {
2296
+		weekDay = 7
2297
+	}
2298
+	weekEnd := 7 - weekDay
2299
+	weekStart := weekEnd - 6
2300
+	weekTitle := make([]string, 0)
2301
+	days := make([]string, 0)
2302
+	for index := weekStart; index <= weekEnd; index++ {
2303
+		theDay := thisTime.AddDate(0, 0, index)
2304
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2305
+		indexMonth := int(indexMonthTime)
2306
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2307
+		weekTitle = append(weekTitle, indexWeek)
2308
+		days = append(days, theDay.Format("2006-01-02"))
2309
+	}
2310
+	fmt.Println(days)
2311
+
2312
+	var targetDayStr string
2313
+	var startTime string
2314
+	switch week_type {
2315
+	case 0:
2316
+		startTime = days[0]
2317
+		targetDayStr = days[6]
2318
+		break
2319
+	case 1:
2320
+		targetDayStr = days[0]
2321
+		break
2322
+	case 2:
2323
+		targetDayStr = days[1]
2324
+
2325
+		break
2326
+	case 3:
2327
+		targetDayStr = days[2]
2328
+
2329
+		break
2330
+	case 4:
2331
+		targetDayStr = days[3]
2332
+
2333
+		break
2334
+	case 5:
2335
+		targetDayStr = days[4]
2336
+
2337
+		break
2338
+	case 6:
2339
+		targetDayStr = days[5]
2340
+
2341
+		break
2342
+	case 7:
2343
+		targetDayStr = days[6]
2344
+
2345
+		break
2346
+	}
2347
+	targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
2348
+
2349
+	if parseErr != nil {
2350
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2351
+		return
2352
+	}
2353
+
2354
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2355
+	if week_type > 0 {
2356
+		list, err := service.GetWeekDayScheduleById(orgId, targetDay.Unix(), week_time)
2357
+		if err != nil {
2358
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2359
+			return
2360
+		}
2361
+
2362
+		this.ServeSuccessJSON(map[string]interface{}{
2363
+			"list": list,
2364
+			"day":  targetDayStr,
2365
+		})
2366
+	}
2367
+
2368
+	if week_type == 0 {
2369
+		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
2370
+		list, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone)
2371
+		if err != nil {
2372
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2373
+			return
2374
+		}
2375
+
2376
+		this.ServeSuccessJSON(map[string]interface{}{
2377
+			"list": list,
2378
+			"day":  targetDayStr,
2379
+		})
2380
+	}
2381
+
2382
+}
2383
+
2384
+func (this *ScheduleApiController) GetPrintList() {
2385
+
2386
+	adminUserInfo := this.GetAdminUserInfo()
2387
+	orgId := adminUserInfo.CurrentOrgId
2388
+
2389
+	list, err := service.GetRemindPrintList(orgId)
2390
+	if err != nil {
2391
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2392
+		return
2393
+	}
2394
+
2395
+	this.ServeSuccessJSON(map[string]interface{}{
2396
+		"list": list,
2397
+	})
2398
+}
2399
+
2400
+func (this *ScheduleApiController) GetAllZoneList() {
2401
+
2402
+	adminUserInfo := this.GetAdminUserInfo()
2403
+	orgId := adminUserInfo.CurrentOrgId
2404
+	zoneList, err := service.GetAllZoneOne(orgId)
2405
+	if err != nil {
2406
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2407
+		return
2408
+	}
2409
+
2410
+	this.ServeSuccessJSON(map[string]interface{}{
2411
+		"zoneList": zoneList,
2412
+	})
2413
+}

+ 25 - 0
models/device_models.go View File

@@ -1022,3 +1022,28 @@ func (XtDevicePh) TableName() string {
1022 1022
 
1023 1023
 	return "xt_device_ph"
1024 1024
 }
1025
+
1026
+type XtRemindPrintSetting struct {
1027
+	ID                     int64 `gorm:"column:id" json:"id" form:"id"`
1028
+	PrescriptionStatus     int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
1029
+	Week                   int64 `gorm:"column:week" json:"week" form:"week"`
1030
+	Name                   int64 `gorm:"column:name" json:"name" form:"name"`
1031
+	Zone                   int64 `gorm:"column:zone" json:"zone" form:"zone"`
1032
+	Classes                int64 `gorm:"column:classes" json:"classes" form:"classes"`
1033
+	Number                 int64 `gorm:"column:number" json:"number" form:"number"`
1034
+	Mode                   int64 `gorm:"column:mode" json:"mode" form:"mode"`
1035
+	Dialyzers              int64 `gorm:"column:dialyzers" json:"dialyzers" form:"dialyzers"`
1036
+	PerfusionApparatus     int64 `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
1037
+	Anticoagulant          int64 `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
1038
+	DoctorAdvice           int64 `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
1039
+	UserOrgId              int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1040
+	Status                 int64 `gorm:"column:status" json:"status" form:"status"`
1041
+	Ctime                  int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1042
+	Mtime                  int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1043
+	AnticoagulantZongliang int64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
1044
+}
1045
+
1046
+func (XtRemindPrintSetting) TableName() string {
1047
+
1048
+	return "xt_remind_print_setting"
1049
+}

+ 3 - 0
models/dialysis.go View File

@@ -596,6 +596,8 @@ type AssessmentAfterDislysis struct {
596 596
 	Hypopiesia                      int64   `gorm:"column:hypopiesia" json:"hypopiesia" form:"hypopiesia"`
597 597
 	LeaveOfficeMethod               int64   `gorm:"column:leave_office_method" json:"leave_office_method" form:"leave_office_method"`
598 598
 	Lapse                           int64   `gorm:"column:lapse" json:"lapse" form:"lapse"`
599
+	Consciousness                   int64   `gorm:"column:consciousness" json:"consciousness" form:"consciousness"`
600
+	Fallrisk                        int64   `gorm:"column:fallrisk" json:"fallrisk" form:"fallrisk"`
599 601
 }
600 602
 
601 603
 func (AssessmentAfterDislysis) TableName() string {
@@ -879,6 +881,7 @@ type ReceiveTreatmentAsses struct {
879 881
 	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
880 882
 	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
881 883
 	AdmissionNumber              string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
884
+	Tumble                       int64  `gorm:"column:tumble" json:"tumble" form:"tumble"`
882 885
 }
883 886
 
884 887
 func (ReceiveTreatmentAsses) TableName() string {

+ 4 - 0
models/patient_models.go View File

@@ -331,6 +331,10 @@ type DialysisSolution struct {
331 331
 	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv"`
332 332
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
333 333
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
334
+	AntioxidantCommodityName   string  `gorm:"column:antioxidant_commodity_name" json:"antioxidant_commodity_name" form:"antioxidant_commodity_name"`
335
+	DisplaceSpeed              string  `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
336
+	Illness                    int64   `gorm:"column:illness" json:"illness" form:"illness"`
337
+	Amylaceum                  string  `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
334 338
 }
335 339
 
336 340
 func (DialysisSolution) TableName() string {

+ 45 - 17
models/schedule_models.go View File

@@ -1,6 +1,6 @@
1 1
 package models
2 2
 
3
-type Schedule struct {
3
+type VmSchedules struct {
4 4
 	ID           int64 `gorm:"column:id" json:"id" form:"id"`
5 5
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6 6
 	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
@@ -15,20 +15,20 @@ type Schedule struct {
15 15
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
16 16
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
17 17
 
18
-	Patient       string        `gorm:"-" json:"patient" form:"patient"`
19
-	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
20
-	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
21
-	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
22
-	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
23
-
24
-	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
18
+	DeviceZone           DeviceZone             `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
19
+	DeviceNumber         DeviceNumber           `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
20
+	DialysisOrder        DialysisOrder          `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
21
+	XtPatients           XtPatients             `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
22
+	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
23
+	DialysisPrescription DialysisPrescription   `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
24
+	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
25 25
 }
26 26
 
27
-func (Schedule) TableName() string {
27
+func (VmSchedules) TableName() string {
28 28
 	return "xt_schedule"
29 29
 }
30 30
 
31
-type SchedulePatients struct {
31
+type Schedule struct {
32 32
 	ID           int64 `gorm:"column:id" json:"id" form:"id"`
33 33
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
34 34
 	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
@@ -42,13 +42,40 @@ type SchedulePatients struct {
42 42
 	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
43 43
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
44 44
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
45
-	Patient      PatientListForFace        `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
45
+
46
+	Patient       string        `gorm:"-" json:"patient" form:"patient"`
47
+	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
48
+	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
49
+	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
50
+	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
51
+
52
+	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
46 53
 }
47 54
 
48
-func (SchedulePatients) TableName() string {
55
+func (Schedule) TableName() string {
49 56
 	return "xt_schedule"
50 57
 }
51 58
 
59
+type SchedulePatients struct {
60
+	ID           int64              `gorm:"column:id" json:"id" form:"id"`
61
+	UserOrgId    int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
62
+	PartitionId  int64              `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
63
+	BedId        int64              `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
64
+	PatientId    int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
65
+	ScheduleDate int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
66
+	ScheduleType int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
67
+	ScheduleWeek int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
68
+	ModeId       int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
69
+	Status       int64              `gorm:"column:status" json:"status" form:"status"`
70
+	CreatedTime  int64              `gorm:"column:created_time" json:"created_time" form:"created_time"`
71
+	UpdatedTime  int64              `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
72
+	IsExport     int64              `gorm:"column:is_export" json:"is_export" form:"is_export"`
73
+	Patient      PatientListForFace `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
74
+}
75
+
76
+func (SchedulePatients) TableName() string {
77
+	return "xt_schedule"
78
+}
52 79
 
53 80
 type PatientSchedule struct {
54 81
 	Schedule
@@ -104,11 +131,12 @@ type WeekSchedule struct {
104 131
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
105 132
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
106 133
 
107
-	Patient              string           `gorm:"-" json:"patient" form:"patient"`
108
-	DeviceZone           DeviceZone       `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
109
-	DeviceNumber         DeviceNumber     `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
110
-	DialysisPrescription DialysisSolution `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
111
-	DoctorAdvice         []*DoctorAdvice  `json:"doctor_advice" gorm:"-"`
134
+	Patient              string                 `gorm:"-" json:"patient" form:"patient"`
135
+	DeviceZone           DeviceZone             `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
136
+	DeviceNumber         DeviceNumber           `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
137
+	DialysisPrescription DialysisSolution       `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
138
+	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
139
+	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
112 140
 }
113 141
 
114 142
 func (WeekSchedule) TableName() string {

+ 197 - 34
service/common_service.go View File

@@ -204,19 +204,64 @@ func DeleteCheck(id int64) error {
204 204
 	return err
205 205
 }
206 206
 
207
-func GetDialysiTotal(startime int64, endtime int64, orgid int64) (order []*models.DialysisOrder, total int64, err error) {
208
-	err = XTReadDB().Model(&order).Where("dialysis_date >= ? and dialysis_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&order).Error
209
-	return order, total, err
207
+//
208
+//func GetDialysiTotal(startime int64, endtime int64, orgid int64,lapsetotype int64,sourcetype int64) (order []*models.DialysisOrder, total int64, err error) {
209
+//	err = XTReadDB().Model(&order).Where("dialysis_date >= ? and dialysis_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&order).Error
210
+//	return order, total, err
211
+//}
212
+
213
+func GetDialysiTotal(startime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (models.PatientPrescriptionCountStruct, error) {
214
+	counts := models.PatientPrescriptionCountStruct{}
215
+
216
+	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
217
+	table := XTReadDB().Table("xt_paitents as s").Where("s.status = 1")
218
+	fmt.Println(table)
219
+
220
+	if lapsetotype > 0 {
221
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.lapseto = ?", startime, endtime, orgid, lapsetotype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
222
+	}
223
+	if lapsetotype == 0 {
224
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? ", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
225
+	}
226
+
227
+	if sourcetype > 0 {
228
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.source = ?", startime, endtime, orgid, sourcetype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
229
+	}
210 230
 
231
+	if sourcetype == 0 {
232
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ?", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
233
+	}
234
+
235
+	return counts, err
211 236
 }
212 237
 
213
-func GetDialysisCountMode(starttime int64, endtime int64, orgid int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
214
-	//err = readDb.Table("xt_dialysis_prescription as p").Where("p.record_date>= ? and p.record_date<=? and p.user_org_id=?", starttime, endtime, orgid).Select("p.mode_id,count(p.mode_id) as count").Group("p.mode_id").Scan(&counts).Error
238
+func GetDialysisCountMode(starttime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
239
+
240
+	//err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
215 241
 	//return counts, err
216 242
 
217
-	err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
243
+	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
244
+	table := readDb.Table("xt_schedule as s").Where("s.status = 1")
245
+	fmt.Println(table)
246
+	p := readDb.Table("xt_patients as p").Where("p.status = 1")
247
+	fmt.Println(p)
248
+	if starttime > 0 {
249
+		db = db.Where("o.dialysis_date >=?", starttime)
250
+	}
251
+	if endtime > 0 {
252
+		db = db.Where("o.dialysis_date<=?", endtime)
253
+	}
254
+	if orgid > 0 {
255
+		db = db.Where("o.user_org_id = ?", orgid)
256
+	}
257
+	if lapsetotype > 0 {
258
+		db = db.Where("p.lapseto = ?", lapsetotype)
259
+	}
260
+	if sourcetype > 0 {
261
+		db = db.Where("p.source = ?", sourcetype)
262
+	}
263
+	err = db.Select("s.mode_id,count(s.mode_id) as count").Joins("left join xt_schedule as s on s.patient_id = o.patient_id and s.schedule_date = o.dialysis_date and s.status= 1").Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
218 264
 	return counts, err
219
-
220 265
 }
221 266
 
222 267
 func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*models.PatientLapseto, total int64, err error) {
@@ -228,22 +273,41 @@ func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*mod
228 273
 	return counts, total, err
229 274
 }
230 275
 
231
-func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
276
+func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
277
+
278
+	db := XTReadDB().Table("xt_patients as x")
232 279
 
233
-	db := XTReadDB().Table("x.patients as x")
234
-	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
280
+	if sourcetype == 0 {
281
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
282
+	}
283
+	if sourcetype > 0 {
284
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
285
+	}
235 286
 	return patients, err
236 287
 }
237 288
 
238
-func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
289
+func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
290
+
291
+	db := XTReadDB().Table("xt_patients as x")
292
+	if sourcetype == 0 {
293
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
239 294
 
240
-	db := XTReadDB().Table("x.patients as x")
241
-	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
295
+	}
296
+	if sourcetype > 0 {
297
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
298
+	}
242 299
 	return patients, err
243 300
 }
244 301
 
245
-func GetPatientTotalCount(orgID int64) (total int64) {
246
-	readDb.Model(&models.XtPatients{}).Where("user_org_id=? and status=1", orgID).Count(&total)
302
+func GetPatientTotalCount(orgID int64, lapsetotype int64, sourcetype int64) (total int64) {
303
+	db := readDb.Table("xt_patients as x")
304
+	//if lapsetotype > 0 {
305
+	// db = db.Where("x.lapseto = ?", lapsetotype)
306
+	//}
307
+	//if sourcetype > 0 {
308
+	// db = db.Where("x.source = ?", sourcetype)
309
+	//}
310
+	db.Where("x.user_org_id=? and x.status=1", orgID).Count(&total)
247 311
 	return
248 312
 }
249 313
 
@@ -263,9 +327,28 @@ func GetManPatientTotalCount(orgid int64, starttime int64, endtime int64) (dialy
263 327
 
264 328
 }
265 329
 
266
-func GetManPatientTotal(orgid int64) (patients []*models.XtPatients, total int64, err error) {
330
+func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
267 331
 
268
-	err = XTReadDB().Model(&patients).Where("user_org_id = ? and status = 1 and gender = 1", orgid).Count(&total).Find(&patients).Error
332
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
333
+	if lapsetotype > 0 {
334
+		db = db.Where("x.lapseto = ?", lapsetotype)
335
+	}
336
+	if sourcetype > 0 {
337
+		db = db.Where("x.source = ?", sourcetype)
338
+	}
339
+	err = db.Where("x.user_org_id = ? and x.status = 1 and x.gender = 1", orgid).Count(&total).Find(&patients).Error
340
+	return patients, total, err
341
+}
342
+
343
+func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
344
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
345
+	if lapsetotype > 0 {
346
+		db = db.Where("x.lapseto = ?", lapsetotype)
347
+	}
348
+	if sourcetype > 0 {
349
+		db = db.Where("x.source = ?", sourcetype)
350
+	}
351
+	err = db.Where("x.user_org_id = ? and x.status = 1 and x.gender = 2", orgid).Count(&total).Find(&patients).Error
269 352
 	return patients, total, err
270 353
 }
271 354
 
@@ -274,10 +357,25 @@ func GetManPatientTotal(orgid int64) (patients []*models.XtPatients, total int64
274 357
 //	return counts, err
275 358
 //}
276 359
 
277
-func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64) (counts []*models.PatientContagionsCountStruct, err error) {
360
+func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientContagionsCountStruct, err error) {
361
+
362
+	if lapsetotype == 0 {
363
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
364
+	}
365
+	if sourcetype == 0 {
366
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
367
+	}
368
+
369
+	if lapsetotype > 0 {
370
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
371
+	}
372
+
373
+	if sourcetype > 0 {
374
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
375
+	}
278 376
 
279
-	err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
280 377
 	return counts, err
378
+
281 379
 }
282 380
 
283 381
 func GetPatientOtherInfectious(orgid int64) (patients []*models.XtPatients, total int64, err error) {
@@ -286,9 +384,10 @@ func GetPatientOtherInfectious(orgid int64) (patients []*models.XtPatients, tota
286 384
 	return patients, total, err
287 385
 }
288 386
 
289
-func GetTotalAgeCount(orgid int64) (counts []*models.PatientAgeCountStruct, err error) {
387
+func GetTotalAgeCount(orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientAgeCountStruct, err error) {
290 388
 
291
-	readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
389
+	if lapsetotype == 0 || sourcetype == 0 {
390
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
292 391
 	 SELECT
293 392
 	 CASE
294 393
 	  WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
@@ -299,8 +398,39 @@ func GetTotalAgeCount(orgid int64) (counts []*models.PatientAgeCountStruct, err
299 398
 	 END
300 399
 	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1
301 400
 	 )a GROUP BY nnd`, orgid).Scan(&counts)
302
-	return
303 401
 
402
+	}
403
+
404
+	if lapsetotype > 0 {
405
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
406
+	 SELECT
407
+	 CASE
408
+	  WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
409
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=40 THEN '40'
410
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=60 THEN '60'
411
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
412
+    ELSE '150'
413
+	 END
414
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.lapseto = ?
415
+	 )a GROUP BY nnd`, orgid, lapsetotype).Scan(&counts)
416
+
417
+	}
418
+
419
+	if sourcetype > 0 {
420
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
421
+	 SELECT
422
+	 CASE
423
+	  WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
424
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=40 THEN '40'
425
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=60 THEN '60'
426
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
427
+    ELSE '150'
428
+	 END
429
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.source = ?
430
+	 )a GROUP BY nnd`, orgid, sourcetype).Scan(&counts)
431
+
432
+	}
433
+	return
304 434
 }
305 435
 
306 436
 func GetTotalAgeCountTwo(orgid int64, starttime int64, endtime int64) (counts []*models.PatientAgeCountStruct, err error) {
@@ -320,18 +450,42 @@ func GetTotalDialysisAgeCount(orgid int64) (patients []*models.XtPatients, err e
320 450
 	return patients, err
321 451
 }
322 452
 
323
-func GetDialysisAgeData(orgID int64) (counts []*models.DialysisAgePieDataStruct, err error) {
453
+func GetDialysisAgeData(orgID int64, lapsetotype int64, sourcetype int64) (counts []*models.DialysisAgePieDataStruct, err error) {
324 454
 
325
-	readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
326
-	SELECT
327
-	CASE
328
-	WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
329
-  WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
330
-  WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
331
-  WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
332
-  END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0)a GROUP BY nnd`, orgID).Scan(&counts)
333
-	return
455
+	if lapsetotype == 0 || sourcetype == 0 {
456
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
457
+    SELECT
458
+    CASE
459
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
460
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
461
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
462
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
463
+    END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0)a GROUP BY nnd`, orgID).Scan(&counts)
464
+	}
465
+
466
+	if lapsetotype > 0 {
467
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
468
+    SELECT
469
+    CASE
470
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
471
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
472
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
473
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
474
+    END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0 and p.lapseto = ?)a GROUP BY nnd`, orgID, lapsetotype).Scan(&counts)
475
+	}
476
+
477
+	if sourcetype > 0 {
478
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
479
+    SELECT
480
+    CASE
481
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
482
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
483
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
484
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
485
+    END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0 and p.source = ?)a GROUP BY nnd`, orgID, sourcetype).Scan(&counts)
486
+	}
334 487
 
488
+	return
335 489
 }
336 490
 
337 491
 func GetCurentOrgPatients(orgid int64) (patients []*models.BloodXtPatients, err error) {
@@ -3375,7 +3529,7 @@ func GetCountModeId(startime int64, endtime int64, modeid int64, orgid int64) (o
3375 3529
 
3376 3530
 }
3377 3531
 
3378
-func GetCountRollout(orgid int64, startime int64, endtime int64) (lapseto []*models.BloodLapsetoCount, err error) {
3532
+func GetCountRollout(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (lapseto []*models.BloodLapsetoCount, err error) {
3379 3533
 
3380 3534
 	table := XTReadDB().Table("xt_patients as s")
3381 3535
 	fmt.Println(table)
@@ -3386,6 +3540,15 @@ func GetCountRollout(orgid int64, startime int64, endtime int64) (lapseto []*mod
3386 3540
 	if endtime > 0 {
3387 3541
 		db = db.Where("x.lapseto_time<=?", endtime)
3388 3542
 	}
3389
-	err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ?", orgid).Scan(&lapseto).Error
3543
+	if lapsetotype == 0 || sourcetype == 0 {
3544
+		err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ?", orgid).Scan(&lapseto).Error
3545
+	}
3546
+
3547
+	if lapsetotype > 0 {
3548
+		err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ? and s.lapseto = ?", orgid, lapsetotype).Scan(&lapseto).Error
3549
+	}
3550
+	if sourcetype > 0 {
3551
+		err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ? and s.source = ?", orgid, sourcetype).Scan(&lapseto).Error
3552
+	}
3390 3553
 	return lapseto, err
3391 3554
 }

+ 83 - 5
service/schedule_service.go View File

@@ -19,7 +19,7 @@ func GetSchedulePartitionPanel(orgID int64) (partitions []*models.Partition, err
19 19
 }
20 20
 
21 21
 func GetSchedulePartitionPanelOne(orgID int64, partionId int64) (partitions []*models.Partition, err error) {
22
-	fmt.Println("partionId3333333333333333", partionId)
22
+
23 23
 	if partionId > 0 {
24 24
 		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1 and zone_id = ?", orgID, partionId).Where("org_id=? and status=1 and id = ?", orgID, partionId).Find(&partitions).Error
25 25
 	}
@@ -534,6 +534,49 @@ func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Tim
534 534
 	return
535 535
 }
536 536
 
537
+func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64) (list []*models.VmSchedules, err error) {
538
+
539
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
540
+	if orgid > 0 {
541
+		db = db.Where("x.user_org_id = ?", orgid)
542
+	}
543
+	if scheduleDate > 0 {
544
+		db = db.Where("x.schedule_date = ?", scheduleDate)
545
+	}
546
+	if scheduleType > 0 {
547
+		db = db.Where("x.schedule_type = ?", scheduleType)
548
+	}
549
+
550
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
551
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
552
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Find(&list).Error
553
+
554
+	return list, err
555
+}
556
+
557
+func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone int64) (list []*models.VmSchedules, err error) {
558
+
559
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
560
+	if orgid > 0 {
561
+		db = db.Where("x.user_org_id = ?", orgid)
562
+	}
563
+	if scheduleDate > 0 {
564
+		db = db.Where("x.schedule_date >=? and x.schedule_date<=?", startDate, scheduleDate)
565
+	}
566
+	if scheduleType > 0 {
567
+		db = db.Where("x.schedule_type = ?", scheduleType)
568
+	}
569
+	if zone > 0 {
570
+		db = db.Where("s.partition_id = ?", zone)
571
+	}
572
+
573
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
574
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
575
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Find(&list).Error
576
+
577
+	return list, err
578
+}
579
+
537 580
 func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
538 581
 	newArr = make([]*models.DoctorAdvice, 0)
539 582
 	for i := 0; i < len(arr); i++ {
@@ -678,7 +721,7 @@ func UpdateNewScheduleTemplateStatus(id int64, org_id int64) (err error) {
678 721
 	return
679 722
 }
680 723
 
681
-func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64) (schedules []*models.WeekSchedule, err error) {
724
+func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone int64) (schedules []*models.WeekSchedule, err error) {
682 725
 
683 726
 	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
684 727
 	if orgID > 0 {
@@ -696,14 +739,18 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
696 739
 	if weektype > 0 {
697 740
 		db = db.Where("s.schedule_week = ?", weektype)
698 741
 	}
742
+	if zone > 0 {
743
+		db = db.Where("s.partition_id = ?", zone)
744
+	}
699 745
 	err = db.
700 746
 		Preload("DeviceZone", "status = 1 ").
701 747
 		Preload("DeviceNumber", "status = 1 ").
702 748
 		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
703 749
 			return db.Where("status = 1").Order("id asc")
704
-		}).
705
-		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
706
-		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
750
+		}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
751
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
752
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
753
+		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
707 754
 		Order("s.partition_id asc").
708 755
 		Find(&schedules).Error
709 756
 	return schedules, err
@@ -768,3 +815,34 @@ func UpdatePatientSchedule(orgid int64, startime int64, endtime int64) error {
768 815
 	err := XTWriteDB().Model(&schedule).Where("user_org_id = ? and schedule_date>=? and schedule_date<=? and status =1", orgid, startime, endtime).Updates(map[string]interface{}{"status": 0}).Error
769 816
 	return err
770 817
 }
818
+
819
+func GetSettingById(id int64) (*models.XtRemindPrintSetting, error) {
820
+	setting := models.XtRemindPrintSetting{}
821
+	err := XTReadDB().Model(&setting).Where("id = ? and status = 1", id).Find(&setting).Error
822
+	if err == gorm.ErrRecordNotFound {
823
+		return nil, err
824
+	}
825
+	if err != nil {
826
+		return nil, err
827
+	}
828
+	return &setting, nil
829
+}
830
+
831
+func CreateSetting(setting *models.XtRemindPrintSetting) error {
832
+
833
+	err := XTReadDB().Create(&setting).Error
834
+	return err
835
+}
836
+
837
+func UpdatedRemindPrint(set *models.XtRemindPrintSetting, id int64) error {
838
+
839
+	err := XTWriteDB().Model(&set).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"prescription_status": set.PrescriptionStatus, "week": set.Week, "name": set.Name, "zone": set.Zone, "classes": set.Classes, "number": set.Number, "mode": set.Mode, "dialyzers": set.Dialyzers, "perfusion_apparatus": set.PerfusionApparatus, "anticoagulant": set.Anticoagulant, "doctor_advice": set.DoctorAdvice, "anticoagulant_zongliang": set.AnticoagulantZongliang}).Error
840
+	return err
841
+}
842
+
843
+func GetRemindPrintList(id int64) (models.XtRemindPrintSetting, error) {
844
+
845
+	setting := models.XtRemindPrintSetting{}
846
+	err := XTReadDB().Model(&setting).Where("user_org_id = ? and status =1", id).Find(&setting).Error
847
+	return setting, err
848
+}