瀏覽代碼

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

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

@@ -3303,7 +3303,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3303 3303
 		dewater_amount = 0
3304 3304
 		if evaluation.DryWeight > 0 {
3305 3305
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3306
-			if templateInfo.TemplateId == 17 {
3306
+			if templateInfo.TemplateId == 17 && templateInfo.TemplateId == 22 {
3307 3307
 				dewater_amount = dewater_amount * 1000
3308 3308
 			}
3309 3309
 			if dewater_amount <= 0 {
@@ -4863,7 +4863,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
4863 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 4867
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
4868 4868
 				record.UltrafiltrationRate = ultrafiltration_rate
4869 4869
 			}
@@ -4885,7 +4885,7 @@ func (this *DialysisApiController) GetTodayMonitor() {
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 4889
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
4890 4890
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
4891 4891
 			record.UltrafiltrationVolume = ultrafiltration_volume

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

@@ -741,9 +741,11 @@ func (this *DialysisRecordAPIController) StartDialysis() {
741 741
 						}
742 742
 						//查出入库记录中最后一条记录
743 743
 						stockInInfo, _ := service.FindLastStockInInfoRecord(prescription.Niprocart, adminUserInfo.CurrentOrgId)
744
+
744 745
 						warehouseOutInfo.Price = stockInInfo.Price
745 746
 						warehouseOutInfo.GoodId = prescription.Niprocart
746 747
 						warehouseOutInfo.GoodTypeId = niprocart
748
+
747 749
 						err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
748 750
 
749 751
 						if err == nil {
@@ -762,6 +764,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
762 764
 							service.AddSigleAutoReduceRecordInfo(details)
763 765
 						}
764 766
 					}
767
+
765 768
 					if prescription.Jms > 0 {
766 769
 						warehouseOutInfo := &models.WarehouseOutInfo{
767 770
 							WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
@@ -1711,7 +1714,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1711 1714
 								Status:                  1,
1712 1715
 								RecordTime:              startDate.Unix(),
1713 1716
 								OrgId:                   adminUserInfo.CurrentOrgId,
1714
-								GoodId:                  prescription.Dialyzer,
1717
+								GoodId:                  prescription.Dialyzers,
1715 1718
 								GoodTypeId:              dialyzers,
1716 1719
 							}
1717 1720
 							service.AddSigleAutoReduceRecordInfo(details)
@@ -2155,7 +2158,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
2155 2158
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2156 2159
 
2157 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 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,6 +330,12 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
330 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 339
 	if dialysistype == 1 {
334 340
 		// 保存透前相关数据
335 341
 		// 获取透析处方
@@ -846,6 +852,8 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
846 852
 	// 获取患者透前干体重或者获取患者透前体重
847 853
 	var dry_weight map[string]interface{}
848 854
 	dry_weight = make(map[string]interface{})
855
+	var after_dry_weight map[string]interface{}
856
+	after_dry_weight = make(map[string]interface{})
849 857
 	if dialysistype == 1 {
850 858
 
851 859
 		lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
@@ -900,6 +908,44 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
900 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 951
 	c.ServeSuccessJSON(map[string]interface{}{
@@ -907,6 +953,7 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
907 953
 		"patient":      dialysisinfo,
908 954
 		"schedule":     sc,
909 955
 		"dryweight":    dry_weight,
956
+		"after_dry_weight":    after_dry_weight,
910 957
 	})
911 958
 	return
912 959
 }

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

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

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

@@ -885,9 +885,12 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
885 885
 	dewater_amount = 0
886 886
 	if evaluation.DryWeight > 0 {
887 887
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
888
-		if template.TemplateId == 17 {
888
+
889
+		if template.TemplateId == 17 || template.TemplateId == 22 {
889 890
 			dewater_amount = dewater_amount * 1000
891
+
890 892
 		}
893
+
891 894
 		if dewater_amount <= 0 {
892 895
 			dewater_amount = 0
893 896
 		}

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

@@ -82,10 +82,13 @@ func (this *ManagementAnalyseApiController) StatisticsPatientChart() {
82 82
 	data, total_one, _ := management_service.GetPatientChartData(adminUserInfo.Org.Id, startTime, endTime, statistics_type)
83 83
 	total, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, statistics_type)
84 84
 
85
+	total_three, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, 2)
86
+
85 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,6 +547,8 @@ func (c *ScheduleApiController) ChangeSchedule() {
547 547
 // @param date:string yyyy-MM-dd 要打印的那一周中的任一天
548 548
 func (this *ScheduleApiController) PrintInitData() {
549 549
 	dateStr := this.GetString("date")
550
+	//week_type, _ := this.GetInt64("type", 0)
551
+
550 552
 	var date *time.Time
551 553
 	if len(dateStr) == 0 {
552 554
 		now := time.Now()
@@ -562,7 +564,21 @@ func (this *ScheduleApiController) PrintInitData() {
562 564
 
563 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 582
 	schedules, getScheduleErr := service.GetPrinitWeekSchedules(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
567 583
 	if getScheduleErr != nil {
568 584
 		this.ErrorLog("获取周排班失败:%v", getScheduleErr)
@@ -570,7 +586,7 @@ func (this *ScheduleApiController) PrintInitData() {
570 586
 		return
571 587
 	}
572 588
 
573
-	thisTime := time.Now()
589
+	thisTime := date
574 590
 
575 591
 	weekDay := int(thisTime.Weekday())
576 592
 	if weekDay == 0 {

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

@@ -274,11 +274,14 @@ func (PredialysisEvaluation) TableName() string {
274 274
 }
275 275
 
276 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 287
 func (PredialysisEvaluationList) TableName() string {

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

@@ -35,7 +35,7 @@ func init() {
35 35
 	controllers.ScheduleApiRegistRouters()
36 36
 	controllers.SignWeighAPIControllerRegistRouters()
37 37
 	controllers.InvoiceApiRegistRouters()
38
-	controllers.StockApiRegistRouters()
38
+	//controllers.StockApiRegistRouters()
39 39
 	controllers.StockGoodApiRegistRouters()
40 40
 	controllers.StockManagerApiRegistRouters()
41 41
 	controllers.PatientScheduleTemplateAPIControllerRegistRouters()

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

@@ -17,8 +17,8 @@ func GetPatientChartData(user_org_id int64, start_time int64, end_time int64, st
17 17
 		break
18 18
 	case 2:
19 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 23
 		break
24 24
 	}
@@ -45,9 +45,18 @@ func GetPatientTableData(orgID int64, page, limit, start, end int64, statistics_
45 45
 	var err error
46 46
 	var patients []*PatientTableStruct
47 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 60
 	return patients, total, err
52 61
 }
53 62
 

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

@@ -35,6 +35,7 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
35 35
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
36 36
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
37 37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38
+		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
38 39
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
39 40
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
40 41
 		// }).
@@ -63,6 +64,7 @@ func MobileGetWaitingScheduals(orgID int64, scheduleDate int64) ([]*MDialysisSch
63 64
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
64 65
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 ", orgID).
65 66
 		Preload("TreatmentMode", "status = 1").
67
+		Preload("TreatmentSummary", "status = 1  AND user_org_id = ?", orgID).
66 68
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
67 69
 	if scheduleDate != 0 {
68 70
 		db = db.Where("schedule_date = ?", scheduleDate)
@@ -72,6 +74,18 @@ func MobileGetWaitingScheduals(orgID int64, scheduleDate int64) ([]*MDialysisSch
72 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 89
 type MDialysisScheduleVM struct {
76 90
 	ID           int64 `gorm:"column:id" json:"id"`
77 91
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
@@ -90,7 +104,7 @@ type MDialysisScheduleVM struct {
90 104
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
91 105
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
92 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 110
 func (MDialysisScheduleVM) TableName() string {

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

@@ -1186,7 +1186,7 @@ func FindAllGoodTypeByType(types int64) (goodType []*models.GoodsType, err error
1186 1186
 }
1187 1187
 
1188 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 1190
 	return info, err
1191 1191
 
1192 1192
 }

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

@@ -229,3 +229,33 @@ func GetMondayAndSundayOfWeekDate(date *time.Time) (time.Time, time.Time) {
229 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 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
+}