28169 1 mese fa
parent
commit
5122b79877

BIN
XT_New.exe Vedi File


+ 6 - 6
controllers/base_api_controller.go Vedi File

83
 		userAdmin.ModifyTime = 1530786071
83
 		userAdmin.ModifyTime = 1530786071
84
 		var subscibe models.ServeSubscibe
84
 		var subscibe models.ServeSubscibe
85
 		subscibe.ID = 11
85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10721 //机构id
86
+		subscibe.OrgId = 9478 //机构id
87
 		subscibe.PeriodStart = 1547447814
87
 		subscibe.PeriodStart = 1547447814
88
 		subscibe.PeriodEnd = 1550039814
88
 		subscibe.PeriodEnd = 1550039814
89
 		subscibe.State = 1
89
 		subscibe.State = 1
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94
 		subscibes[4] = &subscibe
94
 		subscibes[4] = &subscibe
95
 		var adminUserInfo service.AdminUserInfo
95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10721 //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 12123 //4
96
+		adminUserInfo.CurrentOrgId = 9478  //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 18470 //4
98
 		adminUserInfo.AdminUser = &userAdmin
98
 		adminUserInfo.AdminUser = &userAdmin
99
 		adminUserInfo.Subscibes = subscibes
99
 		adminUserInfo.Subscibes = subscibes
100
 		this.SetSession("admin_user_info", &adminUserInfo)
100
 		this.SetSession("admin_user_info", &adminUserInfo)
329
 		userAdmin.ModifyTime = 1530786071
329
 		userAdmin.ModifyTime = 1530786071
330
 		var subscibe models.ServeSubscibe
330
 		var subscibe models.ServeSubscibe
331
 		subscibe.ID = 11
331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10721 //机构id小英9675或4
332
+		subscibe.OrgId = 9478 //机构id小英9675或4
333
 		subscibe.PeriodStart = 1538035409
333
 		subscibe.PeriodStart = 1538035409
334
 		subscibe.PeriodEnd = 1569571409
334
 		subscibe.PeriodEnd = 1569571409
335
 		subscibe.State = 1
335
 		subscibe.State = 1
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340
 		subscibes[4] = &subscibe
340
 		subscibes[4] = &subscibe
341
 		var adminUserInfo service.AdminUserInfo
341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10721 //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 12123 //4
342
+		adminUserInfo.CurrentOrgId = 9478  //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 18470 //4
344
 		adminUserInfo.AdminUser = &userAdmin
344
 		adminUserInfo.AdminUser = &userAdmin
345
 		adminUserInfo.Subscibes = subscibes
345
 		adminUserInfo.Subscibes = subscibes
346
 		this.SetSession("admin_user_info", &adminUserInfo)
346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 2 - 2
controllers/dialysis_api_controller.go Vedi File

3239
 		dewater_amount = 0
3239
 		dewater_amount = 0
3240
 		if evaluation.DryWeight > 0 {
3240
 		if evaluation.DryWeight > 0 {
3241
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3241
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3242
-			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 {
3242
+			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 {
3243
 				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 {
3243
 				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 {
3244
 					dewater_amount = dewater_amount * 1000
3244
 					dewater_amount = dewater_amount * 1000
3245
 				}
3245
 				}
3517
 		}
3517
 		}
3518
 
3518
 
3519
 		//针对孝昌康桥超滤率计算问题
3519
 		//针对孝昌康桥超滤率计算问题
3520
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
3520
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10697 {
3521
 			if assessmentBeforeDislysis.ID == 0 {
3521
 			if assessmentBeforeDislysis.ID == 0 {
3522
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3522
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3523
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3523
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {

+ 7 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go Vedi File

981
 		}
981
 		}
982
 
982
 
983
 		//针对患者称重两次没有数据的问题
983
 		//针对患者称重两次没有数据的问题
984
-		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
984
+		if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 || adminUserInfo.Org.Id == 10697 {
985
 
985
 
986
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
986
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
987
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
987
 			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
1002
 			service.UpdateMobileGetDialysisPrescribeOne(lastDialysisPrescription.ID, dewater_amount)
1002
 			service.UpdateMobileGetDialysisPrescribeOne(lastDialysisPrescription.ID, dewater_amount)
1003
 		}
1003
 		}
1004
 
1004
 
1005
+		if adminUserInfo.Org.Id == 10757 {
1006
+			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
1007
+			lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
1008
+			service.UpdateMobileGetDialysisPrescribeOne(lastDialysisPrescription.ID, dewater_amount)
1009
+		}
1010
+
1005
 		err := service.UpadatePredialysisEvaluation(&evaluation)
1011
 		err := service.UpadatePredialysisEvaluation(&evaluation)
1006
 
1012
 
1007
 		//记录日志
1013
 		//记录日志

+ 26 - 7
controllers/mobile_api_controllers/dialysis_api_controller.go Vedi File

4054
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4054
 				ultrafiltration_rate = ultrafiltration_rate / 1000
4055
 			}
4055
 			}
4056
 
4056
 
4057
-			if adminUserInfo.Org.Id == 10721 {
4057
+			if adminUserInfo.Org.Id == 10757 {
4058
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
4059
+				ultrafiltration_rate = ultrafiltration_rate / 1000
4060
+			}
4061
+
4062
+			if adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10757 {
4058
 				if prescription.ModeId == 2 {
4063
 				if prescription.ModeId == 2 {
4059
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4064
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4060
 					if totalMin == 0 {
4065
 					if totalMin == 0 {
4069
 				}
4074
 				}
4070
 			}
4075
 			}
4071
 
4076
 
4072
-			fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhh", adminUserInfo.Org.Id)
4073
 			if adminUserInfo.Org.Id == 10752 {
4077
 			if adminUserInfo.Org.Id == 10752 {
4074
 
4078
 
4075
 				if prescription.ModeId == 2 {
4079
 				if prescription.ModeId == 2 {
4084
 					//乘10 除10是为了保留一位小数
4088
 					//乘10 除10是为了保留一位小数
4085
 					replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*10) / 10
4089
 					replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*10) / 10
4086
 
4090
 
4087
-					fmt.Println("hhhhhhhhhhhhhhhhhhhhh", replacement_rate)
4088
 				}
4091
 				}
4089
 			}
4092
 			}
4090
 
4093
 
5335
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5338
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5336
 			}
5339
 			}
5337
 
5340
 
5341
+			if adminInfo.Org.Id == 10757 {
5342
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
5343
+				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5344
+			}
5345
+
5338
 			if adminInfo.Org.Id == 10752 {
5346
 			if adminInfo.Org.Id == 10752 {
5339
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
5347
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)
5340
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5348
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5362
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5370
 				record.UltrafiltrationRate = ultrafiltration_rate / 1000
5363
 			}
5371
 			}
5364
 
5372
 
5373
+			if adminInfo.Org.Id == 9919 {
5374
+				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 1000 / float64(totalMin) * 60 * 1000)
5375
+				record.UltrafiltrationRate = math.Floor(ultrafiltration_rate / 1000)
5376
+			}
5377
+
5365
 			//if template.TemplateId == 47 {
5378
 			//if template.TemplateId == 47 {
5366
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
5379
 			//	ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
5367
 			//	record.UltrafiltrationRate = ultrafiltration_rate
5380
 			//	record.UltrafiltrationRate = ultrafiltration_rate
5464
 		record.UltrafiltrationVolume = 0
5477
 		record.UltrafiltrationVolume = 0
5465
 	}
5478
 	}
5466
 
5479
 
5467
-	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10164 || adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10752 {
5480
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10164 || adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10752 || adminInfo.Org.Id == 10757 {
5468
 		if ultrafiltration_rate > 0 {
5481
 		if ultrafiltration_rate > 0 {
5469
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5482
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5470
 			record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5483
 			record.UltrafiltrationVolume = ultrafiltration_volume / 1000
5481
 
5494
 
5482
 	}
5495
 	}
5483
 
5496
 
5497
+	if adminInfo.Org.Id == 9919 {
5498
+		if ultrafiltration_rate > 0 {
5499
+			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5500
+			record.UltrafiltrationVolume = math.Floor(ultrafiltration_volume / 1000)
5501
+		}
5502
+
5503
+	}
5504
+
5484
 	if adminInfo.Org.Id == 10206 {
5505
 	if adminInfo.Org.Id == 10206 {
5485
 		if ultrafiltration_rate > 0 {
5506
 		if ultrafiltration_rate > 0 {
5486
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5507
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
5488
 		}
5509
 		}
5489
 	}
5510
 	}
5490
 
5511
 
5491
-	if adminInfo.Org.Id == 10721 {
5512
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 {
5492
 		var replacement_rate float64
5513
 		var replacement_rate float64
5493
 		var displacement_quantity float64
5514
 		var displacement_quantity float64
5494
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5515
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5495
 		replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*60) / 1000
5516
 		replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*60) / 1000
5496
 		record.ReplacementRate = replacement_rate
5517
 		record.ReplacementRate = replacement_rate
5497
-		fmt.Println("hhhhhhhhhhhhhhhhhh", record.ReplacementRate)
5498
 		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5518
 		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5499
 		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5519
 		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5500
 		record.DisplacementQuantity = displacement_quantity
5520
 		record.DisplacementQuantity = displacement_quantity
5508
 		replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*60) / 1000
5528
 		replacement_rate = math.Floor(prescription.DisplaceLiquiValue*1000/float64(totalMin)*60) / 1000
5509
 		record.ReplacementRate = replacement_rate
5529
 		record.ReplacementRate = replacement_rate
5510
 
5530
 
5511
-		fmt.Println(math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600))
5512
 		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5531
 		displacement_quantity = math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime)/3600) * replacement_rate
5513
 		record.DisplacementQuantity = displacement_quantity
5532
 		record.DisplacementQuantity = displacement_quantity
5514
 
5533
 

+ 4 - 4
controllers/mobile_api_controllers/patient_api_controller.go Vedi File

3505
 		var advice models.DoctorAdvice
3505
 		var advice models.DoctorAdvice
3506
 
3506
 
3507
 		if groupno > 0 {
3507
 		if groupno > 0 {
3508
-			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
3508
+			advices, _ := service.FindAllDoctorAdviceByGoroupNoThree(adminUserInfo.Org.Id, groupno, patient_id, record_date)
3509
 			for _, item := range advices {
3509
 			for _, item := range advices {
3510
 				if item.CheckState == 0 {
3510
 				if item.CheckState == 0 {
3511
 					advice = item
3511
 					advice = item
3605
 
3605
 
3606
 				}
3606
 				}
3607
 			}
3607
 			}
3608
-			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
3608
+			err = service.CheckDoctorAdviceByGroupNoTwo(&advices, groupno, adminUserInfo.Org.Id, patient_id, record_date)
3609
 
3609
 
3610
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3610
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3611
 			redis := service.RedisClient()
3611
 			redis := service.RedisClient()
3870
 	if evaluation.DryWeight > 0 {
3870
 	if evaluation.DryWeight > 0 {
3871
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3871
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3872
 
3872
 
3873
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 {
3873
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 {
3874
 
3874
 
3875
 			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3875
 			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3876
 				dewater_amount = dewater_amount * 1000
3876
 				dewater_amount = dewater_amount * 1000
4595
 	}
4595
 	}
4596
 
4596
 
4597
 	//针对孝昌康桥超滤率计算问题
4597
 	//针对孝昌康桥超滤率计算问题
4598
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 {
4598
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 {
4599
 		if evaluation.ID == 0 {
4599
 		if evaluation.ID == 0 {
4600
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4600
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4601
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4601
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {

+ 1 - 0
controllers/patient_api_controller.go Vedi File

8665
 
8665
 
8666
 	minMonitorSystolicBloodPressure, _ := service.GetMinMonitorSystolicBloodPressure(patient_id, startTime, endTime, orgId)
8666
 	minMonitorSystolicBloodPressure, _ := service.GetMinMonitorSystolicBloodPressure(patient_id, startTime, endTime, orgId)
8667
 
8667
 
8668
+	fmt.Println("maxMonitorDiastolicBloodPressure", minMonitorSystolicBloodPressure)
8668
 	maxMonitorDiastolicBloodPressure, _ := service.GetMaxMonitorDiastolicBloodPressure(patient_id, startTime, endTime, orgId)
8669
 	maxMonitorDiastolicBloodPressure, _ := service.GetMaxMonitorDiastolicBloodPressure(patient_id, startTime, endTime, orgId)
8669
 
8670
 
8670
 	minMonitorDiastolicBloodPressure, _ := service.GetMinMonitorDiastolicBloodPressure(patient_id, startTime, endTime, orgId)
8671
 	minMonitorDiastolicBloodPressure, _ := service.GetMinMonitorDiastolicBloodPressure(patient_id, startTime, endTime, orgId)

+ 230 - 5
controllers/self_drug_api_congtroller.go Vedi File

197
 
197
 
198
 	beego.Router("/api/drug/getselfdrugwarehouseinfo", &SelfDrugApiController{}, "Get:GetSelfDrugWarhouseInfo")
198
 	beego.Router("/api/drug/getselfdrugwarehouseinfo", &SelfDrugApiController{}, "Get:GetSelfDrugWarhouseInfo")
199
 
199
 
200
+	beego.Router("/api/drug/getdrugpurchasequerylist", &SelfDrugApiController{}, "Get:GetDrugPurchaseQueryList")
201
+
200
 }
202
 }
201
 
203
 
202
 func (this *SelfDrugApiController) GetCurrentPatient() {
204
 func (this *SelfDrugApiController) GetCurrentPatient() {
3915
 			//获取期末结余
3917
 			//获取期末结余
3916
 			flow, _ := service.GetEndLastFlowTwenty(item.ID, orgId, endTime)
3918
 			flow, _ := service.GetEndLastFlowTwenty(item.ID, orgId, endTime)
3917
 
3919
 
3920
+			//goodinfo, _ := service.GetGoodWarehosueInfo(item.GoodEndFlowInfo.WarehousingDetailId)
3921
+			//flow.Price = 0
3922
+			//flow.Price = goodinfo.Price
3918
 			item.GoodEndFlowInfo = flow
3923
 			item.GoodEndFlowInfo = flow
3919
 
3924
 
3920
 			//获取期间增加
3925
 			//获取期间增加
4120
 		}
4125
 		}
4121
 	}
4126
 	}
4122
 
4127
 
4123
-	//infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
4124
-	//for _, it := range infoList {
4125
-	//	infoIds = append(infoIds, it.DrugId)
4126
-	//}
4127
-
4128
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4128
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4129
 	list, total, err := service.GetDrugNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
4129
 	list, total, err := service.GetDrugNewPurchaseStockQuery(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
4130
 
4130
 
6580
 	})
6580
 	})
6581
 
6581
 
6582
 }
6582
 }
6583
+
6584
+func (this *SelfDrugApiController) GetDrugPurchaseQueryList() {
6585
+
6586
+	good_type, _ := this.GetInt64("good_type")
6587
+
6588
+	page, _ := this.GetInt64("page")
6589
+
6590
+	limit, _ := this.GetInt64("limit")
6591
+
6592
+	drug_id, _ := this.GetInt64("drug_id")
6593
+
6594
+	start_time := this.GetString("start_time")
6595
+	end_time := this.GetString("end_time")
6596
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6597
+	timeLayout := "2006-01-02"
6598
+	loc, _ := time.LoadLocation("Local")
6599
+
6600
+	var startTime int64
6601
+
6602
+	if len(start_time) > 0 {
6603
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6604
+		if err != nil {
6605
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6606
+			return
6607
+		}
6608
+		startTime = theTime.Unix()
6609
+	}
6610
+
6611
+	var endTime int64
6612
+	if len(end_time) > 0 {
6613
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
6614
+		if err != nil {
6615
+			utils.ErrorLog(err.Error())
6616
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6617
+			return
6618
+		}
6619
+		endTime = theTime.Unix()
6620
+	}
6621
+	list, total, _ := service.GetDrugPurchaseQueryList(good_type, page, limit, drug_id, orgId, startTime, endTime)
6622
+
6623
+	if len(list) > 0 {
6624
+		for _, item := range list {
6625
+
6626
+			medical, _ := service.GetBaseDrugById(item.ID)
6627
+			//获取期初结余  入库数量减去 出库数量
6628
+			info, _ := service.GetDrugWarehouseInfoByStartTime(item.ID, orgId, startTime)
6629
+
6630
+			//盘盈数量
6631
+			profitflow, _ := service.GetProfitDrugFlow(item.ID, orgId, startTime)
6632
+
6633
+			//盘亏数量
6634
+			reduceflow, _ := service.GetReduceDrugFlow(item.ID, orgId, startTime)
6635
+
6636
+			//退库数量
6637
+			returnDrugFlow, _ := service.GetReturnDrugFlow(item.ID, orgId, startTime)
6638
+
6639
+			//出库数量
6640
+			outflow, _ := service.GetOutDrugFlow(item.ID, orgId, startTime)
6641
+
6642
+			//获取本期增加
6643
+			startBetEndInfo, _ := service.GetInitAddDrugFlow(item.ID, orgId, startTime, endTime)
6644
+
6645
+			//获取本期减少
6646
+			startOutEndInfo, _ := service.GetInitOutDrugFlow(item.ID, orgId, startTime, endTime)
6647
+
6648
+			//期间退库
6649
+			initReturnDrugFlow, _ := service.GetInitReturnDrugFlow(item.ID, orgId, startTime, endTime)
6650
+
6651
+			//期间盘盈
6652
+			initProfitflow, _ := service.GetInitProfitDrugFlow(item.ID, orgId, startTime, endTime)
6653
+
6654
+			//期间盘亏
6655
+			initReduceflow, _ := service.GetInitReduceDrugFlow(item.ID, orgId, startTime, endTime)
6656
+
6657
+			var warehouse_in_count int64
6658
+			var profit_in_count int64
6659
+			var reduce_out_count int64
6660
+			var return_out_count int64
6661
+			var out_count int64
6662
+			var start_bet_end_info int64
6663
+			var start_out_end_info int64
6664
+			var start_return_end_info int64
6665
+			var start_profit_end_info int64
6666
+			var start_reduce_end_info int64
6667
+
6668
+			if len(info) > 0 {
6669
+				for _, it := range info {
6670
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6671
+
6672
+						it.WarehousingCount = medical.MinNumber * it.WarehousingCount
6673
+					}
6674
+					warehouse_in_count += it.WarehousingCount
6675
+				}
6676
+			}
6677
+
6678
+			if len(profitflow) > 0 {
6679
+				for _, it := range profitflow {
6680
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6681
+						it.Count = medical.MinNumber * it.Count
6682
+					}
6683
+					profit_in_count += it.Count
6684
+				}
6685
+			}
6686
+
6687
+			if len(reduceflow) > 0 {
6688
+				for _, it := range reduceflow {
6689
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6690
+						it.Count = medical.MinNumber * it.Count
6691
+					}
6692
+					reduce_out_count += it.Count
6693
+				}
6694
+
6695
+			}
6696
+
6697
+			if len(returnDrugFlow) > 0 {
6698
+
6699
+				for _, it := range returnDrugFlow {
6700
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6701
+						it.Count = medical.MinNumber * it.Count
6702
+					}
6703
+					return_out_count += it.Count
6704
+				}
6705
+			}
6706
+
6707
+			if len(outflow) > 0 {
6708
+				for _, it := range outflow {
6709
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6710
+						it.Count = medical.MinNumber * it.Count
6711
+					}
6712
+					out_count += it.Count
6713
+				}
6714
+			}
6715
+
6716
+			fmt.Println("warehouse_inf_count", warehouse_in_count)
6717
+			fmt.Println("profit_in_count", profit_in_count)
6718
+			fmt.Println("return_out_count", return_out_count)
6719
+			fmt.Println("out_count", out_count)
6720
+			fmt.Println("reduce_out_count", reduce_out_count)
6721
+
6722
+			item.StartCount = warehouse_in_count + profit_in_count + return_out_count - out_count - reduce_out_count
6723
+
6724
+			item.StartMinUnit = item.MinUnit
6725
+
6726
+			// 期间入库
6727
+			if len(startBetEndInfo) > 0 {
6728
+				for _, it := range startBetEndInfo {
6729
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6730
+						it.WarehousingCount = medical.MinNumber * it.WarehousingCount
6731
+					}
6732
+					start_bet_end_info += it.WarehousingCount
6733
+				}
6734
+			}
6735
+
6736
+			item.AddCount = start_bet_end_info
6737
+			item.AddCountMinUnit = item.MinUnit
6738
+
6739
+			//期间减少
6740
+			if len(startOutEndInfo) > 0 {
6741
+				for _, it := range startOutEndInfo {
6742
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6743
+						it.Count = medical.MinNumber * it.Count
6744
+					}
6745
+					start_out_end_info += it.Count
6746
+				}
6747
+
6748
+				item.OutCount = start_out_end_info
6749
+				item.OutMinUnit = item.MinUnit
6750
+			}
6751
+
6752
+			//期间退库
6753
+			if len(initReturnDrugFlow) > 0 {
6754
+				for _, it := range initReturnDrugFlow {
6755
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6756
+						it.Count = medical.MinNumber * it.Count
6757
+					}
6758
+					start_return_end_info += it.Count
6759
+				}
6760
+
6761
+				item.StartEndReturn = start_return_end_info
6762
+				item.StartEndReturnMinUnit = item.MinUnit
6763
+			}
6764
+
6765
+			//期间盘盈
6766
+			if len(initProfitflow) > 0 {
6767
+				for _, it := range initProfitflow {
6768
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6769
+						it.Count = medical.MinNumber * it.Count
6770
+					}
6771
+					start_profit_end_info += it.Count
6772
+				}
6773
+				item.StartEndProfit = start_profit_end_info
6774
+				item.StartEndProfitMinUnit = item.MinUnit
6775
+			}
6776
+
6777
+			//期间盘亏
6778
+			if len(initReduceflow) > 0 {
6779
+				for _, it := range initReduceflow {
6780
+					if it.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
6781
+						it.Count = medical.MinNumber * it.Count
6782
+					}
6783
+					start_reduce_end_info += it.Count
6784
+				}
6785
+				item.StartEndReduce = start_return_end_info
6786
+				item.StartEndReturnMinUnit = item.MinUnit
6787
+			}
6788
+
6789
+		}
6790
+
6791
+	}
6792
+
6793
+	var drugType = "药品类型"
6794
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
6795
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
6796
+
6797
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
6798
+	dealerList, _ := service.GetAllDealerList(orgId)
6799
+
6800
+	this.ServeSuccessJSON(map[string]interface{}{
6801
+		"list":             list,
6802
+		"total":            total,
6803
+		"drugTypeList":     drugTypeList,
6804
+		"manufacturerList": manufacturerList,
6805
+		"dealerList":       dealerList,
6806
+	})
6807
+}

+ 59 - 0
models/new_stock_models.go Vedi File

554
 func (XtDrugWarehouseInfoLog) TableName() string {
554
 func (XtDrugWarehouseInfoLog) TableName() string {
555
 	return "xt_drug_warehouse_info_log"
555
 	return "xt_drug_warehouse_info_log"
556
 }
556
 }
557
+
558
+type VmBaseDrugThrity struct {
559
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
560
+	DrugType               int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
561
+	DrugName               string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
562
+	MaxUnit                string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
563
+	MinNumber              int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
564
+	MinUnit                string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
565
+	Dose                   string  `gorm:"column:dose" json:"dose" form:"dose"`
566
+	DoseUnit               string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
567
+	RetailPrice            float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
568
+	MinPrice               float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
569
+	LastPrice              float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
570
+	DrugAlias              string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
571
+	Manufacturer           int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
572
+	Dealer                 int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
573
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
574
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
575
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
576
+	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
577
+	IsSelfDrug             int64   `gorm:"column:is_self_drug" json:"is_self_drug" form:"is_self_drug"`
578
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
579
+	IsZeroFlag             int64   `gorm:"column:is_zero_flag" json:"is_zero_flag" form:"is_zero_flag"`
580
+	StartCount             int64   //期末结余
581
+	StartMinUnit           string
582
+	StartMaxUnit           string
583
+	AddCount               int64 //期间增加
584
+	AddCountMinUnit        string
585
+	OutCount               int64 //期间减少
586
+	OutMinUnit             string
587
+	OutMaxUnit             string
588
+	StartEndProfit         int64 //期间盘盈
589
+	StartEndProfitMinUnit  string
590
+	StartEndReduce         int64 //期间盘亏
591
+	StartEndReduceMinUnit  string
592
+	StartEndReturn         int64 //期间退库
593
+	StartEndReturnMinUnit  string
594
+}
595
+
596
+func (VmBaseDrugThrity) TableName() string {
597
+	return "xt_base_drug"
598
+}
599
+
600
+type TsDrugWarehouseInfo struct {
601
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
602
+	DrugId           int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
603
+	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
604
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
605
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
606
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
607
+	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
608
+	WarehouseingUnit string `gorm:"column:warehouseing_unit" json:"warehouseing_unit" form:"warehouseing_unit"`
609
+	IsCheck          int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
610
+	MaxUnit          string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
611
+}
612
+
613
+func (TsDrugWarehouseInfo) TableName() string {
614
+	return "xt_drug_warehouse_info"
615
+}

+ 28 - 0
models/self_drug_models.go Vedi File

1006
 	Dealer           int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1006
 	Dealer           int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1007
 	SumCount         int64  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
1007
 	SumCount         int64  `gorm:"column:sum_count" json:"sum_count" form:"sum_count"`
1008
 	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1008
 	WarehousingCount int64  `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
1009
+	MaxUnitOne       string ` json:"max_unit_one"`
1010
+	MinUnitOne       string ` json:"min_unit_one"`
1009
 }
1011
 }
1010
 
1012
 
1011
 type NewGoodInformation struct {
1013
 type NewGoodInformation struct {
1157
 func (GoodInformation) TableName() string {
1159
 func (GoodInformation) TableName() string {
1158
 	return "xt_good_information"
1160
 	return "xt_good_information"
1159
 }
1161
 }
1162
+
1163
+type LyBaseDrug struct {
1164
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
1165
+	MaxUnit   string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1166
+	MinUnit   string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
1167
+	OrgId     int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1168
+	MinNumber int64  `gorm:"column:min_number" json:"min_number" form:"min_number"`
1169
+}
1170
+
1171
+func (LyBaseDrug) TableName() string {
1172
+	return "xt_base_drug"
1173
+}
1174
+
1175
+type LyDrugFlow struct {
1176
+	DrugId         int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
1177
+	Count          int64  `gorm:"column:count" json:"count" form:"count"`
1178
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1179
+	ConsumableType int64  `gorm:"column:consumable_type" json:"consumable_type" form:"consumable_type"`
1180
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
1181
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1182
+	MaxUnit        string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
1183
+}
1184
+
1185
+func (LyDrugFlow) TableName() string {
1186
+	return "xt_drug_flow"
1187
+}

+ 12 - 0
service/dialysis_service.go Vedi File

1021
 	return err
1021
 	return err
1022
 }
1022
 }
1023
 
1023
 
1024
+func CheckDoctorAdviceByGroupNoTwo(m *models.DoctorAdvice, groupNo int64, org_id int64, patient_id int64, advice_date int64) (err error) {
1025
+	ut := writeDb.Begin()
1026
+	err = ut.Model(&models.DoctorAdvice{}).Where("groupno = ?  AND user_org_id = ?  AND status = 1 AND check_state = 0 and patient_id =? and advice_date =?", groupNo, org_id, patient_id, advice_date).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
1027
+	if err != nil {
1028
+		ut.Rollback()
1029
+		return
1030
+	}
1031
+	ut.Commit()
1032
+
1033
+	return err
1034
+}
1035
+
1024
 func CheckDoctorAdviceByGroupNoOne(m *models.DoctorAdvice, groupNo int64, org_id int64) (err error) {
1036
 func CheckDoctorAdviceByGroupNoOne(m *models.DoctorAdvice, groupNo int64, org_id int64) (err error) {
1025
 	ut := writeDb.Begin()
1037
 	ut := writeDb.Begin()
1026
 	err = ut.Model(&models.DoctorAdvice{}).Where("groupno = ?  AND user_org_id = ?  AND status = 1", groupNo, org_id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error
1038
 	err = ut.Model(&models.DoctorAdvice{}).Where("groupno = ?  AND user_org_id = ?  AND status = 1", groupNo, org_id).Updates(map[string]interface{}{"check_time": m.CheckTime, "checker": m.Checker, "check_state": 1}).Error

+ 13 - 13
service/patient_service.go Vedi File

4704
 func GetPatientLastDryWeightObj(patient_id int64, start_time int64, end_time int64, org_id int64) (models.SgjPatientDryweight, error) {
4704
 func GetPatientLastDryWeightObj(patient_id int64, start_time int64, end_time int64, org_id int64) (models.SgjPatientDryweight, error) {
4705
 
4705
 
4706
 	dryweight := models.SgjPatientDryweight{}
4706
 	dryweight := models.SgjPatientDryweight{}
4707
-	err := XTReadDB().Where("patient_id =? and user_org_id = ? and status=1", patient_id, org_id, start_time, end_time).Order("id asc").Last(&dryweight).Error
4707
+	err := XTReadDB().Where("patient_id =? and user_org_id = ? and status=1", patient_id, org_id).Order("id asc").Last(&dryweight).Error
4708
 	return dryweight, err
4708
 	return dryweight, err
4709
 }
4709
 }
4710
 
4710
 
4781
 func GetMaxAssessmentBforSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4781
 func GetMaxAssessmentBforSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4782
 
4782
 
4783
 	befor := models.XtAssessmentBeforeDislysis{}
4783
 	befor := models.XtAssessmentBeforeDislysis{}
4784
-	err := XTReadDB().Raw("select MAX(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4784
+	err := XTReadDB().Raw("select MAX(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and systolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4785
 	return befor, err
4785
 	return befor, err
4786
 }
4786
 }
4787
 
4787
 
4788
 func GetMminAssessmentBforSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4788
 func GetMminAssessmentBforSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4789
 
4789
 
4790
 	befor := models.XtAssessmentBeforeDislysis{}
4790
 	befor := models.XtAssessmentBeforeDislysis{}
4791
-	err := XTReadDB().Raw("select Min(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4791
+	err := XTReadDB().Raw("select Min(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and systolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4792
 	return befor, err
4792
 	return befor, err
4793
 }
4793
 }
4794
 
4794
 
4795
 func GetMaxAssessmentBforDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4795
 func GetMaxAssessmentBforDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4796
 
4796
 
4797
 	befor := models.XtAssessmentBeforeDislysis{}
4797
 	befor := models.XtAssessmentBeforeDislysis{}
4798
-	err := XTReadDB().Raw("select MAX(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4798
+	err := XTReadDB().Raw("select MAX(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and diastolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4799
 	return befor, err
4799
 	return befor, err
4800
 }
4800
 }
4801
 
4801
 
4802
 func GetMinAssessmentBforDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4802
 func GetMinAssessmentBforDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentBeforeDislysis, error) {
4803
 
4803
 
4804
 	befor := models.XtAssessmentBeforeDislysis{}
4804
 	befor := models.XtAssessmentBeforeDislysis{}
4805
-	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4805
+	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_before_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and diastolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4806
 	return befor, err
4806
 	return befor, err
4807
 }
4807
 }
4808
 
4808
 
4809
 func GetMaxAssessmentAfterSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4809
 func GetMaxAssessmentAfterSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4810
 
4810
 
4811
 	befor := models.XtAssessmentAfterDislysis{}
4811
 	befor := models.XtAssessmentAfterDislysis{}
4812
-	err := XTReadDB().Raw("select MAX(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4812
+	err := XTReadDB().Raw("select MAX(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and systolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4813
 	return befor, err
4813
 	return befor, err
4814
 }
4814
 }
4815
 
4815
 
4816
 func GetMinAssessmentAfterSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4816
 func GetMinAssessmentAfterSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4817
 
4817
 
4818
 	befor := models.XtAssessmentAfterDislysis{}
4818
 	befor := models.XtAssessmentAfterDislysis{}
4819
-	err := XTReadDB().Raw("select Min(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4819
+	err := XTReadDB().Raw("select Min(systolic_blood_pressure) as systolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and systolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4820
 	return befor, err
4820
 	return befor, err
4821
 }
4821
 }
4822
 
4822
 
4823
 func GetMaxAssessmentAfterDiastolicBloodPressureList(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4823
 func GetMaxAssessmentAfterDiastolicBloodPressureList(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4824
 
4824
 
4825
 	befor := models.XtAssessmentAfterDislysis{}
4825
 	befor := models.XtAssessmentAfterDislysis{}
4826
-	err := XTReadDB().Raw("select Max(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4826
+	err := XTReadDB().Raw("select Max(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and diastolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4827
 	return befor, err
4827
 	return befor, err
4828
 }
4828
 }
4829
 
4829
 
4830
 func GetMinAssessmentAfterDiastolicBloodPressureList(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4830
 func GetMinAssessmentAfterDiastolicBloodPressureList(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XtAssessmentAfterDislysis, error) {
4831
 
4831
 
4832
 	befor := models.XtAssessmentAfterDislysis{}
4832
 	befor := models.XtAssessmentAfterDislysis{}
4833
-	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4833
+	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_assessment_after_dislysis where patient_id = ? and assessment_date>=? and assessment_date<=? and user_org_id = ? and diastolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&befor).Error
4834
 	return befor, err
4834
 	return befor, err
4835
 }
4835
 }
4836
 
4836
 
4837
 func GetMaxMonitorSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4837
 func GetMaxMonitorSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4838
 
4838
 
4839
 	monitor := models.XTMonitoringRecord{}
4839
 	monitor := models.XTMonitoringRecord{}
4840
-	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4840
+	err := XTReadDB().Raw("select Max(systolic_blood_pressure) as systolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ? and systolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4841
 	return monitor, err
4841
 	return monitor, err
4842
 }
4842
 }
4843
 
4843
 
4844
 func GetMinMonitorSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4844
 func GetMinMonitorSystolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4845
 
4845
 
4846
 	monitor := models.XTMonitoringRecord{}
4846
 	monitor := models.XTMonitoringRecord{}
4847
-	err := XTReadDB().Raw("select Min(systolic_blood_pressure) as systolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4847
+	err := XTReadDB().Raw("select Min(systolic_blood_pressure) as systolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ? and systolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4848
 	return monitor, err
4848
 	return monitor, err
4849
 
4849
 
4850
 }
4850
 }
4852
 func GetMaxMonitorDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4852
 func GetMaxMonitorDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4853
 
4853
 
4854
 	monitor := models.XTMonitoringRecord{}
4854
 	monitor := models.XTMonitoringRecord{}
4855
-	err := XTReadDB().Raw("select Max(diastolic_blood_pressure) as diastolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4855
+	err := XTReadDB().Raw("select Max(diastolic_blood_pressure) as diastolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ? and diastolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4856
 	return monitor, err
4856
 	return monitor, err
4857
 }
4857
 }
4858
 
4858
 
4859
 func GetMinMonitorDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4859
 func GetMinMonitorDiastolicBloodPressure(patient_id int64, start_time int64, end_time int64, org_id int64) (models.XTMonitoringRecord, error) {
4860
 
4860
 
4861
 	monitor := models.XTMonitoringRecord{}
4861
 	monitor := models.XTMonitoringRecord{}
4862
-	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ?", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4862
+	err := XTReadDB().Raw("select Min(diastolic_blood_pressure) as diastolic_blood_pressure from xt_monitoring_record where patient_id = ? and monitoring_date>=? and monitoring_date<=? and user_org_id = ? and diastolic_blood_pressure>0", patient_id, start_time, end_time, org_id).Scan(&monitor).Error
4863
 	return monitor, err
4863
 	return monitor, err
4864
 }
4864
 }
4865
 
4865
 

+ 245 - 4
service/self_drug_service.go Vedi File

1271
 		if orgid > 0 {
1271
 		if orgid > 0 {
1272
 			db = db.Where("x.org_id = ?", orgid)
1272
 			db = db.Where("x.org_id = ?", orgid)
1273
 		}
1273
 		}
1274
-		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1274
+		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count,x.max_unit as max_unit_one,x.min_unit as min_unit_one").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1275
 		return info, err
1275
 		return info, err
1276
 	} else {
1276
 	} else {
1277
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and (x.warehousing_count>0)")
1277
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and (x.warehousing_count>0)")
1280
 		if orgid > 0 {
1280
 		if orgid > 0 {
1281
 			db = db.Where("x.org_id = ?", orgid)
1281
 			db = db.Where("x.org_id = ?", orgid)
1282
 		}
1282
 		}
1283
-		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1283
+		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count,x.max_unit as max_unit_one,x.min_unit as min_unit_one").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1284
 		return info, err
1284
 		return info, err
1285
 	}
1285
 	}
1286
 
1286
 
2933
 	return flwo, err
2933
 	return flwo, err
2934
 }
2934
 }
2935
 
2935
 
2936
+func GetGoodWarehosueInfo(id int64) (models.WarehousingInfo, error) {
2937
+
2938
+	info := models.WarehousingInfo{}
2939
+
2940
+	err := XTReadDB().Where("id = ? and status=1", id).Find(&info).Error
2941
+
2942
+	return info, err
2943
+}
2944
+
2936
 func GetDrugNewPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
2945
 func GetDrugNewPurchaseStockQuery(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
2937
 
2946
 
2938
 	db := XTReadDB().Model(&druginfo).Where("status = 1 and is_self_drug!=1")
2947
 	db := XTReadDB().Model(&druginfo).Where("status = 1 and is_self_drug!=1")
2952
 	if len(keyword) > 0 {
2961
 	if len(keyword) > 0 {
2953
 		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
2962
 		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
2954
 	}
2963
 	}
2955
-	//if len(infos) > 0 {
2956
-	//	db = db.Where("id in(?)", infos)
2964
+
2965
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&druginfo).Error
2966
+
2967
+	return druginfo, total, err
2968
+}
2969
+
2970
+func GetDrugPurchaseQueryList(good_type int64, page int64, limit int64, drug_id int64, orgId int64, startTime int64, endTime int64) (druginfo []*models.VmBaseDrugThrity, total int64, err error) {
2971
+
2972
+	db := XTReadDB().Model(&druginfo).Where("status = 1 and is_self_drug!=1")
2973
+	offset := (page - 1) * limit
2974
+	if good_type > 0 {
2975
+		db = db.Where("drug_type = ?", good_type)
2976
+	}
2977
+	if orgId == 10697 || orgId == 10644 {
2978
+		db = db.Where("find_in_set('停用',drug_status) = 0")
2979
+	}
2980
+
2981
+	if drug_id > 0 {
2982
+		db = db.Where("id = ?", drug_id)
2983
+	}
2984
+
2985
+	if orgId > 0 {
2986
+		db = db.Where("org_id = ?", orgId)
2987
+	}
2988
+
2989
+	//if startTime > 0 {
2990
+	//	db = db.Where("ctime>=?", startTime)
2957
 	//}
2991
 	//}
2992
+	//if endTime > 0 {
2993
+	//	db = db.Where("ctime<=?", endTime)
2994
+	//}
2995
+
2958
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&druginfo).Error
2996
 	err = db.Count(&total).Offset(offset).Limit(limit).Order("ctime desc").Find(&druginfo).Error
2959
 
2997
 
2960
 	return druginfo, total, err
2998
 	return druginfo, total, err
5432
 
5470
 
5433
 	return info, err
5471
 	return info, err
5434
 }
5472
 }
5473
+
5474
+func GetDrugWarehouseInfoByStartTime(drug_id int64, org_id int64, ctime int64) (drugInfo []*models.TsDrugWarehouseInfo, err error) {
5475
+
5476
+	db := XTReadDB().Model(&drugInfo).Where("status=1 and is_check=1")
5477
+
5478
+	if drug_id > 0 {
5479
+		db = db.Where("drug_id = ?", drug_id)
5480
+	}
5481
+
5482
+	if org_id > 0 {
5483
+		db = db.Where("org_id = ?", org_id)
5484
+	}
5485
+
5486
+	if ctime > 0 {
5487
+		db = db.Where("ctime < ?", ctime)
5488
+	}
5489
+	err = db.Find(&drugInfo).Error
5490
+
5491
+	return drugInfo, err
5492
+}
5493
+
5494
+func GetBaseDrugById(id int64) (models.LyBaseDrug, error) {
5495
+
5496
+	baseDrug := models.LyBaseDrug{}
5497
+	err := XTReadDB().Where("id = ?", id).Find(&baseDrug).Error
5498
+	return baseDrug, err
5499
+}
5500
+
5501
+func GetProfitDrugFlow(drug_id int64, user_org_id int64, ctime int64) (flow []*models.LyDrugFlow, err error) {
5502
+
5503
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 10")
5504
+
5505
+	if drug_id > 0 {
5506
+		db = db.Where("drug_id = ?", drug_id)
5507
+	}
5508
+	if user_org_id > 0 {
5509
+		db = db.Where("user_org_id = ?", user_org_id)
5510
+	}
5511
+
5512
+	if ctime > 0 {
5513
+		db = db.Where("ctime<?", ctime)
5514
+	}
5515
+	err = db.Find(&flow).Error
5516
+
5517
+	return flow, err
5518
+}
5519
+
5520
+func GetReduceDrugFlow(drug_id int64, user_org_id int64, ctime int64) (flow []*models.LyDrugFlow, err error) {
5521
+
5522
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 11")
5523
+
5524
+	if drug_id > 0 {
5525
+		db = db.Where("drug_id = ?", drug_id)
5526
+	}
5527
+	if user_org_id > 0 {
5528
+		db = db.Where("user_org_id = ?", user_org_id)
5529
+	}
5530
+
5531
+	if ctime > 0 {
5532
+		db = db.Where("ctime<?", ctime)
5533
+	}
5534
+
5535
+	err = db.Find(&flow).Error
5536
+	return flow, err
5537
+}
5538
+
5539
+func GetReturnDrugFlow(drug_id int64, user_org_id int64, ctime int64) (flow []*models.LyDrugFlow, err error) {
5540
+
5541
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 7")
5542
+	if drug_id > 0 {
5543
+		db = db.Where("drug_id = ?", drug_id)
5544
+	}
5545
+	if user_org_id > 0 {
5546
+		db = db.Where("user_org_id = ?", user_org_id)
5547
+	}
5548
+
5549
+	if ctime > 0 {
5550
+		db = db.Where("ctime<?", ctime)
5551
+	}
5552
+	err = db.Find(&flow).Error
5553
+	return flow, err
5554
+
5555
+}
5556
+
5557
+func GetOutDrugFlow(drug_id int64, user_org_id int64, ctime int64) (flow []*models.LyDrugFlow, err error) {
5558
+
5559
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 3")
5560
+	if drug_id > 0 {
5561
+		db = db.Where("drug_id = ?", drug_id)
5562
+	}
5563
+	if user_org_id > 0 {
5564
+		db = db.Where("user_org_id = ?", user_org_id)
5565
+	}
5566
+
5567
+	if ctime > 0 {
5568
+		db = db.Where("ctime<?", ctime)
5569
+	}
5570
+	err = db.Find(&flow).Error
5571
+	return flow, err
5572
+
5573
+}
5574
+
5575
+func GetInitAddDrugFlow(drug_id int64, org_id int64, start_time int64, end_time int64) (info []*models.TsDrugWarehouseInfo, err error) {
5576
+
5577
+	db := XTReadDB().Model(&info).Where("status=1 and is_check=1")
5578
+	if drug_id > 0 {
5579
+		db = db.Where("drug_id = ?", drug_id)
5580
+	}
5581
+	if org_id > 0 {
5582
+		db = db.Where("org_id = ?", org_id)
5583
+	}
5584
+
5585
+	if start_time > 0 {
5586
+		db = db.Where("ctime>=?", start_time)
5587
+	}
5588
+
5589
+	if end_time > 0 {
5590
+		db = db.Where("ctime<=?", end_time)
5591
+	}
5592
+	err = db.Find(&info).Error
5593
+	return info, err
5594
+}
5595
+
5596
+func GetInitOutDrugFlow(drug_id int64, org_id int64, start_time int64, end_time int64) (flow []*models.LyDrugFlow, err error) {
5597
+
5598
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 3")
5599
+	if drug_id > 0 {
5600
+		db = db.Where("drug_id = ?", drug_id)
5601
+	}
5602
+	if org_id > 0 {
5603
+		db = db.Where("user_org_id = ?", org_id)
5604
+	}
5605
+
5606
+	if start_time > 0 {
5607
+		db = db.Where("ctime>=?", start_time)
5608
+	}
5609
+	if end_time > 0 {
5610
+		db = db.Where("ctime<=?", end_time)
5611
+	}
5612
+	err = db.Find(&flow).Error
5613
+
5614
+	return flow, err
5615
+}
5616
+
5617
+func GetInitReturnDrugFlow(drug_id int64, org_id int64, start_time int64, end_time int64) (flow []*models.LyDrugFlow, err error) {
5618
+
5619
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 7")
5620
+	if drug_id > 0 {
5621
+		db = db.Where("drug_id = ?", drug_id)
5622
+	}
5623
+	if org_id > 0 {
5624
+		db = db.Where("user_org_id = ?", org_id)
5625
+	}
5626
+
5627
+	if start_time > 0 {
5628
+		db = db.Where("ctime>=?", start_time)
5629
+	}
5630
+	if end_time > 0 {
5631
+		db = db.Where("ctime<=?", end_time)
5632
+	}
5633
+	err = db.Find(&flow).Error
5634
+	return flow, err
5635
+}
5636
+
5637
+func GetInitProfitDrugFlow(drug_id int64, org_id int64, start_time int64, end_time int64) (flow []*models.LyDrugFlow, err error) {
5638
+
5639
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 10")
5640
+	if drug_id > 0 {
5641
+		db = db.Where("drug_id = ?", drug_id)
5642
+	}
5643
+	if org_id > 0 {
5644
+		db = db.Where("user_org_id = ?", org_id)
5645
+	}
5646
+
5647
+	if start_time > 0 {
5648
+		db = db.Where("ctime>=?", start_time)
5649
+	}
5650
+	if end_time > 0 {
5651
+		db = db.Where("ctime<=?", end_time)
5652
+	}
5653
+	err = db.Find(&flow).Error
5654
+	return flow, err
5655
+}
5656
+
5657
+func GetInitReduceDrugFlow(drug_id int64, org_id int64, start_time int64, end_time int64) (flow []*models.LyDrugFlow, err error) {
5658
+
5659
+	db := XTReadDB().Model(&flow).Where("status=1 and consumable_type = 11")
5660
+	if drug_id > 0 {
5661
+		db = db.Where("drug_id = ?", drug_id)
5662
+	}
5663
+	if org_id > 0 {
5664
+		db = db.Where("user_org_id = ?", org_id)
5665
+	}
5666
+
5667
+	if start_time > 0 {
5668
+		db = db.Where("ctime>=?", start_time)
5669
+	}
5670
+	if end_time > 0 {
5671
+		db = db.Where("ctime<=?", end_time)
5672
+	}
5673
+	err = db.Find(&flow).Error
5674
+	return flow, err
5675
+}

+ 2 - 2
service/stock_service.go Vedi File

7472
 		if orgid > 0 {
7472
 		if orgid > 0 {
7473
 			db = db.Where("x.org_id = ?", orgid)
7473
 			db = db.Where("x.org_id = ?", orgid)
7474
 		}
7474
 		}
7475
-		err = db.Select("x.id,x.good_id,x.number,x.number,x.product_date,x.expiry_date,x.warehousing_unit,x.dealer,x.manufacturer,t.good_name,t.specification_name,t.packing_unit,t.remark").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id,x.number").Scan(&info).Error
7475
+		err = db.Select("x.id,x.good_id,x.number,x.number,x.product_date,x.expiry_date,x.warehousing_unit,x.dealer,x.manufacturer,x.stock_count,t.good_name,t.specification_name,t.packing_unit,t.remark").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id,x.number").Scan(&info).Error
7476
 		return info, err
7476
 		return info, err
7477
 	} else {
7477
 	} else {
7478
 		db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1 and x.warehousing_count>0")
7478
 		db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1 and x.warehousing_count>0")
7481
 		if orgid > 0 {
7481
 		if orgid > 0 {
7482
 			db = db.Where("x.org_id = ?", orgid)
7482
 			db = db.Where("x.org_id = ?", orgid)
7483
 		}
7483
 		}
7484
-		err = db.Select("x.id,x.good_id,x.number,x.number,x.product_date,x.expiry_date,x.warehousing_unit,x.dealer,x.manufacturer,t.good_name,t.specification_name,t.packing_unit,t.remark").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id,x.number").Scan(&info).Error
7484
+		err = db.Select("x.id,x.good_id,x.number,x.number,x.product_date,x.expiry_date,x.warehousing_unit,x.dealer,x.manufacturer,x.stock_count,t.good_name,t.specification_name,t.packing_unit,t.remark").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id,x.number").Scan(&info).Error
7485
 		return info, err
7485
 		return info, err
7486
 	}
7486
 	}
7487
 
7487
 

+ 3 - 5
service/warhouse_service.go Vedi File

8139
 		lastOut, _ := FindNewWarehouseOutInfoByPatientIdTwo(patient_id, record_time, goods.GoodId, orgID, goods.ProjectId, tx)
8139
 		lastOut, _ := FindNewWarehouseOutInfoByPatientIdTwo(patient_id, record_time, goods.GoodId, orgID, goods.ProjectId, tx)
8140
 
8140
 
8141
 		//如果本次出库数据大于历史出库数据 新增1条流水
8141
 		//如果本次出库数据大于历史出库数据 新增1条流水
8142
-		fmt.Println("本次出库数据", count)
8143
-		fmt.Println("历史出库数据", out_count)
8144
-		fmt.Println("退库数据", out_count_one)
8142
+
8145
 		if count > (out_count - out_count_one) {
8143
 		if count > (out_count - out_count_one) {
8146
 
8144
 
8147
 			stockFlow := models.VmStockFlow{
8145
 			stockFlow := models.VmStockFlow{
8690
 
8688
 
8691
 	}
8689
 	}
8692
 
8690
 
8693
-	goods.Count = deliver_number - stock_number
8694
 	prepare := &models.DialysisBeforePrepare{
8691
 	prepare := &models.DialysisBeforePrepare{
8695
 		Count:        deliver_number - stock_number,
8692
 		Count:        deliver_number - stock_number,
8696
 		GoodTypeId:   goods.GoodTypeId,
8693
 		GoodTypeId:   goods.GoodTypeId,
8704
 		StorehouseId: goods.StorehouseId,
8701
 		StorehouseId: goods.StorehouseId,
8705
 		ProjectId:    goods.ProjectId,
8702
 		ProjectId:    goods.ProjectId,
8706
 	}
8703
 	}
8704
+	prepare.Count = deliver_number - stock_number
8707
 	ConsumableNewPrescriptionDelivery(orgID, patient_id, record_time, prepare, warehouseOut, creator, count, tx)
8705
 	ConsumableNewPrescriptionDelivery(orgID, patient_id, record_time, prepare, warehouseOut, creator, count, tx)
8708
 
8706
 
8709
 	return nil
8707
 	return nil
8964
 		ProjectId:    goods.ProjectId,
8962
 		ProjectId:    goods.ProjectId,
8965
 	}
8963
 	}
8966
 	CreatedDialysisPrepare(autoMatic, tx)
8964
 	CreatedDialysisPrepare(autoMatic, tx)
8967
-	goods.Count = deliver_number - stock_number
8965
+	dialyPrepareOne.Count = deliver_number - stock_number
8968
 	ConsumableNewHisPrescriptionDelivery(orgID, patient_id, record_time, dialyPrepareOne, warehouseOut, creator, tx)
8966
 	ConsumableNewHisPrescriptionDelivery(orgID, patient_id, record_time, dialyPrepareOne, warehouseOut, creator, tx)
8969
 
8967
 
8970
 	return nil
8968
 	return nil