瀏覽代碼

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

XMLWAN 4 年之前
父節點
當前提交
4ffa77cc0f

+ 7 - 7
conf/app.conf 查看文件

143
 [dev]
143
 [dev]
144
 mobile_token_expiration_second = 3600
144
 mobile_token_expiration_second = 3600
145
 httpdomain = http://new_mobile.xt.api.sgjyun.com
145
 httpdomain = http://new_mobile.xt.api.sgjyun.com
146
-sso_domain = https://testsso.sgjyun.com
146
+sso_domain = http://testsso.sgjyun.com
147
 front_end_domain = "http://xt.test.sgjyun.com/#"
147
 front_end_domain = "http://xt.test.sgjyun.com/#"
148
 
148
 
149
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
149
 readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
150
 readmysqlport = 3306
150
 readmysqlport = 3306
151
 readmysqluser = root
151
 readmysqluser = root
152
 readmysqlpass = 1Q2W3e4r!@#$
152
 readmysqlpass = 1Q2W3e4r!@#$
153
-readmysqlname = sgj_xt
153
+readmysqlname = test_xt
154
 
154
 
155
 writemysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
155
 writemysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
156
 writemysqlport = 3306
156
 writemysqlport = 3306
157
 writemysqluser = root
157
 writemysqluser = root
158
 writemysqlpass = 1Q2W3e4r!@#$
158
 writemysqlpass = 1Q2W3e4r!@#$
159
-writemysqlname = sgj_xt
159
+writemysqlname = test_xt
160
 
160
 
161
 readuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
161
 readuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
162
 readuserport = 3306
162
 readuserport = 3306
163
 readuseruser = root
163
 readuseruser = root
164
 readuserpass = 1Q2W3e4r!@#$
164
 readuserpass = 1Q2W3e4r!@#$
165
-readusername = sgj_users
165
+readusername = test_users
166
 
166
 
167
 
167
 
168
 writeuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
168
 writeuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
169
 writeuserport = 3306
169
 writeuserport = 3306
170
 writeuseruser = root
170
 writeuseruser = root
171
 writeuserpass = 1Q2W3e4r!@#$
171
 writeuserpass = 1Q2W3e4r!@#$
172
-writeusername = sgj_users
172
+writeusername = test_users
173
 
173
 
174
 
174
 
175
 
175
 
215
 
215
 
216
 
216
 
217
 #redishost = 120.77.235.13
217
 #redishost = 120.77.235.13
218
-#redishost = 112.74.16.180
219
-redishost = localhost
218
+redishost = 112.74.16.180
219
+# redishost = localhost
220
 redisport = 6379
220
 redisport = 6379
221
 redispasswrod = 123456
221
 redispasswrod = 123456
222
 redisdb = 0
222
 redisdb = 0

+ 3 - 3
controllers/dialysis_api_controller.go 查看文件

3303
 		dewater_amount = 0
3303
 		dewater_amount = 0
3304
 		if evaluation.DryWeight > 0 {
3304
 		if evaluation.DryWeight > 0 {
3305
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3305
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3306
-			if templateInfo.TemplateId == 17 {
3306
+			if templateInfo.TemplateId == 17 && templateInfo.TemplateId == 22 {
3307
 				dewater_amount = dewater_amount * 1000
3307
 				dewater_amount = dewater_amount * 1000
3308
 			}
3308
 			}
3309
 			if dewater_amount <= 0 {
3309
 			if dewater_amount <= 0 {
4863
 				record.UltrafiltrationRate = ultrafiltration_rate
4863
 				record.UltrafiltrationRate = ultrafiltration_rate
4864
 			}
4864
 			}
4865
 
4865
 
4866
-			if template.TemplateId == 20 { //adminInfo.CurrentOrgId == 9538
4866
+			if template.TemplateId == 20 || template.TemplateId == 22 { //adminInfo.CurrentOrgId == 9538
4867
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
4867
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
4868
 				record.UltrafiltrationRate = ultrafiltration_rate
4868
 				record.UltrafiltrationRate = ultrafiltration_rate
4869
 			}
4869
 			}
4885
 		}
4885
 		}
4886
 	}
4886
 	}
4887
 
4887
 
4888
-	if template.TemplateId == 6 || template.TemplateId == 20 {
4888
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 {
4889
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
4889
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
4890
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
4890
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
4891
 			record.UltrafiltrationVolume = ultrafiltration_volume
4891
 			record.UltrafiltrationVolume = ultrafiltration_volume

+ 5 - 2
controllers/dialysis_record_api_controller.go 查看文件

741
 						}
741
 						}
742
 						//查出入库记录中最后一条记录
742
 						//查出入库记录中最后一条记录
743
 						stockInInfo, _ := service.FindLastStockInInfoRecord(prescription.Niprocart, adminUserInfo.CurrentOrgId)
743
 						stockInInfo, _ := service.FindLastStockInInfoRecord(prescription.Niprocart, adminUserInfo.CurrentOrgId)
744
+
744
 						warehouseOutInfo.Price = stockInInfo.Price
745
 						warehouseOutInfo.Price = stockInInfo.Price
745
 						warehouseOutInfo.GoodId = prescription.Niprocart
746
 						warehouseOutInfo.GoodId = prescription.Niprocart
746
 						warehouseOutInfo.GoodTypeId = niprocart
747
 						warehouseOutInfo.GoodTypeId = niprocart
748
+
747
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
749
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
748
 
750
 
749
 						if err == nil {
751
 						if err == nil {
762
 							service.AddSigleAutoReduceRecordInfo(details)
764
 							service.AddSigleAutoReduceRecordInfo(details)
763
 						}
765
 						}
764
 					}
766
 					}
767
+
765
 					if prescription.Jms > 0 {
768
 					if prescription.Jms > 0 {
766
 						warehouseOutInfo := &models.WarehouseOutInfo{
769
 						warehouseOutInfo := &models.WarehouseOutInfo{
767
 							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
770
 							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1711
 								Status:                  1,
1714
 								Status:                  1,
1712
 								RecordTime:              startDate.Unix(),
1715
 								RecordTime:              startDate.Unix(),
1713
 								OrgId:                   adminUserInfo.CurrentOrgId,
1716
 								OrgId:                   adminUserInfo.CurrentOrgId,
1714
-								GoodId:                  prescription.Dialyzer,
1717
+								GoodId:                  prescription.Dialyzers,
1715
 								GoodTypeId:              dialyzers,
1718
 								GoodTypeId:              dialyzers,
1716
 							}
1719
 							}
1717
 							service.AddSigleAutoReduceRecordInfo(details)
1720
 							service.AddSigleAutoReduceRecordInfo(details)
2155
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2158
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2156
 
2159
 
2157
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2160
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2158
-				if template.TemplateId == 6 || template.TemplateId == 20 {
2161
+				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 {
2159
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2162
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2160
 				}
2163
 				}
2161
 				// 只针对方济医院
2164
 				// 只针对方济医院

+ 47 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go 查看文件

330
 	// 	return
330
 	// 	return
331
 	// }
331
 	// }
332
 
332
 
333
+	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
334
+
335
+	if template.TemplateId == 22 {
336
+		dewater_amount = dewater_amount * 1000
337
+	}
338
+
333
 	if dialysistype == 1 {
339
 	if dialysistype == 1 {
334
 		// 保存透前相关数据
340
 		// 保存透前相关数据
335
 		// 获取透析处方
341
 		// 获取透析处方
846
 	// 获取患者透前干体重或者获取患者透前体重
852
 	// 获取患者透前干体重或者获取患者透前体重
847
 	var dry_weight map[string]interface{}
853
 	var dry_weight map[string]interface{}
848
 	dry_weight = make(map[string]interface{})
854
 	dry_weight = make(map[string]interface{})
855
+	var after_dry_weight map[string]interface{}
856
+	after_dry_weight = make(map[string]interface{})
849
 	if dialysistype == 1 {
857
 	if dialysistype == 1 {
850
 
858
 
851
 		lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
859
 		lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
900
 				dry_weight["dry_weight"] = predialysisEvaluation.WeightBefore
908
 				dry_weight["dry_weight"] = predialysisEvaluation.WeightBefore
901
 			}
909
 			}
902
 		}
910
 		}
911
+
912
+		lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
913
+		weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
914
+		if err == gorm.ErrRecordNotFound {
915
+			if getLPEErr != nil {
916
+				after_dry_weight["code"] = 1
917
+				after_dry_weight["dry_weight"] = nil
918
+			} else {
919
+				if lastPredialysisEvaluation == nil {
920
+					after_dry_weight["code"] = 1
921
+					after_dry_weight["dry_weight"] = nil
922
+				} else {
923
+					// 传输的干体重实际为干体重加上衣服重
924
+					after_dry_weight["code"] = 0
925
+					after_dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight + lastPredialysisEvaluation.AdditionalWeight
926
+				}
927
+			}
928
+		} else {
929
+			if err != nil {
930
+				after_dry_weight["code"] = 1
931
+				after_dry_weight["dry_weight"] = nil
932
+			} else {
933
+				after_dry_weight["code"] = 0
934
+				if getLPEErr != nil {
935
+					after_dry_weight["code"] = 0
936
+					after_dry_weight["dry_weight"] = weight.DryWeight
937
+				} else {
938
+					if lastPredialysisEvaluation == nil {
939
+						after_dry_weight["code"] = 1
940
+						after_dry_weight["dry_weight"] = weight.DryWeight
941
+					} else {
942
+						// 传输的干体重实际为干体重加上衣服重
943
+						after_dry_weight["code"] = 0
944
+						after_dry_weight["dry_weight"] = weight.DryWeight + lastPredialysisEvaluation.AdditionalWeight
945
+					}
946
+				}
947
+			}
948
+		}
903
 	}
949
 	}
904
 
950
 
905
 	c.ServeSuccessJSON(map[string]interface{}{
951
 	c.ServeSuccessJSON(map[string]interface{}{
907
 		"patient":      dialysisinfo,
953
 		"patient":      dialysisinfo,
908
 		"schedule":     sc,
954
 		"schedule":     sc,
909
 		"dryweight":    dry_weight,
955
 		"dryweight":    dry_weight,
956
+		"after_dry_weight":    after_dry_weight,
910
 	})
957
 	})
911
 	return
958
 	return
912
 }
959
 }

+ 11 - 8
controllers/mobile_api_controllers/dialysis_api_controller.go 查看文件

99
 				//缓存数据
99
 				//缓存数据
100
 				scheduals_json, err := json.Marshal(scheduals)
100
 				scheduals_json, err := json.Marshal(scheduals)
101
 				if err == nil {
101
 				if err == nil {
102
-					redis.Set(key, scheduals_json, time.Minute*1)
102
+					redis.Set(key, scheduals_json, time.Second*30)
103
 				}
103
 				}
104
 			}
104
 			}
105
 
105
 
111
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
111
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
112
 
112
 
113
 		var dat []map[string]interface{}
113
 		var dat []map[string]interface{}
114
+
114
 		if err := json.Unmarshal([]byte(scheduals_json_str), &dat); err == nil {
115
 		if err := json.Unmarshal([]byte(scheduals_json_str), &dat); err == nil {
115
 
116
 
116
 		} else {
117
 		} else {
161
 				//缓存数据
162
 				//缓存数据
162
 				wait_scheduals_json, err := json.Marshal(scheduals)
163
 				wait_scheduals_json, err := json.Marshal(scheduals)
163
 				if err == nil {
164
 				if err == nil {
164
-					redis.Set(key, wait_scheduals_json, time.Minute*2)
165
+					redis.Set(key, wait_scheduals_json, time.Second*30)
165
 				}
166
 				}
166
 			}
167
 			}
167
 
168
 
2750
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2751
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2751
 			}
2752
 			}
2752
 
2753
 
2753
-			if template.TemplateId == 20 { //adminUserInfo.Org.Id == 9538
2754
+			if template.TemplateId == 20 || template.TemplateId == 22 { //adminUserInfo.Org.Id == 9538
2754
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
2755
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
2755
 			}
2756
 			}
2756
 
2757
 
3826
 								Status:                  1,
3827
 								Status:                  1,
3827
 								RecordTime:              startDate.Unix(),
3828
 								RecordTime:              startDate.Unix(),
3828
 								OrgId:                   adminUserInfo.Org.Id,
3829
 								OrgId:                   adminUserInfo.Org.Id,
3829
-								GoodId:                  prescription.Dialyzer,
3830
+								GoodId:                  prescription.Dialyzers,
3830
 								GoodTypeId:              dialyzers,
3831
 								GoodTypeId:              dialyzers,
3831
 							}
3832
 							}
3832
 							service.AddSigleAutoReduceRecordInfo(details)
3833
 							service.AddSigleAutoReduceRecordInfo(details)
5593
 	fristrecord, _ := service.FindFirstMonitorRecordToday(patientID, adminInfo.Org.Id, monitorDate)
5594
 	fristrecord, _ := service.FindFirstMonitorRecordToday(patientID, adminInfo.Org.Id, monitorDate)
5594
 
5595
 
5595
 	template, _ := service.GetOrgInfoTemplate(adminInfo.Org.Id)
5596
 	template, _ := service.GetOrgInfoTemplate(adminInfo.Org.Id)
5596
-	fmt.Println("1122233333")
5597
 
5597
 
5598
 	var ultrafiltration_rate float64
5598
 	var ultrafiltration_rate float64
5599
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.Org.Id)
5599
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.Org.Id)
5600
 	if prescription.ID > 0 {
5600
 	if prescription.ID > 0 {
5601
+		fmt.Println("444444444")
5602
+
5601
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
5603
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
5604
+			fmt.Println("4444444445555")
5602
 
5605
 
5603
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5606
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5604
 			if template.TemplateId == 6 {
5607
 			if template.TemplateId == 6 {
5608
+				fmt.Println("12222222")
5605
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
5609
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
5606
 				record.UltrafiltrationRate = ultrafiltration_rate
5610
 				record.UltrafiltrationRate = ultrafiltration_rate
5607
 			}
5611
 			}
5608
 
5612
 
5609
-			if template.TemplateId == 20 {
5613
+			if template.TemplateId == 20 || template.TemplateId == 22 {
5610
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
5614
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
5611
 				record.UltrafiltrationRate = ultrafiltration_rate
5615
 				record.UltrafiltrationRate = ultrafiltration_rate
5612
 			}
5616
 			}
5628
 		}
5632
 		}
5629
 	}
5633
 	}
5630
 
5634
 
5631
-	if template.TemplateId == 6 || template.TemplateId == 20 { //adminInfo.Org.Id == 9538
5635
+	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 { //adminInfo.Org.Id == 9538
5632
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
5636
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
5633
-			fmt.Println("11222344444444443333")
5634
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5637
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5635
 			record.UltrafiltrationVolume = ultrafiltration_volume
5638
 			record.UltrafiltrationVolume = ultrafiltration_volume
5636
 		}
5639
 		}

+ 4 - 1
controllers/mobile_api_controllers/patient_api_controller.go 查看文件

885
 	dewater_amount = 0
885
 	dewater_amount = 0
886
 	if evaluation.DryWeight > 0 {
886
 	if evaluation.DryWeight > 0 {
887
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
887
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
888
-		if template.TemplateId == 17 {
888
+
889
+		if template.TemplateId == 17 || template.TemplateId == 22 {
889
 			dewater_amount = dewater_amount * 1000
890
 			dewater_amount = dewater_amount * 1000
891
+
890
 		}
892
 		}
893
+
891
 		if dewater_amount <= 0 {
894
 		if dewater_amount <= 0 {
892
 			dewater_amount = 0
895
 			dewater_amount = 0
893
 		}
896
 		}

+ 6 - 3
controllers/new_mobile_api_controllers/management_analyse_api_controller.go 查看文件

82
 	data, total_one, _ := management_service.GetPatientChartData(adminUserInfo.Org.Id, startTime, endTime, statistics_type)
82
 	data, total_one, _ := management_service.GetPatientChartData(adminUserInfo.Org.Id, startTime, endTime, statistics_type)
83
 	total, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, statistics_type)
83
 	total, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, statistics_type)
84
 
84
 
85
+	total_three, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, 2)
86
+
85
 	this.ServeSuccessJSON(map[string]interface{}{
87
 	this.ServeSuccessJSON(map[string]interface{}{
86
-		"chart_data": data,
87
-		"total_one":  total_one,
88
-		"total":      total,
88
+		"chart_data":  data,
89
+		"total_one":   total_one,
90
+		"total":       total,
91
+		"total_three": total + total_three,
89
 	})
92
 	})
90
 
93
 
91
 }
94
 }

+ 18 - 2
controllers/schedule_api_controller.go 查看文件

547
 // @param date:string yyyy-MM-dd 要打印的那一周中的任一天
547
 // @param date:string yyyy-MM-dd 要打印的那一周中的任一天
548
 func (this *ScheduleApiController) PrintInitData() {
548
 func (this *ScheduleApiController) PrintInitData() {
549
 	dateStr := this.GetString("date")
549
 	dateStr := this.GetString("date")
550
+	//week_type, _ := this.GetInt64("type", 0)
551
+
550
 	var date *time.Time
552
 	var date *time.Time
551
 	if len(dateStr) == 0 {
553
 	if len(dateStr) == 0 {
552
 		now := time.Now()
554
 		now := time.Now()
562
 
564
 
563
 	adminUserInfo := this.GetAdminUserInfo()
565
 	adminUserInfo := this.GetAdminUserInfo()
564
 	// 获取本周的排班
566
 	// 获取本周的排班
565
-	monday, sunday := utils.GetMondayAndSundayOfWeekDate(date)
567
+	var monday time.Time
568
+	var sunday time.Time
569
+	//switch week_type {
570
+	//case 1:
571
+	monday, sunday = utils.GetMondayAndSundayOfWeekDate(date)
572
+
573
+	//	break
574
+	//case 2:
575
+	//	monday, sunday = utils.GetMondayAndSundayOfNextWeekDate(date)
576
+	//
577
+	//	break
578
+	//case 3:
579
+	//	monday, sunday = utils.GetMondayAndSundayOfNextNextWeekDate(date)
580
+	//	break
581
+	//}
566
 	schedules, getScheduleErr := service.GetPrinitWeekSchedules(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
582
 	schedules, getScheduleErr := service.GetPrinitWeekSchedules(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
567
 	if getScheduleErr != nil {
583
 	if getScheduleErr != nil {
568
 		this.ErrorLog("获取周排班失败:%v", getScheduleErr)
584
 		this.ErrorLog("获取周排班失败:%v", getScheduleErr)
570
 		return
586
 		return
571
 	}
587
 	}
572
 
588
 
573
-	thisTime := time.Now()
589
+	thisTime := date
574
 
590
 
575
 	weekDay := int(thisTime.Weekday())
591
 	weekDay := int(thisTime.Weekday())
576
 	if weekDay == 0 {
592
 	if weekDay == 0 {

+ 8 - 5
models/dialysis.go 查看文件

274
 }
274
 }
275
 
275
 
276
 type PredialysisEvaluationList struct {
276
 type PredialysisEvaluationList struct {
277
-	ID             int64   `gorm:"column:id" json:"id"`
278
-	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id"`
279
-	PatientId      int64   `gorm:"column:patient_id" json:"patient_id"`
280
-	AssessmentDate int64   `gorm:"column:assessment_date" json:"assessment_date"`
281
-	WeightBefore   float64 `gorm:"column:weight_before" json:"weight_before"`
277
+	ID                     int64   `gorm:"column:id" json:"id"`
278
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id"`
279
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id"`
280
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date"`
281
+	WeightBefore           float64 `gorm:"column:weight_before" json:"weight_before"`
282
+	CreatedTime            int64   `gorm:"column:created_time" json:"created_time"`
283
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
284
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
282
 }
285
 }
283
 
286
 
284
 func (PredialysisEvaluationList) TableName() string {
287
 func (PredialysisEvaluationList) TableName() string {

+ 1 - 1
routers/router.go 查看文件

35
 	controllers.ScheduleApiRegistRouters()
35
 	controllers.ScheduleApiRegistRouters()
36
 	controllers.SignWeighAPIControllerRegistRouters()
36
 	controllers.SignWeighAPIControllerRegistRouters()
37
 	controllers.InvoiceApiRegistRouters()
37
 	controllers.InvoiceApiRegistRouters()
38
-	controllers.StockApiRegistRouters()
38
+	//controllers.StockApiRegistRouters()
39
 	controllers.StockGoodApiRegistRouters()
39
 	controllers.StockGoodApiRegistRouters()
40
 	controllers.StockManagerApiRegistRouters()
40
 	controllers.StockManagerApiRegistRouters()
41
 	controllers.PatientScheduleTemplateAPIControllerRegistRouters()
41
 	controllers.PatientScheduleTemplateAPIControllerRegistRouters()

+ 14 - 5
service/management_service/management_analyse_service.go 查看文件

17
 		break
17
 		break
18
 	case 2:
18
 	case 2:
19
 		//err = db.Raw("select from_unixtime(assessment_date,'%Y-%m-%d') as date, weight_after as value from xt_assessment_after_dislysis  Where status = 1 AND user_org_id = ? AND patient_id = ?  AND assessment_date <= ? AND  assessment_date >= ? ", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
19
 		//err = db.Raw("select from_unixtime(assessment_date,'%Y-%m-%d') as date, weight_after as value from xt_assessment_after_dislysis  Where status = 1 AND user_org_id = ? AND patient_id = ?  AND assessment_date <= ? AND  assessment_date >= ? ", user_org_id, patient_id, end_time, start_time).Scan(&datas).Error
20
-		//err = db.Raw("select from_unixtime(lapseto_time,'%m-%d') as date, count(distinct patient_id) as value  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = 2 AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?   Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
21
-		err = db.Raw("select from_unixtime(created_time,'%m-%d') as date, count(distinct id) as value  from xt_patients patient   Where  patient.user_org_id = ? AND patient.created_time >=? AND patient.created_time <=? AND patient.status = 1   AND patient.lapseto = 2  Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
20
+		err = db.Raw("select from_unixtime(lapseto_time,'%m-%d') as date, count(distinct patient_id) as value  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = 2 AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?   Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
21
+		//err = db.Raw("select from_unixtime(updated_time,'%m-%d') as date, count(distinct id) as value  from xt_patients patient   Where  patient.user_org_id = ? AND patient.updated_time >=? AND patient.updated_time <=? AND patient.status = 1   AND patient.lapseto = 2  Group by date", user_org_id, start_time, end_time).Scan(&datas).Error
22
 
22
 
23
 		break
23
 		break
24
 	}
24
 	}
45
 	var err error
45
 	var err error
46
 	var patients []*PatientTableStruct
46
 	var patients []*PatientTableStruct
47
 	readDb := service.XTReadDB()
47
 	readDb := service.XTReadDB()
48
-	//db := readDb.Raw("select from_unixtime(lapseto.`lapseto_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = ? AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?  ", orgID, statistics_type, start, end)
49
-	db := readDb.Raw("select from_unixtime(patient.`created_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from `xt_patients` patient Where patient.user_org_id = ? AND patient.status = 1 AND patient.lapseto = ?  AND patient.created_time >= ? AND patient.created_time <= ?  ", orgID, statistics_type, start, end)
50
-	err = db.Order("patient.created_time desc").Scan(&patients).Error
48
+	if statistics_type == 1 {
49
+		db := readDb.Raw("select from_unixtime(patient.`created_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from `xt_patients` patient Where patient.user_org_id = ? AND patient.status = 1 AND patient.lapseto = ?  AND patient.created_time >= ? AND patient.created_time <= ?  ", orgID, statistics_type, start, end)
50
+		err = db.Order("patient.created_time desc").Scan(&patients).Error
51
+
52
+	} else {
53
+
54
+		db := readDb.Raw("select from_unixtime(lapseto.`lapseto_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from xt_patient_lapseto lapseto JOIN `xt_patients` patient ON lapseto.`patient_id` = patient.id AND patient.user_org_id = ? Where lapseto.status = 1 AND lapseto.lapseto_type = ? AND lapseto.lapseto_time >= ? AND lapseto.lapseto_time <= ?  ", orgID, statistics_type, start, end)
55
+		//db := readDb.Raw("select from_unixtime(patient.`updated_time`,'%Y-%m-%d %H:%m') as date , patient.name as name, patient.`id_card_no` as id_card_no, patient.`gender` as gender  from `xt_patients` patient Where patient.user_org_id = ? AND patient.status = 1 AND patient.lapseto = ?  AND patient.updated_time >= ? AND patient.updated_time <= ?  ", orgID, statistics_type, start, end)
56
+		err = db.Group("lapseto.`patient_id`").Order("lapseto.lapseto_time desc").Scan(&patients).Error
57
+
58
+	}
59
+
51
 	return patients, total, err
60
 	return patients, total, err
52
 }
61
 }
53
 
62
 

+ 15 - 1
service/mobile_dialysis_service.go 查看文件

35
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
35
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
36
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
36
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38
+		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
38
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
39
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
39
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
40
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
40
 		// }).
41
 		// }).
63
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
64
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
64
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 ", orgID).
65
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 ", orgID).
65
 		Preload("TreatmentMode", "status = 1").
66
 		Preload("TreatmentMode", "status = 1").
67
+		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
66
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
68
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
67
 	if scheduleDate != 0 {
69
 	if scheduleDate != 0 {
68
 		db = db.Where("schedule_date = ?", scheduleDate)
70
 		db = db.Where("schedule_date = ?", scheduleDate)
72
 	return vms, err
74
 	return vms, err
73
 }
75
 }
74
 
76
 
77
+type VMTreatmentSummary struct {
78
+	ID              int64  `gorm:"column:id" json:"id"`
79
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id"`
80
+	PatientId       int64  `gorm:"column:patient_id" json:"patient_id"`
81
+	AssessmentDate  int64  `gorm:"column:assessment_date" json:"assessment_date"`
82
+	DialysisSummary string `gorm:"column:dialysis_summary" json:"dialysis_summary" form:"dialysis_summary"`
83
+}
84
+
85
+func (VMTreatmentSummary) TableName() string {
86
+	return "xt_treatment_summary"
87
+}
88
+
75
 type MDialysisScheduleVM struct {
89
 type MDialysisScheduleVM struct {
76
 	ID           int64 `gorm:"column:id" json:"id"`
90
 	ID           int64 `gorm:"column:id" json:"id"`
77
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
91
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
90
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
104
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
91
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
105
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
92
 	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
106
 	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"doctor_advice"`
93
-	TreatmentSummary         *models.TreatmentSummary          `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
107
+	TreatmentSummary         *VMTreatmentSummary               `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"treatment_summary"`
94
 }
108
 }
95
 
109
 
96
 func (MDialysisScheduleVM) TableName() string {
110
 func (MDialysisScheduleVM) TableName() string {

+ 1 - 1
service/stock_service.go 查看文件

1186
 }
1186
 }
1187
 
1187
 
1188
 func FindWarehouseInfoByGoodType(good_type_id int64, org_id int64) (info []*models.WarehousingInfo, err error) {
1188
 func FindWarehouseInfoByGoodType(good_type_id int64, org_id int64) (info []*models.WarehousingInfo, err error) {
1189
-	err = readDb.Model(&models.WarehousingInfo{}).Preload("GoodInfo", "status = 1 AND org_id = ?", org_id).Where("good_type_id = ? AND status = 1 AND org_id = ?", good_type_id, org_id).Find(&info).Error
1189
+	err = readDb.Model(&models.WarehousingInfo{}).Preload("GoodInfo", " org_id = ? AND good_type_id = ? AND status = 1 AND specification_name <> '' ", org_id, good_type_id).Where(" org_id = ? AND good_type_id = ?  AND status = 1 ", org_id, good_type_id).Find(&info).Error
1190
 	return info, err
1190
 	return info, err
1191
 
1191
 
1192
 }
1192
 }

+ 30 - 0
utils/tools.go 查看文件

229
 	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 7-weekday).Format("2006-01-02")+" 23:59:59", loc)
229
 	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 7-weekday).Format("2006-01-02")+" 23:59:59", loc)
230
 	return monday, sunday
230
 	return monday, sunday
231
 }
231
 }
232
+
233
+func GetMondayAndSundayOfNextWeekDate(date *time.Time) (time.Time, time.Time) {
234
+	if date == nil {
235
+		now := time.Now()
236
+		date = &now
237
+	}
238
+	weekday := int(date.Weekday())
239
+	if weekday == 0 {
240
+		weekday = 7
241
+	}
242
+	loc, _ := time.LoadLocation("Local")
243
+	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 8-weekday).Format("2006-01-02")+" 00:00:00", loc)
244
+	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 14-weekday).Format("2006-01-02")+" 23:59:59", loc)
245
+	return monday, sunday
246
+}
247
+
248
+func GetMondayAndSundayOfNextNextWeekDate(date *time.Time) (time.Time, time.Time) {
249
+	if date == nil {
250
+		now := time.Now()
251
+		date = &now
252
+	}
253
+	weekday := int(date.Weekday())
254
+	if weekday == 0 {
255
+		weekday = 7
256
+	}
257
+	loc, _ := time.LoadLocation("Local")
258
+	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 15-weekday).Format("2006-01-02")+" 00:00:00", loc)
259
+	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 21-weekday).Format("2006-01-02")+" 23:59:59", loc)
260
+	return monday, sunday
261
+}